Rework graph interfaces again

This commit is contained in:
DarkPhoenix
2019-05-17 17:48:20 +03:00
parent 512f48ebdd
commit fb5eb220fd
12 changed files with 89 additions and 183 deletions

View File

@@ -18,6 +18,8 @@
# =============================================================================
from collections import OrderedDict
from eos.graph.fitCapAmountVsTime import FitCapAmountVsTimeGraph as EosGraph
from gui.graph import Graph, XDef, YDef
@@ -31,15 +33,11 @@ class FitCapAmountVsTimeGraph(Graph):
@property
def xDef(self):
return XDef(handle='time', inputDefault='0-300', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s')
return XDef(inputDefault='0-300', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s')
@property
def yDefs(self):
return [YDef(handle='capAmount', switchLabel='Cap amount', axisLabel='Cap amount, GJ')]
def getPlotPoints(self, fit, extraData, xRange, xAmount):
xRange = self.parseRange(xRange)
return self.eosGraph.getPlotPoints(fit, extraData, xRange, xAmount)
return OrderedDict([('capAmount', YDef(switchLabel='Cap amount', axisLabel='Cap amount, GJ', eosGraph='eosGraph'))])
FitCapAmountVsTimeGraph.register()

View File

@@ -18,6 +18,8 @@
# =============================================================================
from collections import OrderedDict
from eos.graph.fitCapRegenVsCapPerc import FitCapRegenVsCapPercGraph as EosGraph
from gui.graph import Graph, XDef, YDef
@@ -31,15 +33,11 @@ class FitCapRegenVsCapPercGraph(Graph):
@property
def xDef(self):
return XDef(handle='percentage', 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):
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)
return OrderedDict([('capRegen', YDef(switchLabel='Cap regen', axisLabel='Cap regen, GJ/s', eosGraph='eosGraph'))])
FitCapRegenVsCapPercGraph.register()

View File

@@ -17,7 +17,11 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
from eos.graph.fitMobilityVsTime import FitMobilityVsTimeGraph as EosGraph
from collections import OrderedDict
from eos.graph.fitDistanceVsTime import FitDistanceVsTimeGraph as EosGraphDistance
from eos.graph.fitSpeedVsTime import FitSpeedVsTimeGraph as EosGraphSpeed
from gui.graph import Graph, XDef, YDef
@@ -26,19 +30,18 @@ class FitMobilityVsTimeGraph(Graph):
name = 'Mobility vs Time'
def __init__(self):
self.eosGraph = EosGraph()
self.eosGraphSpeed = EosGraphSpeed()
self.eosGraphDistance = EosGraphDistance()
@property
def xDef(self):
return XDef(handle='time', inputDefault='0-80', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s')
return XDef(inputDefault='0-80', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s')
@property
def yDefs(self):
return [YDef(handle='speed', switchLabel='Speed', axisLabel='Speed, m/s'), YDef(handle='distance', switchLabel='Distance', axisLabel='Distance, m')]
def getPlotPoints(self, fit, extraData, xRange, xAmount):
xRange = self.parseRange(xRange)
return self.eosGraph.getPlotPoints(fit, extraData, xRange, xAmount)
return OrderedDict([
('speed', YDef(switchLabel='Speed', axisLabel='Speed, m/s', eosGraph='eosGraphSpeed')),
('distance', YDef(switchLabel='Distance', axisLabel='Distance, m', eosGraph='eosGraphDistance'))])
FitMobilityVsTimeGraph.register()

View File

@@ -1,81 +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.fitSpeedTime import FitSpeedTimeGraph as EosFitSpeedTimeGraph
from gui.bitmap_loader import BitmapLoader
from gui.graph import Graph
from service.attribute import Attribute
class FitSpeedTimeGraph(Graph):
propertyLabelMap = {"time": "Time (seconds)"}
defaults = EosFitSpeedTimeGraph.defaults.copy()
def __init__(self):
Graph.__init__(self)
self.defaults["time"] = "0-80"
self.name = "Speed 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 = EosFitSpeedTimeGraph(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
FitSpeedTimeGraph.register()