diff --git a/gui/builtinGraphs/__init__.py b/gui/builtinGraphs/__init__.py index de2446088..5cf1cd831 100644 --- a/gui/builtinGraphs/__init__.py +++ b/gui/builtinGraphs/__init__.py @@ -7,5 +7,5 @@ from gui.builtinGraphs import ( # noqa: E402,F401 # fitCapRegenVsCapPerc, # fitCapAmountVsTime, # fitMobilityVsTime, - # fitWarpTimeVsDistance + fitWarpTimeVsDistance ) diff --git a/gui/builtinGraphs/fitWarpTimeVsDistance.py b/gui/builtinGraphs/fitWarpTimeVsDistance.py index c7bce5c1d..b54015dff 100644 --- a/gui/builtinGraphs/fitWarpTimeVsDistance.py +++ b/gui/builtinGraphs/fitWarpTimeVsDistance.py @@ -18,27 +18,33 @@ # ============================================================================= -from collections import OrderedDict - from eos.graph.fitWarpTimeVsDistance import FitWarpTimeVsDistanceGraph as EosGraph -from .base import Graph, XDef, YDef +from .base import Graph, XDef, YDef, Input class FitWarpTimeVsDistanceGraph(Graph): - name = 'Warp Time vs Distance' + name = 'Warp Time' def __init__(self): super().__init__() self.eosGraph = EosGraph() @property - def xDef(self): - return XDef(inputDefault='0-50', inputLabel='Distance (AU)', inputIconID=1391, axisLabel='Warp distance, AU') + def xDefs(self): + return [ + XDef(handle='distance', unit='AU', label='Distance', mainInput=('distance', 'AU')), + XDef(handle='distance', unit='km', label='Distance', mainInput=('distance', 'km'))] @property def yDefs(self): - return OrderedDict([('time', YDef(switchLabel='Warp time', axisLabel='Warp time, s', eosGraph='eosGraph'))]) + return [YDef(handle='time', unit='s', label='Warp time', eosGraph='eosGraph')] + + @property + def inputs(self): + return [ + Input(handle='distance', unit='AU', label='Distance', iconID=1391, defaultValue=50, defaultRange=(0, 50), mainOnly=False), + Input(handle='distance', unit='km', label='Distance', iconID=1391, defaultValue=10000, defaultRange=(150, 5000), mainOnly=False)] FitWarpTimeVsDistanceGraph.register() diff --git a/gui/graphFrame/panel.py b/gui/graphFrame/panel.py index 35be02b9b..4d6f25767 100644 --- a/gui/graphFrame/panel.py +++ b/gui/graphFrame/panel.py @@ -111,9 +111,11 @@ class GraphControlPanel(wx.Panel): for yDef in view.yDefs: self.ySubSelection.Append(self._formatLabel(yDef), (yDef.handle, yDef.unit)) self.ySubSelection.SetSelection(0) + self.ySubSelection.Enable(len(view.yDefs) > 1) for xDef in view.xDefs: self.xSubSelection.Append(self._formatLabel(xDef), (xDef.handle, xDef.unit)) self.xSubSelection.SetSelection(0) + self.xSubSelection.Enable(len(view.xDefs) > 1) # Vectors self._setVectorDefaults() @@ -136,14 +138,15 @@ class GraphControlPanel(wx.Panel): self.targetList.Show(view.hasTargets) # Inputs - self._updateInputs() + self._updateInputs(storeInputs=False) if layout: self.graphFrame.Layout() self.graphFrame.UpdateWindowSize() - def _updateInputs(self): - self._storeCurrentValues() + def _updateInputs(self, storeInputs=True): + if storeInputs: + self._storeCurrentValues() # Clean up old inputs for children in self._inputs.values(): for child in children: @@ -287,7 +290,7 @@ class GraphControlPanel(wx.Panel): self._storedConsts[(handle, unit)] = value def _clearStoredValues(self): - self._storedRanges.clear() + self._storedConsts.clear() self._storedRanges.clear() def _setVectorDefaults(self):