Do not store fit service and main frame on every command
This commit is contained in:
@@ -22,11 +22,9 @@ class GuiFillWithModuleCommand(wx.Command):
|
||||
:param position: Optional. The position in fit.modules that we are attempting to set the item to
|
||||
"""
|
||||
wx.Command.__init__(self, True, "Module Fill: {}".format(itemID))
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
self.position = position
|
||||
self.old_mod = None
|
||||
|
||||
@@ -34,19 +32,19 @@ class GuiFillWithModuleCommand(wx.Command):
|
||||
pyfalog.debug("{} Do()".format(self))
|
||||
pyfalog.debug("Trying to append a module")
|
||||
added_modules = 0
|
||||
while self.internal_history.Submit(CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=ModuleInfo(itemID=self.itemID))):
|
||||
while self.internalHistory.Submit(CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=ModuleInfo(itemID=self.itemID))):
|
||||
added_modules += 1
|
||||
|
||||
if added_modules > 0:
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="modadd", typeID=self.itemID))
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="modadd", typeID=self.itemID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug("{} Undo()".format(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, action="moddel", typeID=self.itemID))
|
||||
for _ in self.internalHistory.Commands:
|
||||
self.internalHistory.Undo()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID, action="moddel", typeID=self.itemID))
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user