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)
#get the current slider value o = self.helper.getObject("newCube") #get the cube if o is not None: #if the cube exists change the scale value self.helper.scaleObj(o, scale) #this is a script, we need some special code for the Tk and the Qt case. #the most important part are the instanciation of our dialog class, #and the two functio setup and display #setup initialise the widget and the layout #display wil actually show the dialog. if uiadaptor.host == "tk": from DejaVu import Viewer vi = Viewer() #require a master #import Tkinter #Tkinter if python2.x tkinter for python3.x #root = Tkinter.Tk() mygui = Cubi(title="CubeUI", master=vi) mygui.setup(vi=vi) #mygui.display() elif uiadaptor.host == "qt": from PyQt4 import QtGui app = QtGui.QApplication(sys.argv) mygui = Cubi(title="CubeUI") mygui.setup() #ex.show() else: mygui = Cubi(title="CubeUI") mygui.setup()
GL.GL_BACK, propConst[k], backMat[k][sB[stripNum] + i]) # draw vertex #GL.glVertex3dv(v) gllib.glVertex3fv(v) i = i + 1 GL.glEnd() GL.glPopName() return 1 if __name__ == '__main__': import pdb, numpy.oldnumeric as Numeric 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),
# create a Viewer from DejaVu import Viewer if ViewerType == 'dejavu': vi = Viewer() from DejaVu.Box import Box from DejaVu.Spheres import Spheres from DejaVu.Cylinders import Cylinders from DejaVu.Geom import Geom from DejaVu.IndexedPolygons import IndexedPolygons from DejaVu.Points import Points from DejaVu.glfLabels import GlfLabels from DejaVu.Polylines import Polylines elif ViewerType == 'c4d': import c4d #from Pmv.hostappInterface import pdb_c4d import Pmv.hostappInterface.cinema4d.helperC4D as pdb_c4d vi = pdb_c4d Box = pdb_c4d.box Geom = pdb_c4d.newEmpty IndexedPolygons = pdb_c4d.polygons Points = pdb_c4d.PointCloudObject sc = pdb_c4d.getCurrentScene() dejavumat = vi.createDejaVuColorMat() helper = pdb_c4d elif ViewerType == 'blender': import Blender from Pmv.hostappInterface import pdb_blender vi = pdb_blender Box = pdb_blender.box Geom = pdb_blender.newEmpty IndexedPolygons = pdb_blender.polygons
GL.glColor3f(1.0, 1.0, 0.0) GL.glBegin(GL.GL_POINTS) for i in range(4): 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
'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()
faces = [] for residue in residues: faces.extend(residue._base_faces) geom_bases = IndexedPolygons('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()
# create a Viewer from DejaVu import Viewer if ViewerType == 'dejavu': vi = Viewer() from DejaVu.Box import Box from DejaVu.Spheres import Spheres from DejaVu.Cylinders import Cylinders from DejaVu.Geom import Geom from DejaVu.IndexedPolygons import IndexedPolygons from DejaVu.Points import Points from DejaVu.glfLabels import GlfLabels from DejaVu.Polylines import Polylines elif ViewerType == 'c4d': import c4d #from Pmv.hostappInterface import pdb_c4d import Pmv.hostappInterface.cinema4d.helperC4D as pdb_c4d vi = pdb_c4d Box = pdb_c4d.box Geom = pdb_c4d.newEmpty IndexedPolygons = pdb_c4d.polygons Points = pdb_c4d.PointCloudObject sc=pdb_c4d.getCurrentScene() dejavumat = vi.createDejaVuColorMat() helper = pdb_c4d elif ViewerType == 'blender': import Blender from Pmv.hostappInterface import pdb_blender vi = pdb_blender Box = pdb_blender.box Geom = pdb_blender.newEmpty IndexedPolygons = pdb_blender.polygons
if __name__ == '__main__': from DejaVu.IndexedPolygons import IndexedPolygonsFromFile geomS = IndexedPolygonsFromFile('cv', 'mesh') faces = geomS.getFaces() vertices = geomS.getVertices() vnormals = geomS.getVNormals() planePoint = (3., 0., 0.) planeNormal = (1., 0., 0.) vertsC, facesC = cap(vertices, faces, planePoint, planeNormal) 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)
( 15.445000, 7.667000, 15.246000 ), (16.093000, 5.705000, 14.039000), ( 13.512000, 5.395000, 12.878000 ), (13.733000, 6.929000, 11.026000))) nchords=10 nrib=2 nres=46 natoms=2*nres offset=1.2 width=1.5 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