rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
" (%d selection had no hydrogens)" \
" (%d selected chunk(s) had no hydrogens)" \
def modifyDehydrogenate(self): # Moved to MWsemantics. Mark 050116
filesize = (natoms * 32) + 25
filesize = natoms * 32
def writemovie(assy, mflag = False): """Creates a moviefile. The name of the moviefile it creates is found in assy.m.filename. The moviefile is either a DPB file or an XYZ trajectory file. DPB = Differential Position Bytes (binary file) XYZ = XYZ trajectory file (text file) mflag: 0 = default, runs a full simulation ...
cutoverMax = env.prefs[cutoverMax_prefs_key]
cutoverMax = orig_cutoverMax = env.prefs[cutoverMax_prefs_key]
def set_minimize_threshhold_prefs(self, simopts): #bruce 060628 try: if env.debug(): print "debug: running set_minimize_threshhold_prefs" from prefs_constants import endRMS_prefs_key, endMax_prefs_key from prefs_constants import cutoverRMS_prefs_key, cutoverMax_prefs_key endRMS = env.prefs[endRMS_prefs_key] endMax = en...
print_compact_traceback("error in set_minimize_threshhold_prefs, ignored: ")
print_compact_traceback("error in set_minimize_threshhold_prefs (the ones from the last run might be used): ")
def warn(msg): env.history.message(orangemsg("Warning: ") + quote_html(msg))
print "frame %d" % self.__frame_number, getFrame()
if debug_sim_exceptions: print "frame %d" % self.__frame_number, self._simobj.getFrame() else: print "frame %d" % self.__frame_number, getFrame() pass
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...
self.atoms = owner.atoms
def __init__(self, owner): self._posn_offset = Numeric.array((0.0, 0.0, 0.0)) # owner is a measurement jig. It is expected to provide an # atom list and a glpane. It should also have a center() # method which gives the average position of the atoms in the # atom list. self.owner = owner self.atoms = owner.atoms self.gl...
p = c + self._posn_offset + offset self._posn_offset = p - c if BETTER_CURSOR_FOLLOWING: self._posn_offset = self.constrainedPosition() - c
self._posn_offset = pos - c
def move(self, offset): c = self.owner.center() p = c + self._posn_offset + offset self._posn_offset = p - c if BETTER_CURSOR_FOLLOWING: # Maintain a constrained position rather than # unconstrained? Bruce thinks some people will be confused # by this, but it fixes the stability problem with the # better _constrainHand...
a = self.atoms
a = self.owner.atoms
def constrainedPosition(self): a = self.atoms pos, p0, p1 = self.posn(), a[0].posn(), a[1].posn() z = p1 - p0 nz = norm(z) dotprod = dot(pos - p0, nz) if dotprod < 0.0: return pos - dotprod * nz elif dotprod > vlen(z): return pos - (dotprod - vlen(z)) * nz else: return pos
if BETTER_CURSOR_FOLLOWING: def __constrainHandleToAngle(pos, p0, p1, p2, glpane): u = pos - p1 z0 = norm(p0 - p1) z2 = norm(p2 - p1) y2 = norm(z2 - dot(z0, z2) * z0) oop = norm(cross(z0, z2)) los = glpane.lineOfSight u = u - (dot(oop, u) / dot(oop, los)) * los if dot(cross(z0, u), oop) < 0: u = vle...
def _constrainHandleToAngle(pos, p0, p1, p2, glpane): u = pos - p1 z0 = norm(p0 - p1) z2 = norm(p2 - p1) oop = norm(cross(z0, z2)) u = u - dot(oop, u) * oop # clip the point so it lies within the angle if dot(cross(z0, u), oop) < 0: # Clip on the z0 side of the angle. u = vlen(u) * z0 elif dot(cross(u, z2), oop) < 0: #...
a = self.atoms
import types a = self.owner.atoms
def constrainedPosition(self): a = self.atoms return _constrainHandleToAngle(self.posn(), a[0].posn(), a[1].posn(), a[2].posn(), self.glpane)
a = self.atoms
a = self.owner.atoms
def constrainedPosition(self): a = self.atoms p0, p1, p2, p3 = a[0].posn(), a[1].posn(), a[2].posn(), a[3].posn() axis = norm(p2 - p1) midpoint = 0.5 * (p1 + p2) return _constrainHandleToAngle(self.posn(), p0 - dot(p0 - midpoint, axis) * axis, midpoint, p3 - dot(p3 - midpoint, axis) * axis, self.glpane)
Record the current pushed GL name.
Record the current pushed GL name, which must not be 0.
def pushName(glname): """\ Record the current pushed GL name. """ ColorSorter._gl_name_stack.append(glname)
glPushName(ColorSorter._gl_name_stack[-1])
name = ColorSorter._gl_name_stack[-1] if name: glPushName(name)
def _invoke_immediately(color, func, params): """\ Internal function that invokes 'scheduled' operations right now, outside a start/finish. """ ColorSorter._immediate += 1 # 20060216 We know we can do this here because the stack is # only ever one element deep. glPushName(ColorSorter._gl_name_stack[-1])
glPopName()
if name: glPopName() return
def _invoke_immediately(color, func, params): """\ Internal function that invokes 'scheduled' operations right now, outside a start/finish. """ ColorSorter._immediate += 1 # 20060216 We know we can do this here because the stack is # only ever one element deep. glPushName(ColorSorter._gl_name_stack[-1])
if atom_debug: print "editor = ",editor print "Spawnv args are %r" % (args,)
def open_file_in_editor(file, history = None): #bruce 050704 added history arg """Opens a file in a standard text editor. If history arg is provided, it should be the history widget, and error messages will be printed there; in all cases, the same error messages are printed to the console. """ if history is not None: f...
deposited_stuff[0].pickatoms()
for d in deposited_stuff[:]: d.pickatoms()
def deposit_from_MMKit(self, atom_or_pos): #mark circa 051200; revised by bruce 051227 '''Deposit a new object based on the current selection in the MMKit/dashboard, which is either an atom, a chunk on the clipboard, or a part from the library. If 'atom_or_pos' is a singlet, then it will bond the object to that singlet...
self.plotPB = QPushButton(self,"plotPB") layout1.addWidget(self.plotPB)
self.plot_btn = QPushButton(self,"plot_btn") layout1.addWidget(self.plot_btn)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.quitPB = QPushButton(self,"quitPB") layout1.addWidget(self.quitPB)
self.done_btn = QPushButton(self,"done_btn") layout1.addWidget(self.done_btn)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.plotCB = QComboBox(0,self,"plotCB")
self.plot_combox = QComboBox(0,self,"plot_combox")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout2.addWidget(self.plotCB,1,0)
layout2.addWidget(self.plot_combox,1,0)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.openTraceFilePB = QPushButton(self,"openTraceFilePB") layout6.addWidget(self.openTraceFilePB)
self.open_trace_file_btn = QPushButton(self,"open_trace_file_btn") layout6.addWidget(self.open_trace_file_btn)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.openGNUplotPB = QPushButton(self,"openGNUplotPB") layout6.addWidget(self.openGNUplotPB)
self.open_gnuplot_btn = QPushButton(self,"open_gnuplot_btn") layout6.addWidget(self.open_gnuplot_btn)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.connect(self.quitPB,SIGNAL("clicked()"),self,SLOT("close()")) self.connect(self.plotPB,SIGNAL("clicked()"),self.genPlot) self.connect(self.openGNUplotPB,SIGNAL("clicked()"),self.openGNUplotFile) self.connect(self.openTraceFilePB,SIGNAL("clicked()"),self.openTraceFile)
self.connect(self.done_btn,SIGNAL("clicked()"),self,SLOT("close()")) self.connect(self.plot_btn,SIGNAL("clicked()"),self.genPlot) self.connect(self.open_gnuplot_btn,SIGNAL("clicked()"),self.openGNUplotFile) self.connect(self.open_trace_file_btn,SIGNAL("clicked()"),self.openTraceFile)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.plotPB.setText(self.__tr("Plot")) self.quitPB.setText(self.__tr("Quit"))
self.plot_btn.setText(self.__tr("Plot")) self.done_btn.setText(self.__tr("Done"))
def languageChange(self): self.setCaption(self.__tr("Plot Tool")) self.plotPB.setText(self.__tr("Plot")) self.quitPB.setText(self.__tr("Quit")) self.textLabel1.setText(self.__tr("Select Jig to Graph:")) self.openTraceFilePB.setText(self.__tr("Open Trace File")) self.openGNUplotPB.setText(self.__tr("Open GNUplot File"))
self.openTraceFilePB.setText(self.__tr("Open Trace File")) self.openGNUplotPB.setText(self.__tr("Open GNUplot File"))
self.open_trace_file_btn.setText(self.__tr("Open Trace File")) self.open_gnuplot_btn.setText(self.__tr("Open GNUplot File"))
def languageChange(self): self.setCaption(self.__tr("Plot Tool")) self.plotPB.setText(self.__tr("Plot")) self.quitPB.setText(self.__tr("Quit")) self.textLabel1.setText(self.__tr("Select Jig to Graph:")) self.openTraceFilePB.setText(self.__tr("Open Trace File")) self.openGNUplotPB.setText(self.__tr("Open GNUplot File"))
assy.tree.writepov(f, assy.o.display)
assy.part.writepov(f, assy.o.display)
def writepovfile(assy, filename): f = open(filename,"w") ## bruce 050325 removed this (no effect except on assy.alist which is bad now) ## atnums = {} ## atnums['NUM'] = 0 ## assy.alist = [] cdist = 6.0 ###5.0 # Camera distance aspect = (assy.o.width + 0.0)/(assy.o.height + 0.0) zfactor = 0.4 # zoom factor up = V(0.0...
assy.tree.writemdl(alist, f, assy.o.display)
assy.part.writemdl(alist, f, assy.o.display)
def writemdlfile(assy, filename): alist = [] #bruce 050325 changed assy.alist to localvar alist natoms = 0 # Specular values keyed by atom color # Only Carbon, Hydrogen and Silicon supported here specValues = {(117,117,117):((183, 183, 183), 16, 44), \ (256,256,256):((183, 183, 183), 15, 44), \ (111,93,133):((187,176,2...
if draw_bond_letters: glDisable(GL_LIGHTING) glPushMatrix() font = QFont( QString("Times"), 10)
if draw_bond_letters:
def draw_bond_main( self, glpane, disp, col, level, highlighted, sigmabond_cyl_radius): # figure out preferences (should do this less often somehow -- once per user event, # or at least, once per separate use of begin_tracking_usage/end_tracking_usage) if self.v6 != V_SINGLE: if platform.atom_debug: #bruce 050716 debu...
glpane.qglColor(QColor(255, 255, 255))
def draw_bond_main( self, glpane, disp, col, level, highlighted, sigmabond_cyl_radius): # figure out preferences (should do this less often somehow -- once per user event, # or at least, once per separate use of begin_tracking_usage/end_tracking_usage) if self.v6 != V_SINGLE: if platform.atom_debug: #bruce 050716 debu...
p = self.center + glpane_out * 0.6
textpos = self.center + glpane_out * 0.6
def draw_bond_main( self, glpane, disp, col, level, highlighted, sigmabond_cyl_radius): # figure out preferences (should do this less often somehow -- once per user event, # or at least, once per separate use of begin_tracking_usage/end_tracking_usage) if self.v6 != V_SINGLE: if platform.atom_debug: #bruce 050716 debu...
ltr = bond_letter_from_v6(v6).upper() glpane.renderText(p[0], p[1], p[2], QString(ltr), font) glPopMatrix() glEnable(GL_LIGHTING)
text = bond_letter_from_v6(v6).upper() font_size = 12 if 1: text_qcolor = QColor(255, 255, 255) font = QFont( QString("Helvetica"), font_size) glDisable(GL_LIGHTING) glpane.qglColor(text_qcolor) p = textpos glpane.renderText(p[0], p[1], p[2], QString(text), font) glEnable(GL_LIGHTING)
def draw_bond_main( self, glpane, disp, col, level, highlighted, sigmabond_cyl_radius): # figure out preferences (should do this less often somehow -- once per user event, # or at least, once per separate use of begin_tracking_usage/end_tracking_usage) if self.v6 != V_SINGLE: if platform.atom_debug: #bruce 050716 debu...
def get_move_xyz(win, Plus = 1):
def get_move_xyz(win, Plus = True): '''Returns X, Y and Z values in the dashboard based on Plus. If Plus is True, returns x, y, z If Plus is False, returns -x, -y, -z '''
def get_move_xyz(win, Plus = 1): self = win x = self.moveXSpinBox.floatValue() y = self.moveYSpinBox.floatValue() z = self.moveZSpinBox.floatValue() if Plus: return (x,y,z) # Plus else: return (-x, -y, -z) # Minus
offset = get_move_xyz(self.w, 1)
offset = get_move_xyz(self.w)
def moveDeltaPlus(self): "Add X, Y, and Z to the selected chunk(s) current position" if not self.o.assy.getSelectedMovables(): env.history.message(redmsg("No chunks or movable jigs selected.")) return offset = get_move_xyz(self.w, 1) self.o.assy.movesel(offset) self.o.gl_update()
offset = get_move_xyz(self.w, 0)
offset = get_move_xyz(self.w, Plus=False)
def moveDeltaMinus(self): "Subtract X, Y, and Z from the selected chunk(s) current position" if not self.o.assy.getSelectedMovables(): env.history.message(redmsg("No chunks or movable jigs selected.")) return offset = get_move_xyz(self.w, 0) self.o.assy.movesel(offset) self.o.gl_update()
pt2 = get_move_xyz(self.w, 1)
pt2 = get_move_xyz(self.w)
def moveAbsolute(self): '''Move selected chunk(s), jig(s) to absolute X, Y, and Z by computing the bbox center of everything as if they were one big chunk, then move everything as a unit. ''' movables = self.o.assy.getSelectedMovables() if not movables: env.history.message(redmsg("No chunks or movable jigs selected."))...
bg2 = QButtonGroup(w.depositAtomDashboard) bg2.setExclusive(1)
bg2 = w.depositAtomDashboard.submode_btngrp = QButtonGroup(w.depositAtomDashboard) bg2.setExclusive(True)
def do_what_MainWindowUI_should_do(w): w.depositAtomDashboard.clear() w.depositAtomLabel = QLabel(w.depositAtomDashboard,"Build") w.depositAtomLabel.setText(" Build ") w.depositAtomDashboard.addSeparator() w.pasteComboBox = QComboBox(0,w.depositAtomDashboard, "pasteComboBox") # bruce 041124: that combobox needs to b...
w.depositAtomDashboard.atomBtn = QToolButton(bg2, "") w.depositAtomDashboard.atomBtn.setPixmap(imagename_to_pixmap('atom.png')) w.depositAtomDashboard.atomBtn.setToggleButton(1) w.depositAtomDashboard.atomBtn.setAutoRaise(1) QToolTip.add(w.depositAtomDashboard.atomBtn, qApp.translate("MainWindow","Change Atom Mode", No...
def do_what_MainWindowUI_should_do(w): w.depositAtomDashboard.clear() w.depositAtomLabel = QLabel(w.depositAtomDashboard,"Build") w.depositAtomLabel.setText(" Build ") w.depositAtomDashboard.addSeparator() w.pasteComboBox = QComboBox(0,w.depositAtomDashboard, "pasteComboBox") # bruce 041124: that combobox needs to b...
w.depositAtomDashboard.atomBtn.hide()
def do_what_MainWindowUI_should_do(w): w.depositAtomDashboard.clear() w.depositAtomLabel = QLabel(w.depositAtomDashboard,"Build") w.depositAtomLabel.setText(" Build ") w.depositAtomDashboard.addSeparator() w.pasteComboBox = QComboBox(0,w.depositAtomDashboard, "pasteComboBox") # bruce 041124: that combobox needs to b...
if not self.w.depositAtomDashboard.buildBtn.isOn() and not self.w.depositAtomDashboard.atomBtn.isOn():
if not self.w.depositAtomDashboard.buildBtn.isOn():
def bondLeftUp(self, b, event): # was bondClicked(). mark 060220. '''Bond <b> was clicked, so select or unselect its atoms or delete bond <b> based on the current modkey. - If no modkey is pressed, clear the selection and pick <b>'s two atoms. - If Shift is pressed, pick <b>'s two atoms, adding them to the current sele...
assy.w.history.message( redmsg( "Warning: Pdb file: can't find atom at column %d in: %s" % (6,card) ))
assy.w.history.message( redmsg( "Warning: Pdb file: can't find first atom in CONECT record: %s" % (card,) ))
def _readpdb(assy, filename, isInsert = False): #bruce 050322 revised method & docstring in several ways """Read a Protein DataBank-format file into a single new chunk, which is returned, unless there are no atoms in the file, in which case a warning is printed and None is returned. (The new chunk (if returned) is in a...
except: assy.w.history.message( redmsg( "Warning: Pdb file: can't find atom at column %d in: %s" % (i,card) ))
except ValueError:
def _readpdb(assy, filename, isInsert = False): #bruce 050322 revised method & docstring in several ways """Read a Protein DataBank-format file into a single new chunk, which is returned, unless there are no atoms in the file, in which case a warning is printed and None is returned. (The new chunk (if returned) is in a...
self.suppress_updates = False
self.transdepositing = False
def reset_drag_vars(self): selectAtomsMode.reset_drag_vars(self) self.pivot = None self.pivax = None self.line = None # endpoints of the white line drawn between the cursor and a bondpoint when # dragging a singlet. self.suppress_updates = False # used to suppress multiple win_updates and history msgs when trans-depos...
self.suppress_updates = True
self.transdepositing = True
def transdeposit_from_MMKit(self, singlet): '''Trans-deposit the current object in the MMKit on all singlets reachable through any sequence of bonds to the singlet <singlet>. '''
self.suppress_updates = False
self.transdepositing = False
def transdeposit_from_MMKit(self, singlet): '''Trans-deposit the current object in the MMKit on all singlets reachable through any sequence of bonds to the singlet <singlet>. '''
if self.suppress_updates:
if self.transdepositing: if not deposited_stuff: return None
def deposit_from_MMKit(self, atom_or_pos): #mark circa 051200; revised by bruce 051227 '''Deposit a new object based on the current selection in the MMKit/dashboard, which is either an atom, a chunk on the clipboard, or a part from the library. If 'atom_or_pos' is a singlet, then it will bond the object to that singlet...
"""Find or make the given directory, making containing directories as needed unless make_higher_dirs is false. (If make is false, don't make it, only find it.) Make sure it's really a directory. For any error, return (1, errortext); on success return (0, full_path_of_dir). In other words, return (errorcode, path_or_err...
"""Find or make the given directory, making containing directories as needed unless make_higher_dirs is False. If <make> is False, don't make it, only find it, and make sure it's really a directory. Return (errorcode, message), where: - on success, return (0, the full and normalized path of <dirname>), or if <make> is...
def find_or_make_any_directory(dirname, make = True, make_higher_dirs = True): #bruce 060614 """Find or make the given directory, making containing directories as needed unless make_higher_dirs is false. (If make is false, don't make it, only find it.) Make sure it's really a directory. For any error, return (1, errort...
return 1, "[%s] does not exist" % (dirname,)
return 0, None
def find_or_make_any_directory(dirname, make = True, make_higher_dirs = True): #bruce 060614 """Find or make the given directory, making containing directories as needed unless make_higher_dirs is false. (If make is false, don't make it, only find it.) Make sure it's really a directory. For any error, return (1, errort...
for j in self.dct[i]: if j < i: if not dct.has_key(i): dct[i] = [ ] dct[i].append(j+1)
for e, j in self.dct[i]: a1, a2 = e.atoms() if not dct.has_key(a2): dct[a2] = [ ] if a1+1 not in dct[a2]: dct[a2].append(a1+1)
def mmpBonds(self): dct = { } for i in self.dct.keys(): for j in self.dct[i]: if j < i: # optimize for MMP generation if not dct.has_key(i): dct[i] = [ ] dct[i].append(j+1) return dct
self.history_height_spinbox.setValue(6)
self.history_height_spinbox.setValue(4)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.per_frame_state.saved_projection_matrix self.per_frame_state.saved_modelview_matrix
projection_matrix = self.per_frame_state.saved_projection_matrix modelview_matrix = self.per_frame_state.saved_modelview_matrix
def begin_using_saved_coords(self): # fyi: examples of glLoadMatrix (and thus hopefully the glGet for that) can be found in these places on bruce's G4: # - /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/OpenGLContext/renderpass.py # - /Library/Frameworks/Python.framework/Versions/2.3/lib/...
glLoadMatrixd(self.per_frame_state.saved_projection_matrix)
self.safe_glLoadMatrixd( projection_matrix, "projection_matrix")
def begin_using_saved_coords(self): # fyi: examples of glLoadMatrix (and thus hopefully the glGet for that) can be found in these places on bruce's G4: # - /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/OpenGLContext/renderpass.py # - /Library/Frameworks/Python.framework/Versions/2.3/lib/...
glLoadMatrixd(self.per_frame_state.saved_modelview_matrix)
self.safe_glLoadMatrixd( modelview_matrix, "modelview_matrix")
def begin_using_saved_coords(self): # fyi: examples of glLoadMatrix (and thus hopefully the glGet for that) can be found in these places on bruce's G4: # - /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/OpenGLContext/renderpass.py # - /Library/Frameworks/Python.framework/Versions/2.3/lib/...
if self.assy.selwhat != SELWHAT_CHUNKS:
if self.selatoms and self.assy.selwhat == SELWHAT_CHUNKS and env.debug(): print "debug: bug: permit_pick_parts sees self.selatoms even though self.assy.selwhat == SELWHAT_CHUNKS; unpicking them" if self.selatoms:
def permit_pick_parts(self): #bruce 050125; see also pickParts, but that can leave some chunks initially selected "ensure it's legal to pick chunks using mouse selection, and deselect any selected atoms (if picking chunks does so)" if self.assy.selwhat != SELWHAT_CHUNKS: self.unpickatoms() self.assy.set_selwhat(SELWHAT...
self.sellist = [] self.w.win_update() return self.sellist += [p1] self.sellist += [self.sellist[0]] self.o.backlist += [p2] self.o.backlist += [self.o.backlist[0]] self.o.shape=SelectionShape(self.o.right, self.o.up, self.o.lineOfSight) eyeball = (-self.o.quat).rot(V(0,0,6*self.o.scale)) - self.o.pov if self.selLassRe...
def EndPick(self, event, selSense): """Close a selection curve and do the selection """ if not self.picking: return self.picking = False
self.o.shape.pickline(self.o.backlist, -self.o.pov, selSense,
self.sellist += [p1] self.sellist += [self.sellist[0]] self.o.backlist += [p2] self.o.backlist += [self.o.backlist[0]] self.o.shape=SelectionShape(self.o.right, self.o.up, self.o.lineOfSight) eyeball = (-self.o.quat).rot(V(0,0,6*self.o.scale)) - self.o.pov if self.selLassRect: self.o.shape.pickrect(self.o.backlist[0], ...
def EndPick(self, event, selSense): """Close a selection curve and do the selection """ if not self.picking: return self.picking = False
self.w.SAFilter.setChecked(0)
self.w.filterCheckBox.setChecked(0)
def restore_gui(self): self.w.selectAtomsDashboard.hide() self.w.SAFilter.setChecked(0)
bbox.merge(m.bbox)
if hasattr(m, "bbox"): bbox.merge(m.bbox)
def moveAbsolute(self): '''Move selected chunk(s), jig(s) to absolute X, Y, and Z by computing the bbox center of everything as if they were one big chunk, then move everything as a unit. ''' movables = self.o.assy.getSelectedMovables() if not movables: env.history.message(redmsg("No chunks or movable jigs selected."))...
elif selSense == 1 and not obj.picked: obj.pick() else:
elif selSense == 1: if not obj.picked: obj.pick() else:
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...
obj.pick()
if not obj.picked: obj.pick()
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...
if platform.atom_debug: print_compact_stack("fyi, something called standard_inval twice (not illegal but weird -- bug hint?) in %r: " % self, linesep = '\n')
if _debug_standard_inval_twice: msg = "debug: fyi: something called standard_inval twice (not illegal but weird -- bug hint?) in %r" % self if _debug_standard_inval_twice_stack: print_compact_stack(msg + ": ", linesep = '\n') else: print msg
def standard_inval(self): """This is used to receive the invalidation signal, and call self.invalidator after some bookkeeping. See class docstring for more info. It also removes all cyclic or large attrs of self, to prevent memory leaks. """ # this needs to remove every subs except the one which is being fulfilled by ...
font = QFont( QString("Times"), 10) glpane.qglColor(QColor(75, 75, 75))
font = QFont( QString("Times"), 10) glpane.qglColor(QColor(255, 255, 255))
via dispdef from the calling molecule -- this might cause bugs if some
return do_error("can't increase valence of bond between atoms %r and %r" % (a1,a2), None)
return self.do_error("can't increase valence of bond between atoms %r and %r" % (a1,a2), None)
def upgrade_existing_bond(self): s1, a1 = self.s1, self.a1 s2, a2 = self.s2, self.a2 v1, v2 = s1.singlet_v6(), s2.singlet_v6() vdelta = min(v1,v2) # but depending on the existing bond, we might use less than this, or none bond = find_bond(a1, a2) vdelta_used = bond.increase_valence_noupdate(vdelta) # increases to legal...
_initialize_custom_display_modes()
_initialize_custom_display_modes(win)
def pre_main_show( win): "Do whatever should be done after the main window is created but before it's first shown." # Determine the screen resolution and compute the normal window size for NE-1 # [bruce 041230 corrected this for Macintosh, and made sure it never exceeds # screen size even on a very small screen.] # [...
def _initialize_custom_display_modes():
def _initialize_custom_display_modes(win):
def _initialize_custom_display_modes(): import CylinderChunks #bruce 060609 import SurfaceChunks #mark 060610 return
if sys.argv[1] == '--initial-file':
if len(sys.argv) >= 3 and sys.argv[1] == '--initial-file':
def __import__(*args, **kws): global not_these arg = args[0] if arg not in not_these and not os.path.exists(arg + ".py"): not_these.append(arg) print "import " + arg return _old_import(*args, **kws)
if nsa > 30: self.assy.w.history.message(cmd + redmsg(str(nsa) + " atoms selected. The limit is 30. Try again.")) return
if nsa > 200: self.assy.w.history.message(cmd + redmsg(str(nsa) + " atoms selected. The limit is 200. Try again.")) return if nsa > 50: ret = QMessageBox.warning( self.assy.w, "Large GAMESS Jig", "GAMESS Jigs with more than 50 atoms may take an\n" "excessively long time to compute (days or weeks).\n" "Are you sure y...
def makegamess(self): """Makes a GAMESS jig... """ # [bruce 050210 modified docstring] cmd = greenmsg("Gamess: ") if not self.assy.selatoms: self.assy.w.history.message(cmd + redmsg("You must first select an atom(s) to create a Gamess Jig.")) return # Make sure that no more than 30 atoms are selected. nsa = len(self...
self.n = string.atoi(str(self.textEdit1.text()))
try: self.n = string.atoi(str(self.textEdit1.text())) except ValueError: if hasattr(self, "n"): del self.n
def setN(self): import string self.n = string.atoi(str(self.textEdit1.text()))
self.m = string.atoi(str(self.textEdit2.text()))
try: self.m = string.atoi(str(self.textEdit2.text())) except ValueError: if hasattr(self, "m"): del self.m
def setM(self): import string self.m = string.atoi(str(self.textEdit2.text()))
self.length = string.atof(str(self.textEdit3.text()))
try: self.length = string.atof(str(self.textEdit3.text())) except ValueError: if hasattr(self, "length"): del self.length
def setLength(self): import string self.length = string.atof(str(self.textEdit3.text()))
def __init__(self,parent = None, name = None, fl = 0):
def __init__(self, parent = None, name = None):
def __init__(self,parent = None, name = None, fl = 0):
MainWindow.__init__(self, parent, name, fl)
MainWindow.__init__(self, parent, name, Qt.WDestructiveClose)
def __init__(self,parent = None, name = None, fl = 0):
def debug_print(self, fmt, **args):
def debug_print(self, fmt, *args):
def debug_print(self, fmt, **args): """Any code that wants to print debug-only notes, properly timestamped and intermixed with other history, and included in the history file, can use this method.""" if not platform.atom_debug: return msg = ("atom_debug: " + fmt) % args self._print_msg(msg)
msg = ("atom_debug: " + fmt) % args
msg = ("debug: " + fmt) % args
def debug_print(self, fmt, **args): """Any code that wants to print debug-only notes, properly timestamped and intermixed with other history, and included in the history file, can use this method.""" if not platform.atom_debug: return msg = ("atom_debug: " + fmt) % args self._print_msg(msg)
delattr(self,attr)
if not attr.startswith('_'): if platform.atom_debug: print "atom_debug: destroying part - deleting i mean resetting attr:",attr setattr(self, attr, None)
def destroy(self): "forget everything, let all storage be reclaimed; only valid if we have no nodes left" # implem is a guess if debug_parts: print "debug_parts: fyi: destroying part", self assert self.nodecount == 0, "can't destroy a Part which still has nodes" # esp. since it doesn't have a list of them! # actually i...
print "bug: some chunk occurs twice in assy.tree; semi-tolerated but not fixed"
print "bug: some chunk occurs twice in this part's topnode tree; semi-tolerated but not fixed"
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.highlightTimer = self.startTimer(100)
from debug_prefs import debug_pref, Choice interval = int( debug_pref("glpane timer interval", Choice([100, 0]), non_debug = True, prefs_key = True) ) self.highlightTimer = self.startTimer(interval)
def enterEvent(self, event): # Mark 060806. """Event handler for when the cursor enters the GLPane. <event> is the mouse event after entering the GLpane. """ self.highlightTimer = self.startTimer(100) # 100-millisecond timer return
if self.selobj:
if self.selobj is not None:
def leaveEvent(self, event): # Mark 060806. """Event handler for when the cursor leaves the GLPane. <event> is the last mouse event before leaving the GLpane. """ # If an object is "hover highlighted", unhighlight it when leaving the GLpane. if self.selobj: self.selobj = None self.gl_update() # Kill timer when the cur...
"Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;GAMESS (*.out);;All of the above (*.pdb *.mmp *.out)",
"Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;GAMESS (*.out);;All Files (*.pdb *.mmp *.out)",
def fileInsert(self): env.history.message(greenmsg("Insert File:")) wd = globalParms['WorkingDirectory'] fn = QFileDialog.getOpenFileName(wd, "Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;GAMESS (*.out);;All of the above (*.pdb *.mmp *.out)", self, "Insert File dialog", "Select file to insert" ) # This...
"All Files (*.mmp *.pdb);;Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb)", self )
"Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;All Files (*.mmp *.pdb)", self )
def fileOpen(self, recentFile = None): '''By default, users open a file through 'Open File' dialog. If <recentFile> is provided, it means user is opening a file named <recentFile> through the 'Recent Files' menu list. The file may or may not exist. ''' env.history.message(greenmsg("Open File:")) mmkit_was_hidden = sel...
[[1, 30, None]]),
[[1, 30, onebond]]),
def __repr__(self): return "<Element: " + self.symbol + "(" + self.name + ")>"
[[1, 64, None]]),
[[1, 64, onebond]]),
def __repr__(self): return "<Element: " + self.symbol + "(" + self.name + ")>"
[[1, 99, None]]),
[[1, 99, onebond]]),
def __repr__(self): return "<Element: " + self.symbol + "(" + self.name + ")>"
[[1, 119, None]]),
[[1, 119, onebond]]),
def __repr__(self): return "<Element: " + self.symbol + "(" + self.name + ")>"
via dispdef from the calling molecule -- this is probably a bug
via dispdef from the calling molecule -- this might cause bugs if some callers change display mode but don't set havelist = 0, but maybe they do).
via dispdef from the calling molecule -- this is probably a bug ###e).
dir, basename = os.path.split(self.povrayscene_file) mapping.write("info povrayscene povrayscene_file = POV-Ray Scene Files/%s\n" % basename)
mapping.write("info povrayscene povrayscene_file = POV-Ray Scene Files/%s\n" % self.name)
def writemmp(self, mapping): mapping.write("povrayscene (" + mapping.encode_name(self.name) + ") %d %d %s\n" % \ (self.width, self.height, self.output_type)) # Write absolute path of POV-Ray Scene file into info record. # Get the basename from the povrayscene_file since there is no guarantee that the name and the base...
return os.path.normpath(os.path.join(dir, outfile))
output_image_filename = os.path.normpath(os.path.join(dir, outfile)) print "get_output_image_filename(): output_image_filename = ", output_image_filename return output_image_filename
def get_output_image_filename(self): """Returns the fullpath of the output image filename based on the <povrayscene_file> and <output_type> attrs. """ if not self.povrayscene_file: return "" if self.output_type == 'bmp': output_ext = '.bmp' else: # default output_ext = '.png' dir, tmp_pov = os.path.split(self.povray...
msg = "Rendering scene" else: msg = "Rendering raytrace image from POV-Ray Scene file. Please wait...."
msg = "Rendering scene. Please wait..." else: msg = "Rendering raytrace image from POV-Ray Scene file. Please wait..."
def raytrace_scene(self, tmpscene=False): """Render scene. If tmpscene is False, the INI and pov files are written to the 'POV-Ray Scene Files' directory. If tmpscene is True, the INI and pov files are written to a temporary directory (~/Nanorex/POV-Ray). Callers should set <tmpscene> = True when they want to render th...
else: env.history.message(cmd + "Rendered image: " + self.get_output_image_filename())
return env.history.message(cmd + "Rendered image: " + self.get_output_image_filename()) imageviewer = ImageViewer(self.get_output_image_filename(), env.mainwindow()) imageviewer.display()
def raytrace_scene(self, tmpscene=False): """Render scene. If tmpscene is False, the INI and pov files are written to the 'POV-Ray Scene Files' directory. If tmpscene is True, the INI and pov files are written to a temporary directory (~/Nanorex/POV-Ray). Callers should set <tmpscene> = True when they want to render th...
if os.path.exists(self.povrayscene_file):
if os.path.isfile(self.povrayscene_file):
def kill(self, require_confirmation=True): """Delete the POV-Ray Scene node and its associated .pov file if it exists. If <require_confirmation> is True, make the user confirm first. Otherwise, delete the file without user confirmation. """ if os.path.exists(self.povrayscene_file): if 0: # Don't require confirmation fo...
if (len(newAtomsPos) != len(atomList)): print "The number of atoms from %s is not matching with the current model." % xyzFile
if (len(newAtomsPos) != len(atomList)): print "readxyz: The number of atoms from %s (%d) is not matching with the current model (%d)." % \ (xyzFile, len(newAtomsPos), len(atomList))
def readxyz(assy): """Read a single-frame XYZ file created by the simulator, typically for minimizing a part. Check file format, return a list of atom new positions in the same order as assy.alist """ xyzFile = assy.m.filename lines = open(xyzFile, "rU").readlines() if len(lines) < 3: ##Invalid file format print "%s:...
for ob in new.members:
for ob in new.members[:]:
def cut(self): 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 Atoms mode self.w.history.message(redmsg("Cutting selected atoms is not yet supported.")) #bruce 0...
self.topnode.apply2picked(lambda o: o.kill())
try: self.topnode.apply2picked(lambda o: o.kill()) except: pass
def delete_sel(self, use_selatoms = True): #bruce 050505 added use_selatoms = True option, so MT ops can pass False (bugfix) "delete all selected nodes or atoms in this Part [except the top node, if we're an immortal Part]" #bruce 050419 renamed this from kill, to distinguish it # from standard meaning of obj.kill() ==...
if not os.path.exists(fn): return
if not os.path.exists(fn): self.history.message( redmsg( "File not found: " + fn) ) return
def fileInsert(self): self.history.message(greenmsg("Insert File:")) wd = globalParms['WorkingDirectory'] fn = QFileDialog.getOpenFileName(wd, "Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;All of the above (*.pdb *.mmp)", self ) if not fn: self.history.message("Cancelled") return if fn: fn = str(fn) ...
print "MWsemantics.py: fileInsert(): error inserting file" + fn self.history.message( "Problem inserting MMP file: " + fn )
print_compact_traceback( "MWsemantics.py: fileInsert(): error inserting MMP file [%s]: " % fn ) self.history.message( redmsg( "Internal error while inserting MMP file: " + fn) )
def fileInsert(self): self.history.message(greenmsg("Insert File:")) wd = globalParms['WorkingDirectory'] fn = QFileDialog.getOpenFileName(wd, "Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;All of the above (*.pdb *.mmp)", self ) if not fn: self.history.message("Cancelled") return if fn: fn = str(fn) ...
print "MWsemantics.py: fileInsert(): error inserting PDB file" + fn self.history.message( "Problem inserting file: " + fn )
print_compact_traceback( "MWsemantics.py: fileInsert(): error inserting PDB file [%s]: " % fn ) self.history.message( redmsg( "Internal error while inserting PDB file: " + fn) )
def fileInsert(self): self.history.message(greenmsg("Insert File:")) wd = globalParms['WorkingDirectory'] fn = QFileDialog.getOpenFileName(wd, "Molecular machine parts (*.mmp);;Protein Data Bank (*.pdb);;All of the above (*.pdb *.mmp)", self ) if not fn: self.history.message("Cancelled") return if fn: fn = str(fn) ...
mrd = MovieRewindDialog(self.o.assy.current_movie) mrd.exec_loop()
movie = self.o.assy.current_movie if movie.currentFrame is not 0: mrd = MovieRewindDialog(movie) mrd.exec_loop()
def _exitMode(self, new_mode = None): mrd = MovieRewindDialog(self.o.assy.current_movie) mrd.exec_loop() basicMode._exitMode(self, new_mode)
'%.4f rotations' % (nsecs / 0.2)
'%.3f rotations' % (nsecs / 0.2)
def textlist_6ps(framenumber): # 200 fs is 200.0e-6 nanoseconds nsecs = framenumber * 200.0e-6 return [ '%.4f nanoseconds' % nsecs, '%.4f rotations' % (nsecs / 0.2) ]
'%.4f rotations' % (nsecs / 0.2)
'%.3f rotations' % (nsecs / 0.2)
def textlist_0_6ps(framenumber): nsecs = framenumber * 20.0e-6 return [ '%.4f nanoseconds' % nsecs, '%.4f rotations' % (nsecs / 0.2) ]
'%.4f rotations' % (nsecs / 0.2)
'%.3f rotations' % (nsecs / 0.2)
def textlist_0_15ps(framenumber): nsecs = framenumber * 5.0e-6 return [ '%.4f nanoseconds' % nsecs, '%.4f rotations' % (nsecs / 0.2) ]
def cross_fade(real_seconds, from_filespec, to_filespec, start=0, avg=10):
def cross_fade(real_seconds, from_filespec, to_filespec, start=0, avg=10, textlist=textlist_6ps):
def cross_fade(real_seconds, from_filespec, to_filespec, start=0, avg=10): # We only do cross-fades at 6 ps/sec return m.motionBlur(from_filespec, start=start, incr=10, frames=real_seconds*m.SECOND, avg=avg, textlist=textlist_6ps, fadeTo=to_filespec)