rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if text: listItem.object.name = str(text) | if text: listItem.object.name = str(text) self.assy.modified = 1 | def changename(self, listItem, col, text): if col != 0: return self.assy.modified = 1 # Huaicai: the following line to make sure file name is not just space text = text.stripWhiteSpace() # Check if there is text for the listitem's name. If not, we must force an MT update. # Otherwise, the name will remain blank unti... |
f3d = Font3D(hw, y1, right, up, False) | f3d = Font3D(xoff=hw, yoff=y1, right=right, up=up, rot90=False, glBegin=True) | def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ... |
f3d = Font3D(x1, hh, right, up, True) | f3d = Font3D(xoff=x1, yoff=hh, right=right, up=up, rot90=True, glBegin=True) | def drawGPGrid(color, line_type, w, h, uw, uh, up, right): '''Draw grid lines for a Grid Plane, where: color = grid line color line_type is: 0=None, 1=Solid, 2=Dashed" or 3=Dotted w = width h = height uw = width spacing between grid lines uh = height spacing between grid lines ''' from prefs_constants import NO_LINE, ... |
debug_part_files = True | debug_part_files = False | def set_waitcursor(on_or_off): """For on_or_off True, set the main window waitcursor. For on_or_off False, revert to the prior cursor. [It might be necessary to always call it in matched pairs, I don't know [bruce 050401]. #k] """ if on_or_off: QApplication.setOverrideCursor( QCursor(Qt.WaitCursor) ) else: QApplication... |
drawer.drawaxes(2.5, (0.0,0.0,0.0), coloraxes=True) drawer.drawaxes(5, -self.o.pov) | drawer.drawaxes(5, (0.0,0.0,0.0), coloraxes=True) if vlen(self.o.pov): drawer.drawaxes(5, -self.o.pov) | def Draw(self): """Generic Draw method, with drawing code common to all modes. Specific modes should call this within their own Draw method, unless they have a good reason not to. """ # Draw the Csys "coloraxes" and the POV "blue" axes # Mark 050131 if self.o.cSysToggleButton: drawer.drawaxes(2.5, (0.0,0.0,0.0), color... |
else: self.gamess_path_linedit.setText('') | def set_gamess_path(self): '''Slot for GAMESS path "Modify" button. ''' self.gmspath = get_gamess_path(self) if self.gmspath: self.gamess_path_linedit.setText(self.gmspath) else: self.gamess_path_linedit.setText('') | |
if change_mode_to_fit: | if change_mode_to_fit and selwhat_from_mode != selwhat: | def update_select_mode(self): #bruce 050124; should generalize and refile; should be used for more or for all events ###@@@ """This should be called at the end of event handlers which might have changed the current internal selection mode (atoms vs chunks), to resolve disagreements between that and the visible selectio... |
ddhhXmat = A([[1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [0, 1, 0, 1, -1, 0, 0, 1, 1, 1, 1, -1, -1], [0, 0, 1, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1]]) def makeddhhlist(mins, maxs): ax = maxs[0], mins[0], maxs[1], mins[1], maxs[2], mins[2] u = maxs[3]-maxs[0], def drawddhh(color, v): glPolygonMode(GL_FRONT, GL_... | def drawlinelist(color,lines): glDisable(GL_LIGHTING) glColor3fv(color) glBegin(GL_LINES) for v in lines: glVertex3fv(v) glEnd() glEnable(GL_LIGHTING) | |
class MyToolTip(QToolTip): """Extend QToolTip to work on QListViewItems in the viewport of a QListView. This requires keeping track of the QRects they occupy, so that maybeTip can respond to QPoints falling in those QRects.""" def __init__(self, owner): QToolTip.__init__(self, owner) self.__things = { } def add(self, n... | def cleanup(self, client = None): ###@@@ call this from above "we're done; reset whatever we set outside this object, remove reference cycles, etc" assert self.client is None or self.client is client self.dragsource = self.client = None #e clean statusbar; dragobj if stored here | |
xyz.readFromList(questionableXyz) | raise Exception, type(questionableXyz) | def compare(self, questionableXyz, knownGoodXyzFile, lengthTolerance, angleTolerance): todo("handle multiple-frame xyz files from animations") xyz = XyzFile() if type(questionableXyz) == types.StringType: xyz.read(questionableXyz) else: xyz.readFromList(questionableXyz) L1, A1 = self.getLAfromXYZ(xyz) xyz = XyzFile() x... |
z = s.go() lac.compare(z, BASE + ".xyzcmp", LENGTH_TOLERANCE, ANGLE_TOLERANCE) | s.go() lac.compare(BASE + ".xyz", BASE + ".xyzcmp", LENGTH_TOLERANCE, ANGLE_TOLERANCE) | def test_minH2(self): import sim BASE = "tests/minimize/test_h2" lac = LengthAngleComparison(BASE + ".mmp") s = sim.Minimize(BASE + ".mmp") s.Temperature = 300 z = s.go() lac.compare(z, BASE + ".xyzcmp", LENGTH_TOLERANCE, ANGLE_TOLERANCE) |
lac.compare(z, BASE + ".xyzcmp", LENGTH_TOLERANCE, ANGLE_TOLERANCE) | lac.compare(BASE + ".xyz", BASE + ".xyzcmp", LENGTH_TOLERANCE, ANGLE_TOLERANCE) | def test_other(self): import sim BASE = "tests/minimize/test_0001" lac = LengthAngleComparison(BASE + ".mmp") s = sim.Minimize(BASE + ".mmp") s.Temperature = 300 z = s.go() lac.compare(z, BASE + ".xyzcmp", LENGTH_TOLERANCE, ANGLE_TOLERANCE) |
self.resize(QSize(1115,1003).expandedTo(self.minimumSizeHint())) | self.resize(QSize(1115,1006).expandedTo(self.minimumSizeHint())) | def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar() |
self.toolsMoveMoleculeAction.setText(self.__tr("Move Chunk")) self.toolsMoveMoleculeAction.setToolTip(self.__tr("Move Chunk")) self.toolsMoveMoleculeAction.setMenuText(self.__tr("Move Chunk")) | self.toolsMoveMoleculeAction.setText(self.__tr("Move Chunks")) self.toolsMoveMoleculeAction.setToolTip(self.__tr("Move Chunks")) self.toolsMoveMoleculeAction.setMenuText(self.__tr("Move Chunks")) | def languageChange(self): self.setCaption(self.__tr("nanoENGINEER-1")) self.fileNewAction.setText(self.__tr("New")) self.fileNewAction.setMenuText(self.__tr("&New")) self.fileNewAction.setAccel(self.__tr("Ctrl+N")) self.fileOpenAction.setText(self.__tr("Open")) self.fileOpenAction.setMenuText(self.__tr("&Open...")) sel... |
elif word.endswith("(s)"): | elif word.endswith("(s)") or word.endswith("(s),"): suflen = ( word.endswith("(s),") and 1) or 0 | def fix_plurals(text, between = 1): """fix plurals in text (a message for the user) by changing: 1 thing(s) -> 1 thing 2 thing(s) -> 2 things permitting at most 'between' extra words in between, e.g. by default 2 green thing(s) -> 2 green things. #""" words = text.split(" ") numpos = -1 count = 0 for word,i in zip(word... |
words[i] = words[i][:-3] | words[i] = words[i][:-3] + suffix | def fix_plurals(text, between = 1): """fix plurals in text (a message for the user) by changing: 1 thing(s) -> 1 thing 2 thing(s) -> 2 things permitting at most 'between' extra words in between, e.g. by default 2 green thing(s) -> 2 green things. #""" words = text.split(" ") numpos = -1 count = 0 for word,i in zip(word... |
words[i] = words[i][:-3] + "s" | words[i] = words[i][:-3] + "s" + suffix | def fix_plurals(text, between = 1): """fix plurals in text (a message for the user) by changing: 1 thing(s) -> 1 thing 2 thing(s) -> 2 things permitting at most 'between' extra words in between, e.g. by default 2 green thing(s) -> 2 green things. #""" words = text.split(" ") numpos = -1 count = 0 for word,i in zip(word... |
args = [program, '-m', str(formarg), outfile, infile] | args = [program, '-m', str(formarg), traceFile, outfile, infile] | 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 ... |
def setViewFromCsys(self, csys): | def setViewFromCsys(self, csys, animate = False): | def setViewFromCsys(self, csys): "Set the initial or current view used by this GLPane to the one stored in the given Csys object." self.quat = Q(csys.quat) self.scale = csys.scale self.pov = V(csys.pov[0], csys.pov[1], csys.pov[2]) self.zoomFactor = csys.zoomFactor |
self.quat = Q(csys.quat) self.scale = csys.scale self.pov = V(csys.pov[0], csys.pov[1], csys.pov[2]) self.zoomFactor = csys.zoomFactor | self.animateView(csys.quat, csys.scale, csys.pov, csys.zoomFactor, animate) | def setViewFromCsys(self, csys): "Set the initial or current view used by this GLPane to the one stored in the given Csys object." self.quat = Q(csys.quat) self.scale = csys.scale self.pov = V(csys.pov[0], csys.pov[1], csys.pov[2]) self.zoomFactor = csys.zoomFactor |
self.setViewFromCsys( self.part.homeCsys) self.gl_update() | self.setViewFromCsys( self.part.homeCsys, animate=True) | def setViewHome(self): "Change current view to our model's home view (for glpane's current part), and gl_update." self.setViewFromCsys( self.part.homeCsys) self.gl_update() |
self.scale = float( part.bbox.scale() ) | scale = float( part.bbox.scale() * .75) | def setViewFitToWindow(self): "Change current view so that our model's bbox fits in our window, and gl_update." #Recalculate center and bounding box for the current part part = self.part part.computeBoundingBox() self.scale = float( part.bbox.scale() ) #bruce 050616 added float() as a precaution, probably not needed # ... |
self.scale /= aspect self.pov = V(-part.center[0], -part.center[1], -part.center[2]) self.setZoomFactor(1.0) self.gl_update() | scale /= aspect pov = V(-part.center[0], -part.center[1], -part.center[2]) self.animateView(self.quat, scale, pov, 1.0) | def setViewFitToWindow(self): "Change current view so that our model's bbox fits in our window, and gl_update." #Recalculate center and bounding box for the current part part = self.part part.computeBoundingBox() self.scale = float( part.bbox.scale() ) #bruce 050616 added float() as a precaution, probably not needed # ... |
self.pov = V(0,0,0) | def setViewRecenter(self): "Recenter our current view around the origin of modeling space in our current part, and gl_update." part = self.part self.pov = V(0,0,0) part.computeBoundingBox() self.scale = part.bbox.scale() + vlen(part.center) #bruce 050418 comments: # - doesn't this need to correct for aspect ratio, like... | |
self.scale = part.bbox.scale() + vlen(part.center) part.changed() self.gl_update() | scale = (part.bbox.scale() * .75) + (vlen(part.center) * .5) aspect = float(self.width) / self.height if aspect < 1.0: scale /= aspect pov = V(0,0,0) self.animateView(self.quat, scale, pov, 1.0) | def setViewRecenter(self): "Recenter our current view around the origin of modeling space in our current part, and gl_update." part = self.part self.pov = V(0,0,0) part.computeBoundingBox() self.scale = part.bbox.scale() + vlen(part.center) #bruce 050418 comments: # - doesn't this need to correct for aspect ratio, like... |
angle = int(deltaq.angle * 180/pi) nsteps = int (min (self.fps, angle)) if nsteps <= 1: self.quat = Q(q2) self.gl_update() return angle_inc = angle / nsteps if angle_inc > 25: self.quat = Q(q2) self.gl_update() return | angle = deltaq.angle * 180/pi if angle > 180: angle = 360-angle nsteps = int(min(max(self.fps, 2), angle)) | def rotateView(self, q2): "Rotate current view to quat (viewpoint) q2" # Check User Preference "General | Standard Views: Animate" if not env.prefs[animateStandardViews_prefs_key]: self.quat = Q(q2) self.gl_update() return wxyz1 = V(self.quat.w, self.quat.x, self.quat.y, self.quat.z) wxyz2 = V(q2.w, q2.x, q2.y, q2.z)... |
end_time = time.time() self.fps = nsteps / (end_time - start_time) | env.call_qApp_processEvents() end_time = time.time() self.fps = nsteps / (end_time - start_time + .001 ) def animateView(self, q2, s2, p2, z2, animate=True): "Animate current view to quat (viewpoint) q2, scale s2, pov p2, and zoom factor z2" if not animate or not env.prefs[animateStandardViews_prefs_key]: self... | def rotateView(self, q2): "Rotate current view to quat (viewpoint) q2" # Check User Preference "General | Standard Views: Animate" if not env.prefs[animateStandardViews_prefs_key]: self.quat = Q(q2) self.gl_update() return wxyz1 = V(self.quat.w, self.quat.x, self.quat.y, self.quat.z) wxyz2 = V(q2.w, q2.x, q2.y, q2.z)... |
self.textLabel3 = QLabel(self.extrudeToolbar,"textLabel3") | self.textLabel_extrude_toolbar = QLabel(self.extrudeToolbar,"textLabel_extrude_toolbar") | def do_what_MainWindowUI_should_do(self): "self should be the main MWSemantics object -- at the moment this is a function, not a method" from qt import SIGNAL, QToolBar, QLabel, QLineEdit, QSpinBox # 1. connect the mode-entering button to its MWSemantics method self.connect(self.toolsExtrudeAction,SIGNAL("activated()... |
assy.csys.quat = self.win.glpane.quat | assy.csys.quat = Q(self.win.glpane.quat) | def processCsysMenu(self, id): if id == 0: #Rename self.selectedTreeItem.startRename(0) else: # Set current view as default view assy = self.win.assy assy.csys.quat = self.win.glpane.quat |
self.csysPopupMenu.insertItem("Set Default View", 1) | self.csysPopupMenu.insertItem("Set Home View", 1) | def setPopupMenus(self): self.treePopupMenu = QPopupMenu() self.treePopupMenu.insertItem("Collapse", 0) self.treePopupMenu.insertItem("Expand", 1) #self.treePopupMenu.insertItem("Hide", 2) self.treePopupMenu.insertItem("Unhide All", 3) #self.treePopupMenu.insertItem("Filter...", 4) self.connect(self.treePopupMenu, SIGN... |
os.remove(tracefile) | try: os.remove(tracefile) except OSError: print 'Warning: OSError in remove_old_tracefile' if os.path.exists(tracefile): raise print 'File got successfully deleted anyway, so ignore OSError' | def remove_old_tracefile(self, tracefile): #bruce 060101 "remove the tracefile if it exists, after warning anything that might care [nim]; can raise exceptions" if os.path.exists(tracefile): os.remove(tracefile) # can raise exception, e.g. due to directory permission error return |
if not self.alist: return for a in self.alist: self.copybasepos = + a.molecule.basepos | for m in self.molecules: m._savedbasepos = + m.basepos | def savebasepos(self): """Copy current atom positions into an array. """ if not self.alist: return for a in self.alist: self.copybasepos = + a.molecule.basepos |
if not self.alist: return for a in self.alist: a.molecule.basepos[a.index] = self.copybasepos[a.index] | for m in self.molecules: m.basepos = m.curpos = + m._savedbasepos | def restorebasepos(self): """Restore atom positions copied earlier by savebasepos(). """ if not self.alist: return for a in self.alist: a.molecule.basepos[a.index] = self.copybasepos[a.index] for b in self.blist.itervalues(): b.setup_invalidate() for m in self.molecules: m.changeapp(0) |
ma = self.selected_chunk.getaxis() self.selected_chunk.move(dx*ma) self.selected_chunk.rot(Q(ma,-dy)) self.find_bondable_pairs() | for mol in self.o.assy.selmols: ma = mol.getaxis() mol.move(dx*ma) mol.rot(Q(ma,-dy)) self.find_bondable_pairs() | def leftShiftDrag(self, event): """move chunk along its axis (mouse goes up or down) rotate around its axis (left-right) """ self.o.setCursor(self.w.MoveRotateMolCursor) w=self.o.width+0.0 h=self.o.height+0.0 deltaMouse = V(event.pos().x() - self.o.MousePos[0], self.o.MousePos[1] - event.pos().y()) a = dot(self.Zmat,... |
return + self.xyz | res = + self.xyz | def posn(self): """Return the absolute position of the atom in space. Public method, should be ok to call for any atom at any time. Private implementation note (fyi): this info is sometimes stored in the atom, and sometimes in its molecule. """ #bruce 041104,041112 revised docstring #bruce 041130 made this return copi... |
return + self.molecule.curpos[self.index] | res = + self.molecule.curpos[self.index] try: res * 1000 except: print_compact_stack("bug: atom position overflow for %r; setting position to 0,0,0: " % self) res = V(0,0,0) self.setposn(res) return res | def posn(self): """Return the absolute position of the atom in space. Public method, should be ok to call for any atom at any time. Private implementation note (fyi): this info is sometimes stored in the atom, and sometimes in its molecule. """ #bruce 041104,041112 revised docstring #bruce 041130 made this return copi... |
return selobj.a1.molecule.part is self.o.part | return selobj.atom1.molecule.part is self.o.part | def selobj_still_ok(self, selobj): #bruce 050702 added this to mode API """Say whether a highlighted mouseover object from a prior draw (in the same mode) is still ok. Default implem says yes unless it's been killed (assuming selobj provides a .killed() method). [overrides anyMode method; subclasses might want to overr... |
self.assemblyIcon = QPixmap("../images/assembly.png") self.csysIcon = QPixmap("../images/csys.png") self.datumPlaneIcon = QPixmap("../images/datumplane.png") self.partIcon = QPixmap("../images/part.png") self.motorIcon = QPixmap("../images/motor.png") self.insertHereIcon = QPixmap("../images/inserthere.png") | filePath = os.path.dirname(os.path.abspath(sys.argv[0])) self.assemblyIcon = QPixmap(filePath + "/../images/assembly.png") self.csysIcon = QPixmap(filePath + "/../images/csys.png") self.datumPlaneIcon = QPixmap(filePath + "/../images/datumplane.png") self.partIcon = QPixmap(filePath + "/../images/part.png") self.motorI... | def __init__(self, parent, win): QListView.__init__(self,parent,"modelTreeView") self.addColumn("Model Tree") #self.win = win1 |
if modelItem.__class__.__name__ == 'molecule': | if isinstance(modelItem, molecule): | def treeItemChanged(self, listItem): if self.lastSelectedItem: modelItem = self.treeItems[self.lastSelectedItem] if modelItem.__class__.__name__ == 'molecule': modelItem.setSelectionState(self, modelItem, False) |
if target.__class__.__name__ == 'molecule': | if isinstance(target, molecule): | def changeModelSelection(self, trigger, target, state): if self == trigger: #don't respond if it is triggered by itself return # Find the corresponding tree item for the target and set the state if target.__class__.__name__ == 'molecule': item = self.objectToTreeItems[target] self.setSelected(item, state) |
if clickedItem.__class__.__name__ == 'LinearMotor': | if isinstance(clickedItem, LinearMotor): | def processRightButton(self, listItem, pos, col): """ Context menu items function handler for the Model Tree View """ if col == -1: return if not listItem or not self.isSelected(listItem): return self.selectedTreeItem = listItem clickedItem = self.treeItems[listItem] |
elif clickedItem.__class__.__name__ == 'motor': | elif isinstance(clickedItem, motor): | def processRightButton(self, listItem, pos, col): """ Context menu items function handler for the Model Tree View """ if col == -1: return if not listItem or not self.isSelected(listItem): return self.selectedTreeItem = listItem clickedItem = self.treeItems[listItem] |
env.history.message(redmsg("Enter into 'Free View' of cookie cutter mode. No cookie can be cut until exit from it.")) | env.history.message(orangemsg("'Free View' enabled. You can not cut cookies while Free View is enabled.")) | def setFreeView(self, freeView): """When in this mode(freeView is true), cookie-cutting is freezing """ self.freeView = freeView if freeView: #Save current pov before free view transformation self.cookiePov = V(self.o.pov[0], self.o.pov[1], self.o.pov[2]) env.history.message(redmsg("Enter into 'Free View' of cookie cu... |
if MMKitWin: MMKitWin.change2PastePage() | if MMKitWin: MMKitWin.change2ClipboardPage() | def editPaste(self): if self.assy.shelf.members: env.history.message(greenmsg("Paste:")) self.glpane.setMode('DEPOSIT') global MMKitWin if MMKitWin: MMKitWin.change2PastePage() |
glpane.grabKeyboard() | def update_selobj(self, event): #bruce 050610 """Keep glpane.selobj up-to-date, as object under mouse, or None (whether or not that kind of object should get highlighted). Return True if selobj is already updated when we return, or False if that will not happen until the next paintGL. Warning: if selobj needs to change... | |
If an atom was double-clicked, select all the atoms reachable through any sequence of bonds to that atom. If the Control modkey is pressed, unselect all the atoms. | def leftDouble(self, event): # mark 060126. '''Double click event handler for the left mouse button. If an atom was double-clicked, select all the atoms reachable through any sequence of bonds to that atom. If the Control modkey is pressed, unselect all the atoms. ''' if self.cursor_over_when_LMB_pressed == 'Empty Spa... | |
modkey = self.modkey if self.modkey is None: self.modkey = 'Shift' for s in self.singlet_list[:]: if s is not self.obj_doubleclicked: self.deposit_from_MMKit(s) self.modkey = modkey | self.transdeposit_from_MMKit(self.singlet_list) | def leftDouble(self, event): # mark 060126. '''Double click event handler for the left mouse button. If an atom was double-clicked, select all the atoms reachable through any sequence of bonds to that atom. If the Control modkey is pressed, unselect all the atoms. ''' if self.cursor_over_when_LMB_pressed == 'Empty Spa... |
import multiarray | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
if "we should be faster": | import multiarray import OpenGL.GL import OpenGL.GLU import OpenGL.GLUT import OpenGL.GLE import sip import Numeric import numeric_version import _numpy import umath import Precision import ArrayPrinter import LinearAlgebra import lapack_lite import MLab import RandomArray import ranlib import idlelib.Delegator i... | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) |
import sip | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
import Numeric import numeric_version import _numpy import umath import Precision | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
import ArrayPrinter | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
import OpenGL.GL | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
import OpenGL.GLU import OpenGL.GLUT import OpenGL.GLE import LinearAlgebra import lapack_lite import MLab import RandomArray import ranlib | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
import idlelib.Delegator import Image import FixTk import _imaging import ImagePalette import array import ImageOps import PngImagePlugin import ImageFile | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
import ic import icglue import Carbon import _Res import Carbon.File import _File import macostools import MacOS | def __import__(*args, **kws): arg = args[0] print >>sys.stderr, "about to import " + arg # helps determine which module had the problem return _old_import(*args, **kws) | |
zflip = dot(csys.z, right) < 0 | xflip = dot(csys.z, right) < 0 | def drawLinearDimension(color, right, up, bpos, p0, p1, text, highlighted=False): outOfScreen = cross(right, up) bdiff = bpos - 0.5 * (p0 + p1) csys = CylindricalCoordinates(p0, p1 - p0, bdiff, right) # This works OK until we want to keep the text right side up, then the # criterion for right-side-up-ness changes becau... |
theoreticalRight = (zflip and -csys.z) or csys.z | theoreticalRight = (xflip and -csys.z) or csys.z | def drawLinearDimension(color, right, up, bpos, p0, p1, text, highlighted=False): outOfScreen = cross(right, up) bdiff = bpos - 0.5 * (p0 + p1) csys = CylindricalCoordinates(p0, p1 - p0, bdiff, right) # This works OK until we want to keep the text right side up, then the # criterion for right-side-up-ness changes becau... |
xflip = dot(theoreticalOutOfScreen, outOfScreen) < 0 def fx(y, xflip=xflip): if xflip: return br + 1.5 - y / (1. * HEIGHT) else: return br + 0.5 + y / (1. * HEIGHT) def fz(x, zflip=zflip): if zflip: return 0.9 - csys.zinv * x / (1. * WIDTH) else: return 0.1 + csys.zinv * x / (1. * WIDTH) | yflip = dot(theoreticalOutOfScreen, outOfScreen) < 0 if platform.atom_debug: print "DEBUG INFO FROM drawLinearDimension" print csys print theoreticalRight, theoreticalOutOfScreen print xflip, yflip if yflip: def fx(y): return br + 1.5 - y / (1. * HEIGHT) else: def fx(y): return br + 0.5 + y / (1. * HEIGHT) if xflip: de... | def drawLinearDimension(color, right, up, bpos, p0, p1, text, highlighted=False): outOfScreen = cross(right, up) bdiff = bpos - 0.5 * (p0 + p1) csys = CylindricalCoordinates(p0, p1 - p0, bdiff, right) # This works OK until we want to keep the text right side up, then the # criterion for right-side-up-ness changes becau... |
def add(element, x, y, z, mol=mol): | def add(element, x, y, z): | def add(element, x, y, z, mol=mol): atm = Atom(element, chem.V(x, y, z), mol) atm.set_atomtype("sp2") |
for m in range(mmin-1, mmax+1): | mfirst.append(mmin) mlast.append(mmax) for m in range(mmin, mmax+1): | def add(element, x, y, z, mol=mol): atm = Atom(element, chem.V(x, y, z), mol) atm.set_atomtype("sp2") |
if -.5 * length <= y <= .5 * length: add("C", x, y, z) | atm = add("C", x, y, z) evenAtomDict[(n,m)] = atm bondDict[atm] = [(n,m)] | def add(element, x, y, z, mol=mol): atm = Atom(element, chem.V(x, y, z), mol) atm.set_atomtype("sp2") |
if -.5 * length <= y <= .5 * length: add("C", x, y, z) | atm = add("C", x, y, z) oddAtomDict[(n,m)] = atm bondDict[atm] = [(n+1, m), (n, m+1)] n = self.n - 1 mmid = (mfirst[n] + mlast[n]) / 2 atm = oddAtomDict[(n, mmid)] class FoundMOffset(Exception): pass try: for m2 in range(mfirst[0], mlast[0] + 1): atm2 = evenAtomDict[(0, m2)] diff = atm.posn() - atm2.posn() if ... | def add(element, x, y, z, mol=mol): atm = Atom(element, chem.V(x, y, z), mol) atm.set_atomtype("sp2") |
from Numeric import dot | PROFILE = False if PROFILE: from debug import Stopwatch sw = Stopwatch() sw.start() | def buildChunk(self): from Numeric import dot length = self.length xyz = self.chirality.xyz atoms = self.mol.atoms mlimits = self.chirality.mlimits maxLen = 1.2 * Chirality.BONDLENGTH maxLenSq = maxLen ** 2 # populate the tube with some extra carbons on the ends # so that we can trim them later self.chirality.populate(... |
maxLen = 1.2 * Chirality.BONDLENGTH maxLenSq = maxLen ** 2 | def buildChunk(self): from Numeric import dot length = self.length xyz = self.chirality.xyz atoms = self.mol.atoms mlimits = self.chirality.mlimits maxLen = 1.2 * Chirality.BONDLENGTH maxLenSq = maxLen ** 2 # populate the tube with some extra carbons on the ends # so that we can trim them later self.chirality.populate(... | |
self.chirality.populate(self.mol, length + 4 * maxLen) | self.chirality.populate(self.mol, length + 4 * Chirality.MAXLEN) | def buildChunk(self): from Numeric import dot length = self.length xyz = self.chirality.xyz atoms = self.mol.atoms mlimits = self.chirality.mlimits maxLen = 1.2 * Chirality.BONDLENGTH maxLenSq = maxLen ** 2 # populate the tube with some extra carbons on the ends # so that we can trim them later self.chirality.populate(... |
voxels = { } for atm in atoms.values(): x, y, z = map(float, atm.posn()) idx = (int(x / maxLen), int(y / maxLen), int(z / maxLen)) try: voxels[idx].append(atm) except KeyError: voxels[idx] = [ atm ] for atm in atoms.values(): x, y, z = map(float, atm.posn()) x1 = int(x / maxLen) y1 = int(y / maxLen) z1 = int(z / max... | LENGTH_TWEAK = Chirality.BONDLENGTH | def buildChunk(self): from Numeric import dot length = self.length xyz = self.chirality.xyz atoms = self.mol.atoms mlimits = self.chirality.mlimits maxLen = 1.2 * Chirality.BONDLENGTH maxLenSq = maxLen ** 2 # populate the tube with some extra carbons on the ends # so that we can trim them later self.chirality.populate(... |
if y > .5 * (length + maxLen) or y < -.5 * (length + maxLen): | if (y > .5 * (length + LENGTH_TWEAK) or y < -.5 * (length + LENGTH_TWEAK)): | def closeEnough(atm2): if atm2 == atm or bonds.bonded(atm, atm2): return False x, y, z = map(float, atm2.posn()) if x < xmin or x > xmax: return False if y < ymin or y > ymax: return False if z < zmin or z > zmax: return False diff = atm.posn() - atm2.posn() return dot(diff, diff) < maxLenSq |
from platform import fix_plurals | def Invert(self): '''Invert the atoms of the selected chunk(s)''' cmd = greenmsg("Invert: ") if not self.selmols: msg = redmsg("No selected chunks to invert") self.w.history.message(cmd + msg) return self.changed() for m in self.selmols: m.stretch(-1.0) self.o.gl_update() from platform import fix_plurals info = fix_... | |
from platform import fix_plurals | def align(self): cmd = greenmsg("Align to Common Axis: ") if len(self.selmols) < 2: msg = redmsg("Need two or more selected chunks to align") self.w.history.message(cmd + msg) return self.changed() #bruce 050131 bugfix or precaution #ax = V(0,0,0) #for m in self.selmols: # ax += m.getaxis() #ax = norm(ax) ax = sel... | |
if v1 == v2: pass | if 0: if v1 == v2: pass else: res[key] = (v1,v2) | def diffdicts(d1, d2, dflt = None, whatret = 0): ###e dflt is problematic since we don't know it here and it might vary by obj or class """Given two dicts, return a new one with entries at keys where their values differ (according to ==), treating missing values as dflt (which is None if not provided, but many callers ... |
res[key] = (v1,v2) | if v1 != v2: res[key] = (v1,v2) else: pass | def diffdicts(d1, d2, dflt = None, whatret = 0): ###e dflt is problematic since we don't know it here and it might vary by obj or class """Given two dicts, return a new one with entries at keys where their values differ (according to ==), treating missing values as dflt (which is None if not provided, but many callers ... |
res[key] = pair[ind] | res[key] = copy_val(pair[ind]) | def diffdicts(d1, d2, dflt = None, whatret = 0): ###e dflt is problematic since we don't know it here and it might vary by obj or class """Given two dicts, return a new one with entries at keys where their values differ (according to ==), treating missing values as dflt (which is None if not provided, but many callers ... |
shakedown (of both involved molecules), or to clear externs if this molecule will be killed. | shakedown or kill (of both involved molecules). | def hopmol(self, numol): """move this atom to molecule numol. Caller is responsible for shakedown (of both involved molecules), or to clear externs if this molecule will be killed. We invalidate the externs of both involved molecules so that their erroneous use will be detected. """ if self.molecule == numol: return s... |
print_compact_stack("fyi: atom %r killed twice; ignoring:\n" % self) | if not self.element == Singlet: print_compact_stack("fyi: atom %r killed twice; ignoring:\n" % self) else: pass | def kill(self): """kill an atom: remove it from molecule.atoms, and remove bonds to it from its neighbors. caller is responsible for shakedown or kill of all affected molecules. """ if self.__killed: print_compact_stack("fyi: atom %r killed twice; ignoring:\n" % self) return self.__killed = 1 # do this now, to reduce r... |
drawn = {} self.externs = [] for atm in self.atoms.itervalues(): for bon in atm.bonds: if bon.key not in drawn: if bon.other(atm).molecule != self: self.externs += [bon] else: drawn[bon.key] = bon bon.setup() self.havelist = 0 | self.externs = INVALID_EXTERNS self.fix_externs() return def externs_valid(self): return type(self.externs) == type([]) def fix_externs(self): "if self.externs is marked as invalid, make it correct (and setup all bonds)" if type(self.externs) != type([]): assert self.externs == INVALID_EXTERNS drawn = {} self.extern... | 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 = [] #bruce 041029 take more precautions: se... |
if self.havelist: | if self.havelist and self.externs_valid(): | def draw(self, o, dispdef): """draw all the atoms, using the atom's, molecule's, or GLPane's display mode in that order of preference Use the hash table drawn to draw each bond only once, as each one will be referenced from two atoms If the molecule itself is selected, draw its bounding box as a wireframe o is a GLPane... |
mol.externs = [] | def merge(self, mol): """merge the given molecule into this one. assume they are in the same assy. """ pairlis = [] ndix = {} for a in mol.atoms.values(): a.hopmol(self) self.shakedown() mol.externs = [] mol.kill() | |
if a.picked and len(self.o.assy.selatoms_list()) > 1: | if a.picked: | def atomLeftDown(self, a, event): if not a.picked and self.o.modkeys is None: self.o.assy.unpickatoms() a.pick() if not a.picked and self.o.modkeys == 'Shift': a.pick() if a.picked and len(self.o.assy.selatoms_list()) > 1: # now called when two or more atoms are selected. mark 060202. self.cursor_over_when_LMB_pressed... |
self.drag_multiple_atoms = True self.atomsSetup(a) else: if a.picked: self.cursor_over_when_LMB_pressed = 'Picked Atom' else: self.cursor_over_when_LMB_pressed = 'Unpicked Atom' self.drag_multiple_atoms = False self.atomSetup(a) | else: self.cursor_over_when_LMB_pressed = 'Unpicked Atom' self.atomSetup(a) | def atomLeftDown(self, a, event): if not a.picked and self.o.modkeys is None: self.o.assy.unpickatoms() a.pick() if not a.picked and self.o.modkeys == 'Shift': a.pick() if a.picked and len(self.o.assy.selatoms_list()) > 1: # now called when two or more atoms are selected. mark 060202. self.cursor_over_when_LMB_pressed... |
self.baggage = [] self.nonbaggage = [] self.baggage, self.nonbaggage = a.baggage_and_other_neighbors() def atomsSetup(self, a): '''Setup for a click or double-click of real atom <a>, but also handles setup of dragging of real atom <a> and all other currently selected atoms. ''' self.objectSetup(a) self.baggage = [] se... | if len(self.o.assy.selatoms_list()) == 1: self.baggage, self.nonbaggage = a.baggage_and_other_neighbors() self.drag_multiple_atoms = False else: self.dragatoms, self.baggage = self.get_dragatoms_and_baggage() self.drag_multiple_atoms = True self.dragjigs = self.o.assy.getSelectedJigs() def get_dragatoms_and_baggage... | def atomSetup(self, a): '''Setup for a click, double-click or drag event for real atom <a>. ''' self.objectSetup(a) self.baggage = [] self.nonbaggage = [] self.baggage, self.nonbaggage = a.baggage_and_other_neighbors() |
baggage, nonbaggage = at.baggage_and_other_neighbors() self.baggage += baggage | bag, nbag = at.baggage_and_other_neighbors() baggage += bag | def atomsSetup(self, a): '''Setup for a click or double-click of real atom <a>, but also handles setup of dragging of real atom <a> and all other currently selected atoms. ''' self.objectSetup(a) self.baggage = [] self.nonbaggage = [] #all_nonbaggage = [] # NIY. mark 060202. selatoms = self.o.assy.selatoms_list() # A... |
if not at in self.baggage: self.dragobjs.append(at) | if not at in baggage: dragatoms.append(at) | def atomsSetup(self, a): '''Setup for a click or double-click of real atom <a>, but also handles setup of dragging of real atom <a> and all other currently selected atoms. ''' self.objectSetup(a) self.baggage = [] self.nonbaggage = [] #all_nonbaggage = [] # NIY. mark 060202. selatoms = self.o.assy.selatoms_list() # A... |
return dragatoms, baggage | def atomsSetup(self, a): '''Setup for a click or double-click of real atom <a>, but also handles setup of dragging of real atom <a> and all other currently selected atoms. ''' self.objectSetup(a) self.baggage = [] self.nonbaggage = [] #all_nonbaggage = [] # NIY. mark 060202. selatoms = self.o.assy.selatoms_list() # A... | |
if self.drag_multiple_atoms: self.atomsDrag(a, event) return apos0 = a.posn() | def atomDrag(self, a, event): """Drag real atom <a>. <event> is a drag event. """ if self.drag_multiple_atoms: self.atomsDrag(a, event) return apos0 = a.posn() px = self.dragto(a.posn(), event) apo = a.posn() delta = px - apo # xyz delta between new and current position of <a>. n = self.nonbaggage # n = real atoms... | |
self.atomDragUpdate(a, apos0) def atomsDrag(self, a, event): """Drag real atom <a> and all picked atoms. <event> is a drag event. """ apos0 = a.posn() px = self.dragto(a.posn(), event) apo = a.posn() delta = px - apo for at in self.dragobjs[:]: at.setposn(at.posn()+delta) | def drag_selected_atoms(self, offset): for at in self.dragatoms[:]: at.setposn(at.posn()+offset) | def atomDrag(self, a, event): """Drag real atom <a>. <event> is a drag event. """ if self.drag_multiple_atoms: self.atomsDrag(a, event) return apos0 = a.posn() px = self.dragto(a.posn(), event) apo = a.posn() delta = px - apo # xyz delta between new and current position of <a>. n = self.nonbaggage # n = real atoms... |
at.setposn(at.posn()+delta) self.atomDragUpdate(a, apos0) | at.setposn(at.posn()+offset) | def atomsDrag(self, a, event): """Drag real atom <a> and all picked atoms. <event> is a drag event. """ # atomsDrag() behaves differently than atomDrag() in that nonbaggage atoms # and their own baggage are not used or moved in any way. I used to think this # was a feature and not a bug, but I'm pretty sure I was wron... |
def bondLeftDrag(self, event): | def bondDrag(self, event): | def bondLeftDrag(self, event): # If a LMB+Drag event has happened after selecting a bond in left*Down(), # do a 2D region selection as if the bond were absent. This takes care of # both Shift and Control mod key cases. self.cursor_over_when_LMB_pressed = 'Empty Space' self.select_2d_region(self.LMB_press_event) self.cu... |
self.dragobjs = [] | self.dragatoms = [] | def reset_drag_vars(self): #bruce 041124 split this out of Enter; as of 041130, # required bits of it are inlined into Down methods as bugfixes self.cursor_over_when_LMB_pressed = None # <cursor_over_when_LMB_pressed> keeps track of what the cursor was over # when the LMB was pressed, which can be one of: # 'Empty Sp... |
self.atoms_of_last_deleted_jig = [] | def reset_drag_vars(self): #bruce 041124 split this out of Enter; as of 041130, # required bits of it are inlined into Down methods as bugfixes self.cursor_over_when_LMB_pressed = None # <cursor_over_when_LMB_pressed> keeps track of what the cursor was over # when the LMB was pressed, which can be one of: # 'Empty Sp... | |
a = self.o.selatom if a is None and self.o.selobj: a = self.o.selobj | obj = self.o.selatom if obj is None and self.o.selobj: obj = self.o.selobj if obj is None: obj = self.get_jig_under_cursor(event) | def get_obj_under_cursor(self, event): '''Return the object under the cursor. Only atoms, singlets and bonds are returned. Returns None for all other cases, including when a bond, jig or nothing is under the cursor. ''' if self.hover_highlighting_enabled: self.update_selatom(event) #bruce 041130 in case no update_sela... |
a = self.o.assy.findAtomUnderMouse(event, self.water_enabled, singlet_ok = True) | obj = self.o.assy.findAtomUnderMouse(event, self.water_enabled, singlet_ok = True) | def get_obj_under_cursor(self, event): '''Return the object under the cursor. Only atoms, singlets and bonds are returned. Returns None for all other cases, including when a bond, jig or nothing is under the cursor. ''' if self.hover_highlighting_enabled: self.update_selatom(event) #bruce 041130 in case no update_sela... |
return a | return obj | def get_obj_under_cursor(self, event): '''Return the object under the cursor. Only atoms, singlets and bonds are returned. Returns None for all other cases, including when a bond, jig or nothing is under the cursor. ''' if self.hover_highlighting_enabled: self.update_selatom(event) #bruce 041130 in case no update_sela... |
a = self.get_obj_under_cursor(event) if isinstance(a, Atom): if not a.is_singlet(): return a | obj = self.get_obj_under_cursor(event) if isinstance(obj, Atom): if not obj.is_singlet(): return obj | def get_real_atom_under_cursor(self, event): '''If the object under the cursor is a real atom, return it. Otherwise, return None. ''' a = self.get_obj_under_cursor(event) if isinstance(a, Atom): if not a.is_singlet(): return a return None |
return None | if self.o.modkeys == 'Shift+Control': return darkred else: return env.prefs[bondHighlightColor_prefs_key] | def selobj_highlight_color(self, selobj): #bruce 050612 added this to mode API """[mode API method] If we'd like this selobj to be highlighted on mouseover (whenever it's stored in glpane.selobj), return the desired highlight color. If we'd prefer it not be highlighted (though it will still be stored in glpane.selobj a... |
if isinstance(obj, Bond): self.bondLeftDrag(event) return if isinstance(obj, Atom) and obj.is_singlet(): self.singletDrag(obj, event) if isinstance(obj, Atom) and not obj.is_singlet(): self.atomDrag(obj, event) | if isinstance(obj, Atom): if obj.is_singlet(): self.singletDrag(obj, event) else: self.atomDrag(obj, event) elif isinstance(obj, Bond): self.bondDrag(event) elif isinstance(obj, Jig): self.jigDrag(obj, event) else: pass | def leftDrag(self, event): '''Event handler for all LMB+Drag events.''' # Do not change the order of the following conditionals unless you know # what you're doing. mark 060208. if self.mouse_within_stickiness_limit(event, DRAG_STICKINESS_LIMIT): return obj = self.current_obj if self.cursor_over_when_LMB_pressed =... |
if isinstance(obj, Atom) and obj.is_singlet(): self.singletLeftUp(obj, event) if isinstance(obj, Atom) and not obj.is_singlet(): self.atomLeftUp(obj, event) if isinstance(obj, Bond): | if isinstance(obj, Atom): if obj.is_singlet(): self.singletLeftUp(obj, event) else: self.atomLeftUp(obj, event) elif isinstance(obj, Bond): | def leftUp(self, event): '''Event handler for all LMB release events.''' env.history.flush_saved_transients() # flush any transient message it saved up if self.ignore_next_leftUp_event: # This event is the second leftUp of a double click, so ignore it. self.ignore_next_leftUp_event = False self.update_selobj(event) # ... |
self.singletLeftDouble() | def leftDouble(self, event): # mark 060126. '''Double click event handler for the left mouse button. ''' self.ignore_next_leftUp_event = True if isinstance(self.obj_doubleclicked, Atom): if self.obj_doubleclicked.is_singlet(): # Double-clicking on a singlet should do nothing. return else: # real atom if self.o.modke... | |
else: if self.o.modkeys == 'Control': self.o.assy.unselectConnected( [ self.obj_doubleclicked ] ) elif self.o.modkeys == 'Shift+Control': self.o.assy.deleteConnected( self.neighbors_of_last_deleted_atom ) else: self.o.assy.selectConnected( [ self.obj_doubleclicked ] ) | else: self.atomLeftDouble() | def leftDouble(self, event): # mark 060126. '''Double click event handler for the left mouse button. ''' self.ignore_next_leftUp_event = True if isinstance(self.obj_doubleclicked, Atom): if self.obj_doubleclicked.is_singlet(): # Double-clicking on a singlet should do nothing. return else: # real atom if self.o.modke... |
if self.o.modkeys == 'Control': self.o.assy.unselectConnected( [ self.obj_doubleclicked.atom1 ] ) elif self.o.modkeys == 'Shift+Control': self.o.assy.deleteConnected( [ self.obj_doubleclicked.atom1, self.obj_doubleclicked.atom2 ] ) else: self.o.assy.selectConnected( [ self.obj_doubleclicked.atom1 ] ) | self.bondLeftDouble() if isinstance(self.obj_doubleclicked, Jig): self.jigLeftDouble() | def leftDouble(self, event): # mark 060126. '''Double click event handler for the left mouse button. ''' self.ignore_next_leftUp_event = True if isinstance(self.obj_doubleclicked, Atom): if self.obj_doubleclicked.is_singlet(): # Double-clicking on a singlet should do nothing. return else: # real atom if self.o.modke... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.