diff options
author | Mark Sims <mark@nanorex.com> | 2008-12-25 20:14:41 +0000 |
---|---|---|
committer | Mark Sims <mark@nanorex.com> | 2008-12-25 20:14:41 +0000 |
commit | 55151bc18b01281c65062d13ef517c7edf9a130a (patch) | |
tree | 1af56afb3b6c8265642cad3d4d04e81b44699be0 | |
parent | 9c5eb33983679a78db83d9da5f8e4cf77466a1a4 (diff) | |
download | nanoengineer-55151bc18b01281c65062d13ef517c7edf9a130a.tar.gz nanoengineer-55151bc18b01281c65062d13ef517c7edf9a130a.zip |
Renamed class "Nanotube" to "NanotubeParameters" since it contains parameters for making a nanotube, not a nanotube model object itself.
-rw-r--r-- | cad/src/cnt/commands/InsertNanotube/InsertNanotube_PropertyManager.py | 10 | ||||
-rw-r--r-- | cad/src/cnt/commands/NanotubeSegment/NanotubeSegment_EditCommand.py | 6 | ||||
-rw-r--r-- | cad/src/cnt/model/NanotubeParameters.py (renamed from cad/src/cnt/model/Nanotube.py) | 43 | ||||
-rw-r--r-- | cad/src/cnt/model/NanotubeSegment.py | 8 |
4 files changed, 48 insertions, 19 deletions
diff --git a/cad/src/cnt/commands/InsertNanotube/InsertNanotube_PropertyManager.py b/cad/src/cnt/commands/InsertNanotube/InsertNanotube_PropertyManager.py index 1a8979d3e..3cd4ca157 100644 --- a/cad/src/cnt/commands/InsertNanotube/InsertNanotube_PropertyManager.py +++ b/cad/src/cnt/commands/InsertNanotube/InsertNanotube_PropertyManager.py @@ -12,10 +12,6 @@ Mark 2008-03-09: __author__ = "Mark" - - -from cnt.model.Nanotube import Nanotube - from PyQt4.Qt import SIGNAL from PyQt4.Qt import Qt from PyQt4.Qt import QAction @@ -29,7 +25,6 @@ from PM.PM_ToolButton import PM_ToolButton from PM.PM_CoordinateSpinBoxes import PM_CoordinateSpinBoxes from PM.PM_CheckBox import PM_CheckBox -from command_support.DnaOrCnt_PropertyManager import DnaOrCnt_PropertyManager from geometry.VQT import V from PM.PM_Constants import PM_DONE_BUTTON from PM.PM_Constants import PM_WHATS_THIS_BUTTON @@ -43,6 +38,9 @@ from utilities.prefs_constants import insertNanotubeEditCommand_showCursorTextCh from widgets.prefs_widgets import connect_checkbox_with_boolean_pref +from cnt.model.NanotubeParameters import NanotubeParameters + +from command_support.DnaOrCnt_PropertyManager import DnaOrCnt_PropertyManager _superclass = DnaOrCnt_PropertyManager class InsertNanotube_PropertyManager( DnaOrCnt_PropertyManager): @@ -73,7 +71,7 @@ class InsertNanotube_PropertyManager( DnaOrCnt_PropertyManager): self.endPoint1 = None self.endPoint2 = None - self.nanotube = Nanotube() # A 5x5 CNT. + self.nanotube = NanotubeParameters() # A 5x5 CNT. _superclass.__init__( self, command) diff --git a/cad/src/cnt/commands/NanotubeSegment/NanotubeSegment_EditCommand.py b/cad/src/cnt/commands/NanotubeSegment/NanotubeSegment_EditCommand.py index 02d199ea8..d97d61724 100644 --- a/cad/src/cnt/commands/NanotubeSegment/NanotubeSegment_EditCommand.py +++ b/cad/src/cnt/commands/NanotubeSegment/NanotubeSegment_EditCommand.py @@ -349,8 +349,8 @@ class NanotubeSegment_EditCommand(State_preMixin, EditCommand): n, m, type, endings, endPoint1, endPoint2 = self._gatherParameters() - from cnt.model.Nanotube import Nanotube - self.nanotube = Nanotube() + from cnt.model.NanotubeParameters import NanotubeParameters + self.nanotube = NanotubeParameters() nanotube = self.nanotube nanotube.setChirality(n, m) nanotube.setType(type) @@ -670,7 +670,7 @@ class NanotubeSegment_EditCommand(State_preMixin, EditCommand): ##self._modifyStructure(params) ############################################ - self.nanotube = Nanotube() #@ Creates 5x5 CNT. Miisng PM params. + self.nanotube = NanotubeParameters() #@ Creates 5x5 CNT. Missing PM params. length_diff = self._determine_how_to_change_length() ladderEndAxisAtom = self.get_axisEndAtom_at_resize_end() #@ diff --git a/cad/src/cnt/model/Nanotube.py b/cad/src/cnt/model/NanotubeParameters.py index 778fa41ad..6a050f5a5 100644 --- a/cad/src/cnt/model/Nanotube.py +++ b/cad/src/cnt/model/NanotubeParameters.py @@ -1,6 +1,6 @@ # Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details. """ -Nanotube.py -- Nanotube generator helper classes, based on empirical data. +NanotubeParameters.py -- Generates Nanotube from parameters. @author: Mark Sims @version: $Id$ @@ -43,10 +43,10 @@ sqrt3 = 3 ** 0.5 ##if not basepath_ok: ## env.history.message(orangemsg("The cad/plugins/Nanotube directory is missing.")) -class Nanotube: +class NanotubeParameters: """ - Nanotube class. Supports both Carbon Nanotubes (CNTs) or Boron Nitride - Nanotubes (BNNT). + Generates a nanotube from parameters. Supports both Carbon Nanotubes (CNTs) + or Boron Nitride Nanotubes (BNNT). """ n = 5 m = 5 @@ -72,6 +72,7 @@ class Nanotube: self.setBondLength() self._computeRise() # Assigns default rise value. self._update() + return def _update(self): """ @@ -479,7 +480,8 @@ class Nanotube: def add(element, x, y, z, atomtype='sp2'): atm = Atom(element, V(x, y, z), mol) - atm.set_atomtype_but_dont_revise_singlets(atomtype) + if element == "C": + atm.set_atomtype_but_dont_revise_singlets(atomtype) return atm evenAtomDict = { } @@ -741,7 +743,36 @@ class Nanotube: # Bruce suggested I add this. It works here, but not if its # before move() and rot() above. Mark 2008-04-11 - cntChunk.full_inval_and_update() + cntChunk.full_inval_and_update() + return + + # override abstract method of DataMixin + def _copyOfObject(self, copyfunc): + """ + Create and return a copy of nanotube. + """ + nanotube = NanotubeParameters() + return nanotube + + # override abstract method of DataMixin + def __eq__(self, other): + """ + Compare. + """ + if self.n != other.n: + return False + elif self.m != other.m: + return False + elif self.n != other.n: + return False + elif self.type != other.type: + return False + elif self.endings != other.endings: + return False + else: + return True + pass + pass diff --git a/cad/src/cnt/model/NanotubeSegment.py b/cad/src/cnt/model/NanotubeSegment.py index 1cd52a2ee..965d09790 100644 --- a/cad/src/cnt/model/NanotubeSegment.py +++ b/cad/src/cnt/model/NanotubeSegment.py @@ -112,8 +112,8 @@ class NanotubeSegment(LeafLikeGroup): self.type = type.lstrip() self.endings = endings.lstrip() # Create the nanotube. - from cnt.model.Nanotube import Nanotube - self.nanotube = Nanotube() # Returns a 5x5 CNT. + from cnt.model.NanotubeParameters import NanotubeParameters + self.nanotube = NanotubeParameters() # Returns a 5x5 CNT. self.nanotube.setChirality(self.n, self.m) self.nanotube.setType(self.type) self.nanotube.setEndings(self.endings) @@ -173,8 +173,8 @@ class NanotubeSegment(LeafLikeGroup): """ (_n, _m), _type, _endings, (_endPoint1, _endPoint2) = props - from cnt.model.Nanotube import Nanotube - self.nanotube = Nanotube() + from cnt.model.NanotubeParameters import NanotubeParameters + self.nanotube = NanotubeParameters() self.nanotube.setChirality(_n, _m) self.nanotube.setType(_type) self.nanotube.setEndings(_endings) |