Move gui commands to their own package to avoid confusion in commands package

This commit is contained in:
DarkPhoenix
2019-04-15 12:15:19 +03:00
parent a560597a85
commit 82777d0b02
127 changed files with 143 additions and 143 deletions

View File

@@ -0,0 +1,30 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calc.module.projectedAdd import CalcAddProjectedModuleCommand
from gui.fitCommands.helpers import InternalCommandHistory, ModuleInfo
from service.fit import Fit
class GuiAddProjectedModuleCommand(wx.Command):
def __init__(self, fitID, itemID):
wx.Command.__init__(self, True, 'Add Projected Module')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.itemID = itemID
def Do(self):
cmd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=ModuleInfo(itemID=self.itemID))
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success

View File

@@ -0,0 +1,31 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calc.module.changeCharges import CalcChangeModuleChargesCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeProjectedModuleChargesCommand(wx.Command):
def __init__(self, fitID, modules, chargeItemID):
wx.Command.__init__(self, True, 'Change Projected Module Charges')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.positions = [mod.modPosition for mod in modules]
self.chargeItemID = chargeItemID
def Do(self):
cmd = CalcChangeModuleChargesCommand(fitID=self.fitID, projected=True, chargeMap={p: self.chargeItemID for p in self.positions})
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success

View File

@@ -0,0 +1,37 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calc.module.changeSpool import CalcChangeModuleSpoolCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeProjectedModuleSpoolCommand(wx.Command):
def __init__(self, fitID, position, spoolType, spoolAmount):
wx.Command.__init__(self, True, 'Change Projected Module Spool')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
self.spoolType = spoolType
self.spoolAmount = spoolAmount
def Do(self):
cmd = CalcChangeModuleSpoolCommand(
fitID=self.fitID,
projected=True,
position=self.position,
spoolType=self.spoolType,
spoolAmount=self.spoolAmount)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success

View File

@@ -0,0 +1,31 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calc.module.projectedChangeState import CalcChangeProjectedModuleStateCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeProjectedModuleStateCommand(wx.Command):
def __init__(self, fitID, position, click):
wx.Command.__init__(self, True, 'Change Projected Module State')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
self.click = click
def Do(self):
cmd = CalcChangeProjectedModuleStateCommand(fitID=self.fitID, position=self.position, click=self.click)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success

View File

@@ -0,0 +1,30 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calc.module.projectedRemove import CalcRemoveProjectedModuleCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiRemoveProjectedModuleCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, 'Remove Projected Module')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
def Do(self):
cmd = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=self.position)
if self.internalHistory.submit(cmd):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success