30 lines
991 B
Python
30 lines
991 B
Python
import math
|
|
|
|
import wx
|
|
from service.fit import Fit
|
|
|
|
import gui.mainFrame
|
|
from gui import globalEvents as GE
|
|
from gui.fitCommands.helpers import CargoInfo
|
|
from .calcCommands.cargo.remove import CalcRemoveCargoCommand
|
|
|
|
|
|
class GuiRemoveCargoCommand(wx.Command):
|
|
def __init__(self, fitID, itemID):
|
|
wx.Command.__init__(self, True, "Cargo Remove")
|
|
self.internalHistory = wx.CommandProcessor()
|
|
self.fitID = fitID
|
|
self.itemID = itemID
|
|
|
|
def Do(self):
|
|
if self.internalHistory.Submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))):
|
|
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
|
return True
|
|
return False
|
|
|
|
def Undo(self):
|
|
for _ in self.internalHistory.GetCommands():
|
|
self.internalHistory.Undo()
|
|
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
|
return True
|