Some documentation
This commit is contained in:
@@ -6,6 +6,8 @@ from .calc.fitAddModule import FitAddModuleCommand
|
||||
from .calc.fitReplaceModule import FitReplaceModuleCommand
|
||||
from .calc.fitSetCharge import FitSetChargeCommand
|
||||
from service.fit import Fit
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class GuiModuleAddCommand(wx.Command):
|
||||
@@ -28,21 +30,27 @@ class GuiModuleAddCommand(wx.Command):
|
||||
self.old_mod = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("{} Do()".format(self))
|
||||
success = False
|
||||
item = eos.db.getItem(self.itemID)
|
||||
if item.isCharge and self.position is not None:
|
||||
pyfalog.debug("Trying to add a charge")
|
||||
success = self.internal_history.Submit(FitSetChargeCommand(self.fitID, [self.position], self.itemID))
|
||||
if not success:
|
||||
pyfalog.debug(" Failed")
|
||||
return False # if it's a charge item and this failed, nothing more we can try.
|
||||
# if we have a position set, try to apply the module to that position
|
||||
elif self.position is not None:
|
||||
pyfalog.debug("Trying to add a module to a specific position")
|
||||
success = self.internal_history.Submit(FitReplaceModuleCommand(self.fitID, self.position, self.itemID))
|
||||
if not success:
|
||||
pyfalog.debug(" Failed")
|
||||
# something went wrong with trying to fit the module into specific location, attempt to append it
|
||||
self.position = None
|
||||
|
||||
# if we're not trying to set module to a position, simply append
|
||||
if self.position is None:
|
||||
pyfalog.debug("Trying to append a module")
|
||||
success = self.internal_history.Submit(FitAddModuleCommand(self.fitID, self.itemID))
|
||||
|
||||
if success:
|
||||
@@ -53,6 +61,7 @@ class GuiModuleAddCommand(wx.Command):
|
||||
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug("{} Undo()".format(self))
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
|
||||
Reference in New Issue
Block a user