Allow to change projection range for projected modules
This commit is contained in:
@@ -55,12 +55,13 @@ class ChangeItemProjectionRange(ContextMenuSingle):
|
|||||||
newRange = None
|
newRange = None
|
||||||
|
|
||||||
if isinstance(mainItem, es_Fit):
|
if isinstance(mainItem, es_Fit):
|
||||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitRangeCommand(
|
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitProjectionRangeCommand(
|
||||||
fitID=fitID, projectedFitID=mainItem.ID, projectionRange=newRange))
|
fitID=fitID, projectedFitID=mainItem.ID, projectionRange=newRange))
|
||||||
elif isinstance(mainItem, Module):
|
elif isinstance(mainItem, Module):
|
||||||
if mainItem in fit.projectedModules:
|
if mainItem in fit.projectedModules:
|
||||||
position = fit.projectedModules.index(mainItem)
|
position = fit.projectedModules.index(mainItem)
|
||||||
pass
|
self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleProjectionRangeCommand(
|
||||||
|
fitID=fitID, position=position, projectionRange=newRange))
|
||||||
elif isinstance(mainItem, Drone):
|
elif isinstance(mainItem, Drone):
|
||||||
pass
|
pass
|
||||||
elif isinstance(mainItem, Fighter):
|
elif isinstance(mainItem, Fighter):
|
||||||
|
|||||||
@@ -66,10 +66,11 @@ from .gui.projectedFighter.changeAmount import GuiChangeProjectedFighterAmountCo
|
|||||||
from .gui.projectedFighter.changeMetas import GuiChangeProjectedFighterMetasCommand
|
from .gui.projectedFighter.changeMetas import GuiChangeProjectedFighterMetasCommand
|
||||||
from .gui.projectedFit.add import GuiAddProjectedFitsCommand
|
from .gui.projectedFit.add import GuiAddProjectedFitsCommand
|
||||||
from .gui.projectedFit.changeAmount import GuiChangeProjectedFitAmountCommand
|
from .gui.projectedFit.changeAmount import GuiChangeProjectedFitAmountCommand
|
||||||
from .gui.projectedFit.changeRange import GuiChangeProjectedFitRangeCommand
|
from .gui.projectedFit.changeProjectionRange import GuiChangeProjectedFitProjectionRangeCommand
|
||||||
from .gui.projectedModule.add import GuiAddProjectedModuleCommand
|
from .gui.projectedModule.add import GuiAddProjectedModuleCommand
|
||||||
from .gui.projectedModule.changeCharges import GuiChangeProjectedModuleChargesCommand
|
from .gui.projectedModule.changeCharges import GuiChangeProjectedModuleChargesCommand
|
||||||
from .gui.projectedModule.changeMetas import GuiChangeProjectedModuleMetasCommand
|
from .gui.projectedModule.changeMetas import GuiChangeProjectedModuleMetasCommand
|
||||||
|
from .gui.projectedModule.changeProjectionRange import GuiChangeProjectedModuleProjectionRangeCommand
|
||||||
from .gui.projectedModule.changeSpool import GuiChangeProjectedModuleSpoolCommand
|
from .gui.projectedModule.changeSpool import GuiChangeProjectedModuleSpoolCommand
|
||||||
from .gui.projectedRemove import GuiRemoveProjectedItemsCommand
|
from .gui.projectedRemove import GuiRemoveProjectedItemsCommand
|
||||||
from .gui.shipModeChange import GuiChangeShipModeCommand
|
from .gui.shipModeChange import GuiChangeShipModeCommand
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import wx
|
||||||
|
from logbook import Logger
|
||||||
|
|
||||||
|
from gui.fitCommands.helpers import restoreCheckedStates
|
||||||
|
from service.fit import Fit
|
||||||
|
|
||||||
|
|
||||||
|
pyfalog = Logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class CalcChangeProjectedModuleProjectionRangeCommand(wx.Command):
|
||||||
|
|
||||||
|
def __init__(self, fitID, position, projectionRange):
|
||||||
|
wx.Command.__init__(self, True)
|
||||||
|
self.fitID = fitID
|
||||||
|
self.position = position
|
||||||
|
self.projectionRange = projectionRange
|
||||||
|
self.savedProjectionRange = None
|
||||||
|
self.savedStateCheckChanges = None
|
||||||
|
|
||||||
|
def Do(self):
|
||||||
|
pyfalog.debug('Doing change of projected module projection range at position {} to range {} on fit {}'.format(
|
||||||
|
self.position, self.projectionRange, self.fitID))
|
||||||
|
|
||||||
|
sFit = Fit.getInstance()
|
||||||
|
fit = sFit.getFit(self.fitID)
|
||||||
|
mod = fit.projectedModules[self.position]
|
||||||
|
if mod.projectionRange == self.projectionRange:
|
||||||
|
return False
|
||||||
|
self.savedProjectionRange = mod.projectionRange
|
||||||
|
mod.projectionRange = self.projectionRange
|
||||||
|
|
||||||
|
sFit.recalc(fit)
|
||||||
|
self.savedStateCheckChanges = sFit.checkStates(fit, mod)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def Undo(self):
|
||||||
|
pyfalog.debug('Undoing change of projected module projection range at position {} to range {} on fit {}'.format(
|
||||||
|
self.position, self.projectionRange, self.fitID))
|
||||||
|
cmd = CalcChangeProjectedModuleProjectionRangeCommand(
|
||||||
|
fitID=self.fitID,
|
||||||
|
position=self.position,
|
||||||
|
projectionRange=self.savedProjectionRange)
|
||||||
|
result = cmd.Do()
|
||||||
|
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||||
|
return result
|
||||||
|
|
||||||
|
@property
|
||||||
|
def needsGuiRecalc(self):
|
||||||
|
if self.savedStateCheckChanges is None:
|
||||||
|
return True
|
||||||
|
for container in self.savedStateCheckChanges:
|
||||||
|
if len(container) > 0:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
@@ -31,9 +31,9 @@ class CalcChangeProjectedFitProjectionRangeCommand(wx.Command):
|
|||||||
if projectionInfo is None:
|
if projectionInfo is None:
|
||||||
pyfalog.warning('Fit projection info is not available')
|
pyfalog.warning('Fit projection info is not available')
|
||||||
return False
|
return False
|
||||||
self.savedProjectionRange = projectionInfo.projectionRange
|
if projectionInfo.projectionRange == self.projectionRange:
|
||||||
if self.projectionRange == self.savedProjectionRange:
|
|
||||||
return False
|
return False
|
||||||
|
self.savedProjectionRange = projectionInfo.projectionRange
|
||||||
projectionInfo.projectionRange = self.projectionRange
|
projectionInfo.projectionRange = self.projectionRange
|
||||||
|
|
||||||
sFit.recalc(fit)
|
sFit.recalc(fit)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from gui.fitCommands.helpers import InternalCommandHistory
|
|||||||
from service.fit import Fit
|
from service.fit import Fit
|
||||||
|
|
||||||
|
|
||||||
class GuiChangeProjectedFitRangeCommand(wx.Command):
|
class GuiChangeProjectedFitProjectionRangeCommand(wx.Command):
|
||||||
|
|
||||||
def __init__(self, fitID, projectedFitID, projectionRange):
|
def __init__(self, fitID, projectedFitID, projectionRange):
|
||||||
wx.Command.__init__(self, True, 'Change Projected Fit Projection Range')
|
wx.Command.__init__(self, True, 'Change Projected Fit Projection Range')
|
||||||
43
gui/fitCommands/gui/projectedModule/changeProjectionRange.py
Normal file
43
gui/fitCommands/gui/projectedModule/changeProjectionRange.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import wx
|
||||||
|
|
||||||
|
import eos.db
|
||||||
|
import gui.mainFrame
|
||||||
|
from gui import globalEvents as GE
|
||||||
|
from gui.fitCommands.calc.module.projectedChangeProjectionRange import CalcChangeProjectedModuleProjectionRangeCommand
|
||||||
|
from gui.fitCommands.helpers import InternalCommandHistory
|
||||||
|
from service.fit import Fit
|
||||||
|
|
||||||
|
|
||||||
|
class GuiChangeProjectedModuleProjectionRangeCommand(wx.Command):
|
||||||
|
|
||||||
|
def __init__(self, fitID, position, projectionRange):
|
||||||
|
wx.Command.__init__(self, True, 'Change Projected Module Projection Range')
|
||||||
|
self.internalHistory = InternalCommandHistory()
|
||||||
|
self.fitID = fitID
|
||||||
|
self.position = position
|
||||||
|
self.projectionRange = projectionRange
|
||||||
|
|
||||||
|
def Do(self):
|
||||||
|
cmd = CalcChangeProjectedModuleProjectionRangeCommand(
|
||||||
|
fitID=self.fitID,
|
||||||
|
position=self.position,
|
||||||
|
projectionRange=self.projectionRange)
|
||||||
|
success = self.internalHistory.submit(cmd)
|
||||||
|
sFit = Fit.getInstance()
|
||||||
|
if cmd.needsGuiRecalc:
|
||||||
|
eos.db.flush()
|
||||||
|
sFit.recalc(self.fitID)
|
||||||
|
sFit.fill(self.fitID)
|
||||||
|
eos.db.commit()
|
||||||
|
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
|
||||||
|
return success
|
||||||
|
|
||||||
|
def Undo(self):
|
||||||
|
success = self.internalHistory.undoAll()
|
||||||
|
eos.db.flush()
|
||||||
|
sFit = Fit.getInstance()
|
||||||
|
sFit.recalc(self.fitID)
|
||||||
|
sFit.fill(self.fitID)
|
||||||
|
eos.db.commit()
|
||||||
|
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
|
||||||
|
return success
|
||||||
Reference in New Issue
Block a user