Created undo/redo command for module remove, along with reapplying some module-specific attributes (state, charge). Fixed a bug when trying to add a module that doesn't fit

This commit is contained in:
blitzmann
2018-07-21 15:34:58 -04:00
parent 0c3fa53bcf
commit 9309ddff07
5 changed files with 57 additions and 21 deletions

View File

@@ -7,8 +7,8 @@ from gui import globalEvents as GE
class FitModuleAddCommand(wx.Command):
def __init__(self, fitID, itemID):
# todo: instead of modules, needs to be positions. Dead objects are a thing
wx.Command.__init__(self, True, "Module Add")
# todo: evaluate mutaplasmid modules
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.fitID = fitID
@@ -16,6 +16,7 @@ class FitModuleAddCommand(wx.Command):
self.new_position = None
def Do(self):
# todo: figure how not to add this command to stack if module doesn't fit correctly.
populate, self.new_position = self.sFit.appendModule(self.fitID, self.itemID)
if populate is not None:
# self.slotsChanged() # unsure how to handle this right now? Perhaps move this to the event itself?
@@ -23,7 +24,8 @@ class FitModuleAddCommand(wx.Command):
return True
def Undo(self):
# todo: self.slotsChanged()
result = self.sFit.removeModule(self.fitID, [self.new_position])
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="moddel", typeID=self.itemID))
if (self.new_position):
# todo: self.slotsChanged()
result = self.sFit.removeModule(self.fitID, [self.new_position])
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="moddel", typeID=self.itemID))
return True