From ec1a2c66ee24fa75309280c658b103609a57a110 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 18 May 2019 22:52:59 +0300 Subject: [PATCH] Restore shield graphs --- eos/graph/fitShieldAmountTime.py | 29 ------- eos/graph/fitShieldAmountVsTime.py | 27 ++++++ eos/graph/fitShieldRegenAmount.py | 49 ----------- eos/graph/fitShieldRegenVsShieldPerc.py | 22 +++++ gui/builtinGraphs/__init__.py | 4 +- gui/builtinGraphs/fitCapRegenVsCapPerc.py | 2 +- gui/builtinGraphs/fitShieldAmountTime.py | 85 ------------------ gui/builtinGraphs/fitShieldAmountVsTime.py | 49 +++++++++++ gui/builtinGraphs/fitShieldRegenAmount.py | 86 ------------------- .../fitShieldRegenVsShieldPerc.py | 50 +++++++++++ 10 files changed, 151 insertions(+), 252 deletions(-) delete mode 100644 eos/graph/fitShieldAmountTime.py create mode 100644 eos/graph/fitShieldAmountVsTime.py delete mode 100644 eos/graph/fitShieldRegenAmount.py create mode 100644 eos/graph/fitShieldRegenVsShieldPerc.py delete mode 100644 gui/builtinGraphs/fitShieldAmountTime.py create mode 100644 gui/builtinGraphs/fitShieldAmountVsTime.py delete mode 100644 gui/builtinGraphs/fitShieldRegenAmount.py create mode 100644 gui/builtinGraphs/fitShieldRegenVsShieldPerc.py diff --git a/eos/graph/fitShieldAmountTime.py b/eos/graph/fitShieldAmountTime.py deleted file mode 100644 index 5db97d99c..000000000 --- a/eos/graph/fitShieldAmountTime.py +++ /dev/null @@ -1,29 +0,0 @@ -import math -from logbook import Logger - -from eos.graph import Graph - - -pyfalog = Logger(__name__) - - -class FitShieldAmountTimeGraph(Graph): - - defaults = {"time": 0} - - def __init__(self, fit, data=None): - Graph.__init__(self, fit, self.calcAmount, data if data is not None else self.defaults) - self.fit = fit - import gui.mainFrame - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - - def calcAmount(self, data): - time = data["time"] - maxShield = self.fit.ship.getModifiedItemAttr('shieldCapacity') - regenTime = self.fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000 - # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate (shield is similar to cap) - shield = maxShield * (1 + math.exp(5 * -time / regenTime) * -1) ** 2 - useEhp = self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective - if self.fit.damagePattern is not None and useEhp: - shield = self.fit.damagePattern.effectivify(self.fit, shield, 'shield') - return shield diff --git a/eos/graph/fitShieldAmountVsTime.py b/eos/graph/fitShieldAmountVsTime.py new file mode 100644 index 000000000..387e80dee --- /dev/null +++ b/eos/graph/fitShieldAmountVsTime.py @@ -0,0 +1,27 @@ +import math +from logbook import Logger + +from eos.graph import SmoothGraph + + +pyfalog = Logger(__name__) + + +class FitShieldAmountVsTimeGraph(SmoothGraph): + + def __init__(self): + super().__init__() + import gui.mainFrame + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + def getYForX(self, fit, extraData, time): + if time < 0: + return 0 + maxShield = fit.ship.getModifiedItemAttr('shieldCapacity') + regenTime = fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000 + # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate (shield is similar to cap) + shield = maxShield * (1 + math.exp(5 * -time / regenTime) * -1) ** 2 + useEhp = self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective + if fit.damagePattern is not None and useEhp: + shield = fit.damagePattern.effectivify(fit, shield, 'shield') + return shield diff --git a/eos/graph/fitShieldRegenAmount.py b/eos/graph/fitShieldRegenAmount.py deleted file mode 100644 index f61b9b603..000000000 --- a/eos/graph/fitShieldRegenAmount.py +++ /dev/null @@ -1,49 +0,0 @@ -# =============================================================================== -# Copyright (C) 2010 Diego Duclos -# -# This file is part of eos. -# -# eos is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# eos 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with eos. If not, see . -# =============================================================================== - -import math -from logbook import Logger - -from eos.graph import Graph - - -pyfalog = Logger(__name__) - - -class FitShieldRegenAmountGraph(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 - import gui.mainFrame - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - - def calcRegen(self, data): - perc = data["percentage"] - maxShield = self.fit.ship.getModifiedItemAttr('shieldCapacity') - regenTime = self.fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000 - currentShield = maxShield * perc / 100 - # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate (shield is similar to cap) - regen = 10 * maxShield / regenTime * (math.sqrt(currentShield / maxShield) - currentShield / maxShield) - useEhp = self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective - if self.fit.damagePattern is not None and useEhp: - regen = self.fit.damagePattern.effectivify(self.fit, regen, 'shield') - return regen diff --git a/eos/graph/fitShieldRegenVsShieldPerc.py b/eos/graph/fitShieldRegenVsShieldPerc.py new file mode 100644 index 000000000..27902e428 --- /dev/null +++ b/eos/graph/fitShieldRegenVsShieldPerc.py @@ -0,0 +1,22 @@ +import math + +from eos.graph import SmoothGraph + + +class FitShieldRegenVsShieldPercGraph(SmoothGraph): + + def __init__(self): + super().__init__() + import gui.mainFrame + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + def getYForX(self, fit, extraData, perc): + maxShield = fit.ship.getModifiedItemAttr('shieldCapacity') + regenTime = fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000 + currentShield = maxShield * perc / 100 + # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate (shield is similar to cap) + regen = 10 * maxShield / regenTime * (math.sqrt(currentShield / maxShield) - currentShield / maxShield) + useEhp = self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective + if fit.damagePattern is not None and useEhp: + regen = fit.damagePattern.effectivify(fit, regen, 'shield') + return regen diff --git a/gui/builtinGraphs/__init__.py b/gui/builtinGraphs/__init__.py index a6ad555da..f594afb6e 100644 --- a/gui/builtinGraphs/__init__.py +++ b/gui/builtinGraphs/__init__.py @@ -3,8 +3,8 @@ from gui.builtinGraphs import ( # noqa: E402,F401 # fitDpsRange, # fitDpsTime, fitDmgVsTime, - # fitShieldRegenAmount, - # fitShieldAmountTime, + fitShieldRegenVsShieldPerc, + fitShieldAmountVsTime, fitCapRegenVsCapPerc, fitCapAmountVsTime, fitMobilityVsTime, diff --git a/gui/builtinGraphs/fitCapRegenVsCapPerc.py b/gui/builtinGraphs/fitCapRegenVsCapPerc.py index 41396f498..88dc4951d 100644 --- a/gui/builtinGraphs/fitCapRegenVsCapPerc.py +++ b/gui/builtinGraphs/fitCapRegenVsCapPerc.py @@ -33,7 +33,7 @@ class FitCapRegenVsCapPercGraph(Graph): @property def xDef(self): - return XDef(inputDefault='0-100', inputLabel='Cap Amount (percent)', inputIconID=1668, axisLabel='Cap amount, %') + return XDef(inputDefault='0-100', inputLabel='Cap amount (percent)', inputIconID=1668, axisLabel='Cap amount, %') @property def yDefs(self): diff --git a/gui/builtinGraphs/fitShieldAmountTime.py b/gui/builtinGraphs/fitShieldAmountTime.py deleted file mode 100644 index 6477ea205..000000000 --- a/gui/builtinGraphs/fitShieldAmountTime.py +++ /dev/null @@ -1,85 +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 . -# ============================================================================= - -import gui.mainFrame -from eos.graph import Data -from eos.graph.fitShieldAmountTime import FitShieldAmountTimeGraph as EosFitShieldAmountTimeGraph -from gui.bitmap_loader import BitmapLoader -from gui.graph import Graph -from service.attribute import Attribute - - -class FitShieldAmountTimeGraph(Graph): - - propertyLabelMap = {"time": "Time (seconds)"} - - defaults = EosFitShieldAmountTimeGraph.defaults.copy() - - def __init__(self): - Graph.__init__(self) - self.defaults["time"] = "0-300" - self.name = "Shield Amount vs Time" - 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('duration').iconID - bitmap = BitmapLoader.getBitmap(iconFile, "icons") - return {"time": bitmap} - - def getPoints(self, fit, fields): - eosGraph = getattr(self, "eosGraph", None) - if eosGraph is None or eosGraph.fit != fit: - eosGraph = self.eosGraph = EosFitShieldAmountTimeGraph(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 - - @property - def redrawOnEffectiveChange(self): - return True - - -FitShieldAmountTimeGraph.register() diff --git a/gui/builtinGraphs/fitShieldAmountVsTime.py b/gui/builtinGraphs/fitShieldAmountVsTime.py new file mode 100644 index 000000000..c3464c6f4 --- /dev/null +++ b/gui/builtinGraphs/fitShieldAmountVsTime.py @@ -0,0 +1,49 @@ +# ============================================================================= +# 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 + +import gui.mainFrame +from eos.graph.fitShieldAmountVsTime import FitShieldAmountVsTimeGraph as EosGraph +from gui.graph import Graph, XDef, YDef + + +class FitShieldAmountVsTimeGraph(Graph): + + name = 'Shield Amount vs Time' + + def __init__(self): + self.eosGraph = EosGraph() + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + @property + def xDef(self): + return XDef(inputDefault='0-300', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s') + + @property + def yDefs(self): + axisLabel = 'Shield amount, {}'.format('EHP' if self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective else 'HP') + return OrderedDict([('shieldAmount', YDef(switchLabel='Shield amount', axisLabel=axisLabel, eosGraph='eosGraph'))]) + + def redrawOnEffectiveChange(self): + return True + + +FitShieldAmountVsTimeGraph.register() diff --git a/gui/builtinGraphs/fitShieldRegenAmount.py b/gui/builtinGraphs/fitShieldRegenAmount.py deleted file mode 100644 index bbff09a4c..000000000 --- a/gui/builtinGraphs/fitShieldRegenAmount.py +++ /dev/null @@ -1,86 +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 . -# ============================================================================= - -import gui.mainFrame -from eos.graph import Data -from eos.graph.fitShieldRegenAmount import FitShieldRegenAmountGraph as EosFitShieldRegenAmountGraph -from gui.bitmap_loader import BitmapLoader -from gui.graph import Graph -from service.attribute import Attribute - - -class FitShieldRegenAmountGraph(Graph): - - propertyLabelMap = {"percentage": "Shield Capacity (percent)"} - - defaults = EosFitShieldRegenAmountGraph.defaults.copy() - - def __init__(self): - Graph.__init__(self) - self.defaults["percentage"] = "0-100" - self.name = "Shield Regen vs Shield 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('shieldCapacity').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 = EosFitShieldRegenAmountGraph(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 - - @property - def redrawOnEffectiveChange(self): - return True - - -FitShieldRegenAmountGraph.register() diff --git a/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py b/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py new file mode 100644 index 000000000..6fcbe3a0c --- /dev/null +++ b/gui/builtinGraphs/fitShieldRegenVsShieldPerc.py @@ -0,0 +1,50 @@ +# ============================================================================= +# 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 + +import gui.mainFrame +from eos.graph.fitShieldRegenVsShieldPerc import FitShieldRegenVsShieldPercGraph as EosGraph +from gui.graph import Graph, XDef, YDef + + +class FitShieldRegenVsShieldPercGraph(Graph): + + name = 'Shield Regen vs Shield Amount' + + def __init__(self): + self.eosGraph = EosGraph() + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + @property + def xDef(self): + return XDef(inputDefault='0-100', inputLabel='Shield amount (percent)', inputIconID=1384, axisLabel='Shield amount, %') + + @property + def yDefs(self): + axisLabel = 'Shield regen, {}/s'.format('EHP' if self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective else 'HP') + return OrderedDict([('shieldRegen', YDef(switchLabel='Shield regen', axisLabel=axisLabel, eosGraph='eosGraph'))]) + + @property + def redrawOnEffectiveChange(self): + return True + + +FitShieldRegenVsShieldPercGraph.register()