rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
except: eic.handle_exception()
except Exception, e:
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))
return 1, "Problem removing an existing part files directory [%s]" % newPartFilesDir
return 1, ("Problem removing an existing part files directory [%s]" % newPartFilesDir + " - ".join(map(str, e.args)))
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))
raise Exception("ouch") except:
except Exception, e:
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))
return 1, "Problem copying files to the new parts file directory " + newPartFilesDir
return 1, ("Problem copying files to the new parts file directory " + newPartFilesDir + " - ".join(map(str, e.args)))
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))
if isinstance(ob, molecule): ob.move(-ob.center)
if isinstance(ob, molecule): center_these.append(ob)
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...
with singlets in the copy. (This has no effect on the
with singlets in the copy, and if this causes the hotspot to become ambiguous, set one explicitly. (This has no effect on the
def copy(self, dad=None, offset=V(0,0,0), cauterize = 1): """Public method: Copy the molecule to a new molecule. Offset tells where it will go relative to the original. Unless cauterize = 0, replace bonds out of the molecule with singlets in the copy. (This has no effect on the original.) If cauterize == 0, the copy ha...
try: numol.hotspot = ndix[self.hotspot.key] except AttributeError: pass
if copied_hotspot: numol.hotspot = ndix[copied_hotspot.key]
def copy(self, dad=None, offset=V(0,0,0), cauterize = 1): """Public method: Copy the molecule to a new molecule. Offset tells where it will go relative to the original. Unless cauterize = 0, replace bonds out of the molecule with singlets in the copy. (This has no effect on the original.) If cauterize == 0, the copy ha...
self.o.paintGL()
self.w.update()
def EndPick(self, event, selSense): """Pick if click """ if not self.picking: return self.picking = False
return os.path.join(nhdir,str(basename)+"-sim.xml")
fn = os.path.normpath(os.path.join(nhdir,str(basename)+"-sim.xml")) print "get_nh_simspec_filename(): filename=", fn return fn
def get_nh_simspec_filename(basename): '''Return the full path of the Nano-Hive simulation specification file. ''' if basename: nhdir = find_or_make_Nanorex_subdir("Nano-Hive") return os.path.join(nhdir,str(basename)+"-sim.xml") else: return None
return os.path.join(nhdir,str(basename)+"-flow.tcl")
fn = os.path.normpath(os.path.join(nhdir,str(basename)+"-flow.tcl")) print "get_nh_workflow_filename(): filename=", fn return fn
def get_nh_workflow_filename(basename): '''Return the full path of the Nano-Hive workflow file. ''' if basename: nhdir = find_or_make_Nanorex_subdir("Nano-Hive") return os.path.join(nhdir,str(basename)+"-flow.tcl") else: return None
return os.path.join(nhdir,str(basename)+".mmp")
fn = os.path.normpath(os.path.join(nhdir,str(basename)+".mmp")) print "get_nh_mmp_filename(): filename=", fn return fn
def get_nh_mmp_filename(basename): '''Return the full path of the Nano-Hive MMP input file. ''' if basename: nhdir = find_or_make_Nanorex_subdir("Nano-Hive") return os.path.join(nhdir,str(basename)+".mmp") else: return None
def get_nh_home():
def get_nh_home_ORIG():
def get_nh_home(): '''Return the Nano-Hive home directory''' # Retreive the Nano-Hive home directory by stripping off the last two directories # from the Nano-Hive executable path. nanohive_exe = env.prefs[nanohive_path_prefs_key] head, tail = os.path.split(nanohive_exe) head, tail = os.path.split(head) nh_home, tail ...
head, tail = os.path.split(nanohive_exe) head, tail = os.path.split(head) nh_home, tail = os.path.split(head)
if os.platform == 'win32': head, tail = os.path.split(nanohive_exe) head, tail = os.path.split(head) nh_home, tail = os.path.split(head)
def get_nh_home(): '''Return the Nano-Hive home directory''' # Retreive the Nano-Hive home directory by stripping off the last two directories # from the Nano-Hive executable path. nanohive_exe = env.prefs[nanohive_path_prefs_key] head, tail = os.path.split(nanohive_exe) head, tail = os.path.split(head) nh_home, tail ...
start_nh()
r = start_nh() if r: print "Nano-Hive startup aborted."
def run_nh_simulation(assy, sim_id, sim_parms, sims_to_run, results_to_save): '''Run a Nano-Hive simulation on the part (assy). Only the MPQC_ESP plug-in used for creating an ESP Image file is supported in A7. sim_id is the simulation id of the simulation. It is used to construct the basename of all the simulation f...
nanohive_config = os.path.join(get_nh_home(), 'conf\configs.txt')
nanohive_config = get_nh_config_filename() if not nanohive_config: return 2
def start_nh(): '''Starts Nano-Hive server in the background. Returns 1 if Nano-Hive path is not set or if the path does not exist. ''' # Get Nano-Hive executable path from the prefs db. nanohive_exe = env.prefs[nanohive_path_prefs_key] if not nanohive_exe: return 1 if not os.path.exists(nanohive_exe): return 1 nano...
w.moveChunksDashboard.addSeparator() w.moveXLabel = QLabel(" X ", w.moveChunksDashboard) w.moveXSpinBox = FloatSpinBox(w.moveChunksDashboard, "moveXSpinBox") w.moveYLabel = QLabel(" Y ", w.moveChunksDashboard) w.moveYSpinBox = FloatSpinBox(w.moveChunksDashboard, "moveYSpinBox") w.moveZLabel = QLabel(" Z ", w.moveChunk...
def do_what_MainWindowUI_should_do(w): 'Populate the Move Chunks dashboard' w.moveChunksDashboard.clear() w.moveChunksLabel = QLabel(w.moveChunksDashboard,"Move Chunks") w.moveChunksLabel.setText(" Move Chunks ") w.moveChunksDashboard.addSeparator() w.moveFreeAction.addTo(w.moveChunksDashboard) w.moveChunksDashboar...
if m1 != m2 and move: status += " and moved one chunk" m1.rot(Q(a1.posn()-s1.posn(), s2.posn()-a2.posn())) m1.move(s2.posn()-s1.posn())
if m1 != m2 and move: def ok_to_move(mol1, mol2): "ok to move mol1 if we're about to bond it to mol2?" return mol1.externs == [] if ok_to_move(m1,m2): status += ", and moved %r to match" % m1.name m1.rot(Q(a1.posn()-s1.posn(), s2.posn()-a2.posn())) m1.move(s2.posn()-s1.posn()) else: status += " (bu...
def do_error(status, error_details): if print_error_details and error_details: print "BUG: bond_at_singlets:", error_details print "Doing nothing (but further bugs may be caused by this)." print_compact_stack() if error_details: # i.e. if it's an error flag = 2 else: flag = 1 status = status or "can't bond here" return...
npnt = esp_window.getaxis() * 1e-10
npnt = cpnt + (esp_window.planeNorm * 1e-10)
def write_nh_mpqc_esp_plane_rec(f, esp_window, output_dir): nh_home = get_nh_home() cpnt = esp_window.center * 1e-10 centerPoint = (float(cpnt[0]), float(cpnt[1]), float(cpnt[2])) #print "ESP Window CenterPoint =", centerPoint npnt = esp_window.getaxis() * 1e-10 # This is a temporary workaround until Brian fixes th...
normalPoint = (float(npnt[0]), 0.5, float(npnt[2]))
normalPoint = (float(npnt[0]), float(npnt[1]), float(npnt[2]))
def write_nh_mpqc_esp_plane_rec(f, esp_window, output_dir): nh_home = get_nh_home() cpnt = esp_window.center * 1e-10 centerPoint = (float(cpnt[0]), float(cpnt[1]), float(cpnt[2])) #print "ESP Window CenterPoint =", centerPoint npnt = esp_window.getaxis() * 1e-10 # This is a temporary workaround until Brian fixes th...
if params != self.previousParams:
if self.struct == None or params != self.previousParams: if DEBUG: print 'self.struct =', self.struct if params != self.previousParams: print 'parameters changed' else: print 'parameters have not changed'
def _build_struct(self): params = self.gather_parameters() if params != self.previousParams: self.remove_struct() self.previousParams = params self.struct = self.build_struct(params) self.win.assy.addnode(self.struct) self.win.win_update() # includes mt_update
self.struct = self.build_struct(params) self.win.assy.addnode(self.struct) self.win.win_update()
if DEBUG: print 'build a new structure' self.struct = self.build_struct(params) self.win.assy.addnode(self.struct) self.win.win_update() else: if DEBUG: print 'Existing structre, same params, do not rebuild'
def _build_struct(self): params = self.gather_parameters() if params != self.previousParams: self.remove_struct() self.previousParams = params self.struct = self.build_struct(params) self.win.assy.addnode(self.struct) self.win.win_update() # includes mt_update
def _ok_or_preview(self, doneMsg=False, previewing=False): QApplication.setOverrideCursor( QCursor(Qt.WaitCursor) ) self.win.assy.current_command_info(cmdname = self.cmdname)
def handlePluginExceptions(self, thunk):
def _ok_or_preview(self, doneMsg=False, previewing=False): QApplication.setOverrideCursor( QCursor(Qt.WaitCursor) ) self.win.assy.current_command_info(cmdname = self.cmdname) #bruce 060616 try: self._build_struct(previewing=previewing) if doneMsg: env.history.message(self.cmd + self.done_msg()) except CadBug, e: env.hi...
self._build_struct(previewing=previewing) if doneMsg: env.history.message(self.cmd + self.done_msg())
return thunk()
def _ok_or_preview(self, doneMsg=False, previewing=False): QApplication.setOverrideCursor( QCursor(Qt.WaitCursor) ) self.win.assy.current_command_info(cmdname = self.cmdname) #bruce 060616 try: self._build_struct(previewing=previewing) if doneMsg: env.history.message(self.cmd + self.done_msg()) except CadBug, e: env.hi...
"""Slot for Contract Selection, which unselects any atom which has a bond to an unselected atom.
"""Slot for Contract Selection, which unselects any atom which has a bond to an unselected atom, or which has any open bonds.
def selectContract(self): """Slot for Contract Selection, which unselects any atom which has a bond to an unselected atom. """ self.assy.selectContract()
def exclude(attrname): return False
def exclude(attrname, obj): return False
def exclude(attrname): return False
flag_and_begin_retval = None if self.assy: begin_retval = self.assy.undo_checkpoint_before_command("(redraw)") flag_and_begin_retval = True, begin_retval
def paintGL(self): #bruce 050127 revised docstring to deprecate direct calls """[PRIVATE METHOD -- call gl_update instead!] The main screen-drawing function, called internally by Qt when our superclass needs to repaint. THIS SHOULD NO LONGER BE CALLED DIRECTLY BY EXTERNAL CODE -- CALL gl_update INSTEAD. Sets up point o...
if flag_and_begin_retval: flagjunk, begin_retval = flag_and_begin_retval if self.assy: self.assy.undo_checkpoint_after_command( begin_retval)
def paintGL(self): #bruce 050127 revised docstring to deprecate direct calls """[PRIVATE METHOD -- call gl_update instead!] The main screen-drawing function, called internally by Qt when our superclass needs to repaint. THIS SHOULD NO LONGER BE CALLED DIRECTLY BY EXTERNAL CODE -- CALL gl_update INSTEAD. Sets up point o...
self.change2ElemPage()
def update_dialog(self, elemNum): """Called when the current element has been changed. Update non user interactive controls display for current selected element: element label info and element graphics info """
if self.w.pasteP: self.change2PastePage() else: self.change2ElemPage()
def update_dialog(self, elemNum): """Called when the current element has been changed. Update non user interactive controls display for current selected element: element label info and element graphics info """
self.viewToolbar.setGeometry(QRect(196,0,272,29))
self.viewToolbar.setGeometry(QRect(196,0,306,29))
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.molecularDispToolbar.setGeometry(QRect(468,0,182,29))
self.molecularDispToolbar.setGeometry(QRect(502,0,182,29))
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.selectToolbar.setGeometry(QRect(650,0,154,29))
self.selectToolbar.setGeometry(QRect(684,0,154,29))
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.helpToolbar.setGeometry(QRect(804,0,70,29))
self.helpToolbar.setGeometry(QRect(838,0,70,29))
def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar()
self.setViewFrontAction.setToolTip(self.__tr("Front"))
self.setViewFrontAction.setToolTip(self.__tr("Front View"))
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")...
self.setViewTopAction.setToolTip(self.__tr("Top"))
self.setViewTopAction.setToolTip(self.__tr("Top View"))
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")...
self.setViewRightAction.setToolTip(self.__tr("Right"))
self.setViewRightAction.setToolTip(self.__tr("Right View")) self.setViewRightAction.setStatusTip(self.__tr("Right View"))
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")...
self.setViewLeftAction.setToolTip(self.__tr("Left"))
self.setViewLeftAction.setToolTip(self.__tr("Left View"))
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")...
self.setViewHomeAction.setToolTip(self.__tr("Home (Home)"))
self.setViewHomeAction.setToolTip(self.__tr("Home View (Home)"))
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")...
self.setViewOppositeAction.setToolTip(self.__tr("Set current view to its opposite.")) self.setViewOppositeAction.setStatusTip(self.__tr("Set current view to its opposite."))
self.setViewOppositeAction.setToolTip(self.__tr("Opposite View")) self.setViewOppositeAction.setStatusTip(self.__tr("Opposite View"))
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")...
def setViewOpposite(self): print "MainWindow.setViewOpposite(): Not implemented yet"
def setViewOpposite(self): print "MainWindow.setViewOpposite(): Not implemented yet"
quux.shapeRendererSetStaticLODLevels(ColorSorter.sphereLevel, 1)
def finish(): """\ Finish sorting - objects recorded since "start" will be sorted and invoked now. """ if TEST_PYREX_OPENGL: quux.shapeRendererInit() # print "VBO %s enabled" % (('is not', 'is')[quux.shapeRendererGetInteger(quux.IS_VBO_ENABLED)]) quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() qu...
glPushName(0)
def finish(): """\ Finish sorting - objects recorded since "start" will be sorted and invoked now. """ if TEST_PYREX_OPENGL: quux.shapeRendererInit() # print "VBO %s enabled" % (('is not', 'is')[quux.shapeRendererGetInteger(quux.IS_VBO_ENABLED)]) quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() qu...
glLoadName(name)
if name != 0: glPushName(name)
def finish(): """\ Finish sorting - objects recorded since "start" will be sorted and invoked now. """ if TEST_PYREX_OPENGL: quux.shapeRendererInit() # print "VBO %s enabled" % (('is not', 'is')[quux.shapeRendererGetInteger(quux.IS_VBO_ENABLED)]) quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() qu...
glPopName()
if name != 0: glPopName()
def finish(): """\ Finish sorting - objects recorded since "start" will be sorted and invoked now. """ if TEST_PYREX_OPENGL: quux.shapeRendererInit() # print "VBO %s enabled" % (('is not', 'is')[quux.shapeRendererGetInteger(quux.IS_VBO_ENABLED)]) quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() qu...
self.ui.diis = p
self.ui.dirscf = p
def info_gamess_setitem(self, name, val, interp, error_if_name_not_known = False): #bruce 050701; extended by Mark 050704 to read and set the actual params; bruce 050704 added error_if_name_not_known """This must set the parameter in self with the given name to the value encoded by the string val (read from an mmp file...
self.ui.diis = p
self.ui.extrap = p
def info_gamess_setitem(self, name, val, interp, error_if_name_not_known = False): #bruce 050701; extended by Mark 050704 to read and set the actual params; bruce 050704 added error_if_name_not_known """This must set the parameter in self with the given name to the value encoded by the string val (read from an mmp file...
('Build Atoms', self.w.toolsAtomStart),
('Build Atoms', self.w.toolsBuildAtoms),
def makeMenus(self): # menus modified by bruce 041103, 041217 self.Menu_spec = [ ('Stretch', self.o.assy.Stretch), ('Delete Del', self.o.assy.kill), ('Hide', self.o.assy.Hide), None, # bruce 041217 added the following (rather than just Done) #bruce 051213 added 'checked' and reordered these to conform with toolbar...
sequence = str(sequence).upper()
def make(self, mol, sequence, strandA, strandB, basenameA={'C': 'cytosine', 'G': 'guanine', 'A': 'adenine', 'T': 'thymine'}, basenameB={'G': 'cytosine', 'C': 'guanine', 'T': 'adenine', 'A': 'thymine'}): sequence = str(sequence).upper() for ch in sequence: if ch not in 'GACT': raise Exception('Unknown DNA base (not G, A...
dnatype = self.dna_type_combox.currentText() if dnatype == 'A-DNA': dna = A_Dna() elif dnatype == 'B-DNA': dna = B_Dna() elif dnatype == 'Z-DNA': dna = Z_Dna() strandA = True strandB = (self.endings_combox.currentText() == 'Double') if strandA or strandB: env.history.message(cmd + "Creating DNA. This may take a moment....
seq = str(self.base_textedit.text()).upper() if len(seq) > 0: dnatype = self.dna_type_combox.currentText() if dnatype == 'A-DNA': dna = A_Dna() elif dnatype == 'B-DNA': dna = B_Dna() elif dnatype == 'Z-DNA': dna = Z_Dna() strandA = True strandB = (self.endings_combox.currentText() == 'Double') if strandA or strandB: en...
def ok_btn_clicked(self): 'Slot for the OK button' dnatype = self.dna_type_combox.currentText() if dnatype == 'A-DNA': dna = A_Dna() elif dnatype == 'B-DNA': dna = B_Dna() elif dnatype == 'Z-DNA': dna = Z_Dna() strandA = True strandB = (self.endings_combox.currentText() == 'Double') if strandA or strandB: env.history.m...
if not self.mflag: numframes = simopts.NumFrames self.win.status_pbar.reset() self.win.status_pbar.setTotalSteps(numframes) self.win.status_pbar.setProgress(0) self.win.status_pbar.show()
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...
env.history.progress_msg("") env.history.statusbar_msg("")
if not self.mflag: self.win.status_pbar.setProgress(numframes) self.win.status_pbar.reset() self.win.status_pbar.hide() env.history.progress_msg("") env.history.statusbar_msg("Done.")
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 platform import hhmmss_str msg = "Elapsed Time: " + hhmmss_str(int(time.time() - self.startTime)) env.history.progress_msg(msg)
from platform import hhmmss_str msg = "Elapsed Time: " + hhmmss_str(int(time.time() - self.startTime)) env.history.progress_msg(msg) if not self.mflag: self.win.status_pbar.setProgress(self.__frame_number)
def sim_frame_callback(self): #bruce 060102 "Per-frame callback function for simulator object." # some of these prints I commented out need to show up as fields in the progress bar instead... ## print "f", # This happened 3550 times for minimizing a small C3 sp3 hydrocarbon... better check the time first. #e Maybe we s...
if selobj is not None and selobj is not self.selobj:
if selobj is not self.selobj:
def set_selobj(self, selobj, why = "why?"): if selobj is not None and selobj is not self.selobj: #bruce 050702 partly address bug 715-3 (the presently-broken Build mode statusbar messages). # Temporary fix, since Build mode's messages are better and should be restored. self.win.history.transient_msg("%s" % (selobj,)) s...
self.win.history.transient_msg("%s" % (selobj,))
if selobj is not None: msg = "%s" % (selobj,) else: msg = " " self.win.history.transient_msg(msg)
def set_selobj(self, selobj, why = "why?"): if selobj is not None and selobj is not self.selobj: #bruce 050702 partly address bug 715-3 (the presently-broken Build mode statusbar messages). # Temporary fix, since Build mode's messages are better and should be restored. self.win.history.transient_msg("%s" % (selobj,)) s...
print "%d hits" % len(hit_records)
if platform.atom_debug: print "%d hits" % len(hit_records)
def jigGLSelect(self, event, selSense): '''Use the OpenGL picking/selection to select any jigs ''' if not self.jigSelectionEnabled: return False wX = event.pos().x() wY = self.o.height - event.pos().y() aspect = float(self.o.width)/self.o.height wZ = glReadPixelsf(wX, wY, 1, 1, GL_DEPTH_COMPONENT) gz = wZ[0][0] pxy...
print "hit record: near,far,names:",near,far,names
if platform.atom_debug: print "hit record: near,far,names:",near,far,names
def jigGLSelect(self, event, selSense): '''Use the OpenGL picking/selection to select any jigs ''' if not self.jigSelectionEnabled: return False wX = event.pos().x() wY = self.o.height - event.pos().y() aspect = float(self.o.width)/self.o.height wZ = glReadPixelsf(wX, wY, 1, 1, GL_DEPTH_COMPONENT) gz = wZ[0][0] pxy...
def fix_buttons(self, but): """ make Alt/Option mod key simulate middle mouse button. [On other platforms, this should either do nothing, or make some other mod key simulate middle button (which seems ok or even good, once we document it). But as of 040916 it has not yet been tested on other platforms. Therefore, for n...
_saved_buttons = 0 def fix_buttons(self, but, when): """Every mouse event's button and modifier key flags should be filtered through this method, which does two things: 1. Store those flags from a mouse-press, and reuse them on the subsequent mouse-drag and mouse-release events (but not on pure mouse-moves), so the cal...
def fix_buttons(self, but): """###bruce's temporary fix for mac [040826/040916]: make Alt/Option mod key simulate middle mouse button. [On other platforms, this should either do nothing, or make some other mod key simulate middle button (which seems ok or even good, once we document it). But as of 040916 it has not yet...
but = self.fix_buttons(but)
but = self.fix_buttons(but, 'press')
def mouseDoubleClickEvent(self, event): self.debug_event(event, 'mouseDoubleClickEvent') but = event.stateAfter() but = self.fix_buttons(but) if but & leftButton: self.mode.leftDouble(event) if but & midButton: self.mode.middleDouble(event) if but & rightButton: self.mode.rightDouble(event)
but = self.fix_buttons(but)
but = self.fix_buttons(but, 'press')
def mousePressEvent(self, event): """Dispatches mouse press events depending on shift and control key state. """ if self.debug_event(event, 'mousePressEvent', permit_debug_menu_popup = 1): return but = event.stateAfter() but = self.fix_buttons(but) if but & leftButton: if but & shiftButton: self.mode.leftShiftDown(eve...
but = self.fix_buttons(but)
but = self.fix_buttons(but, 'release')
def mouseReleaseEvent(self, event): """Only used to detect the end of a freehand selection curve. """ self.debug_event(event, 'mouseReleaseEvent') but = event.state() but = self.fix_buttons(but) if but & leftButton: if but & shiftButton: self.mode.leftShiftUp(event) elif but & cntlButton: self.mode.leftCntlUp(event) e...
but = self.fix_buttons(but)
but = self.fix_buttons(but, 'move')
def mouseMoveEvent(self, event): """Dispatches mouse motion events depending on shift and control key state. """ ##self.debug_event(event, 'mouseMoveEvent') but = event.state() but = self.fix_buttons(but)
if zlen > 1.0e-6: self.zinv = 1.0 / zlen else: self.zinv = 1.
if zlen < 1.0e-6: raise ZeroLengthCylinder() self.zinv = 1.0 / zlen
def __init__(self, point0, z, uhint, uhint2): # u and v and zn are unit vectors # z is NOT a unit vector self.p0 = point0 self.p1 = point1 = point0 + z self.z = z zlen = vlen(z) if zlen > 1.0e-6: self.zinv = 1.0 / zlen else: self.zinv = 1. self.zn = zn = norm(z) u = norm(uhint - (dot(uhint, z) / zlen**2) * z) if vlen(u...
csys = CylindricalCoordinates(p1, z, up, right)
try: csys = CylindricalCoordinates(p1, z, up, right) except ZeroLengthCylinder: len0 = vlen(p1 - p0) len2 = vlen(p1 - p2) assert len0 > 1.0e-6 assert len2 > 1.0e-6 assert vlen(cross(p1 - p2, p1 - p0)) < 1.0e-6 if len0 > len2: L = len0 end = p0 else: L = len2 end = p2 Lb = vlen(bpos - p1) if Lb > L: L = Lb end = p1 +...
def drawAngleDimension(color, right, up, bpos, p0, p1, p2, text, minR1=0.0, minR2=0.0, highlighted=False): z = cross(p0 - p1, p2 - p1) csys = CylindricalCoordinates(p1, z, up, right) br, bt, bz = csys.rtz(bpos) theta1 = csys.rtz(p0)[1] theta2 = csys.rtz(p2)[1] if theta2 < theta1 - math.pi: theta2 += 2 * math.pi elif th...
if 1: containing_node = sg.dad while containing_node is not None and containing_node is not self.root: containing_node.open = True containing_node = containing_node.dad
def __getattr__(self, attr): if attr.startswith('_'): # common case, be fast raise AttributeError, attr elif attr == 'part': sg = self.current_selgroup() # this fixes it if possible; should always be a node but maybe with no Part during init ## return self.parts[node_id(sg)] if 1: # open all containing nodes below assy...
atoms_pm = imagename_to_pixmap("atom.png") self.mmkit_tab.setTabIconSet ( self.atomsPage, QIconSet(atoms_pm)) clipboard_pm = imagename_to_pixmap("clipboard-empty.png") self.mmkit_tab.setTabIconSet ( self.clipboardPage, QIconSet(clipboard_pm)) library_pm = imagename_to_pixmap("library.png") self.mmkit_tab.setTabIconSe...
if sys.platform == 'darwin': self.mmkit_tab.setMargin ( 0 ) self.mmkit_tab.setTabLabel (self.atomsPage, 'Atoms') self.mmkit_tab.setTabLabel (self.clipboardPage, 'Clipbd') self.mmkit_tab.setTabLabel (self.libraryPage, 'Lib') else: atoms_pm = imagename_to_pixmap("atom.png") self.mmkit_tab.setTabIconSet ( self.atomsPag...
def __init__(self, win): MMKitDialog.__init__(self, win, fl=Qt.WType_Dialog)# Qt.WStyle_Customize | Qt.WStyle_Tool | Qt.WStyle_Title | Qt.WStyle_NoBorder) self.w = win self.elemTable = PeriodicTable self.displayMode = diTUBES self.elm = None self.newModel = None ## used to save the selected lib part self.flayout = N...
safile = os.path.join(dir, fil + ext)
safile = os.path.normpath(dir+"/"+fil+ext)
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...
self.assy.current_movie._setup()
self.assy.current_movie._setup(hflag=False)
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...
system("mkisofs -J -l -r -o %s %s" % (ISOFILE, DEST_DIR)) system("mv %s %s" % (ISOFILE, DEST_DIR))
system("mkisofs -J -l -r -o /tmp/%s %s" % (ISOFILE, DEST_DIR)) system("mv /tmp/%s %s" % (ISOFILE, DEST_DIR))
def getTarballs(): system("rm -rf " + DEST_DIR) system("mkdir " + DEST_DIR) for tarball in tarballURLs.keys(): url = tarballURLs[tarball] tarballPath = DEST_DIR + "/" + tarball cmd = "wget -O %s %s" % (tarballPath, url) system(cmd) system("mkisofs -J -l -r -o %s %s" % (ISOFILE, DEST_DIR)) system("mv %s %s" % (ISOFILE, ...
minfo = "Molecule Name: [" + str (self.name) + "] Total Atoms: " + str(len(self.atoms)) + " "
def getinfo(self): # Return information about the selected moledule for the msgbar [mark 2004-10-14] minfo = "Molecule Name: [" + str (self.name) + "] Total Atoms: " + str(len(self.atoms)) + " " ele2Num = {} # Calculating the number of element types in this molecule. for a in self.atoms.itervalues(): if not ele2Nu...
eleStr = "[" + item[0] + ": " + str(item[1]) + "] " minfo += eleStr
if item[0] == "X": nsinglets = int(item[1]) continue else: eleStr = "[" + item[0] + ": " + str(item[1]) + "] " einfo += eleStr if nsinglets: eleStr = "[Singlets: " + str(nsinglets) + "]" einfo += eleStr natoms -= nsinglets minfo = "Chunk Name: [" + str (self.name) + "] Total Atoms: " + str(natoms) + " " + einfo
def getinfo(self): # Return information about the selected moledule for the msgbar [mark 2004-10-14] minfo = "Molecule Name: [" + str (self.name) + "] Total Atoms: " + str(len(self.atoms)) + " " ele2Num = {} # Calculating the number of element types in this molecule. for a in self.atoms.itervalues(): if not ele2Nu...
if c.logic == 2 or c.logic == 0:
if c.logic == 2 or 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 c.logic == 0: for m in assy.selmols:
if c.logic == 1: for m in assy.selmols[:]:
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...
a.molecule.unpick()
m.unpick()
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.logic == 1: for m in assy.selmols: for a in m.atoms.values():
if c.logic == 0: for m in assy.selmols[:]: for a in m.atoms.values():
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 len(chunks) == 1 and len(atoms) == 0:
if len(chunks) > 0 and len(atoms) == 0:
def setViewNormalTo(self): # '''Set view to the normal vector of the plane defined by 3 or more selected atoms or a jig's (Motor or RectGadget) axis. ''' cmd = greenmsg("Set View Normal To: ") chunks = self.assy.selmols jigs = self.assy.getSelectedJigs() atoms = self.assy.selatoms_list() if len(chunks) == 1 and len(a...
atoms = chunks[0].atoms.values()
for c in range(len(chunks)): atoms += chunks[c].atoms.values()
def setViewNormalTo(self): # '''Set view to the normal vector of the plane defined by 3 or more selected atoms or a jig's (Motor or RectGadget) axis. ''' cmd = greenmsg("Set View Normal To: ") chunks = self.assy.selmols jigs = self.assy.getSelectedJigs() atoms = self.assy.selatoms_list() if len(chunks) == 1 and len(a...
use_timestep_arg = False if 1: use_timestep_arg, timestep = timestep_flag_and_arg(mflag) if use_timestep_arg: env.history.message(orangemsg("Note: using experimental non-default dynamics timestamp of %r femtoseconds" % (timestep * 1e15)))
def setup_sim_args(self): #bruce 051231 split this out of spawn_process, added dylib case """Set up arguments for the simulator, using one of two different interfaces: either constructing a command line for the standalone executable simulator, or creating and setting up an instance of an extension class defined in the ...
if not self.haveradii:
disp = self.get_dispdef() if self.haveradii != (disp,):
def get_sel_radii_squared(self): if not self.haveradii: try: res = self.compute_sel_radii_squared() except: print_compact_traceback("bug in %r.compute_sel_radii_squared(), using []: " % self) res = [] #e len(self.atoms) copies of something would be better self.sel_radii_squared_private = res self.haveradii = 1 return s...
self.haveradii = 1
self.haveradii = (disp,)
def get_sel_radii_squared(self): if not self.haveradii: try: res = self.compute_sel_radii_squared() except: print_compact_traceback("bug in %r.compute_sel_radii_squared(), using []: " % self) res = [] #e len(self.atoms) copies of something would be better self.sel_radii_squared_private = res self.haveradii = 1 return s...
bgcolor = self.mode.backgroundColor r = int(bgcolor[0]*255 + 0.5) g = int(bgcolor[1]*255 + 0.5) b = int(bgcolor[2]*255 + 0.5) self.setPaletteBackgroundColor(QColor(r, g, b))
if sys.platform == 'darwin': bgcolor = self.mode.backgroundColor r = int(bgcolor[0]*255 + 0.5) g = int(bgcolor[1]*255 + 0.5) b = int(bgcolor[2]*255 + 0.5) self.setPaletteBackgroundColor(QColor(r, g, b))
def update_after_new_mode(self): """do whatever updates are needed after self.mode might have changed (ok if this is called more than needed, except it might be slower) """ #bruce 050408: change widget's erase color (seen only if it's resized, # and only briefly -- unrelated to OpenGL clearColor) to current mode's # ba...
return abs( f1-f2 ) <= 0.000001 * max(abs(f1),abs(f2))
return abs( f1-f2 ) <= 0.000001 * max( abs(f1), abs(f2), 0.1)
def floats_near(f1,f2): #bruce, circa 040924 """Say whether two floats are "near" in value (just for use in sanity-check assertions). """ ## return abs( f1-f2 ) <= 0.0000001 return abs( f1-f2 ) <= 0.000001 * max(abs(f1),abs(f2)) #bruce 050518 revised this
elapmsg = "Elasped Time: " + self.hhmmss_str(self.duration)
elapmsg = "Elasped Time: " + self.hhmmss_str(int(self.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...
msg = "The following jigs write output to the tracefile: Measure Distance jigs, Rotary Motors, Linear Motors, Anchors, Thermostats and Thermometers."
msg = "The following jigs write output to the tracefile: Measurement jigs, Rotary Motors, Linear Motors, Anchors, Thermostats and Thermometers."
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.accept()
if not self.pluginException: self.accept()
def ok_btn_clicked(self): 'Slot for the OK button' if platform.atom_debug: print 'ok button clicked' self._ok_or_preview(doneMsg=True) self.accept() #bruce 060621 self.struct = None return
self.set_cmdname('Unselect Atom') env.history.message("unpicked %r" % a)
self.set_cmdname('Unselect Atom') if not a.picked: env.history.message("Deselected atom %r" % a) else: env.history.message(orangemsg("Can't deselect atom %r due to selection filter. Hit Escape to clear the filter." % a))
def atomLeftUp(self, a, event): # Was atomClicked(). mark 060220. '''Real atom <a> was clicked, so select, unselect or delete it based on the current modkey. - If no modkey is pressed, clear the selection and pick atom <a>. - If Shift is pressed, pick <a>, adding it to the current selection. - If Ctrl is pressed, unpi...
if sys.platform == 'win32': traceFile = self.traceFile.replace('\\','\\\\')
traceFile = self.traceFile.replace('\\','\\\\')
def genPlot(self): """Generates GNUplot plotfile, then calls self.runGNUplot. """ col = self.plot_combox.currentItem() + 2 # Column number to plot # If this plot was the same as the last plot, just run GNUplot on the plotfile. # This allows us to edit the current plotfile in a text editor via "Open GNUplot File" # and...
f.write('plot "%s" using 1:%d title \"Data Points\" with lines lt 2,\\\n'%(traceFile, col)) f.write(' "%s" using 1:%d:(0.5) smooth acsplines title \"Average\" lt 3\n'%(traceFile, col))
f.write("plot \"%s\" using 1:%d title \"Data Points\" with lines lt 2,\\\n"%(traceFile, col)) f.write(" \"%s\" using 1:%d:(0.5) smooth acsplines title \"Average\" lt 3\n"%(traceFile, col))
def genPlot(self): """Generates GNUplot plotfile, then calls self.runGNUplot. """ col = self.plot_combox.currentItem() + 2 # Column number to plot # If this plot was the same as the last plot, just run GNUplot on the plotfile. # This allows us to edit the current plotfile in a text editor via "Open GNUplot File" # and...
self.singlpos = array(singlpos) self.singlbase = self.singlpos - self.center
if self.singlets: self.singlpos = array(singlpos) self.singlbase = self.singlpos - self.center
def shakedown(self): """Find center and bounding box for atoms, and set each one's xyz to be relative to the center and find principal axes """ if not self.atoms: self.bbox = BBox() self.center = V(0,0,0) self.quat = Q(1,0,0,0) self.axis = V(1,0,0) self.basepos = self.curpos = [] return atpos = [] atlist = [] singlets ...
self.singlbase = self.singlpos
if self.singlets: self.singlbase = self.singlpos
def freeze(self): """ set the molecule up for minimization or simulation""" self.center = V(0,0,0) self.quat = Q(1,0,0,0) self.basepos = self.curpos # reference == same object self.singlbase = self.singlpos # ditto
def copy(self, dad, offset):
def copy(self, dad=None, offset=V(0,0,0)):
def copy(self, dad, offset): """Copy the molecule to a new molecule. offset tells where it will go relative to the original. There should be a rotation parameter but there isn't. """ pairlis = [] ndix = {} numol = molecule(self.assy, gensym(self.name)) for a in self.atoms.itervalues(): na = a.copy(numol) pairlis += [(a...
There should be a rotation parameter but there isn't.
def copy(self, dad, offset): """Copy the molecule to a new molecule. offset tells where it will go relative to the original. There should be a rotation parameter but there isn't. """ pairlis = [] ndix = {} numol = molecule(self.assy, gensym(self.name)) for a in self.atoms.itervalues(): na = a.copy(numol) pairlis += [(a...
self.unpick() numol.pick()
def copy(self, dad, offset): """Copy the molecule to a new molecule. offset tells where it will go relative to the original. There should be a rotation parameter but there isn't. """ pairlis = [] ndix = {} numol = molecule(self.assy, gensym(self.name)) for a in self.atoms.itervalues(): na = a.copy(numol) pairlis += [(a...
babelcmd = 'babel ' + mmpfile + ' ' + fn + ' 2>&1'
babelcmd = 'babel ' + mmpfile + ' ' + fn
def fileExport(self): # Code copied from fileInsert() slot method. Mark 060731. """Slot method for 'File > Export'. """ cmd = greenmsg("Export File: ") # This format list generated from the Open Babel wiki page: # http://openbabel.sourceforge.net/wiki/Babel#File_Formats formats = \ "All Files (*.*);;"\ "Alchemy format...
response = pop.fromchild.read()
response = pop.childerr.read()
def fileExport(self): # Code copied from fileInsert() slot method. Mark 060731. """Slot method for 'File > Export'. """ cmd = greenmsg("Export File: ") # This format list generated from the Open Babel wiki page: # http://openbabel.sourceforge.net/wiki/Babel#File_Formats formats = \ "All Files (*.*);;"\ "Alchemy format...
initial_choice, non_debug = True, prefs_key = use_c_renderer_prefs_key)
initial_choice, prefs_key = use_c_renderer_prefs_key)
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...
def open_wiki_help_page( featurename, actually_open = True ): """Open the wiki help page corresponding to the named nE-1 feature, in ways influenced by user preferences.
def open_wiki_help_page( featurename, actually_open = True ): """Show a dialog containing a link which can open the wiki help page corresponding to the named nE-1 feature, in ways influenced by user preferences.
def open_wiki_help_page( featurename, actually_open = True ): #e actually_open = False is not yet used (and untested) as of 051201 """Open the wiki help page corresponding to the named nE-1 feature, in ways influenced by user preferences. Assume the featurename might contain blanks, but contains no other characters nee...
If actually_open = False, don't open a web browser, but instead
If actually_open = False [not yet implemented, probably won't ever be], don't open a web browser, but instead
def open_wiki_help_page( featurename, actually_open = True ): #e actually_open = False is not yet used (and untested) as of 051201 """Open the wiki help page corresponding to the named nE-1 feature, in ways influenced by user preferences. Assume the featurename might contain blanks, but contains no other characters nee...
if 1: html = """<font color=\"red\">[stub text, will be changed before release]</font><br> Click one of the following links to launch your web browser to a Nanorex wiki page containing help on the appropriate topic:<br> * your current mode or selected jig: %s<br> * nanorex wiki main page: %s """ % (HTML_link(ur...
html = """<font color=\"red\">[stub text, will be changed before release]</font><br> Click one of the following links to launch your web browser to a Nanorex wiki page containing help on the appropriate topic:<br> * your current mode or selected jig: %s<br> * nanorex wiki main page: %s """ % (HTML_link(url, featurename...
def open_wiki_help_page( featurename, actually_open = True ): #e actually_open = False is not yet used (and untested) as of 051201 """Open the wiki help page corresponding to the named nE-1 feature, in ways influenced by user preferences. Assume the featurename might contain blanks, but contains no other characters nee...
def __init__(self, text, parent=None, clicked_func = None):
def __init__(self, text, parent=None, clicked_func = None, caption = "(caption)"):
def __init__(self, text, parent=None, clicked_func = None): class MimeFactory(QMimeSourceFactory): def data(self, name, context=None): # [obs comment:] You'll always get a warning like this: # QTextBrowser: no mimesource for http://.... # This could be avoided with QApplication.qInstallMsgHandler, # but I don't think t...
clicked_func(name) import webbrowser webbrowser.open(name) if 1:
close_dialog = clicked_func(name) else: import webbrowser webbrowser.open(name) close_dialog = True if close_dialog:
def data(self, name, context=None): # [obs comment:] You'll always get a warning like this: # QTextBrowser: no mimesource for http://.... # This could be avoided with QApplication.qInstallMsgHandler, # but I don't think that's supported until PyQt 3.15. Also this falls # victim to all the problems swarming around webbr...