summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Smith <bruce@nanorex.com>2009-01-12 23:43:33 +0000
committerBruce Smith <bruce@nanorex.com>2009-01-12 23:43:33 +0000
commiteedffc4ad72c0bf596cbeee66ee0c633b208517c (patch)
tree54fe8dcb1a5bb876e2bf5045b86e36dabf1a745c
parentc0e1948c73472001c41d4b60e0919c50f15f1cca (diff)
downloadnanoengineer-eedffc4ad72c0bf596cbeee66ee0c633b208517c.tar.gz
nanoengineer-eedffc4ad72c0bf596cbeee66ee0c633b208517c.zip
moved oneUnbonded function to make_Atom_and_bondpoints method
-rwxr-xr-xcad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py14
-rwxr-xr-xcad/src/commands/InsertHeterojunction/CoNTubGenerator.py6
-rwxr-xr-xcad/src/graphics/widgets/ThumbView.py8
-rwxr-xr-xcad/src/model/chem.py38
-rw-r--r--cad/src/model/virtual_site_indicators.py9
-rwxr-xr-xcad/src/operations/ops_atoms.py51
6 files changed, 64 insertions, 62 deletions
diff --git a/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py b/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py
index ae29c8194..049d9eb20 100755
--- a/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py
+++ b/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py
@@ -1,4 +1,4 @@
-# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
BuildAtoms_GraphicsMode.py
@@ -13,7 +13,7 @@ For example:
@version: $Id$
-@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details.
+@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details.
TODO: [as of 2008-01-04]
- Items mentioned in Select_GraphicsMode.py
@@ -63,7 +63,6 @@ from platform_dependent.PlatformDependent import fix_plurals
from model.chunk import Chunk
from model.chem import Atom
-from model.chem import oneUnbonded
from model.elements import Singlet
from geometry.VQT import Q, A, norm, twistor
@@ -1061,10 +1060,10 @@ class BuildAtoms_basicGraphicsMode(SelectAtoms_basicGraphicsMode):
else: # Deposit atom at the cursor position and prep it for dragging
cursorPos = atom_or_pos
- a = self.o.selatom = oneUnbonded(atype.element,
- self.o.assy,
- cursorPos,
- atomtype = atype)
+ a = self.o.assy.make_Atom_and_bondpoints(atype.element,
+ cursorPos,
+ atomtype = atype )
+ self.o.selatom = a
self.objectSetup(a)
self.baggage, self.nonbaggage = a.baggage_and_other_neighbors()
if self.pickit():
@@ -1074,7 +1073,6 @@ class BuildAtoms_basicGraphicsMode(SelectAtoms_basicGraphicsMode):
chunk = self.o.selatom.molecule #bruce 041207
return chunk, status
-
def ensure_visible(self, stuff, status):
"""
diff --git a/cad/src/commands/InsertHeterojunction/CoNTubGenerator.py b/cad/src/commands/InsertHeterojunction/CoNTubGenerator.py
index d27a4ba1f..24500b50b 100755
--- a/cad/src/commands/InsertHeterojunction/CoNTubGenerator.py
+++ b/cad/src/commands/InsertHeterojunction/CoNTubGenerator.py
@@ -1,4 +1,4 @@
-# Copyright 2006-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2006-2009 Nanorex, Inc. See LICENSE file for details.
"""
CoNTubGenerator.py
@@ -6,7 +6,7 @@ Generator functions which use cad/plugins/CoNTub.
@author: Bruce
@version: $Id$
-@copyright: 2006-2008 Nanorex, Inc. See LICENSE file for details.
+@copyright: 2006-2009 Nanorex, Inc. See LICENSE file for details.
Also intended as a prototype of code which could constitute the nE-1 side
of a "generator plugin API". Accordingly, the CoNTub-specific code should
@@ -619,7 +619,7 @@ class PluginlikeGenerator:
n = max(params[0],1)
for x in range(n):
for y in range(2):
- ## build methane, from oneUnbonded
+ ## build methane, much like make_Atom_and_bondpoints method does it
pos = V(x,y,0)
atm = Atom('C', pos, mol)
atm.make_bondpoints_when_no_bonds() # notices atomtype
diff --git a/cad/src/graphics/widgets/ThumbView.py b/cad/src/graphics/widgets/ThumbView.py
index 8b00a73d6..20262c5fb 100755
--- a/cad/src/graphics/widgets/ThumbView.py
+++ b/cad/src/graphics/widgets/ThumbView.py
@@ -1,4 +1,4 @@
-# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
ThumbView.py - a simpler OpenGL widget, similar to GLPane
(which unfortunately has a lot of duplicated but partly modified
@@ -6,7 +6,7 @@ code copied from GLPane)
@author: Huaicai
@version: $Id$
-@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details.
+@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
from Numeric import dot
@@ -734,7 +734,7 @@ class ElementView(ThumbView):
def constructModel(self, elm, pos, dispMode):
"""
- This is to try to repeat what 'oneUnbonded()' function does,
+ This is to try to repeat what 'make_Atom_and_bondpoints()' method does,
but hope to remove some stuff not needed here.
The main purpose is to build the geometry model for element display.
@@ -872,7 +872,7 @@ class MMKitView(ThumbView):
def constructModel(self, elm, pos, dispMode):
"""
- This is to try to repeat what 'oneUnbonded()' function does,
+ This is to try to repeat what 'make_Atom_and_bondpoints()' method does,
but hope to remove some stuff not needed here.
The main purpose is to build the geometry model for element display.
diff --git a/cad/src/model/chem.py b/cad/src/model/chem.py
index 11537efbc..4c0d565e7 100755
--- a/cad/src/model/chem.py
+++ b/cad/src/model/chem.py
@@ -100,7 +100,6 @@ from utilities.constants import atKey
# read from an mmp file), so we now require this in the future even if the
# key type is changed. [Note: this comment appears in two files.]
-from utilities.constants import gensym
from utilities.constants import intRound
from utilities.constants import diDEFAULT
@@ -4770,43 +4769,6 @@ register_class_changedicts( Atom, _Atom_global_dicts )
# ==
-def oneUnbonded(elem, assy, pos, atomtype = None, Chunk_class = None):
- """
- Create one unbonded atom, of element elem
- and (if supplied) the given atomtype
- (otherwise the default atomtype for elem),
- at position pos, in its own new chunk,
- with enough bondpoints to have no valence error.
-
- @param Chunk_class: constructor for the returned atom's new chunk
- (assy.Chunk by default)
-
- @return: one newly created Atom object, already placed into a new
- chunk which has been added to the model using addnode
- """
- #bruce 041215 moved this from chunk.py to chem.py, and split part of it
- # into the new atom method make_bondpoints_when_no_bonds, to help fix bug 131.
- #bruce 050510 added atomtype option
- #bruce 080520 added Chunk_class option
- #todo: refile into operations, maybe as an assy or part method
- if Chunk_class is None:
- Chunk_class = assy.Chunk
- chunk = Chunk_class(assy, 'bug') # name is reset below!
- atom = Atom(elem.symbol, pos, chunk)
- # bruce 041124 revised name of new chunk, was gensym('Chunk.');
- # no need for gensym since atom key makes the name unique, e.g. C1.
- atom.set_atomtype_but_dont_revise_singlets(atomtype)
- # ok to pass None, type name, or type object; this verifies no change in elem
- # note, atomtype might well already be the value we're setting;
- # if it is, this should do nothing
- ## chunk.name = "Chunk-%s" % str(atom)
- chunk.name = gensym("Chunk", assy) #bruce 080407 per Mark NFR desire
- atom.make_bondpoints_when_no_bonds() # notices atomtype
- assy.addnode(chunk)
- return atom
-
-# ==
-
def move_atoms_and_normalize_bondpoints(alist, newPositions):
"""
Move the atoms in alist to the new positions in the given array or sequence
diff --git a/cad/src/model/virtual_site_indicators.py b/cad/src/model/virtual_site_indicators.py
index 07f179f34..09e743150 100644
--- a/cad/src/model/virtual_site_indicators.py
+++ b/cad/src/model/virtual_site_indicators.py
@@ -1,4 +1,4 @@
-# Copyright 2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2008-2009 Nanorex, Inc. See LICENSE file for details.
"""
virtual_site_indicators.py - graphical indicators related to virtual sites
(as used in the current GROMACS implementation of the PAM5 force field);
@@ -7,7 +7,7 @@ not as part of their implementation for minimize.
@author: Bruce
@version: $Id$
-@copyright: 2008 Nanorex, Inc. See LICENSE file for details.
+@copyright: 2008-2009 Nanorex, Inc. See LICENSE file for details.
"""
from model.jigs import Jig
@@ -405,9 +405,8 @@ def make_virtual_site( assy, parent_atoms, site_params, MT_name = None):
"""
@return: ( object to assign to site_atom_id, list of nodes to add to MT )
"""
- from model.chem import oneUnbonded
from model.elements import Vs0
- site_atom = oneUnbonded(Vs0, assy, V(0,0,0), Chunk_class = VirtualSiteChunk)
+ site_atom = assy.make_Atom_and_bondpoints(Vs0, V(0,0,0), Chunk_class = VirtualSiteChunk)
jig = VirtualSiteJig(assy, parent_atoms + [site_atom])
jig.setProps(site_params) # so it knows how to compute site_position
jig._update_site_atom_position()
@@ -432,7 +431,7 @@ def add_virtual_site(assy, parent_atoms, site_params, MT_name = None):
site_atom, nodes = make_virtual_site( assy, parent_atoms, site_params, MT_name = MT_name)
for node in nodes:
assy.addnode(node) # todo: add them in a better place?
- # review: redundant with oneUnbonded?
+ # review: redundant with make_Atom_and_bondpoints?
return site_atom
# ==
diff --git a/cad/src/operations/ops_atoms.py b/cad/src/operations/ops_atoms.py
index 0c8e922ec..5fd30a739 100755
--- a/cad/src/operations/ops_atoms.py
+++ b/cad/src/operations/ops_atoms.py
@@ -1,11 +1,11 @@
-# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
ops_atoms.py -- operations on the atoms and/or bonds inside a Part.
These operations generally create or destroy atoms, bondpoints, or real bonds.
Operations specific to single modes (Build, Crystal, Extrude) are not included here.
@version: $Id$
-@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details.
+@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details.
History:
@@ -16,9 +16,13 @@ from existing modules, from class Part and class basicMode.
from utilities.Log import greenmsg, redmsg
from utilities.constants import SELWHAT_CHUNKS, SELWHAT_ATOMS
+from utilities.constants import gensym
from platform_dependent.PlatformDependent import fix_plurals
+
from model.elements import Singlet
+from model.chem import Atom
+
import foundation.env as env
class ops_atoms_Mixin:
@@ -26,7 +30,47 @@ class ops_atoms_Mixin:
Mixin class for providing these methods to class Part
"""
- def modifyTransmute(self, elem, force = False, atomType=None):
+ def make_Atom_and_bondpoints(self,
+ elem,
+ pos,
+ atomtype = None,
+ Chunk_class = None ):
+ """
+ Create one unbonded atom, of element elem
+ and (if supplied) the given atomtype
+ (otherwise the default atomtype for elem),
+ at position pos, in its own new chunk,
+ with enough bondpoints to have no valence error.
+
+ @param Chunk_class: constructor for the returned atom's new chunk
+ (self.assy.Chunk by default)
+
+ @return: one newly created Atom object, already placed into a new
+ chunk which has been added to the model using addnode
+ """
+ #bruce 041215 moved this from chunk.py to chem.py, and split part of it
+ # into the new atom method make_bondpoints_when_no_bonds, to help fix bug 131.
+ #bruce 050510 added atomtype option
+ #bruce 080520 added Chunk_class option
+ #bruce 090112 renamed oneUnbonded function and turned it into this method
+ assy = self.assy
+ if Chunk_class is None:
+ Chunk_class = assy.Chunk
+ chunk = Chunk_class(assy, 'bug') # name is reset below!
+ atom = Atom(elem.symbol, pos, chunk)
+ # bruce 041124 revised name of new chunk, was gensym('Chunk.');
+ # no need for gensym since atom key makes the name unique, e.g. C1.
+ atom.set_atomtype_but_dont_revise_singlets(atomtype)
+ # ok to pass None, type name, or type object; this verifies no change in elem
+ # note, atomtype might well already be the value we're setting;
+ # if it is, this should do nothing
+ ## chunk.name = "Chunk-%s" % str(atom)
+ chunk.name = gensym("Chunk", assy) #bruce 080407 per Mark NFR desire
+ atom.make_bondpoints_when_no_bonds() # notices atomtype
+ assy.addnode(chunk) # REVIEW: same as self.addnode?
+ return atom
+
+ def modifyTransmute(self, elem, force = False, atomType = None):
"""
This method was originally a method of class mode and selectMode.
Transmute selected atoms into <elem> and with an optional <atomType>.
@@ -61,7 +105,6 @@ class ops_atoms_Mixin:
return
-
def modifyDeleteBonds(self):
"""
Delete all bonds between selected and unselected atoms or chunks