Restore functionality of dmg vs time graph
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
from gui.builtinGraphs import ( # noqa: E402,F401
|
||||
# fitDpsRange,
|
||||
# fitDpsTime,
|
||||
# fitDmgTime,
|
||||
fitDmgVsTime,
|
||||
# fitShieldRegenAmount,
|
||||
# fitShieldAmountTime,
|
||||
fitCapRegenVsCapPerc,
|
||||
|
||||
@@ -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.fitDmgTime import FitDmgTimeGraph as EosFitDmgTimeGraph
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.graph import Graph
|
||||
from service.attribute import Attribute
|
||||
|
||||
|
||||
class FitDmgTimeGraph(Graph):
|
||||
|
||||
propertyLabelMap = {"time": "Time (seconds)"}
|
||||
|
||||
defaults = EosFitDmgTimeGraph.defaults.copy()
|
||||
|
||||
def __init__(self):
|
||||
Graph.__init__(self)
|
||||
self.defaults["time"] = "0-80"
|
||||
self.name = "Damage Inflicted 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 = EosFitDmgTimeGraph(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 = []
|
||||
eosGraph.recalc()
|
||||
for point, val in eosGraph.getIterator():
|
||||
x.append(point[variable])
|
||||
y.append(val)
|
||||
return x, y
|
||||
|
||||
|
||||
FitDmgTimeGraph.register()
|
||||
43
gui/builtinGraphs/fitDmgVsTime.py
Normal file
43
gui/builtinGraphs/fitDmgVsTime.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# =============================================================================
|
||||
# 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 collections import OrderedDict
|
||||
|
||||
from eos.graph.fitDmgVsTime import FitDmgVsTimeGraph as EosGraphDmg
|
||||
from gui.graph import Graph, XDef, YDef
|
||||
|
||||
|
||||
class FitDmgVsTimeGraph(Graph):
|
||||
|
||||
name = 'Damage vs Time'
|
||||
|
||||
def __init__(self):
|
||||
self.eosGraphDmg = EosGraphDmg()
|
||||
|
||||
@property
|
||||
def xDef(self):
|
||||
return XDef(inputDefault='0-80', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s')
|
||||
|
||||
@property
|
||||
def yDefs(self):
|
||||
return OrderedDict([('damage', YDef(switchLabel='Damage inflicted', axisLabel='Damage', eosGraph='eosGraphDmg'))])
|
||||
|
||||
|
||||
FitDmgVsTimeGraph.register()
|
||||
14
gui/graph.py
14
gui/graph.py
@@ -64,12 +64,16 @@ class Graph(metaclass=ABCMeta):
|
||||
m = re.match('\s*(?P<first>\d+(\.\d+)?)\s*(-\s*(?P<second>\d+(\.\d+)?))?', string)
|
||||
if m is None:
|
||||
return (0, 0)
|
||||
first = m.group('first')
|
||||
first = float(m.group('first'))
|
||||
second = m.group('second')
|
||||
if not second:
|
||||
return (0, float(first))
|
||||
else:
|
||||
return (float(first), float(second))
|
||||
second = float(second) if second is not None else 0
|
||||
low = min(first, second)
|
||||
high = max(first, second)
|
||||
return (low, high)
|
||||
|
||||
def clearCache(self, *args, **kwargs):
|
||||
for yDef in self.yDefs.values():
|
||||
getattr(self, yDef.eosGraph).clearCache(*args, **kwargs)
|
||||
|
||||
|
||||
XDef = namedtuple('XDef', ('inputDefault', 'inputLabel', 'inputIconID', 'axisLabel'))
|
||||
|
||||
@@ -286,6 +286,8 @@ class GraphFrame(wx.Frame):
|
||||
|
||||
values = self.getValues()
|
||||
view = self.getView()
|
||||
# todo: we just drop cache so far, need to drop it only for removed/changed fits
|
||||
view.clearCache()
|
||||
self.subplot.clear()
|
||||
self.subplot.grid(True)
|
||||
legend = []
|
||||
|
||||
Reference in New Issue
Block a user