def draw_rectangle(self,x,y): GD.debugt("DRAWRECTANGLE") if self.cursor: self.removeDecoration(self.cursor) col = GD.cfg.get('pick/color','yellow') self.cursor = decors.Grid(self.statex,self.statey,x,y,color=col,linewidth=1) self.addDecoration(self.cursor)
def gl_pickbuffer(): "Return a list of the 2nd numbers in the openGL pick buffer." buf = GL.glRenderMode(GL.GL_RENDER) GD.debugt("translate getpickbuf") return asarray([ r[2] for r in buf ])
def saveBuffer(self): """Save the current OpenGL buffer""" GD.debugt("saveBuffer") self.save_buffer = GL.glGetIntegerv(GL.GL_DRAW_BUFFER)
def pick_parts(self,obj_type,max_objects,store_closest=False): """Set the list of actor parts inside the pick_window. obj_type can be 'element', 'point' or 'edge'(SurfaceActor only) max_objects specifies the maximum number of objects The picked object numbers are stored in self.picked. If store_closest==True, the closest picked object is stored in as a tuple ( [actor,object] ,distance) in self.picked_closest """ GD.debugt("PICKPARTS") self.camera.loadProjection(pick=self.pick_window) self.camera.loadMatrix() stackdepth = 2 GL.glSelectBuffer(max_objects*(3+stackdepth)) GL.glRenderMode(GL.GL_SELECT) GL.glInitNames() GD.debugt("pickGL from %s" % len(self.actors)) for i,a in enumerate(self.actors): GL.glPushName(i) a.pickGL(obj_type) GL.glPopName() GD.debugt("getpickbuf") buf = GL.glRenderMode(GL.GL_RENDER) GD.debugt("translate getpickbuf") self.picked = [ r[2] for r in buf ] GD.debugt("store closest") if store_closest and len(buf) > 0: d = asarray([ r[0] for r in buf ]) dmin = d.min() w = where(d == dmin)[0][0] self.closest_pick = (self.picked[w], dmin) GD.debugt("PICKPARTS DONE")