rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def tests_heteroatom_organics_CH3PH2(self): StructureTest(dir="heteroatom_organics", test="CH3PH2")
def tests_heteroatom_organics_CH3PH2(self): StructureTest(dir="heteroatom_organics", test="CH3PH2")
def tests_heteroatom_organics_CH3SiH2CH3(self): StructureTest(dir="heteroatom_organics", test="CH3SiH2CH3") def tests_heteroatom_organics_CH3SiH3(self): StructureTest(dir="heteroatom_organics", test="CH3SiH3") def tests_heteroatom_organics_P_ADAM_C3v(self): StructureTest(dir="heteroatom_organics", test="P_ADAM_C3v")
def tests_heteroatom_organics_CH3SiH2CH3(self): StructureTest(dir="heteroatom_organics", test="CH3SiH2CH3")
LENGTH_TOLERANCE = 0.7 ANGLE_TOLERANCE = 90
LENGTH_TOLERANCE = 0.15 ANGLE_TOLERANCE = 15
def addFailure(self, test, err): self.failures.append((test, traceback.format_exception(*err)[-1]))
"""Return the Part Files directory for this assembly.
"""Return the Part Files directory for this assembly. Make it if it doesn't already exist. If <make> is False, return the Part Files directory if it already exists. If it doesn't exist, return None. Specifically, return: - on success, return (0, part files directory), or if <make> is False and the Part Files directory...
def find_or_make_part_files_directory(self, make=True): """Return the Part Files directory for this assembly. The Part Files directory exists next to the current MMP file and has the same name as the MMP file (without the .mmp extension) but with the ' Files' suffix. The Part Files directory contains all the associated...
the MMP file (without the .mmp extension) but with the ' Files' suffix. The Part Files directory contains all the associated subdirectories and files for this assembly, such as movie files (*.dpb), POV-Ray Scene files (*.pov), GAMESS files (*.gms), etc. For any error, return (1, errortext); on success return (0, full_p...
the MMP file (without the .mmp extension) but with the ' Files' suffix. For example, the MMP file "DNA Shape.mmp" will have "DNA Shape Files" as its Part Files directory. The Part Files directory contains all the associated subdirectories and files for this MMP part, such as POV-Ray Scene files (*.pov), movie files (*...
def find_or_make_part_files_directory(self, make=True): """Return the Part Files directory for this assembly. The Part Files directory exists next to the current MMP file and has the same name as the MMP file (without the .mmp extension) but with the ' Files' suffix. The Part Files directory contains all the associated...
return 1, "I cannot do this until this part is saved."
if make: return 1, "I cannot do this until this part is saved." else: return 0, None
def find_or_make_part_files_directory(self, make=True): """Return the Part Files directory for this assembly. The Part Files directory exists next to the current MMP file and has the same name as the MMP file (without the .mmp extension) but with the ' Files' suffix. The Part Files directory contains all the associated...
if i and i.dropEnabled():
if i and i.dropEnabled() and i != self.oldCurrent:
def contentsDragMoveEvent(self, e): vp = self.contentsToViewport(e.pos()) i = self.itemAt( vp ) droppable = True if i and i.dropEnabled(): for child in self.descendants: if child == i: droppable = False break if droppable: self.setSelected( i, True ) e.accept() e.acceptAction() else: e.ignore() else: e.ignore()
assert QColor_type != InstanceType known_type_copiers[ QColor_type ] = copy_QColor
if QColor_type != InstanceType: known_type_copiers[ QColor_type ] = copy_QColor else: print "Warning: QColor_type is %r, id % ( QColor_type, id(QColor_type), InstanceType, id(InstanceType) ) print " and they should be != but are not," print " so Undo is not yet able to copy QColors properly; this is not known to cause...
def copy_QColor(obj): from qt import QColor assert obj.__class__ is QColor # might fail (in existing calls) if some other class has the same name if env.debug(): print "atom_debug: ran copy_QColor" # remove when works once; will equality work right? ###@@@ return QColor(obj)
print "runSim.write_minimize_enabled_jigs(): CALLED"
def write_minimize_enabled_jigs(self, mapping): '''Writes any jig to the mmp file which has the attr "enable_minimize"=True ''' print "runSim.write_minimize_enabled_jigs(): CALLED" from jigs import Jig def func_write_jigs(nn): if isinstance(nn, Jig) and nn.enable_minimize: print nn.name, " written to minimize MMP file...
print nn.name, " written to minimize MMP file"
if debug_sim: print "The jig [", nn.name, "] was written to minimize MMP file. It is enabled for minimize."
def func_write_jigs(nn): if isinstance(nn, Jig) and nn.enable_minimize: print nn.name, " written to minimize MMP file" nn.writemmp(mapping) return # from func_write_jigs only
env.history.message("deleted %r" % j)
env.history.message("deleted %r" % j.name)
def jigLeftUp(self, j, event): '''Jig <j> was clicked, so select, unselect or delete it based on the current modkey. - If no modkey is pressed, clear the selection and pick jig <j>. - If Shift is pressed, pick <j>, adding it to the current selection. - If Ctrl is pressed, unpick <j>, removing it from the current selec...
grouppos = common_prefix( first_after, last_after )
grouppos = common_prefix( first_after[:-1], last_after[:-1] )
def node_new_index(node, root, after_these): """If the given node is not already after all the nodes in after_these (a list of nodes), return the new position it should have (expressed in terms of current indices -- the extended index might be different after the original node is moved, leaving a hole where the node us...
and its (possibly inherited) display mode
and its (possibly inherited) display mode.
def draw(self, win, dispdef, col, level): """draw the atom depending on whether it is picked and its (possibly inherited) display mode An atom's display mode overrides the inherited one from the molecule, but a molecule's color overrides the atom's element-dependent one """ color = col or self.element.color disp, rad =...
if not isinstance(obj, Bond) and env.debug(): print "debug fyi: not isinstance(obj, Bond) in get_obj_under_cursor, for %r" % (obj,)
if env.debug(): if isinstance(obj, Atom): print "debug fyi: likely bug: selobj is Atom but not in selatom: %r" % (obj,) elif isinstance(obj, Jig): print "debug fyi: selobj is a Jig in get_obj_under_cursor (comment is wrong), for %r" % (obj,)
def get_obj_under_cursor(self, event): '''Return the object under the cursor. Only atoms, singlets and bonds are returned. Returns None for all other cases, including when a bond, jig or nothing is under the cursor. ''' #bruce 060331 comment: this docstring appears wrong, since the code looks like it can return jigs. ...
pass
def get_obj_under_cursor(self, event): '''Return the object under the cursor. Only atoms, singlets and bonds are returned. Returns None for all other cases, including when a bond, jig or nothing is under the cursor. ''' #bruce 060331 comment: this docstring appears wrong, since the code looks like it can return jigs. ...
if env.debug():
if 0 and env.debug():
def get_obj_under_cursor(self, event): '''Return the object under the cursor. Only atoms, singlets and bonds are returned. Returns None for all other cases, including when a bond, jig or nothing is under the cursor. ''' #bruce 060331 comment: this docstring appears wrong, since the code looks like it can return jigs. ...
self.backgroundGradient = gradient
if 1: self.backgroundGradient = 1 else: self.backgroundGradient = gradient
def change_bg_color(self, color, gradient): '''Set the background to 'color' or 'gradient' (Sky Blue). ''' self.backgroundColor = color self.backgroundGradient = gradient
QWhatsThis.__init__(self, widget) self.__text = text
QWhatsThis.__init__(self, widget) self.__text = text self.__widget = widget
def __init__(self, widget, text = None): QWhatsThis.__init__(self, widget) self.__text = text # note: using QString(text) here is ok but not required
print "text at pos %r in %r was queried by Qt" % (pos, self)
print "text at pos %r in %r for %r queried by Qt" % (pos, self, self.__widget)
def text(self, pos): # this runs when Qt puts up a WhatsThis help window for widget if debug_whatsthis_links: print "text at pos %r in %r was queried by Qt" % (pos, self) # note: pos repr is not useful, doesn't show x,y text = self.__text if not text and debug_whatsthis_links: print " no text" # never happens in curren...
print "clicked hyperlink in %r, href text is %r" % (self,link)
print "clicked hyperlink in %r for %r, href text is %r" % (self, self.__widget, link)
def clicked(self, link): # this runs when user clicks on a hyperlink in the help text, with 'link' being the link text (href attribute) link = str(link) # QString to string (don't know if this is needed, guess yes) # note: link is not a real URL, but either false or "Feature:<featurename>" # (whether or not wiki_help_u...
print "clicked non-link in %r" % self
print "clicked non-link in %r for %r, text starts %r" % (self, self.__widget, (self.__text or "")[:27])
def clicked(self, link): # this runs when user clicks on a hyperlink in the help text, with 'link' being the link text (href attribute) link = str(link) # QString to string (don't know if this is needed, guess yes) # note: link is not a real URL, but either false or "Feature:<featurename>" # (whether or not wiki_help_u...
def fix_whatsthis_text_for_mac(parent): '''If the system is a Mac, this replaces all occurances of 'Ctrl' with 'Cmd' in all the whatsthis text for all QAction widgets that are children of parent. This should be
def fix_whatsthis_text_for_mac(parent): """MISNAMED: does things for all OSes, not just macs. This should be
def create_whats_this_descriptions_for_NanoHive_dialog(w): "Create What's This descriptions for the Nano-Hive dialog widgets." #### MPQC Electrostatics Potential Plane #### MPQCESPText = "<u><b>MPQC Electrostatics Potential Plane</b></u><br>"\ "Enables the <i>MPQC Electrostatics Potential Plane</i> plugin. "\ "</p>" ...
THIS MUST BE CALLED FOR ALL OSes since it now [051227] also does non-Mac-specific things. [ ''' from platform import is_macintosh if is_macintosh():
It does two things: 1. If the system is a Mac, this replaces all occurrences of 'Ctrl' with 'Cmd' in all the whatsthis text for all QAction or QWidget objects that are children of parent. 2. For all systems, it replaces certain whatsthis text patterns with hyperlinks, and adds MyWhatsThis objects to widgets with text m...
def fix_whatsthis_text_for_mac(parent): #bruce 051227-29 revised this; now it's misnamed and needs renaming and/or cleanup ###@@@ '''If the system is a Mac, this replaces all occurances of 'Ctrl' with 'Cmd' in all the whatsthis text for all QAction widgets that are children of parent. This should be called after all w...
original_txt = obj.whatsThis() new_txt = replace_ctrl_with_cmd_text(original_txt) obj.setWhatsThis(new_txt)
text = str(obj.whatsThis()) if mac: text = replace_ctrl_with_cmd(text) if enable_whatsthis_links: text = turn_featurenames_into_links(text) obj.setWhatsThis(text)
def fix_whatsthis_text_for_mac(parent): #bruce 051227-29 revised this; now it's misnamed and needs renaming and/or cleanup ###@@@ '''If the system is a Mac, this replaces all occurances of 'Ctrl' with 'Cmd' in all the whatsthis text for all QAction widgets that are children of parent. This should be called after all w...
hack_whatsthis_object_for_widgets(parent) return def replace_ctrl_with_cmd_text(str): '''Returns a string, replacing all occurances of Ctrl with Cmd in 'str'. ''' str = str.replace('Ctrl', 'Cmd') str = str.replace('ctrl', 'cmd') return str _KEEPERS = [] def hack_whatsthis_object_for_widgets(parent): objList = parent...
objList = parent.queryList("QWidget") for obj in objList: text = whatsthis_text_for_widget(obj) if text: if mac: text = replace_ctrl_with_cmd(text) text = turn_featurenames_into_links(text) assert text else: text = None if text or isinstance(obj, QPopupMenu): give_widget_MyWhatsThis_and_text( obj, text) co...
def fix_whatsthis_text_for_mac(parent): #bruce 051227-29 revised this; now it's misnamed and needs renaming and/or cleanup ###@@@ '''If the system is a Mac, this replaces all occurances of 'Ctrl' with 'Cmd' in all the whatsthis text for all QAction widgets that are children of parent. This should be called after all w...
from sim import SimulatorInterrupted
def sim_loop_using_dylib(self): #bruce 051231; compare to sim_loop_using_standalone_executable # 051231 6:29pm: works, except no trace file is written so results in history come from prior one (if any) """#doc """ movie = self._movie if platform.atom_debug and movie.duration: print "atom_debug: possible bug: movie.dura...
except SimulatorInterrupted:
except SimulatorInterrupted, e: assert e.args[0] in ( 'simulator was interrupted', 'window is preparing to close' )
def sim_loop_using_dylib(self): #bruce 051231; compare to sim_loop_using_standalone_executable # 051231 6:29pm: works, except no trace file is written so results in history come from prior one (if any) """#doc """ movie = self._movie if platform.atom_debug and movie.duration: print "atom_debug: possible bug: movie.dura...
from sim import SimulatorInterrupted raise SimulatorInterrupted
raise SimulatorInterrupted, 'window is preparing to close'
def sim_frame_callback(self, last_frame): "Per-frame callback function for simulator object." if last_frame and env.debug(): print "debug: last_frame is true" #bruce 060712 # Note: this was called 3550 times for minimizing a small C3 sp3 hydrocarbon... better check the elapsed time quickly. #e Maybe we should make this...
arguments.append(arg)
if arg != "": arguments.append(arg)
def spawn_process(self): # also includes monitor_progress, for now """Actually spawn the process, making its args based on the given options (and/or on other options we've specified earlier to this class?) and with other args telling it to use the previously written input files. ###retval? or record some info? ### do w...
"The part has been changed since the last save.\n"
"The part contains unsaved changes.\n"
def closeEvent(self,ce): if not self.assy.modified: ce.accept() return rc = QMessageBox.warning( self, self.name(), "The part has been changed since the last save.\n" "Do you want to save the changes before exiting?", "&Save", "&Discard", "Cancel", 0, # Enter == button 0 2 ) # Escape == button 2
def fileExit(self): if self.assy.modified: ret = QMessageBox.warning( self, self.name(), "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 self.destroy()
def fileExit(self): if self.assy.modified: ret = QMessageBox.warning( self, self.name(), "The part contains unsaved changes.\n" "Do you want to save the changes before exiting?", "&Save", "&Discard", "Cancel", 0, # Enter == button 0 2 ) # Escape == button 2 if ret==0: self.fileSave() # Save clicked or Alt+S p...
for obj, text in _objects_and_text_that_need_fixing_later: give_widget_MyWhatsThis_and_text( obj, text)
def refix_whatsthis_text_and_links( ): #bruce 060319 part of fixing bug 1421
self.moviePlayerDashboard.setGeometry(QRect(0,19,1087,29))
self.moviePlayerDashboard.setGeometry(QRect(0,19,1084,29))
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
distStr = distStr
def getDistHighlightedAtomAndSelectedAtom(self, selectedAtomList, ppa2, atomDistPrecision): from VQT import vlen """ Returns the distance between the selected atom and the highlighted atom. If there is only one atom selected and is same as highlighed atom, then it returns None. (then the function calling this routin...
selectedAtomList.remove(glpane.selobj) lastSelAtom = selectedAtomList[0] secondLastSelAtom = selectedAtomList[1] selectedAtomList.append(glpane.selobj)
i = selectedAtomList.index(glpane.selobj) j = abs((3 - i)- 2) k = (3 - i) -j lastSelAtom = selectedAtomList[j] secondLastSelAtom = selectedAtomList[k]
def getAngleHighlightedAtomAndSelAtoms(self,ppa2, ppa3,selectedAtomList,bendAngPrecision): """ Returns the angle between the last two selected atoms and the current highlighted atom. If the highlighed atom is also one of the selected atoms and there are only 2 selected atoms other than the highlighted one then it ret...
if not atoms: env.history.message(cmd + redmsg("You must first select an atom(s) to create a Rotary Motor."))
if len(atoms) < 2: env.history.message(cmd + redmsg("You must select at least two atoms to create a Rotary Motor."))
def makeRotaryMotor(self, sightline): """Creates a Rotary Motor connected to the selected atoms. """ cmd = greenmsg("Rotary Motor: ")
msg = "Didn't copy %s since none of its atoms were copied." % (self.name) env.history.message(orangemsg(msg))
def will_copy_if_selected(self, sel): "[overrides Node method]" # Copy this jig if asked, provided the copy will refer to atoms if necessary. # Whether it's disabled (here and/or in the copy, and why) doesn't matter. if not self.needs_atoms_to_survive(): return True for atom in self.atoms: if sel.picks_atom(atom): retu...
f3d = Font3D(xoff=hw, yoff=y1, right=right, up=up, rot90=False, glBegin=True)
def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ...
f3d.drawString("%g" % y1, y1)
def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ...
f3d = Font3D(xoff=x1, yoff=hh, right=right, up=up, rot90=True, glBegin=True)
def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ...
f3d.drawString("%g" % x1, x1)
def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ...
if line_type > 1: glDisable (GL_LINE_STIPPLE)
def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ...
self.jigAtomSetAction = QAction(self,"jigAtomSetAction") self.jigAtomSetAction.setIconSet(QIconSet(self.image138))
self.jigsAtomSetAction = QAction(self,"jigsAtomSetAction") self.jigsAtomSetAction.setIconSet(QIconSet(self.image138))
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.jigAtomSetAction.addTo(self.jigsMenu)
self.jigsAtomSetAction.addTo(self.jigsMenu)
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.connect(self.jigAtomSetAction,SIGNAL("activated()"),self.makeAtomSet)
self.connect(self.jigsAtomSetAction,SIGNAL("activated()"),self.makeAtomSet)
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.jigAtomSetAction.setText(self.__tr("Atom Set"))
self.jigsAtomSetAction.setText(self.__tr("Atom Set"))
def languageChange(self): self.setCaption(self.__tr("nanoENGINEER-1")) self.fileOpenAction.setText(self.__tr("Open")) self.fileOpenAction.setMenuText(self.__tr("&Open...")) self.fileOpenAction.setAccel(self.__tr("Ctrl+O")) self.fileSaveAction.setText(self.__tr("Save")) self.fileSaveAction.setMenuText(self.__tr("&Save")...
msg = "minimize thresholds: endRMS = %0.2f, endMax = %0.2f, cutoverRMS = %0.2f, cutoverMax = %0.2f" % \
msg = "convergence criteria: endRMS = %0.2f, endMax = %0.2f, cutoverRMS = %0.2f, cutoverMax = %0.2f" % \
def warn(msg): env.history.message(orangemsg("Warning: ") + quote_html(msg))
info = fix_plurals( "(Treating %d bondpoint(s) as Hydrogens, during minimization)" % nsinglets_H )
info = fix_plurals( "(Treating %d bondpoint(s) as Hydrogens, during adjustment)" % nsinglets_H )
def run(self): """Minimize the Selection or the current Part""" #bruce 050324 made this method from the body of MWsemantics.modifyMinimize # and cleaned it up a bit in terms of how it finds the movie to use. #bruce 050412 added 'Sel' vs 'All' now that we have two different Minimize buttons. # In future the following c...
if atom_limit_exceeded(self.assy.w, cmd, len(atoms), limit=200): return
def makeAnchor(self): """Anchors the selected atoms so that they will not move during a minimization or simulation run. """ # [bruce 050210 modified docstring] # [mark 051104 modified docstring] cmd = greenmsg("Anchor: ")
def atom_limit_exceeded(parent, cmd, natoms, limit=200): '''Displays a warning message if 'natoms' exceeds 'limit'. Returns False if the number of atoms does not exceed the limit, or if the user confirms that the jigs should still be added even though the limit was exceeded. ''' if natoms < limit: return False wmsg ...
def makeMeasureDihedral(self): # Not implemented yet. Mark 051030. """Creates a Measure Dihedral jig connected to three selected atoms. """ cmd = greenmsg("Measure Dihedral Jig: ")
if now > self.__callback_time + 0.05: print "frame %d" % self.__frame_number, now
if now > self.__callback_time + self.__sim_work_time: simtime = now - self.__callback_time if debug_pyrex_prints: print "sim hit frame %d in" % self.__frame_number, simtime
def sim_frame_callback(self): #bruce 060102 "Per-frame callback function for simulator object." ## print "f", # This happened 3550 times for minimizing a small C3 sp3 hydrocarbon... better check the time first. #e Maybe we should make this into a lambda, or even code it in C, to optimize it. First make it work. import ...
self.__callback_time = time.time() print "python stuff took", self.__callback_time - now
self.__callback_time = time.time() pytime = self.__callback_time - now if debug_pyrex_prints: print "python stuff took", pytime self.__sim_work_time = max(0.05, min(pytime * 4, 2.0)) if debug_pyrex_prints: print "set self.__sim_work_time to", self.__sim_work_time if 1: msg = "sim took %0.3f, hit frame %03d, py took ...
def sim_frame_callback(self): #bruce 060102 "Per-frame callback function for simulator object." ## print "f", # This happened 3550 times for minimizing a small C3 sp3 hydrocarbon... better check the time first. #e Maybe we should make this into a lambda, or even code it in C, to optimize it. First make it work. import ...
print "frame no. %d len %d is" % (frame_number, len(frame)), frame
def sim_frame_callback_worker(self, frame_number): #bruce 060102 """Do whatever should be done on frame_callbacks that don't return immediately (due to not enough time passing). Might raise exceptions -- caller should protect itself from them until the sim does. + stuff new frame data into atom positions +? fix singlet...
global CylList, diamondGridList, CapList, CubeList, solidCubeList
global CylList, diamondGridList, CapList, CubeList, solidCubeList, wiresphere1list
def setup(): global CylList, diamondGridList, CapList, CubeList, solidCubeList global sphereList, rotSignList, linearLineList, linearArrowList global circleList, lonsGridList, lonsEdges, lineCubeList, SiCGridList global use_c_renderer_pref listbase = glGenLists(numSphereSizes + 21) for i in range(numSphereSizes): sph...
listbase = glGenLists(numSphereSizes + 21)
listbase = glGenLists(numSphereSizes + 22)
def setup(): global CylList, diamondGridList, CapList, CubeList, solidCubeList global sphereList, rotSignList, linearLineList, linearArrowList global circleList, lonsGridList, lonsEdges, lineCubeList, SiCGridList global use_c_renderer_pref listbase = glGenLists(numSphereSizes + 21) for i in range(numSphereSizes): sph...
CylList = listbase+numSphereSizes
wiresphere1list = listbase + numSphereSizes didlines = {} def shoulddoline(v1,v2): v1 = tuple(v1) v2 = tuple(v2) if (v1,v2) not in didlines: didlines[(v1,v2)] = didlines[(v2,v1)] = None return True return False def doline(v1,v2): if shoulddoline(v1,v2): glVertex3fv(v1) glVertex3fv(v2) return glNewList(wiresphere1list, ...
def setup(): global CylList, diamondGridList, CapList, CubeList, solidCubeList global sphereList, rotSignList, linearLineList, linearArrowList global circleList, lonsGridList, lonsEdges, lineCubeList, SiCGridList global use_c_renderer_pref listbase = glGenLists(numSphereSizes + 21) for i in range(numSphereSizes): sph...
glPolygonMode(GL_FRONT, GL_LINE)
if oldway: glPolygonMode(GL_FRONT, GL_LINE)
def drawwiresphere(color, pos, radius, detailLevel=1): glColor3fv(color) glDisable(GL_LIGHTING) glPolygonMode(GL_FRONT, GL_LINE) glPushMatrix() glTranslatef(pos[0], pos[1], pos[2]) glScale(radius,radius,radius) glCallList(sphereList[detailLevel]) glEnable(GL_LIGHTING) glPopMatrix() glPolygonMode(GL_FRONT, GL_FILL) retu...
glCallList(sphereList[detailLevel])
if oldway: glCallList(sphereList[detailLevel]) else: glCallList(wiresphere1list)
def drawwiresphere(color, pos, radius, detailLevel=1): glColor3fv(color) glDisable(GL_LIGHTING) glPolygonMode(GL_FRONT, GL_LINE) glPushMatrix() glTranslatef(pos[0], pos[1], pos[2]) glScale(radius,radius,radius) glCallList(sphereList[detailLevel]) glEnable(GL_LIGHTING) glPopMatrix() glPolygonMode(GL_FRONT, GL_FILL) retu...
glPolygonMode(GL_FRONT, GL_FILL)
if oldway: glPolygonMode(GL_FRONT, GL_FILL)
def drawwiresphere(color, pos, radius, detailLevel=1): glColor3fv(color) glDisable(GL_LIGHTING) glPolygonMode(GL_FRONT, GL_LINE) glPushMatrix() glTranslatef(pos[0], pos[1], pos[2]) glScale(radius,radius,radius) glCallList(sphereList[detailLevel]) glEnable(GL_LIGHTING) glPopMatrix() glPolygonMode(GL_FRONT, GL_FILL) retu...
"Differential Position Bytes Format (*.dpb);;XYZ Format (*.xyz);;This writes a series of files:;;povray (*.pov)",
"Differential Position Bytes Format (*.dpb);;POV-Ray Series (*.pov)",
def fileSaveMovie(self): """Save a copy of the current movie file loaded in the Movie Player. """ # Make sure there is a moviefile to save. if not self.assy.current_movie or not self.assy.current_movie.filename \ or not os.path.exists(self.assy.current_movie.filename): msg = redmsg("Save Movie File: No movie file to s...
w.hybridComboBox = QComboBox(0, w.selectAtomsDashboard, "hybridComboBox")
w.atomSelect_hybridComboBox = QComboBox(0, w.selectAtomsDashboard, "hybridComboBox")
def do_what_MainWindowUI_should_do(w): '''This creates the Select Atoms (not the Select Chunks) dashboard . ''' # This dashboard needs to be redesigned. Working on the tooltips and What's This descriptions # made me realize how poorly the UI is laid out. Ideas for improvements include: # - totally removing the "Elem...
w.hybridComboBox.setMinimumSize ( QSize (width, 0) ) w.hybridComboBox_elem = None
w.atomSelect_hybridComboBox.setMinimumSize ( QSize (width, 0) )
def do_what_MainWindowUI_should_do(w): '''This creates the Select Atoms (not the Select Chunks) dashboard . ''' # This dashboard needs to be redesigned. Working on the tooltips and What's This descriptions # made me realize how poorly the UI is laid out. Ideas for improvements include: # - totally removing the "Elem...
hybname = self.w.hybridComboBox.currentText()
hybname = self.w.atomSelect_hybridComboBox.currentText()
def getAtomtype(self, elmNo): '''<Param> elm: the current transmuted to element 'atom number'. return the current pastable atomtype''' elm = PeriodicTable.getElement(elmNo) atomtype = None if len(elm.atomtypes) > 1: try: hybname = self.w.hybridComboBox.currentText() atype = elm.find_atomtype(hybname) if atype is not No...
self.modified = 1
def Bond(self): if not self.selatoms: return self.modified = 1 aa=self.selatoms.values() if len(aa)==2: aa[0].molecule.bond(aa[0], aa[1]) aa[0].molecule.changeapp() aa[1].molecule.changeapp() self.o.paintGL()
for b1 in aa[0].bonds: for b2 in aa[1].bonds:
for b1 in aa[0].bonds[:]: for b2 in aa[1].bonds[:]:
def Unbond(self): if not self.selatoms: return self.modified = 1 aa=self.selatoms.values() if len(aa)==2: for b1 in aa[0].bonds: for b2 in aa[1].bonds: if b1 == b2: b1.bust() self.o.paintGL()
QToolTip.add(self.watch_minimization_checkbox,self.__tr("Enables real time graphical updates during simulation runs")) QWhatsThis.add(self.watch_minimization_checkbox,self.__tr("<p><b>Watch Motion In Real Time</b></p>Enables real time graphical updates during simulation runs."))
QToolTip.add(self.watch_minimization_checkbox,self.__tr("Enables real time graphical updates during minimization runs")) QWhatsThis.add(self.watch_minimization_checkbox,self.__tr("<p><b>Watch Motion In Real Time</b></p>Enables real time graphical updates during minimization runs."))
def languageChange(self): self.setCaption(self.__tr("Minimize Energy")) QWhatsThis.add(self,self.__tr("<u><b>Minimize Energy dialog</b></u>\n"
for attr in dir(class1): ca = getattr(class1, attr) ia = getattr(instance1, attr) if ca != ia: try: if ia.im_func == ca.im_func: continue except AttributeError: pass print " attr %r is overridden" % attr
import debug res = debug.overridden_attrs(class1, instance1) print " %r" % res
def print_overrides(self): "[debugging method] print the class attributes overridden in this instance" #e generalize and split that into debug module and use for win, mtree, glpane, history # experiment: need to not do this for instance methods; will the im_func attr (same_method, modes.py) help?? ##### instance1 = sel...
dt = glpane.quat
dt = Q(glpane.quat) if not vlen(V(dt.x, dt.y, dt.z)): dt.x = .00001
def writepovfile(part, glpane, filename): #bruce 050927 replaced assy argument with part and glpane args, added docstring "write the given part into a new POV-Ray file with the given name, using glpane and glpane.mode for lightig, color, etc" f = open(filename,"w") ## bruce 050325 removed this (no effect except on assy...
QWhatsThis.add(self.SimSetupDialog, """<b>NanoDynamics-1 Setup</b><p>NanoEngineer-1 Molecular Dynamics
QWhatsThis.add(self, """<b>NanoDynamics-1 Setup</b><p>NanoEngineer-1 Molecular Dynamics
def __init__(self, part, previous_movie = None, suffix = ""): """use previous_movie (if passed) for default values, otherwise use the same ones last ok'd by user (whether or not that sim got aborted), or default values if that never happened in this session; on success or failure, make a new Movie and store it as self....
if c.logic == 1 or c.logic == 2:
if c.logic == 2 or c.logic == 0:
def partselect(self, assy): """Loop thru all the atoms that are visible and select any that are 'in' the shape, ignoring the thickness parameter. pick the parts that contain them """ #---This function has been modified by Huaicai on 10/05/04 to fix bugs of shift & Ctrl drag#---selection of molecules c=self.curves[0] if...
if c.isin(a.posn()): a.molecule.pick() if c.logic == 2:
if c.isin(a.posn()): a.molecule.pick() break if c.logic == 0:
def partselect(self, assy): """Loop thru all the atoms that are visible and select any that are 'in' the shape, ignoring the thickness parameter. pick the parts that contain them """ #---This function has been modified by Huaicai on 10/05/04 to fix bugs of shift & Ctrl drag#---selection of molecules c=self.curves[0] if...
else:
if c.logic == 1:
def partselect(self, assy): """Loop thru all the atoms that are visible and select any that are 'in' the shape, ignoring the thickness parameter. pick the parts that contain them """ #---This function has been modified by Huaicai on 10/05/04 to fix bugs of shift & Ctrl drag#---selection of molecules c=self.curves[0] if...
if platform.atom_debug and len(nodeset) == 1: res.append(( "debug._node =", self.cm_set_node )) else: res.append(( "debug._nodeset =", self.cm_set_node ))
if platform.atom_debug: if len(nodeset) == 1: res.append(( "debug._node =", self.cm_set_node )) else: res.append(( "debug._nodeset =", self.cm_set_node ))
def make_cmenuspec_for_set(self, nodeset): # [see also the term Menu_spec] "#doc... see superclass docstring"
self.changed() jigs = self.assy.getSelectedJigs() if not jigs: msg = redmsg("No mirror plane selected. Please select a Grid Plane first.") instruction = " (If it doesn't exists, create it first using <b>Jigs > Grid Plane</b>)" env.history.message(cmd + msg + instruction) return self.changed()
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/(or jig with 0 atoms) #This has some known bugs. listed below ninad060812: #What it does: #- Mirrors selected chunks about a selected Grid plane. (M...
for m in self.selmols: mirrorChunk = m.copy(None) self.o.assy.addmol(mirrorChunk) mirrorChunk.stretch(-1.0) self.mirrorAxis = jigs[0].getaxis() mirrorChunk.rot(Q(self.mirrorAxis, pi)) self.mirrorDistance, self.wid = orthodist(m.center, self.mirrorAxis, jigs[0].center) mirrorChunk.move(2*(self.mirrorDistance)*self.m...
jigs = self.assy.getSelectedJigs() jigCounter = self.getQualifiedMirrorJigs(jigs) if jigCounter < 1: msg = redmsg("No mirror plane selected. Please select a Grid Plane first.") instruction = " (If it doesn't exists, create it using <b>Jigs > Grid Plane</b> )" env.history.message(cmd + msg + instruction) return elif ...
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/(or jig with 0 atoms) #This has some known bugs. listed below ninad060812: #What it does: #- Mirrors selected chunks about a selected Grid plane. (M...
self.connect(self.endings_combox,SIGNAL("returnPressed()"),self.parameter_fixup) self.connect(self.members_combox,SIGNAL("activated(const QString&)"),self.parameter_fixup)
self.connect(self.endings_combox,SIGNAL("textChanged(const QString&)"),self.parameter_fixup) self.connect(self.members_combox,SIGNAL("textChanged(const QString&)"),self.parameter_fixup)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.w.pasteComboBox.setCurrentItem(itemId)
def chunkChanged(self, item): '''Slot method. Called when user changed the selected chunk. ''' itemId = self.chunkListBox.index(item) newChunk = self.pastableItems[itemId] #self.w.pasteComboBox.setCurrentItem(itemId) #buildModeObj = self.w.glpane.modetab['DEPOSIT'] #assert buildModeObj #buildModeObj.setPaste() ##Comp...
i = self.chunkListBox.count() - 1
i = self.w.pasteComboBox.currentItem()
def _clipboardPageView(self): '''Updates the clipboard page. ''' if not self.currentPageOpen(ClipboardPage): # (old code permitted this to be false below in 'if len(list):', # but failed to check for it in the 'else' clause, # thus causing bug 1627 [I think], now fixed in our caller) print "bug: _clipboardPageView ca...
progressBarDialog.__init__(self, None, None, True)
ProgressBarDialog.__init__(self, None, None, True)
def __init__(self): ### Huaicai 1/10/05: make the dialog as a modal dialog, ### otherwise, if the user close the main window, it will get ### "RuntimeError: underlying C/C++ object has been deleted progressBarDialog.__init__(self, None, None, True) self.duration = 0 # Seconds that the progress bar takes to complete
def launch( self , nsteps, filename = '', caption = "Progress", message = "Calculating...", dflag = 0): """Launch a progress bar dialog and update while a file is being written.
def launch( self , nsteps, filename = '', caption = "Progress", message = "Calculating...", show_duration = 0): """Launch a progress bar dialog, and update it while a file is being written by some other process, to show the size of that file as progress, while waiting for that size to reach a given value; when it does,...
def launch( self , nsteps, filename = '', caption = "Progress", message = "Calculating...", dflag = 0): """Launch a progress bar dialog and update while a file is being written. nsteps - total steps for the progress bar (final size in bytes of filename) filename - name of file we are waiting for. caption - dialog capti...
dflag - if True, display duration (in seconds) below progressbar
show_duration - if True, display duration (in seconds) below progressbar Return value: 0 if file reached desired size, 1 if user hit abort button.
def launch( self , nsteps, filename = '', caption = "Progress", message = "Calculating...", dflag = 0): """Launch a progress bar dialog and update while a file is being written. nsteps - total steps for the progress bar (final size in bytes of filename) filename - name of file we are waiting for. caption - dialog capti...
if caption == "Minimize":
if caption.startswith("Minimize"):
def launch( self , nsteps, filename = '', caption = "Progress", message = "Calculating...", dflag = 0): """Launch a progress bar dialog and update while a file is being written. nsteps - total steps for the progress bar (final size in bytes of filename) filename - name of file we are waiting for. caption - dialog capti...
if dflag:
if show_duration:
def launch( self , nsteps, filename = '', caption = "Progress", message = "Calculating...", dflag = 0): """Launch a progress bar dialog and update while a file is being written. nsteps - total steps for the progress bar (final size in bytes of filename) filename - name of file we are waiting for. caption - dialog capti...
def oneLiner(cmd):
def listResults(cmd):
def oneLiner(cmd): def strip(x): return x.rstrip() lines = map(strip, os.popen(cmd).readlines()) return repr(lines)
lines = map(strip, os.popen(cmd).readlines()) return repr(lines)
return map(strip, os.popen(cmd).readlines())
def strip(x): return x.rstrip()
print oneLiner("pwd") + " " + oneLiner("ls sim*")
print listResults("pwd"), listResults("ls sim*")
def buildSimulator(self): """Checkout source code from cvs for the release """ os.chdir(os.path.join(self.atomPath, 'sim/src')) system('make') system('make pyx') if False: # verify they got built print oneLiner("pwd") + " " + oneLiner("ls sim*") raise Exception print "----------Sources have been checked out and made.\n...
print "pwd", oneLiner("pwd")[0]
print "pwd", listResults("pwd")[0]
def _addModuleToZip(self, archFile, module): """First, rename *.zip file, and then create a directory, unzip *.zip into that directory, copy module into that directory (Windows only)""" print "\n------------------------------------------------------\nAdding Module to ZIP File" import zipfile, unzip os.chdir(self.curren...
self._ok_or_preview()
self._ok_or_preview(previewing=True)
def preview_btn_clicked(self): if platform.atom_debug: print 'preview button clicked' self._ok_or_preview()
def _ok_or_preview(self, doneMsg=False):
def _ok_or_preview(self, doneMsg=False, previewing=False):
def _ok_or_preview(self, doneMsg=False): QApplication.setOverrideCursor( QCursor(Qt.WaitCursor) ) self.win.assy.current_command_info(cmdname = self.cmdname) #bruce 060616 try: self._build_struct() if doneMsg: env.history.message(self.cmd + self.done_msg()) except CadBug, e: env.history.message(redmsg("Bug in the CAD sy...
self._build_struct()
self._build_struct(previewing=previewing)
def _ok_or_preview(self, doneMsg=False): QApplication.setOverrideCursor( QCursor(Qt.WaitCursor) ) self.win.assy.current_command_info(cmdname = self.cmdname) #bruce 060616 try: self._build_struct() if doneMsg: env.history.message(self.cmd + self.done_msg()) except CadBug, e: env.history.message(redmsg("Bug in the CAD sy...
def _build_struct(self):
def _build_struct(self, previewing=False):
def _build_struct(self): if platform.atom_debug: print '_build_struct' params = self.gather_parameters()
env.history.message(self.cmd + "Creating " + name)
if previewing: env.history.message(self.cmd + "Previewing " + name) else: env.history.message(self.cmd + "Creating " + name)
def _build_struct(self): if platform.atom_debug: print '_build_struct' params = self.gather_parameters()
def __init__(self, assy, movie):
def __init__(self, assy, basefilename):
def __init__(self, assy, movie): #bruce 050326 added movie arg parent = assy.w PlotToolDialog.__init__(self, parent) self.movie = movie # before bruce 050326 was assy.current_movie self.setup() self.show() # Fixed bug 440-1. Mark 050802.
self.movie = movie
try: tracefilename = basefilename[:-4] + "-xyztrace.txt" inf = open(tracefilename) inf.close() except IOError: tracefilename = basefilename[:-4] + "-trace.txt" plotfilename = basefilename[:-4] + "-plot.txt" self.traceFile = tracefilename self.plotFile = plotfilename
def __init__(self, assy, movie): #bruce 050326 added movie arg parent = assy.w PlotToolDialog.__init__(self, parent) self.movie = movie # before bruce 050326 was assy.current_movie self.setup() self.show() # Fixed bug 440-1. Mark 050802.
if not self.movie or not self.movie.filename: msg = redmsg("No tracefile exists for this part. To create one, run a simulation.") env.history.message(cmd + msg) return 1 self.traceFile = self.movie.get_trace_filename()
def setup(self): """Setup the Plot Tool dialog, including populating the combobox with plotting options. """ # To setup the Plot Tool, we need to do the following: # 1. Make sure there is a valid DPB file. This is temporary since the Plot Tool will # soon allow the user to open and plot any trace file. # 2. From th...
self.plotFile = self.movie.get_GNUplot_filename()
def setup(self): """Setup the Plot Tool dialog, including populating the combobox with plotting options. """ # To setup the Plot Tool, we need to do the following: # 1. Make sure there is a valid DPB file. This is temporary since the Plot Tool will # soon allow the user to open and plot any trace file. # 2. From th...
all_nonbaggage += nonbaggage
def setupDragAtoms(self, a): '''Setup dragging of real atom <a> and all other currently selected atoms. ''' self.initDragObject(a) self.dragatom_clicked = True self.obj_doubleclicked = a self.baggage = [] # precaution. mark 060202. self.nonbaggage = [] # precaution. mark 060202. selatoms = self.o.assy.selatoms_list(...
file.insertItem('E&xit',qApp,SLOT('closeAllWindows()'),Qt.CTRL+Qt.Key_X)
# def __init__(self,parent = None,name = None,fl = 0):
try: now = time.time() simtime = now - self.__last_3dupdate_time pytime = self.__last_pytime nframes = self.__frame_number - self.__last_3dupdate_frame update_3dview = self.sim_frame_callback_update_check( simtime, pytime, nframes ) if self.__frame_number == self.totalFramesRequested or debug_all_frames: update_3d...
now = time.time() simtime = now - self.__last_3dupdate_time pytime = self.__last_pytime nframes = self.__frame_number - self.__last_3dupdate_frame update_3dview = self.sim_frame_callback_update_check( simtime, pytime, nframes ) if self.__frame_number == self.totalFramesRequested or debug_all_frames: update_3dview = Tr...
def sim_frame_callback(self): #bruce 060102 "Per-frame callback function for simulator object." # Note: this was called 3550 times for minimizing a small C3 sp3 hydrocarbon... better check the elapsed time quickly. #e Maybe we should make this into a lambda, or even code it in C, to optimize it. if self.PREPARE_TO_CLOS...
class ExceptionInfoCollector: def __init__(self): self.str = '' def write(self, x): self.str += x def handle_exception(self): import sys, traceback traceback.print_tb(sys.exc_traceback, file=self) for s in self.str.split("\n")[:-1]: env.history.message(redmsg(s)) eic = ExceptionInfoCollector()
def copy_part_files_dir(self, oldPartFilesDir): # Mark 060703. NFR bug 2042. Revised by bruce 060704 for user safety, history. """Recursively copy the entire directory tree rooted at oldPartFilesDir to the assy's (new) Part Files directory. Return errorcode, message (message might be for error or for success, but is no...