diff options
author | Mark Sims <mark@nanorex.com> | 2008-12-25 19:43:10 +0000 |
---|---|---|
committer | Mark Sims <mark@nanorex.com> | 2008-12-25 19:43:10 +0000 |
commit | 9c5eb33983679a78db83d9da5f8e4cf77466a1a4 (patch) | |
tree | 4e36e53b334b02f79b602b7eb5e831d53c6f2a47 /cad/src/outtakes | |
parent | d0ed63d5f4a552c2b73334b2c7ed50bb07967415 (diff) | |
download | nanoengineer-theirix-9c5eb33983679a78db83d9da5f8e4cf77466a1a4.tar.gz nanoengineer-theirix-9c5eb33983679a78db83d9da5f8e4cf77466a1a4.zip |
Deprecated NanotubeGroup class. Also updated some file docstrings.
Diffstat (limited to 'cad/src/outtakes')
-rw-r--r-- | cad/src/outtakes/NanotubeGroup.py | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/cad/src/outtakes/NanotubeGroup.py b/cad/src/outtakes/NanotubeGroup.py new file mode 100644 index 000000000..3e59b8050 --- /dev/null +++ b/cad/src/outtakes/NanotubeGroup.py @@ -0,0 +1,200 @@ +# Copyright 2007-2008 Nanorex, Inc. See LICENSE file for details. +""" +NanotubeGroup.py - ... + +@author: Bruce, Mark +@version: $Id$ +@copyright: 2007-2008 Nanorex, Inc. See LICENSE file for details. +""" + +from foundation.Group import Group + +from utilities.constants import gensym + +from utilities.icon_utilities import imagename_to_pixmap + +from utilities import debug_flags + +from utilities.debug import print_compact_stack + + +class NanotubeGroup(Group): + """ + Model object which packages together some Dna Segments, Dna Strands, + and other objects needed to represent all their PAM atoms and markers. + + Specific kinds of Group member contents include: + - NanotubeSegments (optionally inside Groups) + - Groups (someday might be called Blocks when they occur in this context; + note that class Block is deprecated and should not be used for these) + - DnaMarkers (a kind of Jig, always inside an owning NanotubeSegment) + + As other attributes: + - whatever other properties the user needs to assign, which are not + covered by the member nodes or superclass attributes. [nim?] + """ + + # This should be a tuple of classifications that appear in + # files_mmp._GROUP_CLASSIFICATIONS, most general first. + # See comment in class Group for more info. [bruce 080115] + _mmp_group_classifications = ('NanotubeGroup',) + + # Open/closed state of the Dna Group in the Model Tree -- + # default closed. + open = False + + autodelete_when_empty = True + # (but only if current command permits that for this class -- + # see comment near Group.autodelete_when_empty for more info, + # and implems of Command.keep_empty_group) + + def node_icon(self, display_prefs): + """ + Model Tree node icon for the nanotube group node + @see: Group.all_content_is_hidden() + """ + open = display_prefs.get('open', False) + if open: + if self.all_content_is_hidden(): + return imagename_to_pixmap("modeltree/NanotubeGroup-expanded-hide.png") + else: + return imagename_to_pixmap("modeltree/NanotubeGroup-expanded.png") + else: + if self.all_content_is_hidden(): + return imagename_to_pixmap("modeltree/NanotubeGroup-collapsed-hide.png") + else: + return imagename_to_pixmap("modeltree/NanotubeGroup-collapsed.png") + + # Note: some methods below this point are examples or experiments or stubs, + # and are likely to be revised significantly or replaced. + # [bruce 080115 comment] + + # example method: + def getSegments(self): + """ + Return a list of all our NanotubeSegment objects. + """ + return self.get_topmost_subnodes_of_class(self.assy.NanotubeSegment) + + def isEmpty(self): + """ + Returns True if there are no nanotube chunks as its members + (Returns True even when there are empty NanotubeSegment objects inside) + + @see: BuildNanotube_EditCommand._finalizeStructure where this test is used. + """ + #May be for the short term, we can use self.getAtomList()? But that + #doesn't ensure if the DnaGroup always has atom of type either + #'strand' or 'axis' . + if len(self.getSegments()) == 0: + return True + else: + return False + + def addSegment(self, segment): + """ + Adds a new segment object for this dnaGroup. + + @param segment: The NanotubeSegment to be added to this NanotubeGroup object + @type: B{NanotubeSegment} + """ + self.addchild(segment) + + def getProps(self): + """ + Method to support Dna duplex editing. see Group.__init__ for + a comment + + THIS IS THE DEFAULT IMPLEMENTATION. TO BE MODIFIED + """ + #Should it supply the Dna Segment list (children) and then add + #individual segments when setProps is called?? + # [probably not; see B&N email discussion from when this comment was added] + if self.editCommand: + props = () + return props + + def setProps(self, props): + """ + Method to support Dna duplex editing. see Group.__init__ for + a comment + THIS IS THE DEFAULT IMPLEMENTATION. TO BE MODIFIED + """ + #Should it accept the Dna Segment list and then add individual segments? + pass + + def edit(self): + """ + @see: Group.edit() + """ + commandSequencer = self.assy.w.commandSequencer + commandSequencer.userEnterCommand('BUILD_NANOTUBE', always_update = True) + currentCommand = commandSequencer.currentCommand + assert currentCommand.commandName == 'BUILD_NANOTUBE' + currentCommand.editStructure(self) + + + def getSelectedSegments(self): + """ + Returns a list of segments whose all members are selected. + @return: A list containing the selected strand objects + within self. + @rtype: list + """ + #TODO: This is a TEMPORARY KLUDGE until Dna model is fully functional. + #Must be revised. Basically it returns a list of NanotubeSegments whose + #all members are selected. + #See BuildDna_PropertyManager._currentSelectionParams() where it is used + #-- Ninad 2008-01-18 + segmentList = self.getSegments() + + selectedSegmentList = [] + + for segment in segmentList: + + pickedNodes = [] + unpickedNodes = [] + + def func(node): + if isinstance(node, self.assy.Chunk): + if not node.picked: + unpickedNodes.append(node) + else: + pickedNodes.append(node) + + segment.apply2all(func) + + if len(unpickedNodes) == 0 and pickedNodes: + selectedSegmentList.append(segment) + + return selectedSegmentList + + def getAtomList(self): + """ + Return a list of all atoms contained within this NanotubeGroup + """ + atomList = [] + def func(node): + if isinstance(node, self.assy.Chunk): + atomList.extend(node.atoms.itervalues()) + + self.apply2all(func) + return atomList + + def draw_highlighted(self, glpane, color): + """ + Draw the nanotube segment chunks as highlighted. (Calls the related + methods in the chunk class) + @param: GLPane object + @param color: The highlight color + @see: Chunk.draw_highlighted() + @see: SelectChunks_GraphicsMode.draw_highlightedChunk() + @see: SelectChunks_GraphicsMode._get_objects_to_highlight() + """ + for c in self.getSegments(): + c.draw_highlighted(glpane, color) + + pass # end of class NanotubeGroup + +# == + |