Add shield recharge graph

This commit is contained in:
DarkPhoenix
2019-05-12 14:32:57 +03:00
parent d9535b08b1
commit ac132cbb92
5 changed files with 160 additions and 13 deletions

View File

@@ -0,0 +1,48 @@
# ===============================================================================
# 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 <http://www.gnu.org/licenses/>.
# ===============================================================================
import math
from logbook import Logger
import gui.mainFrame
from eos.graph import Graph
pyfalog = Logger(__name__)
class FitShieldRegenRelativeGraph(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
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
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

View File

@@ -1,5 +1,6 @@
__all__ = [
"fitDpsRange",
"fitDpsTime",
"fitDmgTime"
'fitDpsRange',
'fitDpsTime',
'fitDmgTime',
'fitShieldRegenRelative'
]

View File

@@ -0,0 +1,86 @@
# =============================================================================
# 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.fitShieldRegenRelative import FitShieldRegenRelativeGraph as EosFitShieldRegenRelativeGraph
from gui.bitmap_loader import BitmapLoader
from gui.graph import Graph
from service.attribute import Attribute
class FitShieldRegenRelativeGraph(Graph):
propertyLabelMap = {"percentage": "Shield Capacity (percent)"}
defaults = EosFitShieldRegenRelativeGraph.defaults.copy()
def __init__(self):
Graph.__init__(self)
self.defaults["percentage"] = "0-100"
self.name = "Shield Regen vs. Shield Capacity"
self.shieldRegenRelative = 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):
shieldRegenRelative = getattr(self, "shieldRegenRelative", None)
if shieldRegenRelative is None or shieldRegenRelative.fit != fit:
shieldRegenRelative = self.shieldRegenRelative = EosFitShieldRegenRelativeGraph(fit)
shieldRegenRelative.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"
shieldRegenRelative.setData(d)
if variable is None:
return False, "No variable"
x = []
y = []
for point, val in shieldRegenRelative.getIterator():
x.append(point[variable])
y.append(val)
return x, y
@property
def redrawOnEffectiveChange(self):
return True
FitShieldRegenRelativeGraph.register()

View File

@@ -34,10 +34,10 @@ class Graph(object):
def getIcons(self):
return None
@property
def redrawOnEffectiveChange(self):
return False
# noinspection PyUnresolvedReferences
from gui.builtinGraphs import (
fitDpsRange, # noqa: E402, F401
fitDpsTime, # noqa: E402, F401
fitDmgTime, # noqa: E402, F401
)
from gui.builtinGraphs import *

View File

@@ -18,18 +18,19 @@
# =============================================================================
import os
from logbook import Logger
import traceback
# noinspection PyPackageRequirements
import wx
from logbook import Logger
from service.fit import Fit
import gui.display
import gui.mainFrame
import gui.globalEvents as GE
from gui.graph import Graph
import gui.mainFrame
from gui.bitmap_loader import BitmapLoader
import traceback
from gui.graph import Graph
from service.fit import Fit
pyfalog = Logger(__name__)
@@ -69,6 +70,7 @@ except Exception:
class GraphFrame(wx.Frame):
def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT):
global graphFrame_enabled
global mplImported
global mpl_version
@@ -164,6 +166,8 @@ class GraphFrame(wx.Frame):
self.Bind(wx.EVT_CLOSE, self.closeEvent)
self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent)
self.Bind(wx.EVT_CHOICE, self.graphChanged)
from gui.builtinStatsViews.resistancesViewFull import EFFECTIVE_HP_TOGGLED # Grr crclar gons
self.mainFrame.Bind(EFFECTIVE_HP_TOGGLED, self.ehpToggled)
self.Fit()
self.SetMinSize(self.GetSize())
@@ -183,13 +187,21 @@ class GraphFrame(wx.Frame):
return
event.Skip()
def ehpToggled(self, event):
event.Skip()
view = self.getView()
if view.redrawOnEffectiveChange:
self.draw()
def graphChanged(self, event):
self.select(self.graphSelection.GetSelection())
event.Skip()
def closeWindow(self):
from gui.builtinStatsViews.resistancesViewFull import EFFECTIVE_HP_TOGGLED # Grr crclar gons
self.fitList.fitList.Unbind(wx.EVT_LEFT_DCLICK, handler=self.removeItem)
self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.draw)
self.mainFrame.Unbind(EFFECTIVE_HP_TOGGLED, handler=self.ehpToggled)
self.Destroy()
def getView(self):