本文整理汇总了Python中scene.Scene.mouse_move方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.mouse_move方法的具体用法?Python Scene.mouse_move怎么用?Python Scene.mouse_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scene.Scene
的用法示例。
在下文中一共展示了Scene.mouse_move方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouse_move
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import mouse_move [as 别名]
def mouse_move( self , df , buts ) :
Scene.mouse_move( self , df , buts )
if 1 in buts and buts[1] :
self.ab = self.__modify_euler( self.ab , df )
if 2 in buts and buts[2] :
self.ae = self.__modify_euler( self.ae , df )
示例2: App
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import mouse_move [as 别名]
#.........这里部分代码省略.........
self.scene.new_curve_interpolation()
self.tbut_add_inter.set_active(False)
elif self.tbut_del_curve.get_active():
self.scene.delete_curve()
self.tbut_del_curve.set_active(False)
elif self.tbut_sel_curve.get_active():
self.scene.select_curve()
self.tbut_sel_curve.set_active(False)
elif self.tbut_cut.get_active():
self.scene.select_to_cut()
self.tbut_cut.set_active(False)
else:
self.scene.activate_cursor()
self.drawing_area.queue_draw()
def _on_mouse_motion(self, widget, data=None):
diff = map(op.sub, self.mouse_pos, (-data.x, data.y))
rowdiff = copy(diff)
if self.rbut_xy.get_active():
diff[2:2] = [0]
axis1 = (0, 1, 0)
axis2 = (1, 0, 0)
elif self.rbut_xz.get_active():
diff[1:1] = [0]
axis1 = (0, 0, 1)
axis2 = (1, 0, 0)
elif self.rbut_yz.get_active():
diff.reverse()
diff[0:0] = [0]
axis1 = (0, 1, 0)
axis2 = (0, 0, 1)
self.scene.mouse_move(rowdiff, diff, axis1, axis2)
self.mouse_pos = -data.x, data.y
self.drawing_area.queue_draw()
def init_glext(self):
# Query the OpenGL extension version.
# print "OpenGL extension version - %d.%d\n" % gtk.gdkgl.query_version()
# Configure OpenGL framebuffer.
# Try to get a double-buffered framebuffer configuration,
# if not successful then try to get a single-buffered one.
display_mode = gtk.gdkgl.MODE_RGB | gtk.gdkgl.MODE_DEPTH | gtk.gdkgl.MODE_DOUBLE
try:
glconfig = gtk.gdkgl.Config(mode=display_mode)
except gtk.gdkgl.NoMatches:
display_mode &= ~gtk.gdkgl.MODE_DOUBLE
glconfig = gtk.gdkgl.Config(mode=display_mode)
# print "is RGBA:", glconfig.is_rgba()
# print "is double-buffered:", glconfig.is_double_buffered()
# print "is stereo:", glconfig.is_stereo()
# print "has alpha:", glconfig.has_alpha()
# print "has depth buffer:", glconfig.has_depth_buffer()
# print "has stencil buffer:", glconfig.has_stencil_buffer()
# print "has accumulation buffer:", glconfig.has_accum_buffer()
# print
return glconfig
def on_win_main_destroy(self, widget, data=None):
gtk.main_quit()
示例3: App
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import mouse_move [as 别名]
class App(object):
"""Application main class"""
def __init__(self):
self.move = [0,0,0]
self.dirskeys = ( ( ['w'] , ['s'] ) , ( ['a'] , ['d'] ) , ( ['e'] , ['q'] ) )
for d in self.dirskeys :
for e in d :
for i in range(len(e)) : e[i] = ( gtk.gdk.unicode_to_keyval(ord(e[i])) , False )
self.near = 1
self.far = 1000
self.fov = 60
builder = gtk.Builder()
builder.add_from_file(ui_file)
glconfig = self.init_glext()
self.drawing_area = GLDrawingArea(glconfig)
self.drawing_area.set_events( gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.MOTION_NOTIFY | gtk.gdk.BUTTON1_MOTION_MASK | gtk.gdk.BUTTON3_MOTION_MASK )
self.drawing_area.set_size_request(320,240)
builder.get_object("vbox1").pack_start(self.drawing_area)
win_main = builder.get_object("win_main")
self.sp_l1 = builder.get_object("sp_l1")
self.sp_l2 = builder.get_object("sp_l2")
win_main.set_events( gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK )
win_main.connect('key-press-event' , self._on_key_pressed )
win_main.connect('key-release-event', self._on_key_released )
self.scene = Scene( )
self.scene.set_robot_params( self.sp_l1.get_value() , self.sp_l2.get_value() )
self.drawing_area.add( self.scene , ( 0,0,1,1) )
# self.drawing_area.add( self.scene , (.5,0,.5,1) )
print 'Scene added'
win_main.show_all()
width = self.drawing_area.allocation.width
height = self.drawing_area.allocation.height
self.scene.set_screen_size( width , height )
builder.connect_signals(self)
# self.statbar = builder.get_object('statbar')
self.drawing_area.connect('motion_notify_event',self._on_mouse_motion)
self.drawing_area.connect('button_press_event',self._on_button_pressed)
self.drawing_area.connect('button_release_event',self._on_button_released)
self.drawing_area.connect('configure_event',self._on_reshape)
self.drawing_area.connect_after('expose_event',self._after_draw)
gtk.timeout_add( 1 , self._refresh )
def _refresh( self ) :
self.drawing_area.queue_draw()
return True
def _after_draw( self , widget , data=None ) :
self.update_statusbar()
def update_statusbar( self ) :
pass
def _on_reshape( self , widget , data=None ) :
width = self.drawing_area.allocation.width
height = self.drawing_area.allocation.height
ratio = float(width)/float(height)
self.scene.set_screen_size( width , height )
def _on_button_pressed( self , widget , data=None ) :
if data.button in (1,3) :
self.mouse_pos = data.x , data.y
self.scene.mouse_but_pressed( data.button , (data.x,data.y) )
self.drawing_area.queue_draw()
def _on_button_released( self , widget , data=None ) :
self.scene.mouse_but_released( data.button , (data.x,data.y) )
self.drawing_area.queue_draw()
def _on_mouse_motion( self , widget , data=None ) :
diff = map( op.sub , self.mouse_pos , (data.x , data.y) )
self.scene.mouse_move( diff , (data.x,data.y) )
self.mouse_pos = data.x , data.y
self.drawing_area.queue_draw()
#.........这里部分代码省略.........
示例4: mouse_move
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import mouse_move [as 别名]
def mouse_move( self , df , buts ) :
Scene.mouse_move( self , df , buts )
if 1 in buts and buts[1] :
self.qb = self.__modify_quaternion( self.qb , df )
if 2 in buts and buts[2] :
self.qe = self.__modify_quaternion( self.qe , df )
示例5: App
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import mouse_move [as 别名]
class App(object):
"""Application main class"""
def __init__(self):
self.move = [0,0,0]
self.dirskeys = ( ( ['w'] , ['s'] ) , ( ['a'] , ['d'] ) , ( ['e'] , ['q'] ) )
for d in self.dirskeys :
for e in d :
for i in range(len(e)) : e[i] = ( gtk.gdk.unicode_to_keyval(ord(e[i])) , False )
self.near = 1
self.far = 1000
self.fov = 60
builder = gtk.Builder()
builder.add_from_file(ui_file)
glconfig = self.init_glext()
self.drawing_area = GLDrawingArea(glconfig)
self.drawing_area.set_events( gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.BUTTON3_MOTION_MASK )
self.drawing_area.set_size_request(640,480)
builder.get_object("vbox1").pack_start(self.drawing_area)
self.tb_run = builder.get_object("tb_run")
self.sp_xb = builder.get_object("sp_xb")
self.sp_xe = builder.get_object("sp_xe")
self.sp_yb = builder.get_object("sp_yb")
self.sp_ye = builder.get_object("sp_ye")
self.sp_zb = builder.get_object("sp_zb")
self.sp_ze = builder.get_object("sp_ze")
self.sp_ms = builder.get_object("sp_miller_size")
self.cb_m = builder.get_object("cb_miller")
self.pbar = builder.get_object("pbar")
win_main = builder.get_object("win_main")
win_main.set_events( gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK )
self.nosetdrill = False
win_main.connect('key-press-event' , self._on_key_pressed )
win_main.connect('key-release-event', self._on_key_released )
win_main.show_all()
width = self.drawing_area.allocation.width
height = self.drawing_area.allocation.height
ratio = float(width)/float(height)
self.scene = Scene( self.fov , ratio , self.near , self.far , meshes )
self.scene.set_speed( builder.get_object("sp_spd").get_value() )
self.drawing_area.add( self.scene )
builder.connect_signals(self)
self.drawing_area.connect('motion_notify_event',self._on_mouse_motion)
self.drawing_area.connect('button_press_event',self._on_button_pressed)
self.drawing_area.connect('configure_event',self._on_reshape)
self.drawing_area.connect_after('expose_event',self._after_draw)
gtk.timeout_add( 1 , self._refresh )
self.pbar.set_visible(False)
def _refresh( self ) :
self.drawing_area.queue_draw()
return True
def _after_draw( self , widget , data=None ) :
self.update_statusbar()
def update_statusbar( self ) :
pass
def _on_reshape( self , widget , data=None ) :
width = self.drawing_area.allocation.width
height = self.drawing_area.allocation.height
ratio = float(width)/float(height)
self.scene.set_screen_size( width , height )
def _on_button_pressed( self , widget , data=None ) :
if data.button == 3 :
self.mouse_pos = data.x , data.y
self.drawing_area.queue_draw()
def _on_mouse_motion( self , widget , data=None ) :
diff = map( op.sub , self.mouse_pos , (data.x , data.y) )
self.scene.mouse_move( diff )
self.mouse_pos = data.x , data.y
#.........这里部分代码省略.........
示例6: App
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import mouse_move [as 别名]
#.........这里部分代码省略.........
self.dirskeys = ( ( ['w'] , ['s'] ) , ( ['a'] , ['d'] ) , ( ['e'] , ['q'] ) )
for d in self.dirskeys :
for e in d :
for i in range(len(e)) : e[i] = ( gtk.gdk.unicode_to_keyval(ord(e[i])) , False )
def _on_key_pressed( self , widget , data=None ) :
if not any(self.move) :
gtk.timeout_add( 20 , self._move_callback )
for i in range(len(self.dirskeys)) :
if (data.keyval,False) in self.dirskeys[i][0] :
self.dirskeys[i][0][ self.dirskeys[i][0].index( (data.keyval,False) ) ] = (data.keyval,True)
self.move[i]+= 1
elif (data.keyval,False) in self.dirskeys[i][1] :
self.dirskeys[i][1][ self.dirskeys[i][1].index( (data.keyval,False) ) ] = (data.keyval,True)
self.move[i]-= 1
def _on_key_released( self , widget , data=None ) :
for i in range(len(self.dirskeys)) :
if (data.keyval,True) in self.dirskeys[i][0] :
self.dirskeys[i][0][ self.dirskeys[i][0].index( (data.keyval,True) ) ] = (data.keyval,False)
self.move[i]-= 1
elif (data.keyval,True) in self.dirskeys[i][1] :
self.dirskeys[i][1][ self.dirskeys[i][1].index( (data.keyval,True) ) ] = (data.keyval,False)
self.move[i]+= 1
def _move_callback( self ) :
self.scene.key_pressed( self.move )
self.drawing_area.queue_draw()
return any(self.move)
def _refresh( self ) :
self.drawing_area.queue_draw()
return True
def _after_draw( self , widget , data=None ) :
self.update_statusbar()
def update_statusbar( self ) :
pass
def _on_reshape( self , widget , data=None ) :
width = self.drawing_area.allocation.width
height = self.drawing_area.allocation.height
ratio = float(width)/float(height)
self.scene.set_screen_size( width , height )
self.scene.set_ratio( ratio )
def _on_button_pressed( self , widget , data=None ) :
if data.button == 3 :
self.mouse_pos = data.x , data.y
self.drawing_area.queue_draw()
def _on_mouse_motion( self , widget , data=None ) :
diff = map( op.sub , self.mouse_pos , (data.x , data.y) )
self.scene.mouse_move( diff )
self.mouse_pos = data.x , data.y
self.drawing_area.queue_draw()
def init_glext(self):
# Query the OpenGL extension version.
# print "OpenGL extension version - %d.%d\n" % gtk.gdkgl.query_version()
# Configure OpenGL framebuffer.
# Try to get a double-buffered framebuffer configuration,
# if not successful then try to get a single-buffered one.
display_mode = (gtk.gdkgl.MODE_RGB |
gtk.gdkgl.MODE_DEPTH |
gtk.gdkgl.MODE_DOUBLE)
try:
glconfig = gtk.gdkgl.Config(mode=display_mode)
except gtk.gdkgl.NoMatches:
display_mode &= ~gtk.gdkgl.MODE_DOUBLE
glconfig = gtk.gdkgl.Config(mode=display_mode)
return glconfig
def _load_img( self , filename ) :
gimg = gtk.image_new_from_file( filename )
gpb = gimg.get_pixbuf()
return Image( gpb.get_width() , gpb.get_height() , gpb.get_pixels() )
def _load_cube_img( self , filenames ) :
pbs = [ gtk.image_new_from_file(filename).get_pixbuf() for filename in filenames ]
w = pbs[0].get_width()
h = pbs[0].get_height()
for p in pbs : assert( w == p.get_width () )
for p in pbs : assert( h == p.get_height() )
return CubeImage( w , h , [ p.get_pixels() for p in pbs ] )
def on_win_main_destroy(self,widget,data=None):
gtk.main_quit()
def on_but_quit_clicked(self,widget,data=None):
gtk.main_quit()