Add more columns to DPS graphs

This commit is contained in:
DarkPhoenix
2019-07-07 18:55:52 +03:00
parent 3bc3705c42
commit e2ae89f6b9
8 changed files with 162 additions and 121 deletions

View File

@@ -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 = {

View File

@@ -2,10 +2,10 @@ __all__ = [
"ammo",
"ammoIcon",
"attributeDisplay",
"attributeDisplayGraph",
"baseIcon",
"baseName",
"capacitorUse",
"dps",
"maxRange",
"price",
"propertyDisplay",

View File

@@ -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 <http://www.gnu.org/licenses/>.
# =============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
# =============================================================================
# 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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
# =============================================================================
# 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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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
)