Make it possible to fill with mutated modules
This commit is contained in:
@@ -10,25 +10,31 @@ from service.fit import Fit
|
||||
|
||||
class GuiFillWithLocalModulesCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, 'Fill with Local Modules')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.position = position
|
||||
self.savedItemID = None
|
||||
|
||||
def Do(self):
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.fitID)
|
||||
mod = fit.modules[self.position]
|
||||
self.savedItemID = mod.itemID
|
||||
info = ModuleInfo.fromModule(mod)
|
||||
added_modules = 0
|
||||
while True:
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=ModuleInfo(itemID=self.itemID), commit=False)
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=info, commit=False)
|
||||
if not self.internalHistory.submit(cmd):
|
||||
break
|
||||
added_modules += 1
|
||||
eos.db.commit()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
sFit.recalc(self.fitID)
|
||||
success = added_modules > 0
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.itemID) if success else GE.FitChanged(fitID=self.fitID))
|
||||
GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.savedItemID) if success else GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
@@ -37,5 +43,5 @@ class GuiFillWithLocalModulesCommand(wx.Command):
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.itemID) if success else GE.FitChanged(fitID=self.fitID))
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.savedItemID) if success else GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
Reference in New Issue
Block a user