Add support for dps over time graph

This commit is contained in:
DarkPhoenix
2019-05-10 02:46:50 +03:00
parent 306710a314
commit 0f1cbb4234
7 changed files with 156 additions and 21 deletions

View File

@@ -1 +1,4 @@
__all__ = ["fitDps"]
__all__ = [
"fitDpsRange",
"fitDpsTime"
]

View File

@@ -17,15 +17,16 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
from gui.graph import Graph
from gui.bitmap_loader import BitmapLoader
from eos.graph.fitDps import FitDpsGraph as FitDps
from eos.graph import Data
import gui.mainFrame
from eos.graph import Data
from eos.graph.fitDpsRange import FitDpsRangeGraph as EosFitDpsRangeGraph
from gui.bitmap_loader import BitmapLoader
from gui.graph import Graph
from service.attribute import Attribute
class FitDpsGraph(Graph):
class FitDpsRangeGraph(Graph):
propertyAttributeMap = {"angle": "maxVelocity",
"distance": "maxRange",
"signatureRadius": "signatureRadius",
@@ -36,13 +37,13 @@ class FitDpsGraph(Graph):
"signatureRadius": "Target Signature Radius (m)",
"velocity": "Target Velocity (m/s)"}
defaults = FitDps.defaults.copy()
defaults = EosFitDpsRangeGraph.defaults.copy()
def __init__(self):
Graph.__init__(self)
self.defaults["distance"] = "0-100"
self.name = "DPS"
self.fitDps = None
self.name = "DPS over range"
self.fitDpsRange = None
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def getFields(self):
@@ -63,11 +64,11 @@ class FitDpsGraph(Graph):
return icons
def getPoints(self, fit, fields):
fitDps = getattr(self, "fitDps", None)
if fitDps is None or fitDps.fit != fit:
fitDps = self.fitDps = FitDps(fit)
fitDpsRange = getattr(self, "fitDpsRange", None)
if fitDpsRange is None or fitDpsRange.fit != fit:
fitDpsRange = self.fitDpsRange = EosFitDpsRangeGraph(fit)
fitDps.clearData()
fitDpsRange.clearData()
variable = None
for fieldName, value in fields.items():
d = Data(fieldName, value)
@@ -78,18 +79,18 @@ class FitDpsGraph(Graph):
# We can't handle more then one variable atm, OOPS FUCK OUT
return False, "Can only handle 1 variable"
fitDps.setData(d)
fitDpsRange.setData(d)
if variable is None:
return False, "No variable"
x = []
y = []
for point, val in fitDps.getIterator():
for point, val in fitDpsRange.getIterator():
x.append(point[variable])
y.append(val)
return x, y
FitDpsGraph.register()
FitDpsRangeGraph.register()

View File

@@ -0,0 +1,82 @@
# =============================================================================
# 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.fitDpsTime import FitDpsTimeGraph as EosFitDpsTimeGraph
from gui.bitmap_loader import BitmapLoader
from gui.graph import Graph
from service.attribute import Attribute
class FitDpsTimeGraph(Graph):
propertyLabelMap = {"time": "Time (seconds)"}
defaults = EosFitDpsTimeGraph.defaults.copy()
def __init__(self):
Graph.__init__(self)
self.defaults["time"] = "0-300"
self.name = "DPS over time"
self.fitDpsTime = 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):
fitDpsTime = getattr(self, "fitDpsTime", None)
if fitDpsTime is None or fitDpsTime.fit != fit:
fitDpsTime = self.fitDps = EosFitDpsTimeGraph(fit)
fitDpsTime.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"
fitDpsTime.setData(d)
if variable is None:
return False, "No variable"
x = []
y = []
for point, val in fitDpsTime.getIterator():
x.append(point[variable])
y.append(val)
return x, y
FitDpsTimeGraph.register()

View File

@@ -36,4 +36,7 @@ class Graph(object):
# noinspection PyUnresolvedReferences
from gui.builtinGraphs import fitDps # noqa: E402, F401
from gui.builtinGraphs import (
fitDpsRange, # noqa: E402, F401
fitDpsTime, # noqa: E402, F401
)