diff options
author | Ninad Sathaye <ninad@nanorex.com> | 2008-09-09 17:21:10 +0000 |
---|---|---|
committer | Ninad Sathaye <ninad@nanorex.com> | 2008-09-09 17:21:10 +0000 |
commit | 413de5d730d3bb88f5f489b5a1f98582d99095da (patch) | |
tree | c9fb9a7808ecd37a0e56ea9b22c08cb91a1ef5f0 | |
parent | f14de607ed715d578274c687515ea5d13dcbef9c (diff) | |
download | nanoengineer-413de5d730d3bb88f5f489b5a1f98582d99095da.tar.gz nanoengineer-413de5d730d3bb88f5f489b5a1f98582d99095da.zip |
cleanup and ported FuseCommand to new command API
-rwxr-xr-x | cad/src/commands/Fuse/FuseChunks_Command.py | 59 | ||||
-rwxr-xr-x | cad/src/commands/Move/Move_Command.py | 83 |
2 files changed, 67 insertions, 75 deletions
diff --git a/cad/src/commands/Fuse/FuseChunks_Command.py b/cad/src/commands/Fuse/FuseChunks_Command.py index bf43f2ebf..0ccca943b 100755 --- a/cad/src/commands/Fuse/FuseChunks_Command.py +++ b/cad/src/commands/Fuse/FuseChunks_Command.py @@ -11,6 +11,11 @@ Originally by Mark as class 'fuseChunksMode'. Ninad 2008-01-25: Split Command and GraphicsMode classes out of class fuseChunksMode. The graphicsMode class can be found in FuseChunks_GraphicsMode.py + +TODO as of 2008-09-09: +-refactor update ui related code. Example some methods call propMgr.updateMessage() +etc. this needs to be in a central place... either in this callls or +in PM._update_UI_do_updates() """ import foundation.env as env @@ -49,7 +54,14 @@ class FuseChunks_Command(Move_Command, fusechunksBase): 2. Fuse Atoms - atoms between chunks will be fused when they overlap each other. """ + #Temporary attr 'command_porting_status. See baseCommand for details. + command_porting_status = None #fully ported. But some refactoring related to the update code is needed in future. + + # class constants + PM_class = FusePropertyManager + GraphicsMode_class = FuseChunks_GraphicsMode + commandName = 'FUSECHUNKS' featurename = "Fuse Chunks Mode" from utilities.constants import CL_ENVIRONMENT_PROVIDING @@ -69,9 +81,7 @@ class FuseChunks_Command(Move_Command, fusechunksBase): # considered overlapping fuse_mode = '' # The Fuse mode, either 'Make Bonds' or 'Fuse Atoms'. - propMgr = None - - GraphicsMode_class = FuseChunks_GraphicsMode + def _create_GraphicsMode(self): GM_class = self.GraphicsMode_class @@ -82,10 +92,7 @@ class FuseChunks_Command(Move_Command, fusechunksBase): self.translate_graphicsMode = Translate_in_FuseChunks_GraphicsMode(*args, **kws) self.rotate_graphicsMode = Rotate_in_FuseChunks_GraphicsMode(*args, **kws) - - def _createPropMgrObject(self): - return FusePropertyManager(self) def _createFlyoutToolBarObject(self): """ @@ -95,43 +102,21 @@ class FuseChunks_Command(Move_Command, fusechunksBase): @see: self.command_enter_flyout() """ flyoutToolbar = FuseFlyout(self) - return flyoutToolbar - - - def init_gui(self): - """ - Do changes to the GUI while entering this mode. This includes opening - the property manager, updating the command toolbar, connecting widget - slots etc. - - Called once each time the mode is entered; should be called only by code - in modes.py - - @see: L{self.restore_gui} - """ - self.command_enter_misc_actions() - self.command_enter_PM() - self.command_enter_flyout() + return flyoutToolbar + def command_entered(self): + """ + Overrides superclass method. + @see: baseCommand.command_entered() for documentation. + """ + super(FuseChunks_Command, self).command_entered() self.change_fuse_mode(str(self.propMgr.fuseComboBox.currentText())) # This maintains state of fuse mode when leaving/reentering mode, # and syncs the PM and glpane (and does a gl_update). if self.o.assy.selmols: self.graphicsMode.something_was_picked = True - - def restore_gui(self): - """ - Do changes to the GUI while exiting this mode. This includes closing - this mode's property manager, updating the command toolbar, - disconnecting widget slots etc. - @see: L{self.init_gui} - """ - self.command_exit_misc_actions() - self.command_exit_flyout() - self.command_exit_PM() - def command_enter_misc_actions(self): self.w.toolsFuseChunksAction.setChecked(1) @@ -421,9 +406,7 @@ class FuseChunks_Command(Move_Command, fusechunksBase): def _delete_overlapping_atoms(self): pass - - - + def fuse_atoms(self): """ Deletes overlapping atoms found with the selected chunk(s). diff --git a/cad/src/commands/Move/Move_Command.py b/cad/src/commands/Move/Move_Command.py index 237c7db1c..e60517004 100755 --- a/cad/src/commands/Move/Move_Command.py +++ b/cad/src/commands/Move/Move_Command.py @@ -20,11 +20,14 @@ For example: History: See Move_GraphicsMode.py +TODO as of 2008-09-09: +-refactor update ui related code. Example some methods call propMgr.updateMessage() +etc. this needs to be in a central place... either in this callls or +in PM._update_UI_do_updates() + """ import foundation.env as env import math -from Numeric import dot -import foundation.changes as changes from commands.Move.MovePropertyManager import MovePropertyManager from commands.SelectChunks.SelectChunks_Command import SelectChunks_basicCommand from command_support.GraphicsMode_API import GraphicsMode_API @@ -42,12 +45,19 @@ from utilities.GlobalPreferences import USE_COMMAND_STACK class Move_basicCommand(SelectChunks_basicCommand): """ """ + + #Temporary attr 'command_porting_status. See baseCommand for details. + command_porting_status = None #fully ported. But some refactoring related to the update code is needed in future. + + #The class constant PM_class defines the class for the Property Manager of + #this command. See Command.py for more infor about this class constant + PM_class = MovePropertyManager + commandName = 'MODIFY' featurename = "Move Chunks Mode" from utilities.constants import CL_EDIT_GENERIC command_level = CL_EDIT_GENERIC - propMgr = None pw = None command_can_be_suspended = True @@ -56,21 +66,18 @@ class Move_basicCommand(SelectChunks_basicCommand): flyoutToolbar = None - #The class constant PM_class defines the class for the Property Manager of - #this command. See Command.py for more infor about this class constant - PM_class = MovePropertyManager #START new command API methods ============================================= #currently [2008-08-01 ] also called in by self,init_gui and #self.restore_gui. - def command_enter_PM(self): + def command_entered(self): """ Overrides superclass method. @see: baseCommand.command_enter_PM() for documentation """ - SelectChunks_basicCommand.command_enter_PM(self) + super(Move_basicCommand, self).command_entered() self.propMgr.set_move_xyz(0, 0, 0) # Init X, Y, and Z to zero self.propMgr.set_move_delta_xyz(0,0,0) # Init DelX,DelY, DelZ to zero @@ -126,35 +133,37 @@ class Move_basicCommand(SelectChunks_basicCommand): #END new command API methods ============================================== - - def init_gui(self): - """ - Do changes to the GUI while entering this mode. This includes opening - the property manager, updating the command toolbar, connecting widget - slots etc. - - Called once each time the mode is entered; should be called only by code - in modes.py - - @see: L{self.restore_gui} - """ - self.command_enter_misc_actions() - self.command_enter_PM() - self.command_enter_flyout() - self.propMgr.show() - - def restore_gui(self): - """ - Do changes to the GUI while exiting this mode. This includes closing - this mode's property manager, updating the command toolbar, - disconnecting widget slots etc. - @see: L{self.init_gui} - """ - self.command_exit_misc_actions() - self.command_exit_flyout() - self.command_exit_PM() - if self.propMgr: - self.propMgr.close() + + #Old command api methods (under if not USE_COMMAND_STACK) ==== + if not USE_COMMAND_STACK: + def init_gui(self): + """ + Do changes to the GUI while entering this mode. This includes opening + the property manager, updating the command toolbar, connecting widget + slots etc. + + Called once each time the mode is entered; should be called only by code + in modes.py + + @see: L{self.restore_gui} + """ + self.command_enter_misc_actions() + self.command_enter_PM() + self.command_enter_flyout() + self.propMgr.show() + + def restore_gui(self): + """ + Do changes to the GUI while exiting this mode. This includes closing + this mode's property manager, updating the command toolbar, + disconnecting widget slots etc. + @see: L{self.init_gui} + """ + self.command_exit_misc_actions() + self.command_exit_flyout() + self.command_exit_PM() + if self.propMgr: + self.propMgr.close() def _acceptLineModePoints(self, params): #bruce 080801, revises acceptParamsFromTemporaryMode """ |