def __init__(self, parent=None, image=None,application=None,winid=None): EMImage3DWidget.allim[self] = 0 EMGLWidget.__init__(self,parent) EMLightsDrawer.__init__(self) EMGLProjectionViewMatrices.__init__(self) fmt=QtOpenGL.QGLFormat() fmt.setDoubleBuffer(True) fmt.setDepth(True) fmt.setStencil(True) fmt.setSampleBuffers(True) self.setFormat(fmt) self.aspect=1.0 self.fov = 50 # field of view angle used by gluPerspective self.d = 0 self.zwidth = 0 self.yheight = None self.data = None # should eventually be an EMData object # self.cam = Camera() self.cam = Camera2(self) self.cam.cam_z = -250 self.resize(480,480) self.startz = 1 self.endz = 500 self.currentselection = -1 self.inspector = None self.viewables = [] self.num_iso = 0 self.num_vol = 0 self.num_sli = 0 self.num_sym = 0 self.vdtools = EMViewportDepthTools(self) self.last_window_width = -1 # used for automatic resizing from the desktop self.last_window_height = -1 # used for automatic resizing from the desktop self.file_name = None self.emit_events = False self.perspective = False if image != None: self.set_data(image) #From get_qt_widget... if isinstance(self.data,EMData): self.set_cam_z_from_fov_image(self.get_fov(),self.data) self.qt_parent.setWindowIcon(QtGui.QIcon(get_image_directory() +"single_image_3d.png")) #End from get_qt_widget self.updateGL() #Solves "error, OpenGL seems not to be initialized" message
def mouseReleaseEvent(self, event): if self.current_mouse_mode: EMLightsDrawer.mouseReleaseEvent(self, event) else: for model in self.viewables: try: model.mouseReleaseEvent(event) except AttributeError, e: pass
def mousePressEvent(self, event): if event.button()==Qt.MidButton or (event.button()==Qt.LeftButton and event.modifiers()&Qt.AltModifier): self.show_inspector() if self.current_mouse_mode: EMLightsDrawer.mousePressEvent(self, event) else: for model in self.viewables: try: model.mousePressEvent(event) except AttributeError, e: pass
def render(self): try: self.image_change_count = self.data["changecount"] # this is important when the user has more than one display instance of the same image, for instance in e2.py if except: try: self.image_change_count = self.data[0]["changecount"] except: pass glPushMatrix() self.cam.position(True) # the ones are dummy variables atm... they don't do anything self.vdtools.update(1,1) glPopMatrix() dz = None if not self.perspective: glMatrixMode(GL_PROJECTION) glPushMatrix() self.load_orthographic() glMatrixMode(GL_MODELVIEW) glPushMatrix() self.cam.position() for i in self.viewables: glPushMatrix() i.render() glPopMatrix() glPopMatrix() glPushMatrix() self.cam.translate_only() EMLightsDrawer.draw(self) glPopMatrix() if not self.perspective: glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW)