32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import wx
|
|
|
|
import gui.mainFrame
|
|
from gui import globalEvents as GE
|
|
from gui.fitCommands.helpers import InternalCommandHistory, BoosterInfo
|
|
from service.fit import Fit
|
|
from .calcCommands.booster.add import CalcAddBoosterCommand
|
|
|
|
|
|
class GuiAddBoosterCommand(wx.Command):
|
|
|
|
def __init__(self, fitID, itemID):
|
|
wx.Command.__init__(self, True, 'Add Booster')
|
|
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
|
self.sFit = Fit.getInstance()
|
|
self.internalHistory = InternalCommandHistory()
|
|
self.fitID = fitID
|
|
self.itemID = itemID
|
|
|
|
def Do(self):
|
|
if self.internalHistory.submit(CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=BoosterInfo(itemID=self.itemID))):
|
|
self.sFit.recalc(self.fitID)
|
|
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
|
return True
|
|
return False
|
|
|
|
def Undo(self):
|
|
self.internalHistory.undoAll()
|
|
self.sFit.recalc(self.fitID)
|
|
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
|
return True
|