def testMSMSParser(): from Pmv.msmsParser import MSMSParser msmsParser = MSMSParser() msmsParser.parse("./gc2.vert", "./gc2.face") msmsParser.parse("./test_0.vert", "./test_0.face") from DejaVu import Viewer vi = Viewer() from DejaVu.IndexedPolygons import IndexedPolygons visrf = IndexedPolygons('test', protected=True) visrf.Set(vertices=msmsParser.vertices, faces=msmsParser.faces, vnormals=msmsParser.normals, tagModified=False) vi.AddObject(visrf)
GL.glColor4fv(colxf) GL.glBegin(GL.GL_LINE_STRIP) for i in range(self.nsegments + 1): GL.glVertex3fv(self.v[i]) GL.glEnd() GL.glPopMatrix() if __name__ == '__main__': from DejaVu.Arcs3D import Arcs3D, Fan3D c = Arcs3D('arc3d', vertices=((0, 0, 0), (5., 0., 0.)), vnormals=((1.0, 0, 0), (0, 1., 0)), materials=((1, 0, 0), (0, 0, 1)), radii=(1.0, 2.0), angles=(360., 180.)) f = Fan3D('fan3d', vertices=((0, 0, 0), (5., 0., 0.)), vnormals=((0, 0, 1), (0, 1., 0)), materials=((1, 0, 0), (0, 0, 1)), radii=(1.0, 2.0), angles=(60., 170.), vectors=((1, 1, 0), (1, 0, 0))) from DejaVu import Viewer vi = Viewer() vi.AddObject(c) vi.AddObject(f)
from DejaVu import Viewer vi = Viewer() vert = [(0, 1, 0), (1, 0, 1), (1, 1, 0), (2, 0, -1), (2, 1, 0), (3, 0, 1), (3, 1, 0), (4, 0, -1), (4, 1, 0), (5, 0, 1), (5, 3, 0), (6, -2, 1)] v1 = Numeric.array(vert) v2 = v1 + 3.0 v3 = Numeric.concatenate((v1, v2)) colors = [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 0), (0, 1, 0)] v4 = v2 + 3.0 v5 = Numeric.concatenate((v3, v4)) strip3 = Triangle_strip(vertices=v5, stripBegin=[0, 12], materials=[(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 0), (0, 1, 0)]) #strip.Set(materials = [(1, 0, 0)]) vi.AddObject(strip3) strip2 = Triangle_strip(vertices=v3, stripBegin=[0, 12, 24], materials=colors + colors[0:8]) #strip2.Set(materials = [(0, 1, 0), (0, 0, 1)]) vi.AddObject(strip2) strip = Triangle_strip(vertices=vert, materials=colors[2:12]) #strip.Set(materials = [(1, 0, 0)]) vi.AddObject(strip)
def restore(self, event=None): if __debug__: if hasattr(DejaVu, 'functionName'): DejaVu.functionName() self.cw.Set(self.savedColor, 'RGB') if __name__ == '__main__': import Tkinter master = Tkinter.Toplevel() from DejaVu import Viewer vi = Viewer() from DejaVu.colorMap import ColorMap test = MaterialEditor(master, vi) from DejaVu.Spheres import Spheres s = Spheres('test', centers=[[0., 0, 0], [5, 0, 0.], [0, 5, 0]], quality=30, matName='tropical', matInd=0) vi.AddObject(s) from DejaVu.materialsDef.tropical import tropical test.defineMaterial(tropical[0]) test.setObject(s) ## root1 = Tkinter.Tk() ## cc = ColorChooser(root1, title='Color chooser')
def GetSize(self): return self.volumeSize if __name__ == '__main__': # create a DejaVu Viewer from DejaVu import Viewer vi = Viewer() #Create a volumerender geoms g = UTVolRenGeom('volren') g.viewer = vi vi.cameras[0].Activate() g.InitVolumeRenderer() g.LoadVolume("vh4.rawiv") g.grayRamp() #g.LoadColorMap("/mgl/ms3/python/dev/Volume/SimpleExample/colormap.map") #g.InitData() # add a transparent object without a dpylist vi.AddObject(g) #Color map editor ## from mglutil.gui.BasicWidgwts.Tk.tablemaker import TableManager ## t = TableManager(master=vi.master, ## ymaxval = 255, ## alphaCallback = g.setVolRenAlpha, ## colorCallback = g.setVolRenColors)
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 g = Geom('organelle_%d' % orga.number) vi.AddObject(g) gs = Geom('surface')
for j in range(4): GL.glVertex3fv(self.ctlpoints[i][j]) GL.glEnd() GL.glDisable(GL.GL_AUTO_NORMAL) GL.glDisable(GL.GL_NORMALIZE) if __name__ == '__main__': from DejaVu.Nurbs import GLUSurfaceNurbs from DejaVu import Viewer vi = Viewer() nurbsg = GLUSurfaceNurbs('nurbs') vi.AddObject(nurbsg) def move(): from random import uniform for n in range(200): for i in range(1, 3): for j in range(1, 3): nurbsg.ctlpoints[i][j][2] += uniform(-0.3, 0.3) vi.OneRedraw() vi.master.update() import numpy def move1(): for n in range(1, 11): v = n * 0.1
'Bases', vertices=vertices, faces=faces, inheritShading=False, shading=GL.GL_FLAT, materials=materials, inheritMaterial=False, ) return geom_bases def returnStarOrQuote(atoms, txt): names = [name.split("@")[0] for name in atoms.name] try: idx = names.index(txt + '*') return atoms[idx] except: idx = names.index(txt + "'") return atoms[idx] if __name__ == '__main__': from DejaVu import Viewer vi = Viewer() from DejaVu import NucleicBases b = NucleicBases.Pyrimidine_old('b') vi.AddObject(b) while (1): vi.update()
from DejaVu import Viewer vi = Viewer() from DejaVu.IndexedPolygons import IndexedPolygons tet = IndexedPolygons('surfaceMesh', vertices=vertices, faces=faces, vnormals=vnormals, inheritFrontPolyMode=False, frontPolyMode='line', inheritCulling=0, culling='none', inheritShading=0, shading='flat', visible=0) vi.AddObject(tet) #from DejaVu.Spheres import Spheres #sectionVsph = Spheres('sectionV', vertices=vertsS, radii=(0.02,)) #vi.AddObject(sectionVsph) #from DejaVu.Points import Points #sectionVpts = Points('sectionV', vertices=allvertsS) #sectionVpts = Points('sectionV', vertices=[vertsS[14], vertsS[159], vertsS[158]]) #vi.AddObject(sectionVpts) #from DejaVu.IndexedPolylines import IndexedPolylines #line = IndexedPolylines( # 'sectionL', vertices=allvertsS, faces=edgesS, # inheritLinewidth=False, Linewidth=3, # inheritMaterial=False, materials=( (0,1,0), )) #vi.AddObject(line)
import profile # profile.run("smooth, ctrl = ribbon2D( nrib, width, nchords, offset, natoms, cao, [0]*46 );") profile.run("smooth = ribbon2D( nrib, width, nchords, offset, natoms, cao, [0]*46 );") from DejaVu import Viewer vi = Viewer() from DejaVu.IndexedPolygons import IndexedPolygons f = [] n = smooth.shape[1] f = map( lambda x: (x, x+1, x+n+1, x+n), range(smooth.shape[1]-1)) v = Numeric.array(Numeric.reshape(smooth, (-1,4))[:,:3]) p = IndexedPolygons('sheet2D', vertices = v, faces = f, protected=True,) if self.vf.userpref['Sharp Color Boundaries for MSMS']['value'] == 'blur': p.Set(inheritSharpColorBoundaries=False, sharpColorBoundaries=False,) p.replace = False vi.AddObject(p) from DejaVu.Spheres import Spheres ctrl.shape = (-1,4) p = Spheres('ctrl', centers = ctrl[:, :3], radii = 0.6, protected=True) p.replace = False vi.AddObject(p) from DejaVu.Spheres import Spheres s = Spheres('sph', vertices = v, quality=5, protected=True) s.radius = 0.2 vi.AddObject(s) from MolKit import Read mol = Read('../1crn.pdb') allatoms = mol.chains.residues.atoms