summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNinad Sathaye <ninad@nanorex.com>2008-09-10 14:21:42 +0000
committerNinad Sathaye <ninad@nanorex.com>2008-09-10 14:21:42 +0000
commitf7eba1c73b956931b80f3495e6330ac96dc1e3fb (patch)
tree19a4e6f1c2d0f8a4a162360098a96e939ec29317
parentca03e8b92b3bc215a5a6d99d0a09e5c92a0ed275 (diff)
downloadnanoengineer-theirix-f7eba1c73b956931b80f3495e6330ac96dc1e3fb.tar.gz
nanoengineer-theirix-f7eba1c73b956931b80f3495e6330ac96dc1e3fb.zip
refactoring -- new Motor_EditCommand superclass for motors; ported motor classes to new command api
-rw-r--r--cad/src/command_support/Motor_EditCommand.py104
-rw-r--r--cad/src/commands/LinearMotorProperties/LinearMotor_EditCommand.py85
-rw-r--r--cad/src/commands/RotaryMotorProperties/RotaryMotor_EditCommand.py86
3 files changed, 115 insertions, 160 deletions
diff --git a/cad/src/command_support/Motor_EditCommand.py b/cad/src/command_support/Motor_EditCommand.py
new file mode 100644
index 000000000..7043a48f2
--- /dev/null
+++ b/cad/src/command_support/Motor_EditCommand.py
@@ -0,0 +1,104 @@
+# Copyright 2007-2008 Nanorex, Inc. See LICENSE file for details.
+"""
+@author: Ninad
+@copyright: 2007-2008 Nanorex, Inc. See LICENSE file for details.
+@version:$Id$
+
+History:
+2008-09-09: Moved common code from Rotarymotor and
+LinearMotor_EditCommand to here.
+
+TODO:
+"""
+
+from command_support.EditCommand import EditCommand
+from commands.SelectAtoms.SelectAtoms_GraphicsMode import SelectAtoms_GraphicsMode
+
+from utilities.GlobalPreferences import USE_COMMAND_STACK
+
+_superclass = EditCommand
+class Motor_EditCommand(EditCommand):
+ #GraphicsMode
+ GraphicsMode_class = SelectAtoms_GraphicsMode
+
+ #Temporary attr 'command_porting_status. See baseCommand for details.
+ command_porting_status = None #fully ported. But need cleanup in PMs of subclasses to move update_widgets_in_PM_* method to perhaps _update_UI_* method.
+
+ prefix = '' # Not used by jigs.
+ # All jigs like rotary and linear motors already created their
+ # name, so do not (re)create it from the prefix.
+ create_name_from_prefix = False
+ propMgr = None
+
+ #See Command.anyCommand for details about the following flags
+ command_should_resume_prevMode = True
+ command_has_its_own_PM = True
+
+ from utilities.constants import CL_EDIT_GENERIC
+ command_level = CL_EDIT_GENERIC
+
+
+ def __init__(self, commandSequencer, struct = None):
+ """
+ Constructs a command Object. The command,
+ depending on what client code needs it to do, may create a new
+ motor or it may be used for an existing motor. See subclasses,
+ RotaryMotor_EditCommand and LinearMotor_EditCommand for details.
+
+ @param commandSequencer: Command sequencer object
+
+ @param struct: The model object (in this case a 'rotary motor') that the
+ this EditCommand may create and/or edit
+ If struct object is specified, it means this
+ editCommand will be used to edit that struct.
+ @type struct: L{RotaryMotor} or None
+
+ """
+ _superclass.__init__(self, commandSequencer)
+ self.struct = struct
+
+ def command_entered(self):
+ """
+ Overrides superclass method.
+ @see: baseCommand.command_entered()
+ """
+ self.struct = None
+ _superclass.command_entered(self)
+ self.o.assy.permit_pick_atoms()
+
+ #Old command API methods (in if not USE_COMMAND_STACK condition block)
+ if not USE_COMMAND_STACK:
+ def Enter(self):
+ """
+ Enter this command.
+ @see: EditCommand.Enter
+ """
+ #See EditCommand.Enter for a detailed comment on why self.struct is
+ #set to None while entering this command.
+ #May not be needed for RotaryMotor and Linear motor edit commands,
+ # but safe to do it for now -- Ninad 2008-01-14
+ if self.struct:
+ self.struct = None
+ EditCommand.Enter(self)
+ self.o.assy.permit_pick_atoms()
+
+ def init_gui(self):
+ """
+ NOT IMPLEMENTED YET.
+ TODO: Move calls that create/ show PM in EditCommand.createStructure
+ out of that method. (That code was written before converting the
+ editCommands into 'Commands'. After this conversion, a better
+ implementation is necessary, in which PM creation and
+ display will be handled in init_gui method.
+ """
+ #Note: This method overrides EditCommand.init_gui. This is just to
+ #prevent the call of self.create_and_or_show_PM_if_wanted. , As that
+ # method is called in self.createStructure. (to be cleaned up)
+ pass
+
+ def restore_gui(self):
+ """
+ """
+ if self.propMgr:
+ self.propMgr.close()
+
diff --git a/cad/src/commands/LinearMotorProperties/LinearMotor_EditCommand.py b/cad/src/commands/LinearMotorProperties/LinearMotor_EditCommand.py
index af7c88c73..bb8edae79 100644
--- a/cad/src/commands/LinearMotorProperties/LinearMotor_EditCommand.py
+++ b/cad/src/commands/LinearMotorProperties/LinearMotor_EditCommand.py
@@ -14,93 +14,21 @@ import foundation.env as env
from utilities.Log import redmsg, greenmsg, orangemsg
from model.jigs_motors import LinearMotor
from operations.jigmakers_Mixin import atom_limit_exceeded_and_confirmed
-from command_support.EditCommand import EditCommand
-
-from commands.SelectAtoms.SelectAtoms_GraphicsMode import SelectAtoms_GraphicsMode
+from command_support.Motor_EditCommand import Motor_EditCommand
from commands.LinearMotorProperties.LinearMotorPropertyManager import LinearMotorPropertyManager
-class LinearMotor_EditCommand(EditCommand):
+class LinearMotor_EditCommand(Motor_EditCommand):
"""
The LinearMotor_EditCommand class provides an editCommand Object.
The editCommand, depending on what client code needs it to do, may create
a new linear motor or it may be used for an existing linear motor.
"""
- PM_class = LinearMotorPropertyManager
-
- cmd = greenmsg("Linear Motor: ")
- #
- prefix = '' # Not used by jigs.
- # All jigs like rotary and linear motors already created their
- # name, so do not (re)create it from the prefix.
- create_name_from_prefix = False
- propMgr = None
-
- #See Command.anyCommand for details about the following flags
- command_should_resume_prevMode = True
- command_has_its_own_PM = True
-
+ PM_class = LinearMotorPropertyManager
+ cmd = greenmsg("Linear Motor: ")
commandName = 'LINEAR_MOTOR'
featurename = "Linear Motor"
- from utilities.constants import CL_EDIT_GENERIC
- command_level = CL_EDIT_GENERIC
-
- GraphicsMode_class = SelectAtoms_GraphicsMode
-
- def __init__(self, commandSequencer, struct = None):
- """
- Constructs an Edit Controller Object. The editCommand,
- depending on what client code needs it to do, may create a new
- Linear motor or it may be used for an existing linear motor.
-
- @param win: The NE1 main window.
- @type win: QMainWindow
-
- @param struct: The model object (in this case a 'linear motor') that the
- this EditCommand may create and/or edit
- If struct object is specified, it means this
- editCommand will be used to edit that struct.
- @type struct: L{LinearMotor} or None
-
- @see: L{LinearMotor.__init__}
- """
- EditCommand.__init__(self, commandSequencer)
- self.struct = struct
-
- def Enter(self):
- """
- Enter this command.
- @see: EditCommand.Enter
- """
- #See EditCommand.Enter for a detailed comment on why self.struct is
- #set to None while entering this command.
- #May not be needed for RotaryMotor and Linear motor edit commands,
- # but safe to do it for now -- Ninad 2008-01-14
- if self.struct:
- self.struct = None
-
- EditCommand.Enter(self)
-
- def init_gui(self):
- """
- NOT IMPLEMENTED YET.
- TODO: Move calls that create/ show PM in editCommand.createStructure
- out of that method. (That code was written before converting the
- editCommands into 'Commands'. After this conversion, a better
- implementation is necessary, in which PM creation and
- display will be handled in init_gui method.
- """
- #Note: This method overrides EditCommand.init_gui. This is just to
- #prevent the call of self.create_and_or_show_PM_if_wanted. , As that
- # method is called in self.createStructure. (to be cleaned up)
- pass
-
- def restore_gui(self):
- """
- """
- if self.propMgr:
- self.propMgr.close()
-
+
def _gatherParameters(self):
"""
Return all the parameters from the Plane Property Manager.
@@ -230,6 +158,3 @@ class LinearMotor_EditCommand(EditCommand):
return (isAtomRequirementMet, logMessage)
return (isAtomRequirementMet, logMessage)
-
-
-
diff --git a/cad/src/commands/RotaryMotorProperties/RotaryMotor_EditCommand.py b/cad/src/commands/RotaryMotorProperties/RotaryMotor_EditCommand.py
index 3f1558f08..fd0852ca5 100644
--- a/cad/src/commands/RotaryMotorProperties/RotaryMotor_EditCommand.py
+++ b/cad/src/commands/RotaryMotorProperties/RotaryMotor_EditCommand.py
@@ -14,96 +14,22 @@ import foundation.env as env
from utilities.Log import redmsg, greenmsg, orangemsg
from model.jigs_motors import RotaryMotor
from operations.jigmakers_Mixin import atom_limit_exceeded_and_confirmed
-from command_support.EditCommand import EditCommand
+from command_support.Motor_EditCommand import Motor_EditCommand
-from commands.SelectAtoms.SelectAtoms_GraphicsMode import SelectAtoms_GraphicsMode
from commands.RotaryMotorProperties.RotaryMotorPropertyManager import RotaryMotorPropertyManager
-class RotaryMotor_EditCommand(EditCommand):
+class RotaryMotor_EditCommand(Motor_EditCommand):
"""
The RotaryMotor_EditCommand class provides an editCommand Object.
The editCommand, depending on what client code needs it to do, may create
a new rotary motor or it may be used for an existing rotary motor.
- """
- #GraphicsMode
- GraphicsMode_class = SelectAtoms_GraphicsMode
-
+ """
#Property Manager
- PM_class = RotaryMotorPropertyManager
-
- cmd = greenmsg("Rotary Motor: ")
- #
- prefix = '' # Not used by jigs.
- # All jigs like rotary and linear motors already created their
- # name, so do not (re)create it from the prefix.
- create_name_from_prefix = False
- propMgr = None
-
- #See Command.anyCommand for details about the following flags
- command_should_resume_prevMode = True
- command_has_its_own_PM = True
-
+ PM_class = RotaryMotorPropertyManager
+ cmd = greenmsg("Rotary Motor: ")
commandName = 'ROTARY_MOTOR'
- featurename = "Rotary Motor"
- from utilities.constants import CL_EDIT_GENERIC
- command_level = CL_EDIT_GENERIC
-
+ featurename = "Rotary Motor"
-
- def __init__(self, commandSequencer, struct = None):
- """
- Constructs an Edit Controller Object. The editCommand,
- depending on what client code needs it to do, may create a new
- rotary motor or it may be used for an existing rotary motor.
-
- @param win: The NE1 main window.
- @type win: QMainWindow
-
- @param struct: The model object (in this case a 'rotary motor') that the
- this EditCommand may create and/or edit
- If struct object is specified, it means this
- editCommand will be used to edit that struct.
- @type struct: L{RotaryMotor} or None
-
- @see: L{RotaryMotor.__init__}
- """
- EditCommand.__init__(self, commandSequencer)
- self.struct = struct
-
- def Enter(self):
- """
- Enter this command.
- @see: EditCommand.Enter
- """
- #See EditCommand.Enter for a detailed comment on why self.struct is
- #set to None while entering this command.
- #May not be needed for RotaryMotor and Linear motor edit commands,
- # but safe to do it for now -- Ninad 2008-01-14
- if self.struct:
- self.struct = None
- EditCommand.Enter(self)
- self.o.assy.permit_pick_atoms()
-
- def init_gui(self):
- """
- NOT IMPLEMENTED YET.
- TODO: Move calls that create/ show PM in EditCommand.createStructure
- out of that method. (That code was written before converting the
- editCommands into 'Commands'. After this conversion, a better
- implementation is necessary, in which PM creation and
- display will be handled in init_gui method.
- """
- #Note: This method overrides EditCommand.init_gui. This is just to
- #prevent the call of self.create_and_or_show_PM_if_wanted. , As that
- # method is called in self.createStructure. (to be cleaned up)
- pass
-
- def restore_gui(self):
- """
- """
- if self.propMgr:
- self.propMgr.close()
-
def _gatherParameters(self):
"""
Return all the parameters from the Rotary Motor Property Manager.