コード例 #1
0
 def deltas(self, x, y, z, dx, dy):
     self.m.f.c.setup_projection()
     self.m.f.c.apply_transformations()
     dxdydz = (util.screen_to_model(x, y, z) -
               util.screen_to_model(x - dx, y - dy, z))
     dxdydz = np.round(dxdydz, decimals=6)  # knob
     self.m.f.c.unset_projection()
     return dxdydz
コード例 #2
0
 def mouse_translate(self, x, y, dx, dy):
     self.setup_projection()
     glTranslatef(0, 0, - self.dist)
     z = util.model_to_screen(0, 0, 0)[2]
     d = (util.screen_to_model(x, y, z) -
          util.screen_to_model(x - dx, y - dy, z))
     self.unset_projection()
     self.x += d[0]; self.y += d[1]
コード例 #3
0
ファイル: plot_camera.py プロジェクト: 101man/sympy
 def mouse_translate(self, x, y, dx, dy):
     glPushMatrix()
     glLoadIdentity()
     glTranslatef(0, 0, -self._dist)
     z = model_to_screen(0, 0, 0)[2]
     d = vec_subs(screen_to_model(x, y, z), screen_to_model(x-dx, y-dy, z))
     glPopMatrix()
     self._x += d[0]
     self._y += d[1]
コード例 #4
0
 def mouse_translate(self, x, y, dx, dy):
     glPushMatrix()
     glLoadIdentity()
     glTranslatef(0,0,-self._dist)
     z = model_to_screen(0,0,0)[2]
     d = vec_subs(screen_to_model(x,y,z), screen_to_model(x-dx,y-dy,z))
     glPopMatrix()
     self._x += d[0]
     self._y += d[1]
コード例 #5
0
 def pick_object(self, pon, x, y, crn=False):
     self.m.f.c.setup_projection()
     self.m.f.c.apply_transformations()
     try:
         z = glReadPixels(x, y, 5, 5, GL_DEPTH_COMPONENT, GL_FLOAT)  # knob
         zc = z != 1.0
         if zc.any():
             z = np.average(z[zc])
             mxyz = util.screen_to_model(x, y, z)
             if pon == 'points':
                 self.pick_point(x, y, mxyz)
             else:
                 self.pick_nurbs(z, mxyz, pon, crn)
     except PickedPlotObject as e:
         self.success = True
         po, pxyz = e.args[:2]
         self.spawn_picked_point(pxyz, po)
         self.set_picked_color(po)
         self.picked_pos.append(po)
         self.update_mode(e)
     else:
         self.__init__(self.m)
     finally:
         pp, ps = self._pp, self.picked_pos
         pxyz = pp.xyz if pp else None
         p = ps[-1] if ps else None
         self.m.f.IP.user_ns.update(
             dict(last_picked_xyz=pxyz,
                  last_picked_object=p,
                  last_picked_objects=ps))
     self.m.f.c.unset_projection()