diff options
author | Bruce Smith <bruce@nanorex.com> | 2008-09-30 04:14:50 +0000 |
---|---|---|
committer | Bruce Smith <bruce@nanorex.com> | 2008-09-30 04:14:50 +0000 |
commit | 316111ac9d6fb77e2d0964e98dd6650b41656892 (patch) | |
tree | c79694057558ff5f509c5bf547e2ae3c140fc58d | |
parent | a7dfe5dca32a52b8528f974f66802b88c240b3b4 (diff) | |
download | nanoengineer-316111ac9d6fb77e2d0964e98dd6650b41656892.tar.gz nanoengineer-316111ac9d6fb77e2d0964e98dd6650b41656892.zip |
more USE_COMMAND_STACK cleanup
-rwxr-xr-x | cad/src/PM/PM_Dialog.py | 5 | ||||
-rw-r--r-- | cad/src/PM/PM_SelectionListWidget.py | 1 | ||||
-rw-r--r-- | cad/src/commandSequencer/CommandSequencer.py | 71 | ||||
-rwxr-xr-x | cad/src/command_support/Command.py | 4 | ||||
-rw-r--r-- | cad/src/command_support/baseCommand.py | 18 | ||||
-rw-r--r-- | cad/src/exprs/scratch/test_animation_mode.py | 5 | ||||
-rwxr-xr-x | cad/src/exprs/testmode.py | 3 | ||||
-rwxr-xr-x | cad/src/operations/ops_files.py | 2 | ||||
-rw-r--r-- | cad/src/utilities/GlobalPreferences.py | 12 |
9 files changed, 47 insertions, 74 deletions
diff --git a/cad/src/PM/PM_Dialog.py b/cad/src/PM/PM_Dialog.py index 59c097119..18f230fee 100755 --- a/cad/src/PM/PM_Dialog.py +++ b/cad/src/PM/PM_Dialog.py @@ -204,7 +204,7 @@ class PM_Dialog( QDialog, SponsorableMixin ): """ pass - def update_UI(self): #bruce 080819 + def update_UI(self): """ Update whatever is shown in this PM based on current state of the rest of the system, especially the state of self.command @@ -214,9 +214,6 @@ class PM_Dialog( QDialog, SponsorableMixin ): submethods '_update_UI_check_change_indicators' and '_update_UI_do_updates' """ - # Note: this is only called when USE_COMMAND_STACK is true. - # API details subject to revision. - anything_changed = self._update_UI_check_change_indicators() if not anything_changed: diff --git a/cad/src/PM/PM_SelectionListWidget.py b/cad/src/PM/PM_SelectionListWidget.py index 253e78527..dcc187f09 100644 --- a/cad/src/PM/PM_SelectionListWidget.py +++ b/cad/src/PM/PM_SelectionListWidget.py @@ -333,7 +333,6 @@ class PM_SelectionListWidget(PM_ListWidget): try: listWidgetItem.setIcon(geticon(item.iconPath)) except: - #bruce 080829 added this while debugging Zoom in or after Insert Dna in USE_COMMAND_STACK print_compact_traceback() self._itemDictionary[listWidgetItem] = item diff --git a/cad/src/commandSequencer/CommandSequencer.py b/cad/src/commandSequencer/CommandSequencer.py index 07ff03e24..c017c0f40 100644 --- a/cad/src/commandSequencer/CommandSequencer.py +++ b/cad/src/commandSequencer/CommandSequencer.py @@ -148,8 +148,8 @@ class CommandSequencer(object): first call self.exit_all_commands(), then do only the "subsequent init calls" mentioned above -- don't call this method again. """ - # note: used when USE_COMMAND_STACK or not. - # should try to clean up init code (see docstring) when USE_COMMAND_STACK is always true. + # todo: should try to clean up init code (see docstring) + # now that USE_COMMAND_STACK is always true. if _DEBUG_CSEQ_INIT: print "_DEBUG_CSEQ_INIT: __init__"### @@ -166,17 +166,12 @@ class CommandSequencer(object): self._registered_command_classes = {} #bruce 080805 - # When not USE_COMMAND_STACK, these might be noops, - # but more likely, we need a nullmode then just as we do now - # (in case of unexpected uses of currentCommand during init). - # So call them in that case too. self._recreate_nullmode() self._use_nullmode() # see docstring for additional inits needed as external calls return def _recreate_nullmode(self): # only called from this file, as of 080805 - # REVIEW whether still needed when USE_COMMAND_STACK; presently still used then self.nullmode = nullMode() # TODO: rename self.nullmode; note that it's semi-public [###REVIEW: what uses it?]; # it's a safe place to absorb events that come at the wrong time @@ -184,11 +179,9 @@ class CommandSequencer(object): return def _reinit_modes(self): #revised, bruce 050911, 080209 - # REVIEW: still ok for USE_COMMAND_STACK? guess yes, for now; - # and still needed, since it's part of how to init or reset the - # command sequencer in its current external API - # (see docstring for __init__) [bruce 080814, still true 080909] - + """ + @see: docstring for __init__ + """ # note: as of 080812, not called directly in this file; called from: # - GLPane.setAssy (end of function), # which is called from: @@ -203,6 +196,8 @@ class CommandSequencer(object): # by the main calls of this listed above; and/or make the reinit of # command objects lazy (per-command-class), so calling this is optional, # at least in methods like extrude_reload. + + # old docstring: """ [bruce comment 040922, when I split this out from GLPane's setAssy method; comment is fairly specific to GLPane:] @@ -306,8 +301,7 @@ class CommandSequencer(object): def exit_all_commands(self, warn_about_abandoned_changes = True): """ - Exit all currently active commands - (even the default command, even when USE_COMMAND_STACK), + Exit all currently active commands (even the default command), and leave the current command as nullMode. During the exiting, make sure self.exit_is_forced is true @@ -449,24 +443,28 @@ class CommandSequencer(object): # has been wrapped by an API-enforcement (or any other) proxy. return self._raw_currentCommand is command - def _update_model_between_commands(self): #bruce 080806 split this out - #bruce 050317: do update_parts to insulate new mode from prior one's bugs - # WARNING: when USE_COMMAND_STACK, this might be needed (as much as it ever was), - # but calling it might be NIM [bruce 080909 comment] - try: - self.assy.update_parts() - # Note: this is overkill (only known to be needed when leaving - # extrude, and really it's a bug that it doesn't do this itself), - # and potentially too slow (though I doubt it), - # and not a substitute for doing this at the end of operations - # that need it (esp. once we have Undo); but doing it here will make - # things more robust. Ideally we should "assert_this_was_not_needed". - except: - print_compact_traceback("bug: update_parts: ") - else: - if debug_flags.atom_debug: - self.assy.checkparts() #bruce 050315 assy/part debug code - return +# not used as of before 080929, but keep for now: +## def _update_model_between_commands(self): +## # review: when USE_COMMAND_STACK, this might be needed (as much as it ever was), +## # but calling it is NIM. For now, we'll try not calling it and +## # see if this ever matters. It may be that we even do update_parts +## # before redraw or undo checkpoint, which makes this even less necessary. +## # [bruce 080909 comment] +## #bruce 050317: do update_parts to insulate new mode from prior one's bugs +## try: +## self.assy.update_parts() +## # Note: this is overkill (only known to be needed when leaving +## # extrude, and really it's a bug that it doesn't do this itself), +## # and potentially too slow (though I doubt it), +## # and not a substitute for doing this at the end of operations +## # that need it (esp. once we have Undo); but doing it here will make +## # things more robust. Ideally we should "assert_this_was_not_needed". +## except: +## print_compact_traceback("bug: update_parts: ") +## else: +## if debug_flags.atom_debug: +## self.assy.checkparts() #bruce 050315 assy/part debug code +## return def start_using_initial_mode(self, mode): #bruce 080812 """ @@ -475,8 +473,7 @@ class CommandSequencer(object): which must be one of the strings '$STARTUP_MODE' or '$DEFAULT_MODE', just after self is created or _reinit_modes is called. - @note: this is called, and is part of our external API for init/reinit, - even after USE_COMMAND_STACK. See docstring of __init__. + @see: docstring of __init__. @see: exit_all_commands """ @@ -553,9 +550,7 @@ class CommandSequencer(object): pre-050911 code, never return some other command than asked for; let caller use a different one if desired. """ - #bruce 050911 and 060403 revised this; - # as of 080804/080929, looks ok for USE_COMMAND_STACK, except for - # the old term MODE used in the string constants + # todo: clean up the old term MODE used in the string constants assert commandName_or_obj, "commandName_or_obj arg should be a command object " \ "or commandName, not None or whatever false value it is here: %r" % \ (commandName_or_obj,) @@ -856,7 +851,7 @@ class CommandSequencer(object): # note: this can happen even if error is True # (when exiting multiple commands at once) - ##### REVIEW: should we call self._update_model_between_commands() like old code did? + # review: should we call self._update_model_between_commands() like old code did? # Note that no calls to it are implemented in USE_COMMAND_STACK case # (not for entering commands, either). This might cause new bugs. diff --git a/cad/src/command_support/Command.py b/cad/src/command_support/Command.py index 69c5fa8c0..5c03e7c20 100755 --- a/cad/src/command_support/Command.py +++ b/cad/src/command_support/Command.py @@ -57,11 +57,12 @@ import foundation.changes as changes class anyCommand(baseCommand, StateMixin): """ - abstract superclass for all Command objects, including nullCommand. + abstract superclass for all Command objects in NE1, including nullCommand. @note: command base class methods are divided somewhat arbitrarily between baseCommand, anyCommand, and basicCommand. In some cases, methods defined in baseCommand are overridden in anyCommand or basicCommand. + For more info see baseCommand docstring. """ #bruce 071008 added object superclass; 071009 split anyMode -> anyCommand @@ -298,6 +299,7 @@ class basicCommand(anyCommand): @note: command base class methods are divided somewhat arbitrarily between baseCommand, anyCommand, and basicCommand. In some cases, methods defined in baseCommand are overridden in anyCommand or basicCommand. + For more info see baseCommand docstring. """ # TODO: split into minimalCommand, which does as little as possible # which meets the Command API and permits switching between commands diff --git a/cad/src/command_support/baseCommand.py b/cad/src/command_support/baseCommand.py index 1741fd5f7..4e0a92837 100644 --- a/cad/src/command_support/baseCommand.py +++ b/cad/src/command_support/baseCommand.py @@ -2,17 +2,11 @@ """ baseCommand.py - base class for command objects on a command sequencer stack -NOTE: only used when USE_COMMAND_STACK is true -(controlled by debug_pref as of before 080905; -not yet used by default as of 080917, but soon will be) - @author: Bruce @version: $Id$ @copyright: 2008 Nanorex, Inc. See LICENSE file for details. - """ - from utilities.debug import print_compact_traceback _pct = print_compact_traceback # local abbreviation for readability @@ -22,7 +16,7 @@ from commandSequencer.command_levels import FIXED_PARENT_LEVELS from commandSequencer.command_levels import AFFECTS_FLYOUT_LEVELS -DEBUG_USE_COMMAND_STACK = False #turn off the debug prints by default +DEBUG_USE_COMMAND_STACK = False # == @@ -31,11 +25,13 @@ class baseCommand(object): Abstract base class for command objects compatible with Command Sequencer. @note: all actual command objects are instances of subclasses of our - subclass anyCommand. + subclass anyCommand. The intended division of methods is that + those needed for CommandSequencer are defined here, whereas + those needed only by other code in NE1 are defined in anyCommand + or basicCommand. This is roughly followed but not completely. - @note: command base class methods are divided somewhat arbitrarily between - baseCommand, anyCommand, and basicCommand. In some cases, methods - defined in baseCommand are overridden in anyCommand or basicCommand. + @note: In some cases, methods defined in baseCommand are overridden + in anyCommand or basicCommand. """ __abstract_command_class = True diff --git a/cad/src/exprs/scratch/test_animation_mode.py b/cad/src/exprs/scratch/test_animation_mode.py index b9346bef8..b54c2bbca 100644 --- a/cad/src/exprs/scratch/test_animation_mode.py +++ b/cad/src/exprs/scratch/test_animation_mode.py @@ -56,8 +56,6 @@ from PM.PM_DoubleSpinBox import PM_DoubleSpinBox from PM.PM_PushButton import PM_PushButton from PM.PM_CheckBox import PM_CheckBox -from utilities.GlobalPreferences import USE_COMMAND_STACK - ##from modes import * ##from modes import basicMode from command_support.Command import Command @@ -1220,8 +1218,7 @@ class test_animation_mode(_superclass, IorE_guest_mixin): # list of supers might # class constants needed by mode API backgroundColor = 103/256.0, 124/256.0, 53/256.0 - commandName = 'test_animation_mode' # bruce 080910 'TEST_ANIMATION' -> 'test_animation_mode' so it works with - # USE_COMMAND_STACK and/or with new asserts in CommandSequencer + commandName = 'test_animation_mode' # must be same as module basename, for 'custom mode' to work featurename = "Prototype: Example Animation Mode" from utilities.constants import CL_ENVIRONMENT_PROVIDING command_level = CL_ENVIRONMENT_PROVIDING diff --git a/cad/src/exprs/testmode.py b/cad/src/exprs/testmode.py index 9fa136547..c34a059eb 100755 --- a/cad/src/exprs/testmode.py +++ b/cad/src/exprs/testmode.py @@ -336,8 +336,7 @@ class testmode(_superclass_C): GraphicsMode_class = testmode_GM - commandName = 'testmode' #bruce 080910 'TEST' -> 'testmode' so it works with - # USE_COMMAND_STACK and/or with new asserts in CommandSequencer + commandName = 'testmode' # must be same as module basename, for 'custom mode' featurename = "Test Command: Exprs Package" from utilities.constants import CL_ENVIRONMENT_PROVIDING command_level = CL_ENVIRONMENT_PROVIDING diff --git a/cad/src/operations/ops_files.py b/cad/src/operations/ops_files.py index 2d7620266..daf18ac13 100755 --- a/cad/src/operations/ops_files.py +++ b/cad/src/operations/ops_files.py @@ -2113,7 +2113,7 @@ class fileSlotsMixin: #bruce 050907 moved these methods out of class MWsemantics self.glpane.setAssy(self.assy) # notes: this calls assy.set_glpane, and _reinit_modes # (which leaves currentCommand as nullmode) - # (whether or not USE_COMMAND_STACK). + # (even after USE_COMMAND_STACK). ### TODO: move _reinit_modes out of that, do it somewhere else. self.assy.set_modelTree(self.mt) diff --git a/cad/src/utilities/GlobalPreferences.py b/cad/src/utilities/GlobalPreferences.py index 4153d48f3..fa2187eee 100644 --- a/cad/src/utilities/GlobalPreferences.py +++ b/cad/src/utilities/GlobalPreferences.py @@ -465,18 +465,6 @@ def debug_pref_support_Qt_4point2(): #bruce 080725 # == -def _debug_pref_use_command_stack(): #bruce 080728 - #ninad circa 080922 revised default value and menu text - res = debug_pref("Use new command stack API (next session)?", - Choice_boolean_True, - prefs_key = True - ) - return res - -USE_COMMAND_STACK = _debug_pref_use_command_stack() - -# == - ENABLE_PROTEINS = debug_pref("Enable Proteins? (next session)", Choice_boolean_True, non_debug = True, |