summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Smith <bruce@nanorex.com>2008-09-09 21:41:54 +0000
committerBruce Smith <bruce@nanorex.com>2008-09-09 21:41:54 +0000
commitb8a163b308e7c2a2cb0f90cbb591614c7855c732 (patch)
treee9f3cd5c01eb2901593921e12e19a1f200650fc3
parenta44e3850f83f712624d69306df9793a6560262a5 (diff)
downloadnanoengineer-b8a163b308e7c2a2cb0f90cbb591614c7855c732.tar.gz
nanoengineer-b8a163b308e7c2a2cb0f90cbb591614c7855c732.zip
port effects of restore_patches_by_Command to USE_COMMAND_STACK; etc
-rwxr-xr-xcad/src/command_support/Command.py34
-rwxr-xr-xcad/src/commands/BuildCrystal/BuildCrystal_Command.py10
-rwxr-xr-xcad/src/commands/PlayMovie/movieMode.py16
-rw-r--r--cad/src/commands/StereoProperties/StereoProperties_PropertyManager.py23
-rwxr-xr-xcad/src/graphics/widgets/GLPane.py2
5 files changed, 59 insertions, 26 deletions
diff --git a/cad/src/command_support/Command.py b/cad/src/command_support/Command.py
index 670f34b08..b2fc10092 100755
--- a/cad/src/command_support/Command.py
+++ b/cad/src/command_support/Command.py
@@ -1707,23 +1707,37 @@ class basicCommand(anyCommand):
# someday call them separately, and also just for code
# clarity. -- bruce 040923)
- if not USE_COMMAND_STACK: #bruce 080805 guess ### REVIEW
- self.commandSequencer.stop_sending_us_events( self)
- # stop receiving events from our command sequencer or glpane
- # (i.e. change current command to nullMode)
- self.restore_gui()
+ self.commandSequencer.stop_sending_us_events( self)
+ # stop receiving events from our command sequencer or glpane
+ # (i.e. change current command to nullMode)
+ # [not needed when USE_COMMAND_STACK -- bruce 080805 guess ### REVIEW]
+
+ self.restore_gui()
+ # [not needed when USE_COMMAND_STACK]
+
self.w.setFocus() #bruce 041010 bugfix (needed in two places)
# (I think that was needed to prevent key events from being sent to
# no-longer-shown command dashboards. [bruce 041220])
-## self.restore_patches()
+ #
+ # REVIEW: is this setFocus needed when USE_COMMAND_STACK?
+ # Need to figure out how to test it, to find out.
+ # [bruce 080909 question]
#### TODO: either rename the following for new command API,
# or copy their code into new command API methods and abandon them.
- # Guess: just do them from per-subclass overrides of command_will_exit.
- # [bruce 080806 comment]
+ # Guess: the latter -- just do them from per-subclass overrides of command_will_exit.
+ # Done for restore_patches_by_GraphicsMode, others need TODO/REVIEW.
+ # [bruce 080806/080909 comment]
- self.graphicsMode.restore_patches_by_GraphicsMode() # move earlier?
+ self.graphicsMode.restore_patches_by_GraphicsMode()
+ # Note: this is no longer part of the GraphicsMode API when USE_COMMAND_STACK is true,
+ # but certain commands retain it as an essentially private method and call it from
+ # self.command.command_will_exit in that case. [bruce 080829/080909 comment]
+
self.restore_patches_by_Command()
+ # only defined in movieMode & Build Crystal;
+ # code copied into command_will_exit in those cases [bruce 080909]
+
self.clear_command_state() # clear our internal state, if any
return # from _cleanup
@@ -1745,7 +1759,7 @@ class basicCommand(anyCommand):
@note: no longer part of the Command API when USE_COMMAND_STACK is true
"""
- assert not USE_COMMAND_STACK #bruce 080829 ### TODO: do the same things in other methods
+ assert not USE_COMMAND_STACK #bruce 080829 ### TODO: indiv commands need to do the same things in other methods
pass
def clear(self): #bruce 080806 deprecated this (old name of clear_command_state) ### rename in subs, in calls
diff --git a/cad/src/commands/BuildCrystal/BuildCrystal_Command.py b/cad/src/commands/BuildCrystal/BuildCrystal_Command.py
index 6d3105e09..6ca32c0fc 100755
--- a/cad/src/commands/BuildCrystal/BuildCrystal_Command.py
+++ b/cad/src/commands/BuildCrystal/BuildCrystal_Command.py
@@ -236,8 +236,9 @@ class BuildCrystal_Command(basicMode):
# (somewhat of a kluge, and whether this is the best place to do it is unknown;
# without this the cmdname is "Done")
- if not self.savedOrtho:
- self.w.setViewPerspecAction.setChecked(True)
+## if not self.savedOrtho:
+## self.w.setViewPerspecAction.setChecked(True)
+ self.o.setViewProjection(self.savedOrtho) #bruce 080909 cleanup, possible bugfix
#Restore GL states
self.o.redrawGL = True
@@ -258,6 +259,9 @@ class BuildCrystal_Command(basicMode):
self.o.shape.buildChunk(self.o.assy)
self.o.shape = None
+
+ self.selCurve_List = [] #bruce 080909
+ self.o.pov = V(self.oldPov[0], self.oldPov[1], self.oldPov[2]) #bruce 080909
super(BuildCrystal_Command, self).command_will_exit()
@@ -531,7 +535,7 @@ class BuildCrystal_Command(basicMode):
# from old Done and Flush methods]
def restore_patches_by_Command(self):
- self.o.ortho = self.savedOrtho
+ self.o.ortho = self.savedOrtho # for USE_COMMAND_STACK, done via setViewProjection in command_will_exit
self.o.shape = None
self.selCurve_List = []
self.o.pov = V(self.oldPov[0], self.oldPov[1], self.oldPov[2])
diff --git a/cad/src/commands/PlayMovie/movieMode.py b/cad/src/commands/PlayMovie/movieMode.py
index 511ef896b..17688bf4c 100755
--- a/cad/src/commands/PlayMovie/movieMode.py
+++ b/cad/src/commands/PlayMovie/movieMode.py
@@ -99,7 +99,7 @@ class movieMode(basicMode):
flyoutToolbar = None
- # methods related to entering this mode
+ # methods related to entering or exiting this mode
def Enter(self):
basicMode.Enter(self)
@@ -150,6 +150,18 @@ class movieMode(basicMode):
ask = True
if ask:
self._offer_to_rewind_if_necessary()
+
+ # copied the old self.restore_patches_by_Command():
+ #bruce 050426 added this, to hold the side effect formerly
+ # done illegally by haveNontrivialState.
+ # ... but why do we need to do this at all?
+ # the only point of what we'd do here would be to stop
+ # having that movie optimize itself for rapid playing....
+ movie = self.o.assy.current_movie
+ if movie:
+ movie._close()
+ # note: this assumes this is the only movie which might be "open",
+ # and that redundant _close is ok.
basicMode.command_will_exit(self)
return
@@ -182,6 +194,7 @@ class movieMode(basicMode):
#START new command API methods =============================================
#currently [2008-08-21 ] also called in by self.init_gui and
#self.restore_gui.
+
# see also command_will_exit, elsewhere in this file
def command_enter_PM(self):
@@ -345,6 +358,7 @@ class movieMode(basicMode):
"""
This is run when we exit self for any reason.
"""
+ assert not USE_COMMAND_STACK # done in command_will_exit in that case
#bruce 050426 added this, to hold the side effect formerly
# done illegally by haveNontrivialState.
# ... but why do we need to do this at all?
diff --git a/cad/src/commands/StereoProperties/StereoProperties_PropertyManager.py b/cad/src/commands/StereoProperties/StereoProperties_PropertyManager.py
index c4034414a..3f7a32b69 100644
--- a/cad/src/commands/StereoProperties/StereoProperties_PropertyManager.py
+++ b/cad/src/commands/StereoProperties/StereoProperties_PropertyManager.py
@@ -219,28 +219,29 @@ class StereoProperties_PropertyManager( PM_Dialog, DebugMenuMixin ):
def _enableStereo(self, enabled):
"""
Enable stereo view.
- """
- if self.o:
- self.o.stereo_enabled = enabled
+ """
+ glpane = self.o
+ if glpane:
+ glpane.stereo_enabled = enabled
# switch to perspective mode
if enabled:
# store current projection mode
- self.o.last_ortho = self.o.ortho
- if self.o.ortho:
+ glpane.__StereoProperties_last_ortho = glpane.ortho
+ if glpane.ortho:
# dont use glpane.setViewProjection
# because we don't want to modify
# default projection setting
- self.o.ortho = 0
+ glpane.ortho = 0
else:
# restore default mode
- if hasattr(self.o, "last_ortho"):
- projection = self.o.last_ortho
- if self.o.ortho != projection:
- self.o.ortho = projection
+ if hasattr(glpane, "__StereoProperties_last_ortho"):
+ projection = glpane.__StereoProperties_last_ortho
+ if glpane.ortho != projection:
+ glpane.ortho = projection
self._updateWidgets()
- self.o.gl_update()
+ glpane.gl_update()
def _stereoModeComboBoxChanged(self, mode):
diff --git a/cad/src/graphics/widgets/GLPane.py b/cad/src/graphics/widgets/GLPane.py
index 56f380fb8..3cdd20c82 100755
--- a/cad/src/graphics/widgets/GLPane.py
+++ b/cad/src/graphics/widgets/GLPane.py
@@ -1324,7 +1324,7 @@ class GLPane(GLPane_minimal,
def setViewProjection(self, projection): # Added by Mark 050918.
"""
Set projection, where 0 = Perspective and 1 = Orthographic. It does not set the
- prefs db value itself, since we don\'t want all user changes to projection to be stored
+ prefs db value itself, since we don't want all user changes to projection to be stored
in the prefs db, only the ones done from the Preferences dialog.
"""
# Set the checkmark for the Ortho/Perspective menu item in the View menu.