def createGeometries(self, obj): from DejaVu.Geom import Geom geomC = obj.geomContainer c = Geom('path', shape=(0,0), protected=True) c.replace = 'force' geomC.addGeom(c, parent=geomC.masterGeom) for a in obj.allAtoms: a.colors['path']=(1.,1.,1.) a.opacities['path']=1.0 for chain in obj.chains: if not hasattr(chain, 'sheet2D') or chain.sheet2D is None: continue # HACK TO DEBUG SECONDARYSTRUCTURE if not chain.sheet2D.has_key('ssSheet2D') or \ chain.sheet2D['ssSheet2D'] is None: continue # Create a geometry per sheet2D name = 'path'+ chain.id g = Spheres( name, quality = 10, radii = 0.15, protected=True) g.replace = 'force' geomC.addGeom( g, parent=c) self.managedGeometries.append(g) # FIXME to update this geom we would have to implement # self.updateGeom specifically for this command geomC.atoms[name] = ResidueSet() g.chain = chain geomC.atomPropToVertices[name] = self.atomPropToVertices geomC.geomPickToAtoms[name] = self.pickedVerticesToAtoms geomC.geomPickToBonds[name] = None
def createGeometries(self, obj): from DejaVu.Geom import Geom geomC = obj.geomContainer c = Geom('path', shape=(0, 0), protected=True) c.replace = 'force' geomC.addGeom(c, parent=geomC.masterGeom) for a in obj.allAtoms: a.colors['path'] = (1., 1., 1.) a.opacities['path'] = 1.0 for chain in obj.chains: if not hasattr(chain, 'sheet2D') or chain.sheet2D is None: continue # HACK TO DEBUG SECONDARYSTRUCTURE if not chain.sheet2D.has_key('ssSheet2D') or \ chain.sheet2D['ssSheet2D'] is None: continue # Create a geometry per sheet2D name = 'path' + chain.id g = Spheres(name, quality=10, radii=0.15, protected=True) g.replace = 'force' geomC.addGeom(g, parent=c) self.managedGeometries.append(g) # FIXME to update this geom we would have to implement # self.updateGeom specifically for this command geomC.atoms[name] = ResidueSet() g.chain = chain geomC.atomPropToVertices[name] = self.atomPropToVertices geomC.geomPickToAtoms[name] = self.pickedVerticesToAtoms geomC.geomPickToBonds[name] = None
def Add(self, check=1, redo=1, **kw): """Add glfLabels """ #print "Add glfLabels" if __debug__: if check: apply(checkKeywords, (self.name, self.keywords), kw) v = kw.get('vertices') if v: self.redoDspLst = 1 labels = kw.get('labels') if labels: #labels is apparently a tuple self.labels = self.labels + labels self.redoDspLst = 1 Geom.Add(self, check=0, redo=0, vertices=kw.get('vertices'), materials=kw.get('materials')) if self.viewer and redo: if self.redoDspLst: self.viewer.objectsNeedingRedo[self] = None
def initGeom(self): self.cylinders = self.geom = Cylinders('hbondCylinders', quality=40, culling=GL.GL_NONE, radii=(0.2), materials=((0, 1, 0), ), pickable=0, inheritMaterial=0) #DejaVu.Cylinders overwrites kw cull so have to reset it here self.cylinders.culling = GL.GL_NONE geoms = [self.cylinders] miscGeom = self.vf.GUI.miscGeom hbond_geoms = check_hbond_geoms(self.vf.GUI) self.masterGeom = Geom('StrutsAsCylindersGeoms', shape=(0, 0), pickable=0, protected=True) self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=hbond_geoms) for item in geoms: self.vf.GUI.VIEWER.AddObject(item, parent=self.masterGeom) self.hasGeom = 0 self.radii = 0.2 self.length = 1.0 self.oldlength = 1.0 self.verts = [] self.faces = []
def getState(self, full=False): """return a dictionary describing this object's state This dictionary can be passed to the Set method to restore the object's state """ state = Geom.getState(self, full).copy() state.update(self.getSubClassState()) return state
def initGeom(self): from DejaVu.IndexedPolylines import IndexedPolylines #from DejaVu.Labels import Labels self.quality = 4 self.spheres = self.geom = Spheres('strutsSpheres', materials=((0, 1, 0), ), shape=(0, 3), radii=0.1, quality=4, pickable=0, inheritMaterial=0, protected=True) geoms = [self.spheres] self.masterGeom = Geom('strutsAsSpheresGeoms', shape=(0, 0), pickable=0, protected=True) self.masterGeom.isScalable = 0 if self.vf.hasGui: miscGeom = self.vf.GUI.miscGeom hbond_geoms = check_hbond_geoms(self.vf.GUI) self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=hbond_geoms) for item in geoms: self.vf.GUI.VIEWER.AddObject(item, parent=self.masterGeom) self.hasGeom = 0 self.spacing = .40 self.radii = 0.1 self.verts = []
def check_measure_geoms(VFGUI): measure_geoms_list = VFGUI.VIEWER.findGeomsByName('measure_geoms') if measure_geoms_list == []: measure_geoms = Geom("measure_geoms", shape=(0, 0), protected=True) VFGUI.VIEWER.AddObject(measure_geoms, parent=VFGUI.miscGeom) measure_geoms_list = [measure_geoms] return measure_geoms_list[0]
def check_hbond_geoms(VFGUI): hbond_geoms_list = VFGUI.VIEWER.findGeomsByName('struts_geoms') if hbond_geoms_list == []: hbond_geoms = Geom("struts_geoms", shape=(0, 0), protected=True) VFGUI.VIEWER.AddObject(hbond_geoms, parent=VFGUI.miscGeom) hbond_geoms_list = [hbond_geoms] return hbond_geoms_list[0]
def getState(self, full=False): if __debug__: if hasattr(DejaVu, 'functionName'): DejaVu.functionName() state = Geom.getState(self, full) if full: state['faces'] = self.getFaces() state['fnormals'] = self.getFNormals() return state
def getState(self, full=False): state = Geom.getState(self, full) # add knots, ctrlPts, displayMode to state ## state['quality'] = self.quality ## if full: ## rad = self.vertexSet.radii.array ## if len(rad): ## state['radii'] = rad return state
def getState(self, full=False): if __debug__: if hasattr(DejaVu, 'functionName'): DejaVu.functionName() state = Geom.getState(self, full) state['quality'] = self.quality if full: rad = self.vertexSet.radii.array if len(rad): state['radii'] = rad return state
def onAddCmdToViewer(self): if not self.vf.commands.has_key('setICOM'): self.vf.loadCommand('interactiveCommands', 'setICOM', 'Pmv', topCommand=0) if not self.vf.commands.has_key('measureDistance'): self.vf.loadCommand('measureCommands', 'measureDistance', 'Pmv', topCommand=0) self.masterGeom = Geom('measureDistGeom', shape=(0, 0), pickable=0) self.masterGeom.isScalable = 0 if self.vf.hasGui: measure_geoms = check_measure_geoms(self.vf.GUI) self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=measure_geoms) self.lines = IndexedPolylines('distLine', materials=((1, 1, 0), ), inheritMaterial=0, lineWidth=3., stippleLines=1, pickable=0) self.labels = GlfLabels(name='distLabel', shape=(0, 3), font='arial1.glf', fontStyle='solid3d', fontScales=(.5, .5, .3), inheritMaterial=0, materials=((1, 1, 0), )) self.spheres = Spheres(name='distSpheres', shape=(0, 3), inheritMaterial=0, radii=0.2, quality=15, materials=((1., 1., 0.), )) if self.vf.hasGui: for item in [self.lines, self.labels, self.spheres]: self.vf.GUI.VIEWER.AddObject(item, parent=self.masterGeom)
def DisplayFunction(self): """ Either executes the present display list or creates a display list to display the triangle strip. """ # if in select mode, switches to IndexedPolygons if self.viewer.currentCamera.renderMode == GL.GL_SELECT: temp = self.primitiveType if self.frontPolyMode == GL.GL_FILL: self.primitiveType = GL.GL_POLYGON elif self.frontPolyMode == GL.GL_LINE: self.primitiveType = GL.GL_LINE_LOOP elif self.frontPolyMode == GL.GL_POINT: self.primitiveType = GL.GL_POINTS self.faceSet = self.IndexedFaceSet IndexedPolygons.DisplayFunction(self) self.faceSet = self.StripFaceSet self.primitiveType = temp return if self.dpyList: Geom.DisplayFunction(self)
def onAddCmdToViewer(self): if not self.vf.commands.has_key('setICOM'): self.vf.loadCommand('interactiveCommands', 'setICOM', 'Pmv', topCommand=0) if not self.vf.commands.has_key('addBonds'): self.vf.loadCommand('bondsCommands', 'addBonds', 'Pmv', topCommand=0) if not self.vf.commands.has_key('removeBondsGC'): self.vf.loadCommand('bondsCommands', 'removeBondsGC', 'Pmv', topCommand=0) self.masterGeom = Geom('addBondsGeom', shape=(0, 0), pickable=0, protected=True) self.masterGeom.isScalable = 0 self.spheres = Spheres(name='addBondsSpheres', shape=(0, 3), inheritMaterial=0, radii=0.2, quality=15, materials=((1., 1., 0.), ), protected=True) if not self.vf.commands.has_key('labelByExpression'): self.vf.loadCommand('labelCommands', [ 'labelByExpression', ], 'Pmv', topCommand=0) if self.vf.hasGui: miscGeom = self.vf.GUI.miscGeom self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=miscGeom) self.vf.GUI.VIEWER.AddObject(self.spheres, parent=self.masterGeom)
def createGeometries(self, name): from DejaVu.Geom import Geom t = Geom(name, shape=(0, 0), protected=True) self.vf.vectfield[name] = t t.replace = True self.vf.GUI.VIEWER.AddObject(t, redo=0)
from Blender import Window, Scene, Draw bb=[[0, -400.0, -400.0], [400.0, 400.0, 400.0]] sc = bl.getCurrentScene() #display fill box fbb = bl.box('fillpBB',cornerPoints=bb) #maybe /10. bl.addObjectToScene(sc,fbb) #fbb = Box('fillpBB', cornerPoints=bb, visible=1) #vi.AddObject(fbb) # create master for extra cellular compartment # bg = bl.newEmpty('extra cellular') orgaToMasterGeom = {} g = Geom('extra cellular', visible=0) orgaToMasterGeom[0] = g orgaToMasterGeom[h1] = g bl.addObjectToScene(sc,bg) # display organelle mesh for orga in h1.organelles: # create master for organelle bg = bl.newEmpty('organelle_%d'%orga.number) g = Geom('organelle_%d'%orga.number) bl.addObjectToScene(sc,bg) gs = Geom('surface') bgs = bl.newEmpty('surface') bl.addObjectToScene(sc,bgs, parent=bg) gc = Geom('cytoplasm') bgc = bl.newEmpty('cytoplasm')
def createGeometries(self, name): from DejaVu.Geom import Geom t = Geom(name,shape=(0,0), protected=True) self.vf.vectfield[name]=t t.replace = True self.vf.GUI.VIEWER.AddObject(t, redo=0)
def onAddCmdToViewer(self): if not hasattr(self.vf, 'GUI'): return self.undoNow = 0 self.save = None from DejaVu.bitPatterns import pat3 from DejaVu.IndexedPolygons import IndexedPolygons if not self.vf.commands.has_key('setICOM'): self.vf.loadCommand('interactiveCommands', 'setICOM', 'Pmv', topCommand=0) if not self.vf.commands.has_key('measureTorsion'): self.vf.loadCommand('measureCommands', 'measureTorsion', 'Pmv', topCommand=0) self.masterGeom = Geom('setTorsionGeom', shape=(0, 0), pickable=0, protected=True) self.masterGeom.isScalable = 0 self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=self.vf.GUI.miscGeom) self.lines = IndexedPolygons( 'settorsionLine', materials=((0, 1, 1), ), inheritMaterial=0, stipplePolygons=1, protected=True, ) if self.vf.userpref['Sharp Color Boundaries for MSMS'][ 'value'] == 'blur': self.lines.Set( inheritSharpColorBoundaries=False, sharpColorBoundaries=False, ) self.lines.polygonstipple.Set(pattern=pat3) #, tagModified=False) #self.lines.RenderMode(GL.GL_FILL, face=GL.GL_BACK) self.lines.Set(backPolyMode=GL.GL_FILL) self.labels = GlfLabels(name='settorsionLabel', shape=(0, 3), inheritMaterial=0, materials=((0, 1, 1), )) self.spheres = Spheres(name='settorsionSpheres', shape=(0, 3), radii=0.2, quality=15, inheritMaterial=0, materials=((0., 1., 1.), ), protected=True) for item in [self.lines, self.labels, self.spheres]: self.vf.GUI.VIEWER.AddObject(item, parent=self.masterGeom) self.snakeLength = 1 self.oldValue = None self.torsionType = Tkinter.StringVar() self.torsionType.set('1') self.newAngList = Tkinter.StringVar() self.TAHdata = None self.molecule = None #self.bondString = Tkinter.StringVar() self.callbackDict = {} self.callbackDict['measureDistanceGC'] = 'update' self.callbackDict['measureAngleGC'] = 'update' self.callbackDict['measureTorsionGC'] = 'update'
def onAddCmdToViewer(self): from DejaVu.bitPatterns import pat3 from DejaVu.IndexedPolygons import IndexedPolygons if not self.vf.commands.has_key('setICOM'): self.vf.loadCommand('interactiveCommands', 'setICOM', 'Pmv', topCommand=0) if not self.vf.commands.has_key('measureAngle'): self.vf.loadCommand('measureCommands', 'measureAngle', 'Pmv', topCommand=0) self.masterGeom = Geom('measureTorsionGeom', shape=(0, 0), pickable=0, protected=True) self.masterGeom.isScalable = 0 if self.vf.hasGui: measure_geoms = check_measure_geoms(self.vf.GUI) self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=measure_geoms) self.lines = IndexedPolygons('torsionLine', materials=((0, 1, 1), ), culling=GL.GL_NONE, inheritStipplePolygons=0, inheritMaterial=0, stipplePolygons=1, backPolyMode=GL.GL_FILL, frontPolyMode=GL.GL_FILL, protected=True, pickable=0) if self.vf.userpref['Sharp Color Boundaries for MSMS'][ 'value'] == 'blur': self.lines.Set( inheritSharpColorBoundaries=False, sharpColorBoundaries=False, ) self.lines.polygonstipple.Set(pattern=pat3) #self.lines.polygonstipple.Set(pattern=pat3, tagModified=False) #self.lines.RenderMode(GL.GL_FILL) #self.lines.RenderMode(GL.GL_FILL, face=GL.GL_BACK) self.labels = GlfLabels(name='torsionLabel', shape=(0, 3), font='arial1.glf', fontStyle='solid3d', fontScales=(.5, .5, .3), inheritMaterial=0, materials=((0, 1, 1), )) self.spheres = Spheres(name='torsionSpheres', shape=(0, 3), inheritMaterial=0, radii=0.2, quality=15, materials=((0., 1., 1.), ), protected=True) if self.vf.hasGui: for item in [self.lines, self.labels, self.spheres]: self.vf.GUI.VIEWER.AddObject(item, parent=self.masterGeom) doc = """Number of labeled torsions displayed. Valid values are integers>0""" self.vf.userpref.add('Measured Torsions', 4, callbackFunc=[self.setLength_cb], category="Molecules", validateFunc=lambda x: x > 0, doc=doc) #used after startICOM is invoked doc = """Continuous update of torsions if 'transformRoot only' is turned off and viewer's current object is not Root.""" choices = ['yes', 'no'] self.vf.userpref.add('Continuous Update Torsion', 'yes', choices, callbackFunc=[self.continuousUpdate_cb], category="Molecules", doc=doc) self.snakeLength = 4
def onAddCmdToViewer(self): from DejaVu.Points import CrossSet self.startCross = CrossSet('StartCross', materials=((1., 1., 0), ), inheritMaterial=0, protected=True, offset=1.0, lineWidth=5, visible=0, pickable=0, listed=0) self.endCross = CrossSet('EndCross', materials=((0, 1, 1), ), inheritMaterial=0, protected=True, offset=1.0, lineWidth=5, visible=0, pickable=0, listed=0) from DejaVu.IndexedPolygons import IndexedPolygons from DejaVu.Box import Box from DejaVu.Spheres import Spheres from DejaVu import viewerConst from DejaVu.bitPatterns import patternList from opengltk.OpenGL import GL face = ((0, 3, 2, 1), (3, 7, 6, 2), (7, 4, 5, 6), (0, 1, 5, 4), (1, 2, 6, 5), (0, 4, 7, 3)) coords = ((1, 1, -1), (-1, 1, -1), (-1, -1, -1), (1, -1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1)) #new style RGB-> materials = ( (0, 0, 1), (0, 1, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 0, 0), ) box = IndexedPolygons('Box', materials=materials, vertices=coords, faces=face, inheritMaterial=0, visible=0, protected=True, listed=0) box.Set(frontPolyMode=GL.GL_LINE) box.Set(backPolyMode=GL.GL_LINE) box.Set(culling=GL.GL_NONE) box.inheritShading = 0 box.shading = GL.GL_FLAT box.Set(matBind=viewerConst.PER_PART) box.polygonstipple.Set(pattern=patternList[0]) box.Set(stipplePolygons=1) box.transparent = 0 self.box = box self.spheres = Spheres('Spheres', visible=0, inheritMaterial=0, radii=(0.3, ), protected=True, listed=0) self.halo = Spheres('Halo', visible=0, inheritMaterial=0, radii=(0.5, ), protected=True, listed=0) from DejaVu.Geom import Geom AutoLigand_geoms = Geom("AutoLigand_geoms", shape=(0, 0), listed=0) self.vf.GUI.VIEWER.AddObject(AutoLigand_geoms, parent=self.vf.GUI.miscGeom) self.vf.GUI.VIEWER.AddObject(self.startCross, parent=AutoLigand_geoms) self.vf.GUI.VIEWER.AddObject(self.endCross, parent=AutoLigand_geoms) self.vf.GUI.VIEWER.AddObject(self.box, parent=AutoLigand_geoms) self.vf.GUI.VIEWER.AddObject(self.spheres, parent=AutoLigand_geoms) self.vf.GUI.VIEWER.AddObject(self.halo, parent=AutoLigand_geoms) self.grids = {} self.vf.showCitation.citations["AutoLigand"] = """
from Pmv.hostappInterface import pdb_blender vi = pdb_blender Box = pdb_blender.box Geom = pdb_blender.newEmpty IndexedPolygons = pdb_blender.polygons sc = pdb_blender.getCurrentScene() Points = None #display fill box #fbb = Box('fillpBB',cornerPoints=bb,visible=1) #maybe /10. #vi.AddObject(fbb) # create master for cytoplasm compartment # orgaToMasterGeom = {} g = Geom('cytoplasm', visible=0) orgaToMasterGeom[0] = g orgaToMasterGeom[h1] = g vi.AddObject(g) # create masters for ingredients r = h1.exteriorRecipe if r: for ingr in r.ingredients: gi = Geom('%s %s' % (ingr.pdb, ingr.name)) vi.AddObject(gi, parent=g) orgaToMasterGeom[ingr] = gi # display organelle mesh for orga in h1.organelles: # create master for organelle