More work on interfaces between gui and eos graphs
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
# noinspection PyUnresolvedReferences
|
||||
from gui.builtinGraphs import ( # noqa: E402,F401
|
||||
fitDamageStats,
|
||||
# fitDamageStats,
|
||||
# fitDmgVsTime,
|
||||
# fitShieldRegenVsShieldPerc,
|
||||
# fitShieldAmountVsTime,
|
||||
# fitCapRegenVsCapPerc,
|
||||
# fitCapAmountVsTime,
|
||||
# fitMobilityVsTime,
|
||||
fitWarpTimeVsDistance
|
||||
fitWarpTime
|
||||
)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
import re
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections import OrderedDict, namedtuple
|
||||
|
||||
@@ -32,7 +31,8 @@ class Graph(metaclass=ABCMeta):
|
||||
def register(cls):
|
||||
Graph.views.append(cls)
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, eosGraph):
|
||||
self._eosGraph = eosGraph
|
||||
self._cache = {}
|
||||
|
||||
@property
|
||||
@@ -84,13 +84,11 @@ class Graph(metaclass=ABCMeta):
|
||||
|
||||
def getPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, fit, tgt=None):
|
||||
try:
|
||||
plotData = self._cache[fit.ID][ySpec]
|
||||
plotData = self._cache[fit.ID][(ySpec, xSpec)]
|
||||
except KeyError:
|
||||
extraData = {k: float(v) if v else None for k, v in extraData.items()}
|
||||
graph = getattr(self, self.yDefs[yType].eosGraph, None)
|
||||
plotData = graph.getPlotPoints(fit, extraData, xRange, xAmount)
|
||||
plotData = self._eosGraph.getPlotPoints(mainInput, miscInputs, xSpec, ySpec, fit, tgt)
|
||||
fitCache = self._cache.setdefault(fit.ID, {})
|
||||
fitCache[yType] = plotData
|
||||
fitCache[(ySpec, xSpec)] = plotData
|
||||
return plotData
|
||||
|
||||
def clearCache(self, key=None):
|
||||
@@ -102,7 +100,7 @@ class Graph(metaclass=ABCMeta):
|
||||
getattr(self, yDef.eosGraph).clearCache(key=key)
|
||||
|
||||
|
||||
YDef = namedtuple('YDef', ('handle', 'unit', 'label', 'eosGraph'))
|
||||
YDef = namedtuple('YDef', ('handle', 'unit', 'label'))
|
||||
XDef = namedtuple('XDef', ('handle', 'unit', 'label', 'mainInput'))
|
||||
Input = namedtuple('Input', ('handle', 'unit', 'label', 'iconID', 'defaultValue', 'defaultRange', 'mainOnly'))
|
||||
VectorDef = namedtuple('VectorDef', ('lengthHandle', 'lengthUnit', 'angleHandle', 'angleUnit', 'label'))
|
||||
|
||||
@@ -29,8 +29,7 @@ class FitDamageStatsGraph(Graph):
|
||||
name = 'Damage Stats'
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.eosGraph = EosGraph()
|
||||
super().__init__(EosGraph())
|
||||
|
||||
@property
|
||||
def xDefs(self):
|
||||
@@ -45,9 +44,9 @@ class FitDamageStatsGraph(Graph):
|
||||
@property
|
||||
def yDefs(self):
|
||||
return [
|
||||
YDef(handle='dps', unit=None, label='DPS', eosGraph='eosGraph'),
|
||||
YDef(handle='volley', unit=None, label='Volley', eosGraph='eosGraph'),
|
||||
YDef(handle='damage', unit=None, label='Damage inflicted', eosGraph='eosGraph')]
|
||||
YDef(handle='dps', unit=None, label='DPS'),
|
||||
YDef(handle='volley', unit=None, label='Volley'),
|
||||
YDef(handle='damage', unit=None, label='Damage inflicted')]
|
||||
|
||||
@property
|
||||
def inputs(self):
|
||||
|
||||
@@ -18,17 +18,16 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from eos.graph.fitWarpTimeVsDistance import FitWarpTimeVsDistanceGraph as EosGraph
|
||||
from eos.graph.fitWarpTime import FitWarpTimeGraph as EosGraph
|
||||
from .base import Graph, XDef, YDef, Input
|
||||
|
||||
|
||||
class FitWarpTimeVsDistanceGraph(Graph):
|
||||
class FitWarpTimeGraph(Graph):
|
||||
|
||||
name = 'Warp Time'
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.eosGraph = EosGraph()
|
||||
super().__init__(EosGraph())
|
||||
|
||||
@property
|
||||
def xDefs(self):
|
||||
@@ -38,7 +37,7 @@ class FitWarpTimeVsDistanceGraph(Graph):
|
||||
|
||||
@property
|
||||
def yDefs(self):
|
||||
return [YDef(handle='time', unit='s', label='Warp time', eosGraph='eosGraph')]
|
||||
return [YDef(handle='time', unit='s', label='Warp time')]
|
||||
|
||||
@property
|
||||
def inputs(self):
|
||||
@@ -47,4 +46,4 @@ class FitWarpTimeVsDistanceGraph(Graph):
|
||||
Input(handle='distance', unit='km', label='Distance', iconID=1391, defaultValue=10000, defaultRange=(150, 5000), mainOnly=False)]
|
||||
|
||||
|
||||
FitWarpTimeVsDistanceGraph.register()
|
||||
FitWarpTimeGraph.register()
|
||||
Reference in New Issue
Block a user