rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
def __imul__(self, q2): | def __imul__(self, n): | def __imul__(self, q2): if type(n) in numTypes: self.setangle(n*self.angle) self.__reset() return self else: raise MulQuat |
def lambda_tol_nbonds(tol, nbonds): | def fusechunks_lambda_tol_nbonds(tol, nbonds): | def lambda_tol_nbonds(tol, nbonds): if nbonds == -1: nbonds_str = "?" else: nbonds_str = "%d" % (nbonds,) tol_str = (" %d" % int(tol*100.0))[-3:] # fixed-width (3 digits) but using initial spaces # (doesn't have all of desired effect, due to non-fixed-width font) tol_str = tol_str + "%" return "%s => %s bonds" % (... |
self.setup_selected_chunk() | self.init_selected_chunk() | def init_gui(self): self.o.setCursor(self.w.MoveSelectCursor) # load default cursor for MODIFY mode self.w.toolsFuseChunksAction.setOn(1) # toggle on the Fuse Chunks icon self.w.fuseChunksDashboard.show() # show the Fuse Chunks dashboard self.w.connect(self.w.makeBondsPB,SIGNAL("clicked()"),self.make_bonds) self.w.conn... |
self.o.assy.unpickparts() self.selected_chunk = None | self.unpick_selected_chunk() | def init_gui(self): self.o.setCursor(self.w.MoveSelectCursor) # load default cursor for MODIFY mode self.w.toolsFuseChunksAction.setOn(1) # toggle on the Fuse Chunks icon self.w.fuseChunksDashboard.show() # show the Fuse Chunks dashboard self.w.connect(self.w.makeBondsPB,SIGNAL("clicked()"),self.make_bonds) self.w.conn... |
if not self.selected_chunk: return self.find_bondable_pairs() self.o.gl_update() | if self.selected_chunk: self.find_bondable_pairs() self.o.gl_update() else: tol_str = fusechunks_lambda_tol_nbonds(self.tol, 0) self.w.toleranceLB.setText(tol_str) | def tolerance_changed(self, val): self.tol = val * .01 if not self.selected_chunk: return self.find_bondable_pairs() # Find bondable pairs of singlets self.o.gl_update() |
"""Pick or unpick if click. Only one chunk can be selected. | """Pick if click | def EndPick(self, event, selSense): """Pick or unpick if click. Only one chunk can be selected. """ if not self.picking: return self.picking = False |
self.bondable_pairs = [] self.ways_of_bonding = {} if selSense == 0: self.o.assy.unpick_at_event(event) self.selected_chunk = None else: self.o.assy.onlypick_at_event(event) if self.o.assy.selmols: self.setup_selected_chunk() | if self.o.assy.selmols: self.init_selected_chunk() else: self.unpick_selected_chunk() | def EndPick(self, event, selSense): """Pick or unpick if click. Only one chunk can be selected. """ if not self.picking: return self.picking = False |
def setup_selected_chunk(self): '''Sets up the selected chunk for finding bondable pairs of singlets. | def init_selected_chunk(self): '''Initializes everything required for finding bondable pairs of singlets with the selected chunk. | def setup_selected_chunk(self): '''Sets up the selected chunk for finding bondable pairs of singlets. ''' self.selected_chunk = self.o.assy.selmols[0] self.selected_chunk_rad = self.selected_chunk.bbox.scale() * self.rfactor self.find_bondable_pairs() # Find bondable pairs of singlets |
tol_str = lambda_tol_nbonds(self.tol, nbonds) | tol_str = fusechunks_lambda_tol_nbonds(self.tol, nbonds) | def find_bondable_pairs(self): '''Checks the open bonds of the selected chunk to see if they are close enough to bond with any other open bonds in the part. Hidden chunks are skipped. ''' self.bondable_pairs = [] self.ways_of_bonding = {} # Get center of the selected chunk. self.selected_chunk_ctr = self.selected_chu... |
self.pset.ui.gridesize = self.gridsize_combox.currentItem() | self.gridsize_combox.setCurrentItem(self.pset.ui.gridsize) | def setup(self, pnum): ''' Setup widgets to initial (default or defined) values. Return True on error. ''' print "setup: pset number =", pnum gamess = self.gamess self.pset = self.gamess.pset_number(pnum) # Init the top widgets (name, psets drop box, comment) self.name_linedit.setText(self.name) self.load_psets_combo... |
for f in dfttyp: | for f in gms_dfttyp_items: | def load_dfttyp_combox(self): '''Load list of DFT function in a combobox widget''' self.dfttyp_combox.clear() # Clear all combo box items if self.gmsver == GAMESS: for f in dfttyp: self.dfttyp_combox.insertItem(f) else: for f in pcgms_dfttyp: self.dfttyp_combox.insertItem(f) |
for f in pcgms_dfttyp: | for f in pcgms_dfttyp_items: | def load_dfttyp_combox(self): '''Load list of DFT function in a combobox widget''' self.dfttyp_combox.clear() # Clear all combo box items if self.gmsver == GAMESS: for f in dfttyp: self.dfttyp_combox.insertItem(f) else: for f in pcgms_dfttyp: self.dfttyp_combox.insertItem(f) |
self.pset.ui.gridesize = self.gridsize_combox.currentItem() | self.pset.ui.gridsize = self.gridsize_combox.currentItem() | def save_ui_settings(self): # Electronic Structure Props and Basis Set section. self.pset.ui.scftyp = self.scftyp_btngrp.selectedId() # SCFTYP = RHF, UHF, or ROHF self.pset.ui.icharg = self.icharg_spinbox.value() # Charge self.pset.ui.mult = self.multi_combox.currentItem() # Multiplicity # Electron Correlation Method... |
self.pset.contrl.dfttyp = pcgms_dfttyp[self.pset.ui.dfttyp] | item = pcgms_dfttyp_items[self.pset.ui.dfttyp] self.pset.contrl.dfttyp, junk = item.split(' ',1) self.pset.contrl.nrad = pcgms_gridsize[self.pset.ui.gridsize] | def save_parms(self): # $CONTRL Section ########################################### # Parms Values self.pset.contrl.scftyp = scftyp[self.pset.ui.scftyp] # SCFTYP self.pset.contrl.icharg = str(self.pset.ui.icharg) # ICHARG self.pset.contrl.mult = str(self.pset.ui.mult) #MULT self.pset.contrl.mplevl = mplevl[self.pset.... |
if self.gmsver == GAMESS: if ecm[self.pset.ui.ecm] == 'DFT': item = gms_dfttyp_items[self.pset.ui.dfttyp] self.pset.dft.dfttyp, junk = item.split(' ',1) self.pset.dft.gridsize = gms_gridsize[self.pset.ui.gridsize] else: self.pset.dft.dfttyp = 'NONE' self.pset.dft.gridsize = 0 | def save_parms(self): # $CONTRL Section ########################################### # Parms Values self.pset.contrl.scftyp = scftyp[self.pset.ui.scftyp] # SCFTYP self.pset.contrl.icharg = str(self.pset.ui.icharg) # ICHARG self.pset.contrl.mult = str(self.pset.ui.mult) #MULT self.pset.contrl.mplevl = mplevl[self.pset.... | |
return | return r | def _setup(self): """Setup this movie for playing """ if DEBUG1: print "movie._setup() called. filename = [" + self.filename + "]" r = self._checkMovieFile() if r == 1: msg = redmsg("Cannot play movie file [" + self.filename + "]. It does not exist.") self.assy.w.history.message(msg) return elif r == 2: msg = redmsg... |
msg = " (%d bonds made)" % n | msg = " (%d bond(s) made)" % n | def attach_to( self, singlet, autobond = True, autobond_msg = True): # in AtomTypeDepositionTool # [bruce 050831 added autobond option; 050901 added autobond_msg] """[public method] Deposit a new atom of self.atomtype onto the given singlet, and (if autobond is true) make other bonds (to other near-enough atoms with si... |
self.bonds.remove(b) | at2 = b.other(self) if self.molecule != at2.molecule: self.molecule.externs = at2.molecule.externs = INVALID_EXTERNS self.molecule.havelist = at2.molecule.havelist = 0 try: self.bonds.remove(b) except ValueError: msg = "fyi: atom.unbond: bond %r should be in bonds %r\n of atom %r, " \ "but is not:\n " % (b, self.bon... | def unbond(self, b): """remove bond b from the atom. called from atom.kill of the other atom. """ # the caller needs to do a shakedown self.bonds.remove(b) if self.element == Singlet: return # normally replace an atom with a singlet, # but don't replace a singlet with a singlet if b.other(self).element == Singlet: retu... |
shakedown, or to zero externs if the molecule will be killed. | shakedown (of both involved molecules), or to clear externs if this molecule will be killed. We invalidate the externs of both involved molecules so that their erroneous use will be detected. | def hopmol(self, numol): """move this atom to molecule numol. Caller is responsible for shakedown, or to zero externs if the molecule will be killed. """ if self.molecule == numol: return nxyz = self.posn() del self.molecule.atoms[self.key] self.unpick() self.xyz = nxyz self.molecule = numol numol.atoms[self.key] = se... |
and remove bonds to it from its neighbors caller is responsible for shakedown """ try: del self.molecule.atoms[self.key] except KeyError: pass | and remove bonds to it from its neighbors. caller is responsible for shakedown or kill of all affected molecules. """ if self.__killed: print_compact_stack("fyi: atom %r killed twice; ignoring:\n" % self) return self.__killed = 1 try: self.unpick() except: print_compact_traceback("fyi: atom.kill: ignoring error in unpi... | def kill(self): """kill an atom: remove it from molecule.atoms, and remove bonds to it from its neighbors caller is responsible for shakedown """ try: del self.molecule.atoms[self.key] except KeyError: pass for b in self.bonds: n = b.other(self) n.unbond(b) if n.element == Singlet: n.kill() # josh 10/26 to fix bug 85 f... |
""" if this is a hydrogen atom, kill it and return 1 (int, not boolean), otherwise return 0. [bruce 041018 added retval feature] | """If this is a hydrogen atom (and if it was not already killed), kill it and return 1 (int, not boolean), otherwise return 0. | def Dehydrogenate(self): """ if this is a hydrogen atom, kill it and return 1 (int, not boolean), otherwise return 0. [bruce 041018 added retval feature] [bruce comment 041018: I think caller MUST do a shakedown on all affected molecules (those of self and its neighbor), or remove them if they are left with no atoms. B... |
if self.element == Hydrogen : | if self.element == Hydrogen and not self.killed(): | def Dehydrogenate(self): """ if this is a hydrogen atom, kill it and return 1 (int, not boolean), otherwise return 0. [bruce 041018 added retval feature] [bruce comment 041018: I think caller MUST do a shakedown on all affected molecules (those of self and its neighbor), or remove them if they are left with no atoms. B... |
self.picked = 0 | def __init__(self, at1, at2): """create a bond from atom at1 to atom at2. the key created will be the same whichever order the atoms are given, and is used to compare bonds. """ self.atom1 = at1 self.atom2 = at2 self.picked = 0 self.key = 65536*min(at1.key,at2.key)+max(at1.key,at2.key) | |
if self.setup_ok(): self.setup() def setup_ok(self): "check whether it's ok (or too early) to call self.setup" try: self.a1pos = self.atom1.molecule.basepos[self.atom1.index] self.a2pos = self.atom2.molecule.basepos[self.atom2.index] return 1 except: return 0 pass | def __init__(self, at1, at2): """create a bond from atom at1 to atom at2. the key created will be the same whichever order the atoms are given, and is used to compare bonds. """ self.atom1 = at1 self.atom2 = at2 self.picked = 0 self.key = 65536*min(at1.key,at2.key)+max(at1.key,at2.key) | |
except ValueError: pass | except ValueError: print "fyi: mol.kill: mol %r not in self.assy.molecules" % self pass | def kill(self): self.unpick() Node.kill(self) try: self.assy.molecules.remove(self) self.assy.modified = 1 except ValueError: pass for b in self.externs: b.bust(self) #10/28/04, delete all atoms, so gadgets attached can be deleted when no atoms # attaching the gadget . Huaicai for a in self.atoms.values(): a.kill() |
if self.atoms: print "fyi: bug (ignored): %r mol.kill retains killed atoms %r" % (self,self.atoms) self.atoms = {} self.shakedown() return | def kill(self): self.unpick() Node.kill(self) try: self.assy.molecules.remove(self) self.assy.modified = 1 except ValueError: pass for b in self.externs: b.bust(self) #10/28/04, delete all atoms, so gadgets attached can be deleted when no atoms # attaching the gadget . Huaicai for a in self.atoms.values(): a.kill() | |
def rematom(self, a): self.atoms.remove(a) | def rematom(self, atm): "remove atom atm from this jig, and remove this jig from atom atm [called from atom.kill]" self.atoms.remove(atm) try: atm.jigs.remove(self) except: if platform.atom_debug: print_compact_traceback("atom_debug: ignoring exception in rematom: ") | def rematom(self, a): self.atoms.remove(a) # should check and delete the jig if no atoms left if not self.atoms: self.kill() |
return | def rematom(self, a): self.atoms.remove(a) # should check and delete the jig if no atoms left if not self.atoms: self.kill() | |
Node.kill(self) | for atm in self.atoms: self.rematom(atm) Node.kill(self) | def kill(self): #e don't we need to remove self from all our atoms' a.jigs? [guess: yes] ####@@@@ # [bruce question 041105; looks like a bug but i will ask josh] Node.kill(self) |
if ret==0: self.fileSave() | if ret==0: self.fileSave() self.__clear() | def fileOpen(self): if self.assy.modified: ret = QMessageBox.information( self, "Atom", "The part contains unsaved changes\n" "Do you want to save the changes before opening a new part?", "&Save", "&Discard", "Cancel", 0, # Enter == button 0 2 ) # Escape == button 2 if ret==0: self.fileSave() # Save clicked o... |
fn = QFileDialog.getOpenFileName(wd, "Molecular machine parts (*.mmp);;Molecules (*.pdb);; All of the above (*.pdb *.mmp)", | fn = QFileDialog.getOpenFileName(wd, "Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;All of the above (*.pdb *.mmp)", | def fileOpen(self): if self.assy.modified: ret = QMessageBox.information( self, "Atom", "The part contains unsaved changes\n" "Do you want to save the changes before opening a new part?", "&Save", "&Discard", "Cancel", 0, # Enter == button 0 2 ) # Escape == button 2 if ret==0: self.fileSave() # Save clicked o... |
self.__clear() | def fileOpen(self): if self.assy.modified: ret = QMessageBox.information( self, "Atom", "The part contains unsaved changes\n" "Do you want to save the changes before opening a new part?", "&Save", "&Discard", "Cancel", 0, # Enter == button 0 2 ) # Escape == button 2 if ret==0: self.fileSave() # Save clicked o... | |
"Molecular machine parts (*.mmp);;Molecules (*.pdb);;POV-Ray (*.pov)", self, "SaveDialog", "Save As") | "Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;POV-Ray (*.pov)", self, self.assy.filename, "Save As", sfilter) | def fileSaveAs(self): if self.assy: if self.assy.filename: dir, fil, ext = fileparse(self.assy.filename) else: dir, fil = "./", self.assy.name |
ext = str(ext) | ext =str(sfilter[-5:-1]) | def fileSaveAs(self): if self.assy: if self.assy.filename: dir, fil, ext = fileparse(self.assy.filename) else: dir, fil = "./", self.assy.name |
if not ext: ext = ".mmp" self.assy.filename = fn + ext else: self.assy.filename = fn print "MWSematics.py: filename =", self.assy.filename | self.assy.filename = dir + fil + ext print "MWSematics.py: filename =", self.assy.filename | def fileSaveAs(self): if self.assy: if self.assy.filename: dir, fil, ext = fileparse(self.assy.filename) else: dir, fil = "./", self.assy.name |
pass | if self.assy.modified: ret = QMessageBox.information( self, "Atom", "The part contains unsaved changes\n" "Do you want to save the changes before exiting?", "&Save", "&Discard", "Cancel", 0, 2 ) if ret==0: self.fileSave() elif ret==2: return | def fileExit(self): pass |
a0 = Arg(Widget2D) | a0 = Arg(Widget2D, None) | def draw(self): if self.print_lbox: print "print_lbox: %r lbox attrs are %r" % (self,(self.bleft, self.bright, self.bbottom, self.btop)) glPushMatrix() prior = None for a in self.drawables: if prior: # move from prior to a dy = prior.bbottom + self.gap + a.btop glTranslatef(0,-dy,0) # positive is up, but Column progres... |
empty = not drawables | empty = not_Expr( drawables) | def draw(self): if self.print_lbox: print "print_lbox: %r lbox attrs are %r" % (self,(self.bleft, self.bright, self.bbottom, self.btop)) glPushMatrix() prior = None for a in self.drawables: if prior: # move from prior to a dy = prior.bbottom + self.gap + a.btop glTranslatef(0,-dy,0) # positive is up, but Column progres... |
bleft = a0 and a0.bleft or 0 | bleft = or_Expr( and_Expr( a0, a0.bleft), 0) | def draw(self): if self.print_lbox: print "print_lbox: %r lbox attrs are %r" % (self,(self.bleft, self.bright, self.bbottom, self.btop)) glPushMatrix() prior = None for a in self.drawables: if prior: # move from prior to a dy = prior.bbottom + self.gap + a.btop glTranslatef(0,-dy,0) # positive is up, but Column progres... |
"""Create elements for all member of <elmTable>. Use preference value of each element if avaible, otherwise, use default value. | """Create elements for all member of <elmTable>. Use preference value of each element if available, otherwise, use default value. | def _createElements(self, startIndex, elmTable): """Create elements for all member of <elmTable>. Use preference value of each element if avaible, otherwise, use default value. <Param> startIndex: the starting element index <Param> elmTable: a list of elements needed to create """ prefs = prefs_context() for elm in elm... |
<Param> elnum2rad_color: A dictionary of (eleSym : (rvdw, [r,g,b])). [r,g,b] can be None, which requires color from default setting""" | <Param> elnum2rad_color: A dictionary of (eleSym : (rvdw, [r,g,b])). [r,g,b] can be None, which requires color from default setting """ self.rvdw_change_counter += 1 self.color_change_counter += 1 | def _loadTableSettings(self, elSym2rad_color, changeNotFound = True ): """Load a table of elements rad/color setting into the current set _perodicalTable. <Param> elnum2rad_color: A dictionary of (eleSym : (rvdw, [r,g,b])). [r,g,b] can be None, which requires color from default setting""" for elm in self._perodicalTab... |
if not self.assy.alist: return | if not self.assy.molecules: self.win.statusBar.message("<span style=\"color: return | def minimize(self): if not self.assy.alist: return # Nothing in the part to minimize. |
glEnable(GL_LINE_SMOOTH) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE) | def drawPlaneGrid(color, w, h, uw, uh): '''Draw grid lines with <color>, unit size is <uw>*<uh>''' if uw > w: uw = w if uh > h: uh = h Z_OFF = 0.0 #0.001 glDisable(GL_LIGHTING) glColor3fv(color) hw = w/2.0; hh = h/2.0 glEnable(GL_LINE_SMOOTH) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE)#_MINUS_SRC_ALPHA) ... | |
glDisable(GL_LINE_SMOOTH) glDisable(GL_BLEND) | def drawPlaneGrid(color, w, h, uw, uh): '''Draw grid lines with <color>, unit size is <uw>*<uh>''' if uw > w: uw = w if uh > h: uh = h Z_OFF = 0.0 #0.001 glDisable(GL_LIGHTING) glColor3fv(color) hw = w/2.0; hh = h/2.0 glEnable(GL_LINE_SMOOTH) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE)#_MINUS_SRC_ALPHA) ... | |
return self.alist[0].molecule.part assert 0, "part needed before alist" | return self.alist[0].molecule.part if platform.atom_debug: self.debug_print_movie_info("bug: part needed before alist") return None | def __getattr__(self, attr): # temporary kluge ###@@@ if attr == 'part': if self.alist: return self.alist[0].molecule.part # not checked for consistency, but correct if anything is assert 0, "part needed before alist" ### can this happen? if it does, return cur part??? main part??? depends on why... if attr == 'history... |
self.w2=wide/2.0 self.h2=high/2.0 self.scale = 1.1 / min(wide/2.0, high/2.0) | self.rescale(wide, high) | def __init__(self, wide, high): '''Create a Trackball object. "size" is the radius of the inner trackball sphere. ''' self.w2=wide/2.0 self.h2=high/2.0 self.scale = 1.1 / min(wide/2.0, high/2.0) self.quat = Q(1,0,0,0) self.oldmouse = None |
self.oldmouse=proj2sphere((px-self.w2)*self.scale, (self.h2-py)*self.scale) def update(self, px, py, uq=None): | self.oldmouse = proj2sphere( (px - self.w2)*self.scale, (self.h2 - py)*self.scale ) def update(self, px, py, uq = None): """This should be called in a mouseDrag binding, with window coordinates of the mouse; return value is an incremental quat, to be used in conjunction with uq as explained below. For trackballing the... | def start(self, px, py): self.oldmouse=proj2sphere((px-self.w2)*self.scale, (self.h2-py)*self.scale) |
if self.oldmouse and not uq: | if self.oldmouse is not None: | def update(self, px, py, uq=None): newmouse = proj2sphere((px-self.w2)*self.scale, (self.h2-py)*self.scale) if self.oldmouse and not uq: quat = Q(self.oldmouse, newmouse) elif self.oldmouse and uq: quat = uq + Q(self.oldmouse, newmouse) - uq else: quat = Q(1,0,0,0) self.oldmouse = newmouse return quat |
elif self.oldmouse and uq: quat = uq + Q(self.oldmouse, newmouse) - uq | if uq is not None: quat = uq + quat - uq | def update(self, px, py, uq=None): newmouse = proj2sphere((px-self.w2)*self.scale, (self.h2-py)*self.scale) if self.oldmouse and not uq: quat = Q(self.oldmouse, newmouse) elif self.oldmouse and uq: quat = uq + Q(self.oldmouse, newmouse) - uq else: quat = Q(1,0,0,0) self.oldmouse = newmouse return quat |
if (hasattr(obj, "__class__") or | if type(obj) in (types.ListType, types.TupleType): lst = [ ] if len(pathname) > 0: lastitem = pathname[-1] pathname = pathname[:-1] else: lastitem = "" for i in range(len(obj)): x = obj[i] if not self.exclude(i, x): y = pathname + [ lastitem + ("[%d]" % i) ] lst.append((i, x, y)) for i, v, pn in lst: if self.showThis(i... | def descend(self, obj, depth=0, pathname=[ ]): if obj in self.already: return self.already.append(obj) if depth == 0: self.handleLeaf(obj, depth, pathname) if depth >= self.maxdepth: return if (hasattr(obj, "__class__") or type(obj) in (types.InstanceType, types.ClassType, types.ModuleType, types.FunctionType)): ckeys ... |
elif type(obj) in (types.ListType, types.TupleType): lst = [ ] if len(pathname) > 0: lastitem = pathname[-1] pathname = pathname[:-1] else: lastitem = "" for i in range(len(obj)): x = obj[i] if not self.exclude(i, x): y = pathname + [ lastitem + ("[%d]" % i) ] lst.append((i, x, y)) for i, v, pn in lst: if self.showThis... | def objectBrowse(obj, maxdepth=5, exclude=None, outf=sys.stderr): | def descend(self, obj, depth=0, pathname=[ ]): if obj in self.already: return self.already.append(obj) if depth == 0: self.handleLeaf(obj, depth, pathname) if depth >= self.maxdepth: return if (hasattr(obj, "__class__") or type(obj) in (types.InstanceType, types.ClassType, types.ModuleType, types.FunctionType)): ckeys ... |
def exclude(self, attrname): return exclude(attrname) od = ObjectDescender(maxdepth=maxdepth) | def exclude(self, attrname, obj): return exclude(attrname, obj) od = Descend(maxdepth=maxdepth, outf=outf) | def exclude(self, attrname): return exclude(attrname) |
self.mirrorDistance = self.getMirrorDistance(m.center, jigs[0].center) mirrorChunk.move(2*(self.mirrorDistance)) | def Mirror(self): "Mirror the selected chunk(s) about a selected grid plane." #ninad060812--: As of 060812 (11 PM EST) it creates mirror chunks about a selected grid plane #This has some known bugs. listed below ninad060812: #What it does: #- Mirrors selected chunks about a selected Grid plane but keeps the mirrored ch... | |
self.invalidate_attrs(['molecules']) self.adjust_natoms( len(node.atoms)) | self.invalidate_attrs(['molecules'], skip = ['natoms']) self.adjust_natoms( len(node.atoms)) | def add(self, node): if node.part == self: # this is normal, e.g. in ensure_one_part, so don't complain |
self.invalidate_attrs(['molecules']) self.adjust_natoms(- len(node.atoms)) | self.invalidate_attrs(['molecules'], skip = ['natoms']) self.adjust_natoms(- len(node.atoms)) | def remove(self, node): """Remove node (a member of this part) from this part's lists and stats; reset node.part; DON'T look for interspace bonds yet (since this node and some of its neighbors might be moving to the same new part). Node (and its atoms, if it's a chunk) will be unpicked before the removal. """ assert no... |
"forget everything, let all storage be reclaimed" | "forget everything, let all storage be reclaimed; only valid if we have no nodes left" if platform.atom_debug: print "atom_debug: fyi: destroying part", self assert self.nodecount == 0, "can't destroy a Part which still has nodes" | def destroy(self): "forget everything, let all storage be reclaimed" # implem is a guess ## self.invalidate_all_attrs() # not needed for attr in self.__dict__.keys(): delattr(self,attr) # is this safe, in arb order?? return |
When true, delete will delete its members (leaving it empty but with its topnode (aka tree) still present), | When true, delete will delete its members (leaving it empty but with its topnode still present), | def immortal(self): """Should this Part be undeletable from the UI (by cut or delete operations)? When true, delete will delete its members (leaving it empty but with its topnode (aka tree) still present), and cut will cut its members and move them into a copy of its topnode, which is left still present and empty. [can... |
def update_mols(self): """[Semi-private method] Caller is telling us that it might have moved molecules into or out of assy.tree (assy == self) without properly updating assy.molecules list (which causes lots of bugs if not fixed), or (less important but still matters) our bbox, center, or drawLevel. Rather than not to... | _inputs_for_molecules = [] | def __getattr__(self, attr): "[overrides InvalMixin.__getattr__]" if attr.startswith('_'): # common case, be fast (even though it's done redundantly by InvalMixin.__getattr__) raise AttributeError, attr if attr in self.assy_attrs_all: # delegate to self.assy return getattr(self.assy, attr) ###@@@ detect error of infrec... |
self.tree.apply2all( func) | self.topnode.apply2all( func) | def func(n): "run this exactly once on all molecules that properly belong in this assy" if isinstance(n, molecule): # check for duplicates (mol at two places in tree) using a dict, whose values accumulate our mols list if seen.get(id(n)): print "bug: some chunk occurs twice in assy.tree; semi-tolerated but not fixed" r... |
self.tree.apply2all( func_alist) | self.topnode.apply2all( func_alist) | def func_alist(nn): "run this exactly once on all molecules (or other nodes) in this part, in tree order" if isinstance(nn, molecule): alist.extend(nn.atoms_in_mmp_file_order()) return # from func_alist only |
self.tree.apply2all( func_selmols) | self.topnode.apply2all( func_selmols) | def func_selmols(nn): "run this exactly once on all molecules (or other nodes) in this part (in any order)" if isinstance(nn, molecule) and nn.picked: res.append(nn) return # from func_selmols only |
self.tree.apply2all( func_selatoms) | self.topnode.apply2all( func_selatoms) | def func_selatoms(nn): "run this exactly once on all molecules (or other nodes) in this part (in any order)" if isinstance(nn, molecule): for atm in nn.atoms.itervalues(): if atm.picked: res[atm.key] = atm return # from func_selatoms only |
self.changed() | def addmol(self, mol): #bruce 050228 revised this for Part (was on assy) and for inval/update of part-summary attrs. """(Public method:) Add a chunk to this Part (usually the "current Part"). Invalidate part attributes which summarize part content (e.g. bbox, drawLevel). | |
self.tree.addmember(mol) | self.topnode.addchild(mol) | def addmol(self, mol): #bruce 050228 revised this for Part (was on assy) and for inval/update of part-summary attrs. """(Public method:) Add a chunk to this Part (usually the "current Part"). Invalidate part attributes which summarize part content (e.g. bbox, drawLevel). |
self.invalidate_attrs(['natoms','molecules']) def ensure_toplevel_group(self): | def ensure_toplevel_group(self): | def addmol(self, mol): #bruce 050228 revised this for Part (was on assy) and for inval/update of part-summary attrs. """(Public method:) Add a chunk to this Part (usually the "current Part"). Invalidate part attributes which summarize part content (e.g. bbox, drawLevel). |
assert self.tree if not self.tree.is_group(): self.tree = Group("Group", self.assy, None, [self.tree]) self.assy.fix_parts() | assert self.topnode if not self.topnode.is_group(): old_top = self.topnode self.topnode = Group("Group", self.assy, None) self.add(self.topnode) old_top.addsibling(self.topnode) self.topnode.addchild(old_top) if self.assy.current_selection_group == old_top: self.assy.current_selection_group = self.topnode | def ensure_toplevel_group(self): "make sure this Part's toplevel node is a Group, by Grouping it if not." assert self.tree if not self.tree.is_group(): self.tree = Group("Group", self.assy, None, [self.tree]) self.assy.fix_parts() return |
self.tree.draw(self.o, self.o.display) | try: text = self.glpane_text() if text: self.drawtext( self.o, text ) except: print_compact_traceback("exception in drawing part title text: ") self.topnode.draw(self.o, self.o.display) def glpane_text(self): return "" def drawtext(self, glpane, text): glDisable(GL_LIGHTING) glDisable(GL_DEPTH_TEST) glPushMatrix() ... | def draw(self, win): ###@@@ win arg, unused, should be renamed or removed self.tree.draw(self.o, self.o.display) |
self.tree.unpick() | self.topnode.unpick() | def unpickparts(self): self.tree.unpick() # before assy/part split, this was root, i.e. assy.tree and assy.shelf |
def sanitize_for_clipboard(self, ob): """Prepare ob for addition to the clipboard as a new toplevel item; should be called just before adding ob to shelf, OR for entire toplevel items already in shelf (or both; should be ok, though slower, to call more than once per item). NOT SURE IF OK to call when ob still has a dad... | def prin(self): for a in self.selatoms.itervalues(): a.prin() | |
if self.immortal() and self.tree.picked: | if self.immortal() and self.topnode.picked: | def cut(self): eh = begin_event_handler("Cut") # bruce ca. 050307; stub for future undo work; experimental try: self.w.history.message(greenmsg("Cut:")) if self.selatoms: #bruce 050201-bug370 (2nd commit here, similar issue to bug 370): # changed condition to not use selwhat, since jigs can be selected even in Select A... |
self.tree.unpick_top() | self.topnode.unpick_top() | def cut(self): eh = begin_event_handler("Cut") # bruce ca. 050307; stub for future undo work; experimental try: self.w.history.message(greenmsg("Cut:")) if self.selatoms: #bruce 050201-bug370 (2nd commit here, similar issue to bug 370): # changed condition to not use selwhat, since jigs can be selected even in Select A... |
self.tree.apply2picked(lambda(x): x.moveto(new)) | self.topnode.apply2picked(lambda(x): x.moveto(new)) | def cut(self): eh = begin_event_handler("Cut") # bruce ca. 050307; stub for future undo work; experimental try: self.w.history.message(greenmsg("Cut:")) if self.selatoms: #bruce 050201-bug370 (2nd commit here, similar issue to bug 370): # changed condition to not use selwhat, since jigs can be selected even in Select A... |
use.name = self.tree.name | use.name = self.topnode.name | def cut(self): eh = begin_event_handler("Cut") # bruce ca. 050307; stub for future undo work; experimental try: self.w.history.message(greenmsg("Cut:")) if self.selatoms: #bruce 050201-bug370 (2nd commit here, similar issue to bug 370): # changed condition to not use selwhat, since jigs can be selected even in Select A... |
self.tree.apply2picked(lambda(x): new.addmember(x.copy(None))) | self.topnode.apply2picked(lambda(x): new.addmember(x.copy(None))) | def copy(self): self.w.history.message(greenmsg("Copy:")) if self.selatoms: #bruce 050201-bug370: revised this in same way as for assy.cut (above) self.w.history.message(redmsg("Copying selected atoms is not yet supported.")) #bruce 050131 ## return new = Group(gensym("Copy"), self.assy, None) # bruce 050201 comment: t... |
self.sanitize_for_clipboard(ob) | def copy(self): self.w.history.message(greenmsg("Copy:")) if self.selatoms: #bruce 050201-bug370: revised this in same way as for assy.cut (above) self.w.history.message(redmsg("Copying selected atoms is not yet supported.")) #bruce 050131 ## return new = Group(gensym("Copy"), self.assy, None) # bruce 050201 comment: t... | |
self.tree.unpick_top() self.tree.apply2picked(lambda o: o.kill()) | self.topnode.unpick_top() self.topnode.apply2picked(lambda o: o.kill()) | def kill(self): "delete everything selected in this Part [except the top node, if we're an immortal Part]" #bruce 050201 for Alpha: revised this to fix bug 370 ## "delete whatever is selected from this assembly " #e use this in the assy version of this method, if we need one self.w.history.message(greenmsg("Delete:")) ... |
self.root.apply2picked(lambda x: x.hide()) | self.topnode.apply2picked(lambda x: x.hide()) | def Hide(self): "Hide all selected chunks and jigs" self.root.apply2picked(lambda x: x.hide()) self.w.win_update() |
self.root.apply2picked(lambda x: x.unhide()) | self.topnode.apply2picked(lambda x: x.unhide()) | def Unhide(self): "Unhide all selected chunks and jigs" self.root.apply2picked(lambda x: x.unhide()) self.w.win_update() |
if oldPartFilesDir == newPartFilesDir: return 0, "Nothing copied since the part files directory is the same." | def copy_part_files_dir(self, oldPartFilesDir): # Mark 060703. NFR bug 2042. """Recursively copy the entire directory tree rooted at oldPartFilesDir to the assy's (new) Part Files directory. """ if not oldPartFilesDir: return 0, "No part files directory to copy." errorcode, newPartFilesDir = self.assy.get_part_files_d... | |
return 1, "The Part Files directory " + newPartFilesDir + " already exists! Part files from " + oldPartFilesDir + " were not copied." import shutil | if os.path.isdir(newPartFilesDir): try: shutil.rmtree(newPartFilesDir) except: return 1, "Problem removing an existing parts file directory " + newPartFilesDir | def copy_part_files_dir(self, oldPartFilesDir): # Mark 060703. NFR bug 2042. """Recursively copy the entire directory tree rooted at oldPartFilesDir to the assy's (new) Part Files directory. """ if not oldPartFilesDir: return 0, "No part files directory to copy." errorcode, newPartFilesDir = self.assy.get_part_files_d... |
shutil.copytree(oldPartFilesDir, newPartFilesDir) return 0, "" | try: shutil.copytree(oldPartFilesDir, newPartFilesDir) except: return 1, "Problem copying files to the new parts file directory " + newPartFilesDir return 0, 'Part files copied from "' + oldPartFilesDir + '" to "' + newPartFilesDir + '"' | def copy_part_files_dir(self, oldPartFilesDir): # Mark 060703. NFR bug 2042. """Recursively copy the entire directory tree rooted at oldPartFilesDir to the assy's (new) Part Files directory. """ if not oldPartFilesDir: return 0, "No part files directory to copy." errorcode, newPartFilesDir = self.assy.get_part_files_d... |
self.w.toleranceLCD.display((self.w.toleranceSL.value() + 50) * .01) | def init_gui(self): self.o.setCursor(self.w.MoveSelectCursor) # load default cursor for MODIFY mode self.w.toolsFuseChunksAction.setOn(1) # toggle on the Fuse Chunks icon self.w.fuseChunksDashboard.show() # show the Fuse Chunks dashboard self.w.toleranceLCD.display((self.w.toleranceSL.value() + 50) * .01) self.w.connec... | |
self.o.assy.unpickparts() self.selected_chunk = None | if len(self.o.assy.selmols) == 1: self.selected_chunk = self.o.assy.selmols[0] self.find_bondable_pairs() else: self.o.assy.unpickparts() self.selected_chunk = None | def init_gui(self): self.o.setCursor(self.w.MoveSelectCursor) # load default cursor for MODIFY mode self.w.toolsFuseChunksAction.setOn(1) # toggle on the Fuse Chunks icon self.w.fuseChunksDashboard.show() # show the Fuse Chunks dashboard self.w.toleranceLCD.display((self.w.toleranceSL.value() + 50) * .01) self.w.connec... |
self.tol = (val + 50) * .01 self.w.toleranceLCD.display(self.tol) self.find_bondable_pairs() self.o.gl_update() | self.tol = val * .01 if not self.selected_chunk: return self.find_bondable_pairs() self.o.gl_update() | def tolerance_changed(self, val): self.tol = (val + 50) * .01 self.w.toleranceLCD.display(self.tol) self.find_bondable_pairs() # Find bondable pairs of singlets self.o.gl_update() |
else: | self.bondable_pairs = [] self.ways_of_bonding = {} else: | def EndPick(self, event, selSense): """Pick if click. Only one chunk can be selected . """ if not self.picking: return self.picking = False |
if self.o.assy.selmols: self.selected_chunk = self.o.assy.selmols[0] | if self.o.assy.selmols: self.selected_chunk = self.o.assy.selmols[0] self.find_bondable_pairs() | def EndPick(self, event, selSense): """Pick if click. Only one chunk can be selected . """ if not self.picking: return self.picking = False |
update_cond = lambda simtime, pytime, nframes: simtime >= max(0.05, min(pytime * 4, 2.0)) | update_cond = ( lambda simtime, pytime, nframes: simtime >= max(0.05, min(pytime * 4, 2.0)) ) elif update_units == 'frames': update_cond = ( lambda simtime, pytime, nframes, _nframes = update_number: nframes >= _nframes ) elif update_units == 'seconds': update_cond = ( lambda simtime, pytime, nframes, _timelimit = upd... | def doMinimize(self, mtype = 1, simaspect = None): #bruce 051115 renamed method from makeMinMovie #bruce 051115 revised docstring to fit current code #e should clean it up more """Minimize self.part (if simaspect is None -- no longer used) or its given simaspect (simulatable aspect) (used for both Minimize Selection an... |
update_cond = (lambda simtime, pytime, nframes, _nframes=uprefs.update_number_spinbox.value(): nframes >= _nframes) | print "don't know how to set update_cond from (%r, %r)" % (update_number, update_units) | def doMinimize(self, mtype = 1, simaspect = None): #bruce 051115 renamed method from makeMinMovie #bruce 051115 revised docstring to fit current code #e should clean it up more """Minimize self.part (if simaspect is None -- no longer used) or its given simaspect (simulatable aspect) (used for both Minimize Selection an... |
def bond_atoms_oldversion(at1,at2): """Make a new bond between atoms at1 and at2 (and add it to their lists of bonds), | bond_atoms_oldversion_noops_seen = {} def bond_atoms_oldversion(a1,a2): """Make a new bond between atoms a1 and a2 (and add it to their lists of bonds), | def bond_atoms_oldversion(at1,at2): #bruce 050502 renamed this from bond_atoms; it's called from the newer version of bond_atoms """Make a new bond between atoms at1 and at2 (and add it to their lists of bonds), if they are not already bonded; if they are already bonded do nothing. Return None. (The new bond object, if... |
If at1 == at2, this is an error; print a warning and do nothing. | If a1 == a2, this is an error; print a warning and do nothing. | def bond_atoms_oldversion(at1,at2): #bruce 050502 renamed this from bond_atoms; it's called from the newer version of bond_atoms """Make a new bond between atoms at1 and at2 (and add it to their lists of bonds), if they are not already bonded; if they are already bonded do nothing. Return None. (The new bond object, if... |
if at1 is at2: print "BUG: bond_atoms was asked to bond %r to itself." % at1 | if a1 is a2: print "BUG: bond_atoms was asked to bond %r to itself." % a1 | def bond_atoms_oldversion(at1,at2): #bruce 050502 renamed this from bond_atoms; it's called from the newer version of bond_atoms """Make a new bond between atoms at1 and at2 (and add it to their lists of bonds), if they are not already bonded; if they are already bonded do nothing. Return None. (The new bond object, if... |
b = Bond(at1,at2) if (b in at1.bonds) != (b in at2.bonds): print "fyi: debug: for new bond %r, (b in at1.bonds) != (b in at2.bonds); removing old bond" % b try: at1.bonds.remove(b) except: | b1 = find_bond(a1,a2) b2 = find_bond(a2,a1) if b1 is not b2: print "bug warning: bond between %r and %r inconsistent in their .bonds lists; %r (id % % (a1,a2, b1, id(b1), b2, id(b2)) print_compact_stack("will remove one or both existing bonds, then make the requested new one: ") if b1: a1.bonds.remove(b1) b1 = None if ... | def bond_atoms_oldversion(at1,at2): #bruce 050502 renamed this from bond_atoms; it's called from the newer version of bond_atoms """Make a new bond between atoms at1 and at2 (and add it to their lists of bonds), if they are not already bonded; if they are already bonded do nothing. Return None. (The new bond object, if... |
try: at2.bonds.remove(b) except: pass if not b in at2.bonds: at1.bonds += [b] at2.bonds += [b] else: if platform.atom_debug: print "atom_debug: fyi (possible bug): bond_atoms_oldversion is a noop since an equal bond exists:", b pass | return b = Bond(a1,a2) a1.bonds.append(b) a2.bonds.append(b) | def bond_atoms_oldversion(at1,at2): #bruce 050502 renamed this from bond_atoms; it's called from the newer version of bond_atoms """Make a new bond between atoms at1 and at2 (and add it to their lists of bonds), if they are not already bonded; if they are already bonded do nothing. Return None. (The new bond object, if... |
for higher-valence bonds. | for higher-valence bonds. [However, as of 051216 it's still called in lots of places.] | def bond_atoms(a1, a2, vnew = None, s1 = None, s2 = None, no_corrections = False): """Bond atoms a1 and a2 by making a new bond of valence vnew (which must be one of the constants in chem.BOND_VALENCES, not a numerically expressed valence; for effect of not providing vnew, see below). The new bond is returned. If for s... |
self.w.connect(self.w.pasteComboBox,SIGNAL("activated(int)"), | self.bondclick_v6 = None self.update_bond_buttons() self.connect_or_disconnect_signals(True) self.w.depositAtomDashboard.show() self.w.zoomToolAction.setEnabled(0) self.w.panToolAction.setEnabled(0) self.w.rotateToolAction.setEnabled(0) self.dont_update_gui = False return def connect_or_disconnect_signals(self, ... | def init_gui(self): """called once each time the mode is entered; should be called only by code in modes.py """ self.dont_update_gui = True # redundant with Enter, I think; changed below # (the possible orders of calling all these mode entering/exiting # methods is badly in need of documentation, if not cleanup... # ... |
self.w.connect(self.w.elemChangeComboBox,SIGNAL("activated(int)"), | change_connect(self.w.elemChangeComboBox,SIGNAL("activated(int)"), | def init_gui(self): """called once each time the mode is entered; should be called only by code in modes.py """ self.dont_update_gui = True # redundant with Enter, I think; changed below # (the possible orders of calling all these mode entering/exiting # methods is badly in need of documentation, if not cleanup... # ... |
self.w.connect(self.w.depositAtomDashboard.pasteRB, | change_connect(self.w.depositAtomDashboard.pasteRB, | def init_gui(self): """called once each time the mode is entered; should be called only by code in modes.py """ self.dont_update_gui = True # redundant with Enter, I think; changed below # (the possible orders of calling all these mode entering/exiting # methods is badly in need of documentation, if not cleanup... # ... |
self.w.connect(self.w.depositAtomDashboard.atomRB, | change_connect(self.w.depositAtomDashboard.atomRB, | def init_gui(self): """called once each time the mode is entered; should be called only by code in modes.py """ self.dont_update_gui = True # redundant with Enter, I think; changed below # (the possible orders of calling all these mode entering/exiting # methods is badly in need of documentation, if not cleanup... # ... |
self.w.connect(self.w.depositAtomDashboard.bond1RB, | change_connect(self.w.depositAtomDashboard.bond1RB, | def init_gui(self): """called once each time the mode is entered; should be called only by code in modes.py """ self.dont_update_gui = True # redundant with Enter, I think; changed below # (the possible orders of calling all these mode entering/exiting # methods is badly in need of documentation, if not cleanup... # ... |
self.w.connect(self.w.depositAtomDashboard.bond2RB, | change_connect(self.w.depositAtomDashboard.bond2RB, | def init_gui(self): """called once each time the mode is entered; should be called only by code in modes.py """ self.dont_update_gui = True # redundant with Enter, I think; changed below # (the possible orders of calling all these mode entering/exiting # methods is badly in need of documentation, if not cleanup... # ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.