[glumpy] 4 new revisions pushed by Nicolas.Rougier@gmail.com on 2012-04-11 06:06 GMT

0 views
Skip to first unread message

glu...@googlecode.com

unread,
Apr 11, 2012, 2:06:30 AM4/11/12
to nicolas...@inria.fr
4 new revisions:

Revision: 2590f9ea9d74
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:03:43 2012
Log: Fix mouse scroll
http://code.google.com/p/glumpy/source/detail?r=2590f9ea9d74

Revision: 8cbc2aa2b277
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:04:45 2012
Log: Removed useless upload of texture data in _build
http://code.google.com/p/glumpy/source/detail?r=8cbc2aa2b277

Revision: e600626e0f33
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:05:53 2012
Log: Cosmetic changes
http://code.google.com/p/glumpy/source/detail?r=e600626e0f33

Revision: 3cd72082f01b
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:06:01 2012
Log: Various cosmetic changes
http://code.google.com/p/glumpy/source/detail?r=3cd72082f01b

==============================================================================
Revision: 2590f9ea9d74
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:03:43 2012
Log: Fix mouse scroll

http://code.google.com/p/glumpy/source/detail?r=2590f9ea9d74

Modified:
/demos/events.py

=======================================
--- /demos/events.py Mon Sep 12 08:00:00 2011
+++ /demos/events.py Tue Apr 10 23:03:43 2012
@@ -82,5 +82,9 @@
def on_mouse_drag(x, y, dx, dy, button):
print 'Mouse drag (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f, button=%d)' %
(x,y,dx,dy,button)

+...@fig.event
+def on_mouse_scroll(x, y, dx, dy):
+ print 'Mouse scroll (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f)' % (x,y,dx,dy)
+

fig.show()

==============================================================================
Revision: 8cbc2aa2b277
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:04:45 2012
Log: Removed useless upload of texture data in _build

http://code.google.com/p/glumpy/source/detail?r=8cbc2aa2b277

Modified:
/glumpy/image/texture.py

=======================================
--- /glumpy/image/texture.py Thu Sep 15 06:33:36 2011
+++ /glumpy/image/texture.py Tue Apr 10 23:04:45 2012
@@ -254,11 +254,15 @@
gl.glTexParameterf (self.target, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP)
gl.glTexParameterf (self.target, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP)
if self._target == gl.GL_TEXTURE_1D:
+ #gl.glTexImage1D (self.target, 0, self.dst_format, width, 0,
+ # self.src_format, self.src_type,
numpy.zeros(Z.shape,Z.dtype))
gl.glTexImage1D (self.target, 0, self.dst_format, width, 0,
- self.src_format, self.src_type,
numpy.zeros(Z.shape,Z.dtype))
+ self.src_format, self.src_type, None)
else:
+ #gl.glTexImage2D (self.target, 0, self.dst_format, width,
height, 0,
+ # self.src_format, self.src_type,
numpy.zeros(Z.shape,Z.dtype))
gl.glTexImage2D (self.target, 0, self.dst_format, width,
height, 0,
- self.src_format, self.src_type,
numpy.zeros(Z.shape,Z.dtype))
+ self.src_format, self.src_type, None)
self.update()

==============================================================================
Revision: e600626e0f33
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:05:53 2012
Log: Cosmetic changes

http://code.google.com/p/glumpy/source/detail?r=e600626e0f33

Modified:
/README.txt

=======================================
--- /README.txt Thu Sep 15 06:41:15 2011
+++ /README.txt Tue Apr 10 23:05:53 2012
@@ -48,7 +48,6 @@
Example usage
-------------

-
demo-simple.py::

import numpy, glumpy

==============================================================================
Revision: 3cd72082f01b
Author: Nicolas Rougier <Nicolas...@inria.fr>
Date: Tue Apr 10 23:06:01 2012
Log: Various cosmetic changes

http://code.google.com/p/glumpy/source/detail?r=3cd72082f01b

Modified:
/glumpy/figure.py
/glumpy/trackball.py
/glumpy/window/backend_glut.py

