rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
for m in movables():
for m in movables:
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.getMovables() if not movables: env.history.message(redmsg("No chunks or jigs selected.")) return ## Comp...
writeMolecule(m, atnum, alist, atnums, f)
atnum = writeMolecule(m, atnum, alist, atnums, f)
def writeGroup(group, atnum, alist, atnums, f): for m in group.members: if isinstance(m, molecule): writeMolecule(m, atnum, alist, atnums, f) else: writeGroup(m, atnum, alist, atnums, f) f.write(group.__str__() + "\n")
writeGroup(m, atnum, alist, atnums, f)
atnum = writeGroup(m, atnum, alist, atnums, f)
def writeGroup(group, atnum, alist, atnums, f): for m in group.members: if isinstance(m, molecule): writeMolecule(m, atnum, alist, atnums, f) else: writeGroup(m, atnum, alist, atnums, f) f.write(group.__str__() + "\n")
return atnum
def writeGroup(group, atnum, alist, atnums, f): for m in group.members: if isinstance(m, molecule): writeMolecule(m, atnum, alist, atnums, f) else: writeGroup(m, atnum, alist, atnums, f) f.write(group.__str__() + "\n")
print "fyi: extrude/revolve debug instructions: __main__.mode = this extrude mode obj; use debug window; has members assy, etc"
import platform if platform.atom_debug: print "fyi: extrude/revolve debug instructions: __main__.mode = this extrude mode obj; use debug window; has members assy, etc"
def Enter(self): self.status_msg("entering %s..." % self.msg_modename) # this msg won't last long enough to be seen, if all goes well self.clear() ##e see comment there self.initial_down = self.o.down self.initial_out = self.o.out reinit_extrude_controls(self.w, self.o, length = 7.0, attr_target = self) basicMode.Enter...
file.write("spoke(" + povpoint(c) + "," + povpoint(a.posn()) + "," + str (self.sradius) + ",<" + str(self.color[0]) + "," + str(self.color[1]) + "," + str(self.color[2]) + ">)\n")
if vlen(c - a.posn()) > 0.001: file.write("spoke(" + povpoint(c) + "," + povpoint(a.posn()) + "," + str (self.sradius) + ",<" + str(self.color[0]) + "," + str(self.color[1]) + "," + str(self.color[2]) + ">)\n")
def writepov(self, file, dispdef): if self.hidden: return if self.is_disabled(): return #bruce 050421 c = self.posn() a = self.axen() file.write("rmotor(" + povpoint(c+(self.length / 2.0)*a) + "," + povpoint(c-(self.length / 2.0)*a) + "," + str (self.radius) + ",<" + str(self.color[0]) + "," + str(self.color[1]) + ","...
file.write("spoke(" + povpoint(c) + "," + povpoint(a.posn()) + "," + str (self.sradius) + ",<" + str(self.color[0]) + "," + str(self.color[1]) + "," + str(self.color[2]) + ">)\n")
if vlen(c - a.posn()) > 0.001: file.write("spoke(" + povpoint(c) + "," + povpoint(a.posn()) + "," + str (self.sradius) + ",<" + str(self.color[0]) + "," + str(self.color[1]) + "," + str(self.color[2]) + ">)\n")
def writepov(self, file, dispdef): if self.hidden: return if self.is_disabled(): return #bruce 050421 c = self.posn() a = self.axen() xrot = -atan2(a[1], sqrt(1-a[1]*a[1]))*180/pi yrot = atan2(a[0], sqrt(1-a[0]*a[0]))*180/pi file.write("lmotor(" \ + povpoint([self.width * 0.5, self.width * 0.5, self.length * 0.5]...
def mousePressEvent(self, event): """Dispatches mouse press events depending on shift and control key state. """ self.makeCurrent() self.begin_select_cmd() if self.debug_event(event, 'mousePressEvent', permit_debug_menu_popup = 1): return but = self.fix_event(event, 'press', self.mode)
def checkpoint_before_drag(self, event, but):
def mouseDoubleClickEvent(self, event): self.debug_event(event, 'mouseDoubleClickEvent') ## but = event.stateAfter() #k I'm guessing this event comes in place of a mousePressEvent; # need to test this, and especially whether a releaseEvent then comes # [bruce 040917 & 060124] #print "Double clicked: ", but but = self....
begin_retval = self.assy.undo_checkpoint_before_command("(press)")
begin_retval = self.assy.undo_checkpoint_before_command("(mouse)")
def mousePressEvent(self, event): """Dispatches mouse press events depending on shift and control key state. """ ## Huaicai 2/25/05. This is to fix item 2 of bug 400: make this rendering context ## as current, otherwise, the first event will get wrong coordinates self.makeCurrent() self.begin_select_cmd() #bruce 05103...
try: if but & leftButton: if but & shiftButton: self.mode.leftShiftUp(event) elif but & cntlButton: self.mode.leftCntlUp(event) else: self.mode.leftUp(event) if but & midButton: if but & shiftButton: self.mode.middleShiftUp(event) elif but & cntlButton: self.mode.middleCntlUp(event) else: self.mode.middleUp(event) if...
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_event(event, 'release', self.mode) #print "Button released: ", but
if but & leftButton: if but & shiftButton: self.mode.leftShiftUp(event) elif but & cntlButton: self.mode.leftCntlUp(event) else: self.mode.leftUp(event) if but & midButton: if but & shiftButton: self.mode.middleShiftUp(event) elif but & cntlButton: self.mode.middleCntlUp(event) else: self.mode.middleUp(event) if but ...
return
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_event(event, 'release', self.mode) #print "Button released: ", but
if not jigs[0]:
if not jigs:
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...
if not item: return
def select(self, item): if not item: return self.win.assy.unpickatoms() if isinstance(self.win.glpane.mode, selectMode): self.win.toolsSelectMolecules() else: self.win.assy.selwhat = 2 if not self.modifier: self.win.assy.unpickparts() if self.modifier == 'Cntl': item.object.unpick() self.selectedItem = None else: it...
if self.modifier == 'Cntl': item.object.unpick() self.selectedItem = None else: item.object.pick() self.selectedItem = item.object
if item: if self.modifier == 'Cntl': item.object.unpick() self.selectedItem = None else: item.object.pick() self.selectedItem = item.object
def select(self, item): if not item: return self.win.assy.unpickatoms() if isinstance(self.win.glpane.mode, selectMode): self.win.toolsSelectMolecules() else: self.win.assy.selwhat = 2 if not self.modifier: self.win.assy.unpickparts() if self.modifier == 'Cntl': item.object.unpick() self.selectedItem = None else: it...
infile = infile
infile = mmpfile
def writemovie(assy, moviefile, mflag = False): """Creates a moviefile. moviefile - name of either a DPB file or an XYZ trajectory file. DPB = Differential Position Bytes (binary file) XYZ = XYZ trajectory file (text file) mflag - if True, creates a minimize dpb moviefile """ # Make sure some chunks are in the part. if...
modifyHydrogenateActionText = "<u><b>Hydrogenate</b></u> (Ctrl + H)</b></p><br>"\
modifyHydrogenateActionText = "<u><b>Hydrogenate</b></u> </b></p><br>"\
def createWhatsThis(self): ############################################## # File Toolbar ############################################## #### Open File #### fileOpenText = "<u><b>Open File</b></u> (Ctrl + O)</b></p><br> "\ "<p><img source=\"fileopen\"><br> "\ "Opens a new file."\ "</p>" QMimeSourceFactory.default...
"<p><b>Ctrl+Left Click</b> - deletes a highlighted atom.</p>"\
"<p><b>Ctrl+Left Click</b> - deletes a highlighted atom or bond.</p>"\
def createWhatsThis(self): ############################################## # File Toolbar ############################################## #### Open File #### fileOpenText = "<u><b>Open File</b></u> (Ctrl + O)</b></p><br> "\ "<p><img source=\"fileopen\"><br> "\ "Opens a new file."\ "</p>" QMimeSourceFactory.default...
"slab of diamond lattice.</p>"
"slab of diamond or londaleite lattice.</p>"
def createWhatsThis(self): ############################################## # File Toolbar ############################################## #### Open File #### fileOpenText = "<u><b>Open File</b></u> (Ctrl + O)</b></p><br> "\ "<p><img source=\"fileopen\"><br> "\ "Opens a new file."\ "</p>" QMimeSourceFactory.default...
self.mode = self.nullmode
self.use_nullmode()
def start_using_mode(self, mode): """Semi-internal method (meant to be called only from self or from one of our mode objects): Start using the given mode (name or object), ignoring any prior mode. If the new mode refuses to become current (e.g. if it requires certain kinds of selection which are not present), it shoul...
print "shift key pressed"
def keyPressEvent(self, e): if e.key() == Qt.Key_Control: self.modifier = 'Cntl' if e.key() == Qt.Key_Shift: self.modifier = 'Shift' print "shift key pressed" print "key pressed"
print "Moving", self.selectedItem, "to", item.object
def dropEvent(self, event): pnt = event.pos() - QPoint(0,24) item = self.itemAt(self.contentsToViewport(pnt)) if item: print "Moving", self.selectedItem, "to", item.object self.selectedItem.moveto(item.object) self.update() self.win.assy.root.dumptree()
('animate_std_views', 'int', animateStandardViews_prefs_key, True),
('animate_std_views', 'boolean', animateStandardViews_prefs_key, True),
def _compute_default_bondVaneColor(): ord_pi_for_color = 0.5 # was ord_pi, when we let the color vary with ord_pi; # if we later want that, then define two colors here and use them as endpoints of a range color = ave_colors(ord_pi_for_color, blue, gray) return ave_colors(0.8, color, black)
if 1:
if platform.atom_debug:
def leftDown(self, event): """If there's nothing nearby, deposit a new atom. If cursor is on a singlet, deposit an atom bonded to it. If it is a real atom, drag it around. """ # bruce 050124 warning: update_selatom now copies lots of logic from here; # see its comments if you change this self.w.history.transient_msg(" ...
self.w.win_update()
def selectInvert(self): """If some parts are selected, select the other parts instead. If some atoms are selected, select the other atoms instead (even in chunks with no atoms selected, which end up with all atoms selected). (And unselect all currently selected parts or atoms.) """ cmd = "Invert Selection: " # revised...
if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.selatoms:
if not self.selatoms:
def selectExpand(self): """Select any atom that is bonded to any currently selected atom. """ # Eric really needed this. Added by Mark 050923. cmd = "Expand Selection: " if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.sela...
assert self.selwhat == SELWHAT_ATOMS
def selectExpand(self): """Select any atom that is bonded to any currently selected atom. """ # Eric really needed this. Added by Mark 050923. cmd = "Expand Selection: " if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.sela...
if n.picked: continue n.pick() num_picked += 1 self.w.win_update() env.history.message(greenmsg(cmd) + str(num_picked) + " atoms selected.")
if not n.picked: n.pick() num_picked += 1 msg = greenmsg(cmd) + str(num_picked) + " atom(s) selected." from platform import fix_plurals env.history.message(fix_plurals(msg)) self.w.win_update()
def selectExpand(self): """Select any atom that is bonded to any currently selected atom. """ # Eric really needed this. Added by Mark 050923. cmd = "Expand Selection: " if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.sela...
"""Unselect any atom that is bonded to only one other selected atom.
"""Unselect any atom which has a bond to an unselected atom.
def selectContract(self): """Unselect any atom that is bonded to only one other selected atom. """ # Added by Mark 050923. cmd = "Contract Selection: " if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.selatoms: env.history.m...
if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.selatoms:
if not self.selatoms:
def selectContract(self): """Unselect any atom that is bonded to only one other selected atom. """ # Added by Mark 050923. cmd = "Contract Selection: " if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.selatoms: env.history.m...
self.w.win_update() env.history.message(greenmsg(cmd) + str(len(contract_list)) + " atoms unselected.")
msg = greenmsg(cmd) + str(len(contract_list)) + " atom(s) unselected." from platform import fix_plurals env.history.message(fix_plurals(msg)) self.w.win_update()
def selectContract(self): """Unselect any atom that is bonded to only one other selected atom. """ # Added by Mark 050923. cmd = "Contract Selection: " if self.selwhat == SELWHAT_CHUNKS: env.history.message(greenmsg(cmd) + redmsg("Doesn't work in Select Chunks mode.")) return if not self.assy.selatoms: env.history.m...
print_compact_stack("fyi, something called standard_inval twice (not illegal but weird -- bug hint?) in %r: " % self)
print_compact_stack("fyi, something called standard_inval twice (not illegal but weird -- bug hint?) in %r: " % self, frame_repr = _std_frame_repr, linesep = '\n')
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 ...
import __main__ maindir, filejunk = os.path.split( __main__.__file__ ) ourdir, filejunk = os.path.split( __file__ ) def canon(path): return os.path.normcase( os.path.abspath(path) ) maindir = canon(maindir) ourdir = canon(ourdir) guess1 = (maindir != ourdir) guess2 = not os.path.exists( os.path.join( ourdir, __name...
import __main__ ourdir = None try: ourdir, filejunk = os.path.split( __file__ ) maindir, filejunk = os.path.split( __main__.__file__ ) except: __main__._end_user = _end_user = True if ourdir is not None: print "end-user build" else: print "end user build" else: def canon(path): return os.path.normcase( os....
def before_most_imports( main_globals ): """Do things that should be done before anything that might possibly have side effects. main_globals should be the value of globals() in the __main__ module (our caller, atom.py). """ # user-specific debug code to be run before any other imports [bruce 040903] # gpl_only check...
self.connect(self, SIGNAL("contextMenuRequested(QListViewItem*, const QPoint&,int)"),
self.connect(self, SIGNAL("rightButtonPressed(QListViewItem*,const QPoint&,int)"),
def __init__(self, parent, win): QListView.__init__(self,parent,"modelTreeView") self.addColumn("Model Tree") self.win = win
self.struct = None
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()) self.struct = None except CadBug, e: env.history.message(redmsg...
v = self.singlpos-point r = sqrt(v[:,0]**2 + v[:,1]**2 + v[:,2]**2) p= r<=radius i=argsort(compress(p,r)) return take(compress(p,self.singlets),i)
singlpos = self.singlpos v = singlpos - point try: r = sqrt(v[:,0]**2 + v[:,1]**2 + v[:,2]**2) p= r<=radius i=argsort(compress(p,r)) return take(compress(p,self.singlets),i) except: print_compact_traceback("exception in nearSinglets (data printed below): ") print "if that was bug 829, this data (point, singlpos, v) mi...
def nearSinglets(self, point, radius): if not self.singlets: return [] v = self.singlpos-point r = sqrt(v[:,0]**2 + v[:,1]**2 + v[:,2]**2) p= r<=radius i=argsort(compress(p,r)) return take(compress(p,self.singlets),i)
self.addColumn("Name")
self.addColumn("Name", width=150)
def __init__(self, parent=None, name=None): QListView.__init__(self, parent, name) global folderClosedIcon, folderLockedIcon, folderOpenIcon, fileIcon
message is printed.]
message is printed [this is now implemented by a debug_pref, 060720].]
def _print_msg(self, msg): """Format and print one message (a string, usually not starting or ending with newline). Precede it with a timestamp. Most printing should go though this method. Client code should call a higher-level method which uses this one. [Someday we might also #e: - compress redundant messages which w...
self.connect(self.light_x_linedit,SIGNAL("returnPressed()"),self.change_lighting) self.connect(self.light_y_linedit,SIGNAL("returnPressed()"),self.change_lighting) self.connect(self.light_z_linedit,SIGNAL("returnPressed()"),self.change_lighting)
self.connect(self.light_x_linedit,SIGNAL("returnPressed()"),self.save_lighting) self.connect(self.light_y_linedit,SIGNAL("returnPressed()"),self.save_lighting) self.connect(self.light_z_linedit,SIGNAL("returnPressed()"),self.save_lighting)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
return len(atom.realNeighbors()) < min_atom_bonds(atm)
return len(atm.realNeighbors()) < min_atom_bonds(atm)
def is_hungry(atm): return len(atom.realNeighbors()) < min_atom_bonds(atm)
num, i = self.traverse( diredge, i)
num, i = self.traverse_nonrec( diredge, i)
def start(self, N1): """If we didn't already, traverse the connected component containing N1 and record all its cutedges in self.cutedges. Return True if we had not already traversed N1's connected component (since it's easy) [#e could return i - i1] """ # (Do we need to use diff value of i each time? doesn't matter, i...
def traverse(self, diredge, i):
def traverse_nonrec(self, diredge, i): "non-recursive version of traverse method (below)" stack = [(0, diredge)] del diredge retval = None while stack: top = stack.pop() if top[0] == 0: zerojunk, diredge = top priornode, N = diredge num = self.nodenums.setdefault(N, i) if num < i: retval = num, i continue assert num...
def traverse(self, diredge, i): # to optimize(??), pass the instvars rather than self (like for i), and split diredge in two """As this call starts, we're crossing diredge for the first time in either direction, but we don't yet know whether we've previously visited the node N at other side or not. (When this call ends...
bringing a "lowest number seen during this call" and a new "next number to assign" i.)
bringing a "lowest number seen during this call" and a new "next number to assign to a node" i.)
def traverse(self, diredge, i): # to optimize(??), pass the instvars rather than self (like for i), and split diredge in two """As this call starts, we're crossing diredge for the first time in either direction, but we don't yet know whether we've previously visited the node N at other side or not. (When this call ends...
all actual cutedges will get noticed this way
all actual cutedges will get noticed this way.
def traverse(self, diredge, i): # to optimize(??), pass the instvars rather than self (like for i), and split diredge in two """As this call starts, we're crossing diredge for the first time in either direction, but we don't yet know whether we've previously visited the node N at other side or not. (When this call ends...
def apply_to_2connset( self, N, func, didem = None):
def apply_to_2connset_nonrec( self, N, func): """Non-recursive version of apply_to_2connset. (Ought to be rewritten to use a non-recursive transcloser helper function made from Select Connected code.) """ didem = {N:1} todo = [N] while todo: newtodo = [] for N in todo: assert self.nodenums.get(N), "self.nodenums should...
def neighbors_except(self, N, priornode): # morally this should be an init param or subclass method (but speed > abstractness here) "Return all N's neighbors except priornode (or all of them, if priornode is None) [assume they can be compared using 'is']" #e assume N is an atom; this justifies using 'is' and also is wh...
assert self.nodenums.get(N)
assert self.nodenums.get(N), "self.nodenums should contain N (%r) but doesn't, or contains false %r" % (N, self.nodenums.get(N))
def apply_to_2connset( self, N, func, didem = None): """Apply func to the 2-connected set including N (or to N alone if all its edges are cutedges). Only works if we previously ran self.start(N1) in a way which hits N (we assert this, to detect the error). [Private: didem can be a dict of N's we already hit, for recurs...
one.apply_to_2connset( atom, lambda a2: resdict.setdefault(a2,a2))
one.apply_to_2connset_nonrec( atom, lambda a2: resdict.setdefault(a2,a2))
def select_doubly_transcloser(atomlist): """Return a list of atoms for which there is some ring of bonds (ok if that ring hits some atoms twice, but it can't include any bonds twice, even in opposite directions) containing both that atom and some atom in atomlist. """ #obs comments about func resdict = {} one = twoconn...
self.abort_sim_run("got real abort at frame %d" % frame_number)
self.abort_sim_run("got real abort at frame %d" % self.__frame_number)
def sim_frame_callback_updates(self): #bruce 060601 split out of sim_frame_callback_worker so it can be called separately """Do Qt-related updates which are needed after something has updated progress bar displays or done gl_update or printed history messages, if anything has set self.need_process_events to indicate it...
while sItem!= atItem and aboveItem != self.rootItem:
while sItem!= atItem and aboveItem != parentItem:
def addTreeItem(self, obj): """create new model object, like molecule""" atItem = self.objectToTreeItems[self.insertHereIcon] parentItem = atItem.parent() if isinstance(obj, molecule): mitem = TreeListViewItem(parentItem, obj.name) mitem.setItemObject(obj) mitem.setPixmap(0, self.moleculeIcon) mitem.setDragEnabled(Tru...
if aboveItem != self.rootItem:
if aboveItem != parentItem:
def addTreeItem(self, obj): """create new model object, like molecule""" atItem = self.objectToTreeItems[self.insertHereIcon] parentItem = atItem.parent() if isinstance(obj, molecule): mitem = TreeListViewItem(parentItem, obj.name) mitem.setItemObject(obj) mitem.setPixmap(0, self.moleculeIcon) mitem.setDragEnabled(Tru...
self.saveModelTree()
def addTreeItem(self, obj): """create new model object, like molecule""" atItem = self.objectToTreeItems[self.insertHereIcon] parentItem = atItem.parent() if isinstance(obj, molecule): mitem = TreeListViewItem(parentItem, obj.name) mitem.setItemObject(obj) mitem.setPixmap(0, self.moleculeIcon) mitem.setDragEnabled(Tru...
f3d.drawString("%g" % j, color=color, yoff=yoff)
f3d.drawString("%-.4g" % yoff, color=color, yoff=yoff)
def drawSiCGrid(color, line_type, w, h, up, right): '''Draw SiC grid. ''' from dimensions import Font3D from prefs_constants import NO_LINE, SOLID_LINE, DASHED_LINE, DOTTED_LINE if line_type == NO_LINE: return XLen = sic_uLen * 3.0 YLen = sic_yU * 2.0 hw = w/2.0; hh = h/2.0 i1 = int(floor(-hw/XLen)) i2 = int(ceil(hw/...
if -hw < yoff + xpos < hw: f3d.drawString("%g" % i, color=color, yoff=yoff)
if -hw < yoff + xpos < hw: f3d.drawString("%-.4g" % yoff, color=color, yoff=yoff)
def drawSiCGrid(color, line_type, w, h, up, right): '''Draw SiC grid. ''' from dimensions import Font3D from prefs_constants import NO_LINE, SOLID_LINE, DASHED_LINE, DOTTED_LINE if line_type == NO_LINE: return XLen = sic_uLen * 3.0 YLen = sic_yU * 2.0 hw = w/2.0; hh = h/2.0 i1 = int(floor(-hw/XLen)) i2 = int(ceil(hw/...
elif self._movie.watch_motion:
elif self._movie.watch_motion and env.prefs[watchRealtimeMinimization_prefs_key]:
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...
ndiffs = len(diffs_to_destroy) print "debug: clear_redo_stack found %d diffs to destroy" % ndiffs len1 = len(self.stored_ops)
print "debug: clear_redo_stack found %d diffs to destroy" % ndiffs
def collector(state_version, dict1): ops = self._raw_find_undoredos( state_version) for op in ops: if op.direction == 1 and op is not except_diff: # redo, not undo # found an edge to destroy, and its endpoint node to further explore diffs_to_destroy[op.key] = op state_version_endpoint = self.state_version_of_cp( op.cps...
if (env.debug() or len1 == len2) and ndiffs: len2 = len(self.stored_ops) print " debug: clear_redo_stack finished; removed %d entries from self.stored_ops" % (len1 - len2)
len2 = len(self.stored_ops) savings = len1 - len2 if ndiffs and (savings < 0 or env.debug()): print " debug: clear_redo_stack finished; removed %d entries from self.stored_ops" % (savings,)
def collector(state_version, dict1): ops = self._raw_find_undoredos( state_version) for op in ops: if op.direction == 1 and op is not except_diff: # redo, not undo # found an edge to destroy, and its endpoint node to further explore diffs_to_destroy[op.key] = op state_version_endpoint = self.state_version_of_cp( op.cps...
if self.prefs_key: self.value = env.prefs[self.prefs_key]
def current_value(self): #e should we look it up in env.prefs (for usage tracking) if self.prefs_key?? [no need to decide this until it matters] return self.value
if self.value == newval:
if self.current_value() == newval:
def newval_receiver_func(newval): assert self.dtype.legal_value(newval), "illegal value for %r: %r" % (self, newval) ###e change to ask dtype, since most of them won't have a list of values!!! this method is specific to Choice. if self.value == newval: #bruce 060126 if self.print_changes: print "redundant change:", ##r...
self.hybrid_btngrp.insert( self.sp_btn,3)
self.hybrid_btngrp.insert( self.sp_btn,2)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
"""Slot for Contract Selection, which unselect any atom that is bonded to only one other selected atom.
"""Slot for Contract Selection, which unselects any atom which has a bond to an unselected atom.
def selectContract(self): """Slot for Contract Selection, which unselect any atom that is bonded to only one other selected atom. """ self.assy.selectContract()
"Reorient view so that the entire model fits in the glpane."
"Change view so that the entire model fits in the glpane."
def setViewFitToWindow(self): "Reorient view so that the entire model fits in the glpane." #Recalculate center and bounding box for the current part part = self.part part.computeBoundingBox() scale = float( part.bbox.scale() * .75) #bruce 050616 added float() as a precaution, probably not needed # appropriate height to...
def snapToView(self, q2, s2, p2, z2, update_duration = False): '''Snap to the destination view defined by quat q2, scale s2, pov p2, and zoom factor z2. ''' self.quat = Q(q2) self.pov = V(p2[0], p2[1], p2[2]) self.zoomFactor = z2 self.scale = s2 if update_duration: self.gl_update_duration() else: self.gl_update() def...
def snapToCsys(self, csys): '''Snap to the destination view defined by csys. ''' self.snapToView(csys.quat, csys.scale, csys.pov, csys.zoomFactor)
self.snapToViewUsingCsys(q2, s2, p2, z2)
self.snapToCsys(csys)
def animateToCsys(self, csys, animate = True): '''Animate to the destination view defined by csys. If animate is False *or* the user pref "Animate between views" is not selected, then do not animate; just snap to the destination view. ''' # Determine whether to snap (don't animate) to the destination view. if not anim...
def snapToView(self, q2, s2, p2, z2, update_duration = False): '''Snap to the destination view defined by quat q2, scale s2, pov p2, and zoom factor z2. ''' typecheckViewArgs(q2, s2, p2, z2) self.quat = Q(q2) self.pov = V(p2[0], p2[1], p2[2]) self.zoomFactor = z2 self.scale = s2 if update_duration: self.gl_update_d...
def animateToCsys(self, csys, animate = True): '''Animate to the destination view defined by csys. If animate is False *or* the user pref "Animate between views" is not selected, then do not animate; just snap to the destination view. ''' # Determine whether to snap (don't animate) to the destination view. if not anim...
'''Redraw GLPane and update the repaint duration variable used animateToView() to compute the number of animation steps.
'''Redraw GLPane and update the repaint duration variable <self._repaint_duration> used by animateToView() to compute the proper number of animation frames.
def gl_update_duration(self, new_part=False): '''Redraw GLPane and update the repaint duration variable used animateToView() to compute the number of animation steps. Redraws the GLPane twice if <new_part> is True and only saves the repaint duration of the second redraw. This is needed in the case of drawing a newly o...
def typecheckViewArgs(q2, s2, p2, z2): '''Typecheck the view arguments quat q2, scale s2, pov p2, and zoom factor z2 used by GLPane.snapToView() and GLPane.animateToView(). ''' assert isinstance(q2, Q) assert isinstance(s2, float) assert len(p2) == 3 assert isinstance(p2[0], float) assert isinstance(p2[1], float) asser...
def enter_custom_mode( self, modename, modefile): #bruce 050515 experiment fn = modefile if not os.path.exists(fn): env.history.message("should never happen: file does not exist: [%s]" % fn) return dir, file = os.path.split(fn) base, ext = os.path.splitext(file) ## modename = base ###e need better way to import from th...
if self.w.hybridComboBox.isVisible():
if 1:
def keyPress(self,key): # bruce comment 041220: # doesn't call basicMode method, so Delete key is not active. Good?? # bruce 050128: no, not good. And it shows selection anyway... so do it below. for sym, code, num in elemKeyTab: # Set the atom type in the MMKit and combobox. if key == code: self.w.setElement(num) ###...
setattr(self, attr, val)
setattr(self, attr, newval)
def own_mutable_copyable_attrs(self): #bruce 050704 """[overrides Node method]""" super = Jig super.own_mutable_copyable_attrs( self) for attr in self.mutable_attrs: if attr == 'psets': # special-case code for this attr, a list of gamessParms objects # (those objects, and the list itself, are mutable and need to be de-...
return
return new
def deepcopy(self): #bruce 050704; don't know whether this is complete [needs review by Mark; is it ok it only sets .ui? #####@@@@@] "Make a copy of self (a gamessParms object), which shares no mutable state with self. (Used to copy a Gamess Jig containing self.)" newname = self.name + " copy" # copy needs a different ...
m1 = fix_plurals( "%d bond(s) made with " % total_bonds_made) m2 = fix_plurals( "%d chunk(s) ." % len(self.merged_chunks)) self.w.history.message(m1 + m2)
msg = fix_plurals( "%d bond(s) made" % total_bonds_made) self.w.history.message(msg)
def make_bonds(self): "Make bonds between all bondable pairs of singlets" self.bondable_pairs_atoms = [] self.merged_chunks = [] singlet_found_with_multiple_bonds = False # True when there are singlets with multiple bonds. total_bonds_made = 0 # The total number of open bond pairs that formed bonds. singlets_not_bonde...
but = self.fix_event(event, 'press', self.mode) self.checkpoint_before_drag(event, but)
self.checkpoint_before_drag(event, but)
def mouseDoubleClickEvent(self, event): # (note: mouseDoubleClickEvent and mousePressEvent share a lot of code) self.makeCurrent() #bruce 060129 precaution, presumably needed for same reasons as in mousePressEvent self.begin_select_cmd() #bruce 060129 bugfix (needed now that this can select atoms in depositMode) self....
"""Only used to detect the end of a freehand selection curve.
"""
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_event(event, 'release', self.mode) #print "Button released: ", but try: if but & leftButton: if but & shiftButton: self.mode.leftShift...
if self.debug_gl_timing: self._print_gl_timing(0)
flag_and_begin_retval = None if self.assy: begin_retval = self.assy.undo_checkpoint_before_command("(redraw)") flag_and_begin_retval = True, begin_retval try: self.most_of_paintGL() except: print_compact_traceback("exception in most_of_paintGL ignored: ") if flag_and_begin_retval: flagjunk, begin_retval = flag_and_b...
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 self.debug_gl_timing: self._print_gl_timing(1) else: glFlush() return debug_gl_timing = False __last_time = time.time() def _print_gl_timing(self, endQ): "private method for timing repaints. Note: doesn't print which widget since we assume only used in one (main GLPane)." assert self.debug_gl_timing if endQ: ...
glFlush() return
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...
try: dflt = getattr(self, attr) except: print "bug, fatal: exception (traceback follows) looking for default value for attr %r of class %r" % \ (attr, self.__class__.__name__) raise self._um_default_values_dict[attr] = dflt
dflt = None
def _um_init_default_values_dict(self): ###obs comments: ### we need a class-specific (*not* allowed to vary on self) dict of all default values of undoable attrs ### actually it can vary depending on initargs, under some conditions (doc'd eleswhere) ### but it would be more efficient to prohibit that, so not every ins...
print "fyi: float spinbox got text %r" % text
def mapTextToValue(self): text = self.cleanText() text = str(text) # since it's a qt string print "fyi: float spinbox got text %r" % text try: fval = float(text) ival = int(fval * self.precision_angstroms) # 2-digit precision return ival, True except: return 0, False
def reinit_extrude_controls(win):
def reinit_extrude_controls(win, glpane = None, length = None):
def reinit_extrude_controls(win): "reinitialize the extrude controls; used whenever we enter the mode; win should be the main window (MWSemantics object)" win.extrudeSpinBox_n.setValue(3) set_extrude_controls_xyz(win, (5,5,5)) # this default should (at least) be fixed in eyespace, not modelspace as it is here
set_extrude_controls_xyz(win, (5,5,5))
x,y,z = 5,5,5 if glpane: try: right = win.glpane.right x,y,z = right if not length: length = 7.0 except: print "fyi (bug?): in extrude: x,y,z = win.glpane.right failed" pass if length: ll = math.sqrt(x*x + y*y + z*z) rr = float(length) / ll x,y,z = (x * rr, y * rr, z * rr) set_extrude_controls_xyz(win, (x,y,z))
def reinit_extrude_controls(win): "reinitialize the extrude controls; used whenever we enter the mode; win should be the main window (MWSemantics object)" win.extrudeSpinBox_n.setValue(3) set_extrude_controls_xyz(win, (5,5,5)) # this default should (at least) be fixed in eyespace, not modelspace as it is here
reinit_extrude_controls(self.w)
self.clear() reinit_extrude_controls(self.w, self.o, length = 7.0)
def Enter(self): reinit_extrude_controls(self.w) basicMode.Enter(self) ### # find out what's selected, which if ok will be the repeating unit we will extrude... explore its atoms, bonds, externs... # what's selected should be its own molecule if it isn't already... # for now let's hope it is exactly one (was checked in...
print "extrude debug instructions: __main__.mode = this extrude mode obj; use debug window; has members assy, etc"
print "fyi: extrude debug instructions: __main__.mode = this extrude mode obj; use debug window; has members assy, etc" print "also, use Menu1 entries to run debug code, like explore() to check out singlet pairs in self.basemol"
def Enter(self): reinit_extrude_controls(self.w) basicMode.Enter(self) ### # find out what's selected, which if ok will be the repeating unit we will extrude... explore its atoms, bonds, externs... # what's selected should be its own molecule if it isn't already... # for now let's hope it is exactly one (was checked in...
self.basemol.pick()
def update_from_controls(self): """make the number and position of the copies of basemol what they should be, based on current control values. Never modify the control values! (That would infloop.) This should be called in Enter and whenever relevant controls might change. """ self.asserts()
mergeables = {} moused_over = None def clear(self): self.mergeables = {} self.moused_over = None
def leftCntlUp(self, event): pass##self.EndDraw(event)
def extrude_update(self): print "extrude_update" try: explore(self.basemol, self.basemol, self) except: raise print "extrude_update done" return def extrude_reload(self): """for debugging: try to reload extrudeMode.py and patch your glpane to use it, so no need to restart Atom. Might not always work. [But it did work ...
def makeMenus(self): ### not yet reviewed for extrude mode self.Menu2 = self.makemenu([('Kill', self.o.assy.kill), ('Copy', self.o.assy.copy), ('Separate', self.o.assy.modifySeparate), ('Bond', self.o.assy.Bond), ('Unbond', self.o.assy.Unbond), ('Stretch', self.o.assy.Stretch)]) self.Menu3 = self.makemenu([('Default',...
LayoutWidget = QWidget(self.elementGroupBox,"layout6_2") LayoutWidget.setGeometry(QRect(60,0,349,56)) layout6_2 = QHBoxLayout(LayoutWidget,11,6,"layout6_2") spacer5 = QSpacerItem(171,31,QSizePolicy.Expanding,QSizePolicy.Minimum) layout6_2.addItem(spacer5)
LayoutWidget = QWidget(self.elementGroupBox,"layout22") LayoutWidget.setGeometry(QRect(-22,10,524,54)) layout22 = QHBoxLayout(LayoutWidget,11,6,"layout22") self.pushButton5_2 = QPushButton(LayoutWidget,"pushButton5_2") self.pushButton5_2.setPaletteBackgroundColor(QColor(208,203,231)) pushButton5_2_font = QFont(self.pu...
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout6_2.addWidget(self.pushButton1)
layout22.addWidget(self.pushButton1)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
self.pushButton2.setSizePolicy(QSizePolicy(1,1,0,0,self.pushButton2.sizePolicy().hasHeightForWidth()))
self.pushButton2.setSizePolicy(QSizePolicy(1,0,0,0,self.pushButton2.sizePolicy().hasHeightForWidth()))
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout6_2.addWidget(self.pushButton2) LayoutWidget_2 = QWidget(self.elementGroupBox,"layout7") LayoutWidget_2.setGeometry(QRect(10,70,524,56)) layout7 = QHBoxLayout(LayoutWidget_2,11,6,"layout7")
layout22.addWidget(self.pushButton2) LayoutWidget_2 = QWidget(self.elementGroupBox,"layout23") LayoutWidget_2.setGeometry(QRect(-20,72,558,54)) layout23 = QHBoxLayout(LayoutWidget_2,11,6,"layout23")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout7.addWidget(self.pushButton5)
layout23.addWidget(self.pushButton5)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout7.addWidget(self.pushButton6)
layout23.addWidget(self.pushButton6)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout7.addWidget(self.pushButton7)
layout23.addWidget(self.pushButton7)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout7.addWidget(self.pushButton8)
layout23.addWidget(self.pushButton8)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout7.addWidget(self.pushButton9)
layout23.addWidget(self.pushButton9)
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout7.addWidget(self.pushButton10) LayoutWidget_3 = QWidget(self.elementGroupBox,"layout9") LayoutWidget_3.setGeometry(QRect(50,206,483,56)) layout9 = QHBoxLayout(LayoutWidget_3,11,6,"layout9") spacer6 = QSpacerItem(41,21,QSizePolicy.Expanding,QSizePolicy.Minimum) layout9.addItem(spacer6) self.pushButton32 = QPushB...
layout23.addWidget(self.pushButton10) LayoutWidget_3 = QWidget(self.elementGroupBox,"layout27") LayoutWidget_3.setGeometry(QRect(20,130,624,58)) layout27 = QHBoxLayout(LayoutWidget_3,11,6,"layout27") self.pushButton13 = QPushButton(LayoutWidget_3,"pushButton13") pushButton13_font = QFont(self.pushButton13.font()) pus...
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout9.addWidget(self.pushButton32) self.pushButton33 = QPushButton(LayoutWidget_3,"pushButton33")
layout25.addWidget(self.pushButton32) self.pushButton33 = QPushButton(LayoutWidget_4,"pushButton33")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout9.addWidget(self.pushButton33) self.pushButton34 = QPushButton(LayoutWidget_3,"pushButton34")
layout25.addWidget(self.pushButton33) self.pushButton34 = QPushButton(LayoutWidget_4,"pushButton34")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout9.addWidget(self.pushButton34) self.pushButton35 = QPushButton(LayoutWidget_3,"pushButton35")
layout25.addWidget(self.pushButton34) self.pushButton35 = QPushButton(LayoutWidget_4,"pushButton35")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout9.addWidget(self.pushButton35) self.pushButton36 = QPushButton(LayoutWidget_3,"pushButton36")
layout25.addWidget(self.pushButton35) self.pushButton36 = QPushButton(LayoutWidget_4,"pushButton36")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout9.addWidget(self.pushButton36) LayoutWidget_4 = QWidget(self.elementGroupBox,"layout10") LayoutWidget_4.setGeometry(QRect(90,280,445,56)) layout10_4 = QHBoxLayout(LayoutWidget_4,11,6,"layout10_4") spacer7 = QSpacerItem(91,21,QSizePolicy.Expanding,QSizePolicy.Minimum) layout10_4.addItem(spacer7) self.pushButton5...
layout25.addWidget(self.pushButton36) LayoutWidget_5 = QWidget(self.elementGroupBox,"layout26") LayoutWidget_5.setGeometry(QRect(-29,250,536,54)) layout26 = QHBoxLayout(LayoutWidget_5,11,6,"layout26") self.pushButton5_2_6 = QPushButton(LayoutWidget_5,"pushButton5_2_6") self.pushButton5_2_6.setPaletteBackgroundColor(Q...
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout10_4.addWidget(self.pushButton51) self.pushButton52 = QPushButton(LayoutWidget_4,"pushButton52")
layout26.addWidget(self.pushButton51) self.pushButton52 = QPushButton(LayoutWidget_5,"pushButton52")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout10_4.addWidget(self.pushButton52) self.pushButton53 = QPushButton(LayoutWidget_4,"pushButton53")
layout26.addWidget(self.pushButton52) self.pushButton53 = QPushButton(LayoutWidget_5,"pushButton53")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)
layout10_4.addWidget(self.pushButton53) self.pushButton54 = QPushButton(LayoutWidget_4,"pushButton54")
layout26.addWidget(self.pushButton53) self.pushButton54 = QPushButton(LayoutWidget_5,"pushButton54")
def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl)