Rework cap regen graph to use new interfaces
This commit is contained in:
@@ -3,21 +3,21 @@ import math
|
||||
from eos.graph import Graph
|
||||
|
||||
|
||||
class FitCapAmountTimeGraph(Graph):
|
||||
class FitCapAmountVsTimeGraph(Graph):
|
||||
|
||||
def getPlotPoints(self, fit, extraData, xRange, xAmount):
|
||||
xs = []
|
||||
ys = []
|
||||
for x in self._xIter(xRange, xAmount):
|
||||
xs.append(x)
|
||||
ys.append(self.calcCap(fit, x))
|
||||
ys.append(self.calc(fit, x))
|
||||
return xs, {'capAmount': ys}
|
||||
|
||||
def getYForX(self, fit, extraData, x):
|
||||
return {'capAmount': self.calcCap(fit, x)}
|
||||
return {'capAmount': self.calc(fit, x)}
|
||||
|
||||
@staticmethod
|
||||
def calcCap(fit, time):
|
||||
def calc(fit, time):
|
||||
if time < 0:
|
||||
return 0
|
||||
maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity')
|
||||
@@ -1,25 +0,0 @@
|
||||
import math
|
||||
from logbook import Logger
|
||||
|
||||
from eos.graph import Graph
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class FitCapRegenAmountGraph(Graph):
|
||||
|
||||
defaults = {"percentage": '0-100'}
|
||||
|
||||
def __init__(self, fit, data=None):
|
||||
Graph.__init__(self, fit, self.calcRegen, data if data is not None else self.defaults)
|
||||
self.fit = fit
|
||||
|
||||
def calcRegen(self, data):
|
||||
perc = data['percentage']
|
||||
maxCap = self.fit.ship.getModifiedItemAttr('capacitorCapacity')
|
||||
regenTime = self.fit.ship.getModifiedItemAttr('rechargeRate') / 1000
|
||||
currentCap = maxCap * perc / 100
|
||||
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
|
||||
regen = 10 * maxCap / regenTime * (math.sqrt(currentCap / maxCap) - currentCap / maxCap)
|
||||
return regen
|
||||
26
eos/graph/fitCapRegenVsCapPerc.py
Normal file
26
eos/graph/fitCapRegenVsCapPerc.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import math
|
||||
|
||||
from eos.graph import Graph
|
||||
|
||||
|
||||
class FitCapRegenVsCapPercGraph(Graph):
|
||||
|
||||
def getPlotPoints(self, fit, extraData, xRange, xAmount):
|
||||
xs = []
|
||||
ys = []
|
||||
for x in self._xIter(xRange, xAmount):
|
||||
xs.append(x)
|
||||
ys.append(self.calc(fit, x))
|
||||
return xs, {'capRegen': ys}
|
||||
|
||||
def getYForX(self, fit, extraData, x):
|
||||
return {'capRegen': self.calc(fit, x)}
|
||||
|
||||
@staticmethod
|
||||
def calc(fit, perc):
|
||||
maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity')
|
||||
regenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000
|
||||
currentCap = maxCap * perc / 100
|
||||
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
|
||||
regen = 10 * maxCap / regenTime * (math.sqrt(currentCap / maxCap) - currentCap / maxCap)
|
||||
return regen
|
||||
@@ -5,8 +5,8 @@ from gui.builtinGraphs import ( # noqa: E402,F401
|
||||
# fitDmgTime,
|
||||
# fitShieldRegenAmount,
|
||||
# fitShieldAmountTime,
|
||||
# fitCapRegenAmount,
|
||||
fitCapAmountTime,
|
||||
fitCapRegenVsCapPerc,
|
||||
fitCapAmountVsTime,
|
||||
# fitSpeedTime,
|
||||
# fitDistanceTime,
|
||||
# fitWarpTimeDistance
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
import gui.mainFrame
|
||||
from eos.graph.fitCapAmountTime import FitCapAmountTimeGraph as EosGraph
|
||||
from eos.graph.fitCapAmountVsTime import FitCapAmountVsTimeGraph as EosGraph
|
||||
from gui.graph import Graph, XDef, YDef
|
||||
|
||||
|
||||
class FitCapAmountTimeGraph(Graph):
|
||||
class FitCapAmountVsTimeGraph(Graph):
|
||||
|
||||
name = 'Cap Amount vs Time'
|
||||
|
||||
def __init__(self):
|
||||
self.eosGraph = EosGraph()
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@property
|
||||
def xDef(self):
|
||||
@@ -44,4 +42,4 @@ class FitCapAmountTimeGraph(Graph):
|
||||
return self.eosGraph.getPlotPoints(fit, extraData, xRange, xAmount)
|
||||
|
||||
|
||||
FitCapAmountTimeGraph.register()
|
||||
FitCapAmountVsTimeGraph.register()
|
||||
@@ -1,82 +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 <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
import gui.mainFrame
|
||||
from eos.graph import Data
|
||||
from eos.graph.fitCapRegenAmount import FitCapRegenAmountGraph as EosFitCapRegenAmountGraph
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.graph import Graph
|
||||
from service.attribute import Attribute
|
||||
|
||||
|
||||
class FitCapRegenAmountGraph(Graph):
|
||||
|
||||
propertyLabelMap = {"percentage": "Cap Amount (percent)"}
|
||||
|
||||
defaults = EosFitCapRegenAmountGraph.defaults.copy()
|
||||
|
||||
def __init__(self):
|
||||
Graph.__init__(self)
|
||||
self.defaults["percentage"] = "0-100"
|
||||
self.name = "Cap Regen vs Cap Amount"
|
||||
self.eosGraph = None
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def getFields(self):
|
||||
return self.defaults
|
||||
|
||||
def getLabels(self):
|
||||
return self.propertyLabelMap
|
||||
|
||||
def getIcons(self):
|
||||
iconFile = Attribute.getInstance().getAttributeInfo('capacitorCapacity').iconID
|
||||
bitmap = BitmapLoader.getBitmap(iconFile, "icons")
|
||||
return {"percentage": bitmap}
|
||||
|
||||
def getPoints(self, fit, fields):
|
||||
eosGraph = getattr(self, "eosGraph", None)
|
||||
if eosGraph is None or eosGraph.fit != fit:
|
||||
eosGraph = self.eosGraph = EosFitCapRegenAmountGraph(fit)
|
||||
|
||||
eosGraph.clearData()
|
||||
variable = None
|
||||
for fieldName, value in fields.items():
|
||||
d = Data(fieldName, value)
|
||||
if not d.isConstant():
|
||||
if variable is None:
|
||||
variable = fieldName
|
||||
else:
|
||||
# We can't handle more then one variable atm, OOPS FUCK OUT
|
||||
return False, "Can only handle 1 variable"
|
||||
|
||||
eosGraph.setData(d)
|
||||
|
||||
if variable is None:
|
||||
return False, "No variable"
|
||||
|
||||
x = []
|
||||
y = []
|
||||
for point, val in eosGraph.getIterator():
|
||||
x.append(point[variable])
|
||||
y.append(val)
|
||||
|
||||
return x, y
|
||||
|
||||
|
||||
FitCapRegenAmountGraph.register()
|
||||
45
gui/builtinGraphs/fitCapRegenVsCapPerc.py
Normal file
45
gui/builtinGraphs/fitCapRegenVsCapPerc.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# =============================================================================
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from eos.graph.fitCapRegenVsCapPerc import FitCapRegenVsCapPercGraph as EosGraph
|
||||
from gui.graph import Graph, XDef, YDef
|
||||
|
||||
|
||||
class FitCapRegenVsCapPercGraph(Graph):
|
||||
|
||||
name = 'Cap Regen vs Cap Amount'
|
||||
|
||||
def __init__(self):
|
||||
self.eosGraph = EosGraph()
|
||||
|
||||
@property
|
||||
def xDef(self):
|
||||
return XDef(handle='percentage', inputDefault='0-100', inputLabel='Cap Amount (percent)', inputIconID=1668, axisLabel='Cap amount, %')
|
||||
|
||||
@property
|
||||
def yDefs(self):
|
||||
return [YDef(handle='capRegen', switchLabel='Cap regen', axisLabel='Cap regen, GJ/s')]
|
||||
|
||||
def getPlotPoints(self, fit, extraData, xRange, xAmount):
|
||||
xRange = self.parseRange(xRange)
|
||||
return self.eosGraph.getPlotPoints(fit, extraData, xRange, xAmount)
|
||||
|
||||
|
||||
FitCapRegenVsCapPercGraph.register()
|
||||
Reference in New Issue
Block a user