def deleteOpenglList(self): #print "Common2d3dObject.deleteOpenglList", self self.redoDspLst = 0 currentcontext = self.viewer.currentCamera.tk.call( self.viewer.currentCamera._w, 'contexttag') if self.dpyList is not None: if currentcontext != self.dpyList[1]: warnings.warn( """deleteOpenglList failed because the current context is the wrong one""" ) #print "currentcontext != self.dpyList[1]", currentcontext, self.dpyList[1] #import traceback;traceback.print_stack() else: #print '-%d'%self.dpyList[0], currentcontext,"glDeleteLists Common2d3dObject" GL.glDeleteLists(self.dpyList[0], 1) self.dpyList = None if self.pickDpyList is not None: if currentcontext != self.pickDpyList[1]: warnings.warn( """deleteOpenglList failed because the current context is the wrong one""" ) #print "currentcontext != self.pickDpyList[1]", currentcontext, self.pickDpyList[1] else: #print '-%d'%self.pickDpyList[0], currentcontext, "glDeleteLists Common2d3dObject2", GL.glDeleteLists(self.pickDpyList[0], 1) self.pickDpyList = None
def redoDisplayListCSG(self): if self.dpyListCSG is not None: GL.glDeleteLists(1, self.dpyListCSG) g = self.geom self.dpyListCSG = GL.glGenLists(1) GL.glNewList(self.dpyListCSG, GL.GL_COMPILE) ## if isinstance(g, Spheres): ## g.DisplayFunction() ## else: self.drawpolygons() GL.glEndList()
def clearCache_cb(self): #print "clearing cache: " vi = self.vf.GUI.VIEWER currentcontext = vi.currentCamera.tk.call(vi.currentCamera._w, 'getcurrentcontext') for dl in self.dpyLists.keys(): if self.dpyLists[dl]is not None: if currentcontext != self.dpyLists[dl][1]: print "currentcontext != self.dpyLists[%d][1]" %(dl,), currentcontext, self.dpyLists[dl][1] c = vi.currentCamera c.tk.call(c._w, 'makecurrent') #import pdb; pdb.set_trace() #print "glDeleteLists TrajPlayerCached", self.dpyLists[dl][0] GL.glDeleteLists(self.dpyLists[dl][0], 1) self.dpyLists.pop(dl)
def deleteTemplate(self): #print "Ellipsoids.deleteTemplate" # it is asumed the right OpenGL context is active assert self.templateDSPL is not None currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag') if currentcontext != self.templateDSPL[1]: import traceback;traceback.print_stack() warnings.warn('deleteTemplate failed because the current context is the wrong one') print "currentcontext != self.templateDSPL[1]", currentcontext, self.templateDSPL[1] else: #print '-%d'%self.templateDSPL[0], currentcontext, "glDeleteLists Ellipsoids" #print '-%d'%(self.templateDSPL[0]+1), currentcontext, "glDeleteLists Ellipsoids" #print '-%d'%(self.templateDSPL[0]+2), currentcontext, "glDeleteLists Ellipsoids" GL.glDeleteLists(self.templateDSPL[0], 3) self.templateDSPL = None
def clearCache_cb(self): #print "clearing cache: " vi = self.vf.GUI.VIEWER currentcontext = vi.currentCamera.tk.call(vi.currentCamera._w, 'contexttag') for dl in self.dpyLists.keys(): if self.dpyLists[dl]is not None: if currentcontext != self.dpyLists[dl][1]: print "currentcontext != self.dpyLists[%d][1]" %(dl,), currentcontext, self.dpyLists[dl][1] c = vi.currentCamera c.tk.call(c._w, 'makecurrent') #import pdb; pdb.set_trace() #print "glDeleteLists TrajPlayerCached", self.dpyLists[dl][0] GL.glDeleteLists(self.dpyLists[dl][0], 1) self.dpyLists.pop(dl)
def deleteTemplate(self): if __debug__: if hasattr(DejaVu, 'functionName'): DejaVu.functionName() #print "Spheres.deleteTemplate", self.templateDSPL # it is asumed the right OpenGL context is active if GL.glGetIntegerv(GL.GL_LIST_INDEX) == [0]: assert self.templateDSPL is not None currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag') if currentcontext != self.templateDSPL[1]: import traceback;traceback.print_stack() warnings.warn('deleteTemplate failed because the current context is the wrong one') print "currentcontext != self.templateDSPL[1]", currentcontext, self.templateDSPL[1] else: #print '-%d'%self.templateDSPL[0], currentcontext, "glDeleteLists Spheres0" #print '-%d'%(self.templateDSPL[0]+1), currentcontext, "glDeleteLists Spheres1" #print '-%d'%(self.templateDSPL[0]+2), currentcontext, "glDeleteLists Spheres2" GL.glDeleteLists(self.templateDSPL[0], 3) self.templateDSPL = None
def deleteTemplate(self): if __debug__: if hasattr(DejaVu, 'functionName'): DejaVu.functionName() #print "Spheres.deleteTemplate", self.templateDSPL # it is asumed the right OpenGL context is active if GL.glGetIntegerv(GL.GL_LIST_INDEX) == [0]: assert self.templateDSPL is not None currentcontext = self.viewer.currentCamera.tk.call( self.viewer.currentCamera._w, 'contexttag') if currentcontext != self.templateDSPL[1]: import traceback traceback.print_stack() warnings.warn( 'deleteTemplate failed because the current context is the wrong one' ) print "currentcontext != self.templateDSPL[1]", currentcontext, self.templateDSPL[ 1] else: #print '-%d'%self.templateDSPL[0], currentcontext, "glDeleteLists Spheres0" #print '-%d'%(self.templateDSPL[0]+1), currentcontext, "glDeleteLists Spheres1" #print '-%d'%(self.templateDSPL[0]+2), currentcontext, "glDeleteLists Spheres2" GL.glDeleteLists(self.templateDSPL[0], 3) self.templateDSPL = None
def deleteOpenglList(self): #print "Common2d3dObject.deleteOpenglList", self self.redoDspLst = 0 currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag') if self.dpyList is not None: if currentcontext != self.dpyList[1]: warnings.warn("""deleteOpenglList failed because the current context is the wrong one""") #print "currentcontext != self.dpyList[1]", currentcontext, self.dpyList[1] #import traceback;traceback.print_stack() else: #print '-%d'%self.dpyList[0], currentcontext,"glDeleteLists Common2d3dObject" GL.glDeleteLists(self.dpyList[0], 1) self.dpyList = None if self.pickDpyList is not None: if currentcontext != self.pickDpyList[1]: warnings.warn("""deleteOpenglList failed because the current context is the wrong one""") #print "currentcontext != self.pickDpyList[1]", currentcontext, self.pickDpyList[1] else: #print '-%d'%self.pickDpyList[0], currentcontext, "glDeleteLists Common2d3dObject2", GL.glDeleteLists(self.pickDpyList[0], 1) self.pickDpyList = None
def RedoDisplayList(self): if __debug__: if hasattr(DejaVu, 'functionName'): DejaVu.functionName() #print "IndexedGeom.RedoDisplayList", self.name ## if __debug__: ## print 'IndexedGeom RedoDisplayList for', self.fullName Geom.RedoDisplayList(self) if len(self.faceSet) and len(self.vertexSet) \ and ( self.primitiveType == GL.GL_TRIANGLES \ or self.primitiveType == GL.GL_QUADS \ or self.primitiveType == GL.GL_POLYGON): # we always build this, that way we don't have to built on demand outl = self.outline if outl.colorAsMaterial: if self.materials[GL.GL_FRONT] and \ not self.inheritMaterial: mat = self.materials[GL.GL_FRONT] fpProp = [] fpBind = [] for propInd in range(4): b, p = mat.GetProperty(propInd) fpProp.append(p) fpBind.append(b) fpProp.append(mat.prop[4]) fpBind.append(mat.binding[4]) else: fpProp = None fpBind = None if self.materials[GL.GL_BACK] and \ not self.inheritMaterial: mat = self.materials[GL.GL_BACK] bpProp = [] bpBind = [] for propInd in range(4): b, p = mat.GetProperty(propInd) bpProp.append(p) bpBind.append(b) bpProp.append(mat.prop[4]) bpBind.append(mat.binding[4]) else: bpProp = None bpBind = None else: fpProp = bpProp = fpBind = bpBind = None texCoords = None if outl.lighting: norms = self.normals else: norms = None # WARNING: if texture, fpProp, bpProp, fpBind, bpBind, # are not passed (either None or arrays) we get a segmentation # fault if the surface has many colors (i.e. color MSMS by atom # type and dispaly outline seg faults) # calling with too many arguments segaults too # just add None, None, None, None, after the line with colors if hasattr(outl, 'dpyList') and outl.dpyList is not None: lNewList = outl.dpyList[0] else: lNewList = GL.glGenLists(1) self.viewer.deleteOpenglList() #print "lNewList IndexedGeom.RedoDisplayList", lNewList, self.name lCurrentContext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag') outl.dpyList = ( lNewList, lCurrentContext) GL.glNewList(outl.dpyList[0], GL.GL_COMPILE) #print '+%d'%outl.dpyList[0], lCurrentContext, "glNewList IndexedGeom" status=glDrawIndexedGeom( GL.GL_TRIANGLES, self.vertexSet.vertices.array, self.faceSet.faces.array, norms, texCoords, fpProp, bpProp, fpBind, bpBind, self.frontAndBack, 1) # 1 means use diffuse component if no lighting #print '*%d'%GL.glGetIntegerv(GL.GL_LIST_INDEX), "glEndList IndexedGeom" GL.glEndList() if not status: #print '-%d'%outl.dpyList[0], "glDeleteLists IndexedGeom" GL.glDeleteLists(outl.dpyList[0], 1) outl.dpyList = None