Implement some various toggles as commands

This commit is contained in:
blitzmann
2018-08-14 01:25:36 -04:00
parent a5a152d395
commit 71257b5265
12 changed files with 199 additions and 10 deletions

View File

@@ -0,0 +1,30 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calc.fitToggleBooster import FitToggleBoosterCommand
class GuiToggleImplantCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, "")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.internal_history = wx.CommandProcessor()
self.fitID = fitID
self.position = position
def Do(self):
if self.internal_history.Submit(FitToggleBoosterCommand(self.fitID, self.position)):
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