def constructModel(self, elm, pos, dispMode): """ This is to try to repeat what 'make_Atom_and_bondpoints()' method does, but hope to remove some stuff not needed here. The main purpose is to build the geometry model for element display. @param elm: An object of class Elem @param elm: L{Elem} @param dispMode: the display mode of the atom @type dispMode: int @return: the Chunk which contains the geometry model. @rtype: L{Chunk} """ assy = Assembly(None, run_updaters=False) assy.set_glpane(self) # sets .o and .glpane mol = Chunk(assy, 'dummy') atm = Atom(elm.symbol, pos, mol) atm.display = dispMode ## bruce 050510 comment: this is approximately how you should change the atom type (e.g. to sp2) for this new atom: if self.hybrid_type_name: atm.set_atomtype_but_dont_revise_singlets(self.hybrid_type_name) ## see also atm.element.atomtypes -> a list of available atomtype objects for that element ## (which can be passed to set_atomtype_but_dont_revise_singlets) atm.make_bondpoints_when_no_bonds() self.elementMode = True return mol
def partChanged(self, selectedItem): """ Method called when user changed the partlib browser tree. @param selectedItem: Item currently selected in the L{self.partLib} @type selectedItem: L{self.partLib.FileItem} @attention: This is called in the L{PM_TreeView.mouseReleaseEvent}. The 'selectionChanged' signal for self.partLib apparently was not emitted so that code has been removed. """ #Copying some old code from deprecated MMKit.py -- ninad 2007-09-06 item = selectedItem self.newModel = None if isinstance(item, self.partLib.FileItem): mmpFile = str(item.getFileObj()) if os.path.isfile(mmpFile): self.newModel = \ Assembly(self.w, os.path.normpath(mmpFile), run_updaters = True # desirable for PartLib [bruce 080403] ) self.newModel.set_glpane( self.elementViewer) # sets its .o and .glpane readmmp(self.newModel, mmpFile) self.newModel.update_parts( ) #k not sure if needed after readmmp self.newModel.checkparts() if self.newModel.shelf.members: for m in self.newModel.shelf.members[:]: m.kill() #k guess about a correct way to handle them self.newModel.update_parts() #k probably not needed self.newModel.checkparts() #k probably not needed self._updateElementViewer(self.newModel)