More tweaks to existing commands

This commit is contained in:
blitzmann
2018-08-03 01:08:33 -04:00
parent 36b158637c
commit c84c79c917
5 changed files with 36 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import gui.mainFrame
from gui import globalEvents as GE
from .calc.fitChangeState import FitChangeStatesCommand
class GuiModuleStateChangeCommand(wx.Command):
def __init__(self, fitID, baseMod, modules, click):
# todo: instead of modules, needs to be positions. Dead objects are a thing
@@ -16,16 +17,19 @@ class GuiModuleStateChangeCommand(wx.Command):
self.modules = modules
self.click = click
self.internal_history = wx.CommandProcessor()
self.cmd = FitChangeStatesCommand(self.fitID, self.baseMod, self.modules, self.click)
def Do(self):
# todo: determine if we've changed state (recalc). If not, store that so we don't attempt to recalc on undo
self.internal_history.Submit(FitChangeStatesCommand(self.fitID, self.baseMod, self.modules, self.click))
if self.internal_history.Submit(self.cmd):
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internal_history.Commands:
self.internal_history.Undo()
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
def Undo(self):
for x in self.internal_history.Commands:
self.internal_history.Undo()
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True