=======================================
--- /glumpy/figure.py Fri Mar 2 11:06:29 2012
+++ /glumpy/figure.py Tue Apr 10 23:06:01 2012
@@ -619,7 +619,7 @@
for fig in self._figures:
if (x,y) in fig:
invoked = fig.dispatch_event('on_mouse_scroll',
- x-fig.x, y-fig.y, scroll_x,
scroll_y)
+ x-fig.x, y-fig.y, dx, dy)
if invoked == event.EVENT_HANDLED: return invoked
return event.EVENT_UNHANDLED

=======================================
--- /glumpy/trackball.py Mon Sep 12 08:00:00 2011
+++ /glumpy/trackball.py Tue Apr 10 23:06:01 2012
@@ -160,6 +160,8 @@
self._RENORMCOUNT = 97
self._TRACKBALLSIZE = 0.8
self._set_orientation(theta,phi)
+ self._x = 0.0
+ self._y = 0.0

def drag_to (self, x, y, dx, dy):
''' Move trackball view from x,y to x+dx,y+dy. '''
@@ -184,6 +186,11 @@
height = float(viewport[3])
self.zoom = self.zoom-5*dy/height

+ def pan_to (self, x, y, dx, dy):
+ ''' Pan trackball by a factor dx,dy '''
+ self.x += dx*0.1
+ self.y += dy*0.1
+

def push(self):
viewport = gl.glGetIntegerv(gl.GL_VIEWPORT)
@@ -202,7 +209,8 @@
gl.glMatrixMode (gl.GL_MODELVIEW)
gl.glPushMatrix()
gl.glLoadIdentity ()
- gl.glTranslate (0.0, 0, -self._distance)
+ # gl.glTranslate (0.0, 0, -self._distance)
+ gl.glTranslate (self._x, self._y, -self._distance)
gl.glMultMatrixf (self._matrix)

def pop(void):
=======================================
--- /glumpy/window/backend_glut.py Sat Oct 1 03:05:48 2011
+++ /glumpy/window/backend_glut.py Tue Apr 10 23:06:01 2012
@@ -31,14 +31,24 @@
#
-----------------------------------------------------------------------------
import sys
import OpenGL.GLUT as glut
+from ctypes import c_float
+from OpenGL.GLUT.special import GLUTCallback
+
import key
import event
import mouse
import window

-
_window = None

+# For OSX, see https://github.com/nanoant/osxglut
+# GLUT for Mac OS X fork with Core Profile and scroll wheel support
+try:
+ glutScrollFunc = GLUTCallback(
+ 'Scroll', (c_float,c_float), ('delta_x','delta_y'),)
+except:
+ glutScrollFunc = None
+

def show():
''' Show all windows and enters the main loop. '''
@@ -127,7 +137,10 @@
glut.glutEntryFunc( self._entry )
glut.glutSpecialFunc( self._special )
glut.glutSpecialUpFunc( self._special_up )
-
+ if glutScrollFunc:
+ glutScrollFunc( self._scroll)
+ elif glut.glutMouseWheelFunc:
+ glutMouseWheelFunc( self._wheel)
if size is not None:
width, height = size
glut.glutReshapeWindow( width, height )
@@ -291,6 +304,16 @@
else:
self.dispatch_event('on_mouse_press', x, y, button)

+ def _wheel(self, wheel, direction, x, y):
+ if wheel == 0:
+ self.dispatch_event('on_mouse_scroll', x, y, 0, direction)
+ elif wheel == 1:
+ self.dispatch_event('on_mouse_scroll', x, y, direction, 0)
+
+ def _scroll( self, dx, dy ):
+ self.dispatch_event('on_mouse_scroll',
+ self._mouse_x, self._mouse_y, dx, dy)
+

def _motion(self, x, y):
y = self._height - y
@@ -533,7 +556,7 @@

if __name__ == '__main__':

- window = Window(640, 480, 0, 0, "Window title")
+ window = Window( (640,480), (0,0), "Window title")

@window.event
def on_init():

Reply all
Reply to author
Forward
0 new messages