Do command fit toggle. Still need to settle on the logic for how to handle deleted fits - seems there's an issue with the queue.

This commit is contained in:
blitzmann
2018-08-03 22:30:09 -04:00
parent 3c7f0258df
commit 425c7f657c
5 changed files with 76 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calc.fitToggleCommand import FitToggleCommandCommand
class GuiToggleCommandCommand(wx.Command):
def __init__(self, fitID, commandFitID):
wx.Command.__init__(self, True, "")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.internal_history = wx.CommandProcessor()
self.fitID = fitID
# can set his up no to not have to set variables on our object
self.cmd = FitToggleCommandCommand(fitID, commandFitID)
def Do(self):
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