From e2ae89f6b9bc1413890ff8bdc8ef41bc262c2c74 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sun, 7 Jul 2019 18:55:52 +0300 Subject: [PATCH] Add more columns to DPS graphs --- gui/builtinGraphs/fitDamageStats/graph.py | 3 +- gui/builtinViewColumns/__init__.py | 2 +- .../attributeDisplayGraph.py | 150 ++++++++++++++++++ gui/builtinViewColumns/dps.py | 57 ------- gui/builtinViewColumns/volley.py | 56 ------- gui/graphFrame/lists.py | 2 +- gui/utils/numberFormatter.py | 8 +- gui/viewColumn.py | 5 +- 8 files changed, 162 insertions(+), 121 deletions(-) create mode 100644 gui/builtinViewColumns/attributeDisplayGraph.py delete mode 100644 gui/builtinViewColumns/dps.py delete mode 100644 gui/builtinViewColumns/volley.py diff --git a/gui/builtinGraphs/fitDamageStats/graph.py b/gui/builtinGraphs/fitDamageStats/graph.py index 5e971ea6b..fbdeca4de 100644 --- a/gui/builtinGraphs/fitDamageStats/graph.py +++ b/gui/builtinGraphs/fitDamageStats/graph.py @@ -67,7 +67,8 @@ class FitDamageStatsGraph(FitGraph): srcVectorDef = VectorDef(lengthHandle='atkSpeed', lengthUnit='%', angleHandle='atkAngle', angleUnit='degrees', label='Attacker') tgtVectorDef = VectorDef(lengthHandle='tgtSpeed', lengthUnit='%', angleHandle='tgtAngle', angleUnit='degrees', label='Target') hasTargets = True - srcExtraCols = ('Dps', 'Volley') + srcExtraCols = ('Dps', 'Volley', 'Speed', 'Radius') + tgtExtraCols = ('Speed', 'SigRadius', 'Radius') # Calculation stuff _normalizers = { diff --git a/gui/builtinViewColumns/__init__.py b/gui/builtinViewColumns/__init__.py index e03fee1ac..64c03c49f 100644 --- a/gui/builtinViewColumns/__init__.py +++ b/gui/builtinViewColumns/__init__.py @@ -2,10 +2,10 @@ __all__ = [ "ammo", "ammoIcon", "attributeDisplay", + "attributeDisplayGraph", "baseIcon", "baseName", "capacitorUse", - "dps", "maxRange", "price", "propertyDisplay", diff --git a/gui/builtinViewColumns/attributeDisplayGraph.py b/gui/builtinViewColumns/attributeDisplayGraph.py new file mode 100644 index 000000000..e8a73b0f2 --- /dev/null +++ b/gui/builtinViewColumns/attributeDisplayGraph.py @@ -0,0 +1,150 @@ +# ============================================================================= +# 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 . +# ============================================================================= + + +from abc import ABCMeta, abstractmethod + +# noinspection PyPackageRequirements +import wx + +import eos.config +import gui.mainFrame +from eos.saveddata.fit import Fit +from eos.utils.spoolSupport import SpoolOptions, SpoolType +from gui.bitmap_loader import BitmapLoader +from gui.viewColumn import ViewColumn +from gui.utils.numberFormatter import formatAmount + + +class GraphColumn(ViewColumn, metaclass=ABCMeta): + + def __init__(self, fittingView, iconID, formatSpec=(3, 0, 3)): + ViewColumn.__init__(self, fittingView) + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + self.imageId = fittingView.imageList.GetImageIndex(iconID, 'icons') + self.bitmap = BitmapLoader.getBitmap(iconID, 'icons') + self.mask = wx.LIST_MASK_TEXT + self.formatSpec = formatSpec + + @abstractmethod + def _getValue(self, fit): + raise NotImplementedError + + def getText(self, stuff): + if isinstance(stuff, Fit): + val, unit = self._getValue(stuff) + if val is None: + return '' + return formatAmount(val, *self.formatSpec, unitName=unit) + return '' + + @abstractmethod + def _getFitTooltip(self): + raise NotImplementedError + + def getToolTip(self, stuff): + if isinstance(stuff, Fit): + return self._getFitTooltip() + return '' + +class DpsColumn(GraphColumn): + + name = 'Dps' + + def __init__(self, fittingView, params): + super().__init__(fittingView, 1432, (3, 0, 0)) + + def _getValue(self, fit): + defaultSpoolValue = eos.config.settings['globalDefaultSpoolupPercentage'] + return fit.getTotalDps(spoolOptions=SpoolOptions(SpoolType.SCALE, defaultSpoolValue, False)).total, None + + def _getFitTooltip(self): + return 'Declared DPS' + + +DpsColumn.register() + + +class VolleyColumn(GraphColumn): + + name = 'Volley' + + def __init__(self, fittingView, params): + super().__init__(fittingView, 1397, (3, 0, 0)) + + def _getValue(self, fit): + defaultSpoolValue = eos.config.settings['globalDefaultSpoolupPercentage'] + return fit.getTotalVolley(spoolOptions=SpoolOptions(SpoolType.SCALE, defaultSpoolValue, False)).total, None + + def _getFitTooltip(self): + return 'Declared volley' + + +VolleyColumn.register() + + +class SpeedColumn(GraphColumn): + + name = 'Speed' + + def __init__(self, fittingView, params): + super().__init__(fittingView, 1389) + + def _getValue(self, fit): + return fit.ship.getModifiedItemAttr('maxVelocity'), 'm/s' + + def _getFitTooltip(self): + return 'Ship maximum speed' + + +SpeedColumn.register() + + +class RadiusColumn(GraphColumn): + + name = 'Radius' + + def __init__(self, fittingView, params): + super().__init__(fittingView, 3266) + + def _getValue(self, fit): + return fit.ship.getModifiedItemAttr('radius'), 'm' + + def _getFitTooltip(self): + return 'Ship radius' + + +RadiusColumn.register() + + +class SignatureRadiusColumn(GraphColumn): + + name = 'SigRadius' + + def __init__(self, fittingView, params): + super().__init__(fittingView, 1390) + + def _getValue(self, fit): + return fit.ship.getModifiedItemAttr('signatureRadius'), 'm' + + def _getFitTooltip(self): + return 'Ship signature radius' + + +SignatureRadiusColumn.register() diff --git a/gui/builtinViewColumns/dps.py b/gui/builtinViewColumns/dps.py deleted file mode 100644 index 7f3bd307f..000000000 --- a/gui/builtinViewColumns/dps.py +++ /dev/null @@ -1,57 +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 . -# ============================================================================= - - -# noinspection PyPackageRequirements -import wx - -import eos.config -import gui.mainFrame -from eos.saveddata.fit import Fit -from eos.utils.spoolSupport import SpoolOptions, SpoolType -from gui.bitmap_loader import BitmapLoader -from gui.viewColumn import ViewColumn -from gui.utils.numberFormatter import formatAmount - - -class DpsColumn(ViewColumn): - - name = 'Dps' - - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.imageId = fittingView.imageList.GetImageIndex(1432, 'icons') - self.bitmap = BitmapLoader.getBitmap(1432, 'icons') - self.mask = wx.LIST_MASK_TEXT - - def getText(self, stuff): - if isinstance(stuff, Fit): - defaultSpoolValue = eos.config.settings['globalDefaultSpoolupPercentage'] - dps = stuff.getTotalDps(spoolOptions=SpoolOptions(SpoolType.SCALE, defaultSpoolValue, False)).total - if dps is None: - return '' - return formatAmount(dps, 3, 0, 0) - return '' - - def getToolTip(self, stuff): - return 'Declared DPS' - - -DpsColumn.register() diff --git a/gui/builtinViewColumns/volley.py b/gui/builtinViewColumns/volley.py deleted file mode 100644 index 47463b266..000000000 --- a/gui/builtinViewColumns/volley.py +++ /dev/null @@ -1,56 +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 . -# ============================================================================= - - -# noinspection PyPackageRequirements -import wx - -import eos.config -import gui.mainFrame -from eos.saveddata.fit import Fit -from eos.utils.spoolSupport import SpoolOptions, SpoolType -from gui.bitmap_loader import BitmapLoader -from gui.viewColumn import ViewColumn -from gui.utils.numberFormatter import formatAmount - - -class VolleyColumn(ViewColumn): - - name = 'Volley' - - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - self.imageId = fittingView.imageList.GetImageIndex(1397, 'icons') - self.bitmap = BitmapLoader.getBitmap(1397, 'icons') - self.mask = wx.LIST_MASK_TEXT - - def getText(self, stuff): - if isinstance(stuff, Fit): - defaultSpoolValue = eos.config.settings['globalDefaultSpoolupPercentage'] - dps = stuff.getTotalVolley(spoolOptions=SpoolOptions(SpoolType.SCALE, defaultSpoolValue, False)).total - if dps is None: - return '' - return formatAmount(dps, 3, 0, 0) - return '' - - def getToolTip(self, stuff): - return 'Declared volley' - -VolleyColumn.register() diff --git a/gui/graphFrame/lists.py b/gui/graphFrame/lists.py index ba8e0094d..a7018dd4b 100644 --- a/gui/graphFrame/lists.py +++ b/gui/graphFrame/lists.py @@ -175,7 +175,7 @@ class BaseList(gui.display.Display): if tooltip: self.SetToolTip(tooltip) else: - self.SetToolTip(self.defaultTT) + self.SetToolTip(None) else: self.SetToolTip(self.defaultTT) event.Skip() diff --git a/gui/utils/numberFormatter.py b/gui/utils/numberFormatter.py index 1c4bd29eb..bd93c0625 100644 --- a/gui/utils/numberFormatter.py +++ b/gui/utils/numberFormatter.py @@ -1,7 +1,7 @@ import math -def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=False): +def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=False, unitName=None): """ Add suffix to value, transform value to match new suffix and round it. @@ -12,6 +12,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal highest -- highest order for suffixizing for numbers |num| > 1 currency -- if currency, billion suffix will be B instead of G forceSign -- if True, positive numbers are signed too + unitName -- if specified, will be formatted into a string """ if val is None: return "" @@ -89,7 +90,10 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal mantissa = roundToPrec(mantissa, prec) sign = "+" if forceSign is True and mantissa > 0 else "" # Round mantissa and add suffix - result = "{0}{1}{2}".format(sign, mantissa, suffix) + if unitName is None: + result = "{}{}{}".format(sign, mantissa, suffix) + else: + result = "{}{} {}{}".format(sign, mantissa, suffix, unitName) return result diff --git a/gui/viewColumn.py b/gui/viewColumn.py index 6e1a54be9..f2b72cdc1 100644 --- a/gui/viewColumn.py +++ b/gui/viewColumn.py @@ -72,15 +72,14 @@ from gui.builtinViewColumns import ( # noqa: E402, F401 ammo, ammoIcon, attributeDisplay, + attributeDisplayGraph, baseIcon, baseName, capacitorUse, - dps, maxRange, misc, price, propertyDisplay, state, - sideEffects, - volley + sideEffects )