diff --git a/eos/graph/fitSpeedVsTime.py b/eos/graph/fitSpeedVsTime.py deleted file mode 100644 index 2aa021adb..000000000 --- a/eos/graph/fitSpeedVsTime.py +++ /dev/null @@ -1,14 +0,0 @@ -import math - -from .base import SmoothGraph - - -class FitSpeedVsTimeGraph(SmoothGraph): - - def getYForX(self, fit, extraData, time): - maxSpeed = fit.ship.getModifiedItemAttr('maxVelocity') - mass = fit.ship.getModifiedItemAttr('mass') - agility = fit.ship.getModifiedItemAttr('agility') - # https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae - speed = maxSpeed * (1 - math.exp((-time * 1000000) / (agility * mass))) - return speed diff --git a/gui/builtinGraphs/__init__.py b/gui/builtinGraphs/__init__.py index ea8b49783..f8495c26e 100644 --- a/gui/builtinGraphs/__init__.py +++ b/gui/builtinGraphs/__init__.py @@ -6,6 +6,6 @@ from gui.builtinGraphs import ( # noqa: E402,F401 # fitShieldAmountVsTime, # fitCapRegenVsCapPerc, # fitCapAmountVsTime, - # fitMobilityVsTime, + fitMobility, fitWarpTime ) diff --git a/gui/builtinGraphs/base.py b/gui/builtinGraphs/base.py index a1a88205b..c5e1262ab 100644 --- a/gui/builtinGraphs/base.py +++ b/gui/builtinGraphs/base.py @@ -28,14 +28,14 @@ Input = namedtuple('Input', ('handle', 'unit', 'label', 'iconID', 'defaultValue' VectorDef = namedtuple('VectorDef', ('lengthHandle', 'lengthUnit', 'angleHandle', 'angleUnit', 'label')) -class Graph(metaclass=ABCMeta): +class FitGraph(metaclass=ABCMeta): # UI stuff views = [] @classmethod def register(cls): - Graph.views.append(cls) + FitGraph.views.append(cls) def __init__(self): self._plotCache = {} diff --git a/gui/builtinGraphs/fitCapAmountVsTime.py b/gui/builtinGraphs/fitCapAmountVsTime.py index f29573175..3958687a7 100644 --- a/gui/builtinGraphs/fitCapAmountVsTime.py +++ b/gui/builtinGraphs/fitCapAmountVsTime.py @@ -21,10 +21,10 @@ from collections import OrderedDict from eos.graph.fitCapAmountVsTime import FitCapAmountVsTimeGraph as EosGraph -from .base import Graph, XDef, YDef +from .base import FitGraph, XDef, YDef -class FitCapAmountVsTimeGraph(Graph): +class FitCapAmountVsTimeGraph(FitGraph): name = 'Cap Amount vs Time' diff --git a/gui/builtinGraphs/fitCapRegenVsCapPerc.py b/gui/builtinGraphs/fitCapRegenVsCapPerc.py index ad4ae639e..a2607837c 100644 --- a/gui/builtinGraphs/fitCapRegenVsCapPerc.py +++ b/gui/builtinGraphs/fitCapRegenVsCapPerc.py @@ -21,10 +21,10 @@ from collections import OrderedDict from eos.graph.fitCapRegenVsCapPerc import FitCapRegenVsCapPercGraph as EosGraph -from .base import Graph, XDef, YDef +from .base import FitGraph, XDef, YDef -class FitCapRegenVsCapPercGraph(Graph): +class FitCapRegenVsCapPercGraph(FitGraph): name = 'Cap Regen vs Cap Amount' diff --git a/gui/builtinGraphs/fitDamageStats.py b/gui/builtinGraphs/fitDamageStats.py index a836c007c..45aa71ef9 100644 --- a/gui/builtinGraphs/fitDamageStats.py +++ b/gui/builtinGraphs/fitDamageStats.py @@ -20,17 +20,13 @@ import math -from eos.graph.fitDpsVsRange import FitDpsVsRangeGraph as EosGraph -from .base import Graph, XDef, YDef, Input, VectorDef +from .base import FitGraph, XDef, YDef, Input, VectorDef -class FitDamageStatsGraph(Graph): +class FitDamageStatsGraph(FitGraph): name = 'Damage Stats' - def __init__(self): - super().__init__(EosGraph()) - @property def xDefs(self): return [ diff --git a/gui/builtinGraphs/fitDmgVsTime.py b/gui/builtinGraphs/fitDmgVsTime.py index e9b1b14a6..cf2af9284 100644 --- a/gui/builtinGraphs/fitDmgVsTime.py +++ b/gui/builtinGraphs/fitDmgVsTime.py @@ -22,10 +22,10 @@ from collections import OrderedDict from eos.graph.fitDmgVsTime import FitDmgVsTimeGraph as EosGraphDmg from eos.graph.fitDpsVsTime import FitDpsVsTimeGraph as EosGraphDps -from .base import Graph, XDef, YDef +from .base import FitGraph, XDef, YDef -class FitDmgVsTimeGraph(Graph): +class FitDmgVsTimeGraph(FitGraph): name = 'Damage vs Time' diff --git a/gui/builtinGraphs/fitMobility.py b/gui/builtinGraphs/fitMobility.py new file mode 100644 index 000000000..4a084d94f --- /dev/null +++ b/gui/builtinGraphs/fitMobility.py @@ -0,0 +1,90 @@ +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + + +import math + +from .base import FitGraph, XDef, YDef, Input + + +class FitMobilityVsTimeGraph(FitGraph): + + name = 'Mobility' + + def __init__(self): + super().__init__() + + # UI stuff + @property + def xDefs(self): + return [XDef(handle='time', unit='s', label='Time', mainInput=('time', 's'))] + + @property + def yDefs(self): + return [ + YDef(handle='speed', unit='m/s', label='Speed'), + YDef(handle='distance', unit='km', label='Distance')] + + @property + def inputs(self): + return [Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=10, defaultRange=(0, 30), mainOnly=False)] + + @property + def xDef(self): + return XDef(inputDefault='0-80', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s') + + # Calculation stuff + _denormalizers = { + ('distance', 'km'): lambda v, fit, tgt: v / 1000} + + def _time2speed(self, mainInput, miscInputs, fit, tgt): + xs = [] + ys = [] + maxSpeed = fit.ship.getModifiedItemAttr('maxVelocity') + mass = fit.ship.getModifiedItemAttr('mass') + agility = fit.ship.getModifiedItemAttr('agility') + for time in self._iterLinear(mainInput[1]): + # https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae + speed = maxSpeed * (1 - math.exp((-time * 1000000) / (agility * mass))) + xs.append(time) + ys.append(speed) + return xs, ys + + def _time2distance(self, mainInput, miscInputs, fit, tgt): + xs = [] + ys = [] + maxSpeed = fit.ship.getModifiedItemAttr('maxVelocity') + mass = fit.ship.getModifiedItemAttr('mass') + agility = fit.ship.getModifiedItemAttr('agility') + for time in self._iterLinear(mainInput[1]): + # Definite integral of: + # https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae + distance_t = maxSpeed * time + (maxSpeed * agility * mass * math.exp((-time * 1000000) / (agility * mass)) / 1000000) + distance_0 = maxSpeed * 0 + (maxSpeed * agility * mass * math.exp((-0 * 1000000) / (agility * mass)) / 1000000) + distance = distance_t - distance_0 + xs.append(time) + ys.append(distance) + return xs, ys + + _getters = { + ('time', 'speed'): _time2speed, + ('time', 'distance'): _time2distance} + + +FitMobilityVsTimeGraph.register() diff --git a/gui/builtinGraphs/fitMobilityVsTime.py b/gui/builtinGraphs/fitMobilityVsTime.py deleted file mode 100644 index 6f002bce9..000000000 --- a/gui/builtinGraphs/fitMobilityVsTime.py +++ /dev/null @@ -1,48 +0,0 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - - -from collections import OrderedDict - -from eos.graph.fitDistanceVsTime import FitDistanceVsTimeGraph as EosGraphDistance -from eos.graph.fitSpeedVsTime import FitSpeedVsTimeGraph as EosGraphSpeed -from .base import Graph, XDef, YDef - - -class FitMobilityVsTimeGraph(Graph): - - name = 'Mobility vs Time' - - def __init__(self): - super().__init__() - self.eosGraphSpeed = EosGraphSpeed() - self.eosGraphDistance = EosGraphDistance() - - @property - def xDef(self): - return XDef(inputDefault='0-80', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s') - - @property - def yDefs(self): - return OrderedDict([ - ('speed', YDef(switchLabel='Speed', axisLabel='Speed, m/s', eosGraph='eosGraphSpeed')), - ('distance', YDef(switchLabel='Distance', axisLabel='Distance, m', eosGraph='eosGraphDistance'))]) - - -FitMobilityVsTimeGraph.register() diff --git a/gui/builtinGraphs/fitShieldAmountVsTime.py b/gui/builtinGraphs/fitShieldAmountVsTime.py index ae44178f6..1cb16aef6 100644 --- a/gui/builtinGraphs/fitShieldAmountVsTime.py +++ b/gui/builtinGraphs/fitShieldAmountVsTime.py @@ -22,10 +22,10 @@ from collections import OrderedDict import gui.mainFrame from eos.graph.fitShieldAmountVsTime import FitShieldAmountVsTimeGraph as EosGraph -from .base import Graph, XDef, YDef +from .base import FitGraph, XDef, YDef -class FitShieldAmountVsTimeGraph(Graph): +class FitShieldAmountVsTimeGraph(FitGraph): name = 'Shield Amount vs Time' diff --git a/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py b/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py index e86ce5aef..7dc8212cb 100644 --- a/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py +++ b/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py @@ -22,10 +22,10 @@ from collections import OrderedDict import gui.mainFrame from eos.graph.fitShieldRegenVsShieldPerc import FitShieldRegenVsShieldPercGraph as EosGraph -from .base import Graph, XDef, YDef +from .base import FitGraph, XDef, YDef -class FitShieldRegenVsShieldPercGraph(Graph): +class FitShieldRegenVsShieldPercGraph(FitGraph): name = 'Shield Regen vs Shield Amount' diff --git a/gui/builtinGraphs/fitWarpTime.py b/gui/builtinGraphs/fitWarpTime.py index d7337f00f..6d2eafcce 100644 --- a/gui/builtinGraphs/fitWarpTime.py +++ b/gui/builtinGraphs/fitWarpTime.py @@ -21,19 +21,16 @@ import math from eos.const import FittingModuleState -from .base import Graph, XDef, YDef, Input +from .base import FitGraph, XDef, YDef, Input AU_METERS = 149597870700 -class FitWarpTimeGraph(Graph): +class FitWarpTimeGraph(FitGraph): name = 'Warp Time' - def __init__(self): - super().__init__() - # UI stuff @property def xDefs(self): diff --git a/gui/graphFrame/frame.py b/gui/graphFrame/frame.py index 0a360eaf3..350f5870b 100644 --- a/gui/graphFrame/frame.py +++ b/gui/graphFrame/frame.py @@ -30,7 +30,7 @@ import gui.display import gui.globalEvents as GE import gui.mainFrame from gui.bitmap_loader import BitmapLoader -from gui.builtinGraphs.base import Graph +from gui.builtinGraphs.base import FitGraph from .panel import GraphControlPanel @@ -111,7 +111,7 @@ class GraphFrame(wx.Frame): self.SetSizer(mainSizer) # Setup - graph selector - for view in Graph.views: + for view in FitGraph.views: self.graphSelection.Append(view.name, view()) self.graphSelection.SetSelection(0) self.ctrlPanel.updateControls(layout=False)