def addGeom(self, geom, parent=None, redo=False): # add geometry to to geomContainer, create atom set and set pointer # from geom to molecule GeomContainer.addGeom(self, geom, parent, redo) self.atoms[geom.name]=AtomSet([]) # FIXME we should use a weakreference to mol here geom.mol = self.mol #need for backtracking picking
def __init__(self, mol, viewer): """constructor of the geometry container""" GeomContainer.__init__(self) self.mol = mol mol.geomContainer = self ## Dictionary of AtomSets used to track which atoms are currently ## each mode self.atoms = {} ## Dictionary of function to be called to expand an atomic ## property to the corresponding vertices in a geometry ## The function has to accept 4 arguments: a geometry name, ## a list of atoms, the name of the property and an optional argument ## the propIndex default is None, specifying the index of the property ## when needed. ## the key is the geometry name self.atomPropToVertices = {} ## Dictionary of function to be called to convert a vertex into an atom ## if no function is registered, used default (1vertex to 1atom) ## mapping ## if None is registered: this geometry cannot represent atoms ## else, call the function registered for this geometry self.geomPickToAtoms = {} ## Dictionary of function to be called when a part into a bond ## if no function is registered, used default (1vertex to 1bond) ## mapping ## if None is registered: this geometry cannot represent bonds ## else, call the function registered for this geometry self.geomPickToBonds = {} ## this set of coordinates should really be shared by all geometries self.allCoords = mol.allAtoms.coords if viewer.hasGui: self.VIEWER = viewer.GUI.VIEWER # master Geometry self.masterGeom = Geom(mol.name, shape=(0,0), pickable=0, protected=True) self.masterGeom.isScalable = 0 self.geoms['master'] = self.masterGeom self.masterGeom.replace = True self.VIEWER.AddObject( self.masterGeom ) # selection Geometry if viewer.viewSelectionIcon=='cross': self.geoms['selectionSpheres'] = CrossSet( 'selection', shape=(0,3), materials=((1.0, 1.0, 0.),), lineWidth=2, inheritMaterial=0, protected=True) elif viewer.viewSelectionIcon=='labels': from DejaVu.glfLabels import GlfLabels self.geoms['selectionSpheres'] = GlfLabels( 'selection', shape=(0,3), font='times_new1.glf', bilboard=True, fontScales=(.5,.5,.5), materials=((1.0, 1.0, 0.),), inheritMaterial=0, protected=True) else: self.geoms['selectionSpheres'] = Spheres( 'selection', shape=(0,3), radii=0.3, quality = 3, materials = ((1.0, 1.0, 0.),), inheritMaterial=0, protected=True) self.geoms['selectionSpheres'].pickable=0 self.VIEWER.AddObject(self.geoms['selectionSpheres'], parent=self.masterGeom, redo=0 )