Add line lightness column
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
from collections import OrderedDict, namedtuple
|
||||
|
||||
from service.const import Color
|
||||
from service.const import GraphColor
|
||||
|
||||
|
||||
ColorData = namedtuple('ColorData', ('hsl', 'name', 'iconName'))
|
||||
@@ -28,14 +28,14 @@ ColorData = namedtuple('ColorData', ('hsl', 'name', 'iconName'))
|
||||
|
||||
# In HSL format
|
||||
BASE_COLORS = OrderedDict([
|
||||
(Color.red, ColorData((0 / 360.0, 1.0, 0.5), 'Red', 'color_red')),
|
||||
(Color.green, ColorData((120 / 360.0, 1.0, 0.5), 'Green', 'color_green')),
|
||||
(Color.blue, ColorData((240 / 360.0, 1.0, 0.5), 'Blue', 'color_blue')),
|
||||
(Color.yellow, ColorData((56 / 360.0, 1.0, 0.5), 'Yellow', 'color_yellow')),
|
||||
(Color.cyan, ColorData((180 / 360.0, 1.0, 0.5), 'Cyan', 'color_cyan')),
|
||||
(Color.magenta, ColorData((300 / 360.0, 1.0, 0.5), 'Magenta', 'color_magenta')),
|
||||
(Color.orange, ColorData((40 / 360.0, 1.0, 0.5), 'Orange', 'color_orange')),
|
||||
(Color.purple, ColorData((275 / 360.0, 1.0, 0.5), 'Purple', 'color_purple'))])
|
||||
(GraphColor.red, ColorData((0 / 360.0, 1.0, 0.5), 'Red', 'color_red')),
|
||||
(GraphColor.green, ColorData((120 / 360.0, 1.0, 0.5), 'Green', 'color_green')),
|
||||
(GraphColor.blue, ColorData((240 / 360.0, 1.0, 0.5), 'Blue', 'color_blue')),
|
||||
(GraphColor.yellow, ColorData((56 / 360.0, 1.0, 0.5), 'Yellow', 'color_yellow')),
|
||||
(GraphColor.cyan, ColorData((180 / 360.0, 1.0, 0.5), 'Cyan', 'color_cyan')),
|
||||
(GraphColor.magenta, ColorData((300 / 360.0, 1.0, 0.5), 'Magenta', 'color_magenta')),
|
||||
(GraphColor.orange, ColorData((40 / 360.0, 1.0, 0.5), 'Orange', 'color_orange')),
|
||||
(GraphColor.purple, ColorData((275 / 360.0, 1.0, 0.5), 'Purple', 'color_purple'))])
|
||||
|
||||
|
||||
def hsl_to_hsv(hsl):
|
||||
@@ -43,3 +43,13 @@ def hsl_to_hsv(hsl):
|
||||
s *= l if (l < 0.5) else (1 - l)
|
||||
l += s
|
||||
return (h, 2 * s / l, l)
|
||||
|
||||
|
||||
def darken(hsl):
|
||||
h, s, l = hsl
|
||||
return h, s * 0.7, l * 0.7
|
||||
|
||||
|
||||
def brighten(hsl):
|
||||
h, s, l = hsl
|
||||
return h, s * 0.7, l + (1 - l) * 0.4
|
||||
|
||||
@@ -269,12 +269,14 @@ class GraphFrame(wx.Frame):
|
||||
else:
|
||||
iterList = tuple((f, None) for f in sources)
|
||||
for source, target in iterList:
|
||||
# Get color data
|
||||
try:
|
||||
colorData = BASE_COLORS[source.color]
|
||||
colorData = BASE_COLORS[source.colorID]
|
||||
except KeyError:
|
||||
pyfalog.warning('Invalid color for "{0}"', source.name)
|
||||
continue
|
||||
color = hsv_to_rgb(hsl_to_hsv(colorData.hsl))
|
||||
# Get point data
|
||||
try:
|
||||
xs, ys = view.getPlotPoints(
|
||||
mainInput=mainInput,
|
||||
|
||||
@@ -25,7 +25,7 @@ import gui.display
|
||||
from eos.saveddata.targetProfile import TargetProfile
|
||||
from graphs.colors import BASE_COLORS
|
||||
from graphs.wrapper import SourceWrapper, TargetWrapper
|
||||
from gui.builtinViewColumns.color import LineColor
|
||||
from gui.builtinViewColumns.graphColor import GraphColor
|
||||
from gui.contextMenu import ContextMenu
|
||||
from service.const import GraphCacheCleanupReason
|
||||
from service.fit import Fit
|
||||
@@ -120,7 +120,7 @@ class BaseWrapperList(gui.display.Display):
|
||||
row, _ = self.HitTest(event.Position)
|
||||
if row != -1:
|
||||
col = self.getColumn(event.Position)
|
||||
if col == self.getColIndex(LineColor):
|
||||
if col == self.getColIndex(GraphColor):
|
||||
wrapper = self.getWrapper(row)
|
||||
if wrapper is not None:
|
||||
win = ColorPickerPopup(parent=self, wrapper=wrapper, ncol=4, nrow=2)
|
||||
@@ -254,7 +254,7 @@ class BaseWrapperList(gui.display.Display):
|
||||
class SourceWrapperList(BaseWrapperList):
|
||||
|
||||
DEFAULT_COLS = (
|
||||
'Color',
|
||||
'Graph Color',
|
||||
'Base Icon',
|
||||
'Base Name')
|
||||
|
||||
@@ -272,9 +272,9 @@ class SourceWrapperList(BaseWrapperList):
|
||||
# Find out least used color
|
||||
colorUseMap = {c: 0 for c in BASE_COLORS}
|
||||
for wrapper in self._wrappers:
|
||||
if wrapper.color not in colorUseMap:
|
||||
if wrapper.colorID not in colorUseMap:
|
||||
continue
|
||||
colorUseMap[wrapper.color] += 1
|
||||
colorUseMap[wrapper.colorID] += 1
|
||||
leastUses = min(colorUseMap.values(), default=0)
|
||||
color = None
|
||||
for color in BASE_COLORS:
|
||||
@@ -300,6 +300,7 @@ class SourceWrapperList(BaseWrapperList):
|
||||
class TargetWrapperList(BaseWrapperList):
|
||||
|
||||
DEFAULT_COLS = (
|
||||
'Graph Lightness',
|
||||
'Base Icon',
|
||||
'Base Name')
|
||||
|
||||
@@ -312,7 +313,7 @@ class TargetWrapperList(BaseWrapperList):
|
||||
self.updateView()
|
||||
|
||||
def appendItem(self, item):
|
||||
self._wrappers.append(TargetWrapper(item))
|
||||
self._wrappers.append(TargetWrapper(item, None))
|
||||
|
||||
def spawnMenu(self, event):
|
||||
selection = self.getSelectedWrappers()
|
||||
|
||||
@@ -53,7 +53,7 @@ class ColorPickerPopup(wx.PopupTransientWindow):
|
||||
def OnLeftDown(self, event):
|
||||
colorID = getattr(event.GetEventObject(), 'colorID', None)
|
||||
if colorID is not None:
|
||||
self.wrapper.color = colorID
|
||||
self.wrapper.colorID = colorID
|
||||
self.Parent.OnColorChange()
|
||||
self.Hide()
|
||||
self.Destroy()
|
||||
|
||||
@@ -95,25 +95,34 @@ class BaseWrapper:
|
||||
|
||||
class SourceWrapper(BaseWrapper):
|
||||
|
||||
def __init__(self, item, color):
|
||||
def __init__(self, item, colorID):
|
||||
super().__init__(item)
|
||||
self._color = color
|
||||
self._colorID = colorID
|
||||
|
||||
@property
|
||||
def color(self):
|
||||
return self._color
|
||||
def colorID(self):
|
||||
return self._colorID
|
||||
|
||||
@color.setter
|
||||
def color(self, value):
|
||||
self._color = value
|
||||
@colorID.setter
|
||||
def colorID(self, value):
|
||||
self._colorID = value
|
||||
|
||||
|
||||
class TargetWrapper(BaseWrapper):
|
||||
|
||||
def __init__(self, item):
|
||||
def __init__(self, item, lightness):
|
||||
super().__init__(item=item)
|
||||
self._lightness = lightness
|
||||
self.__resistMode = TargetResistMode.auto
|
||||
|
||||
@property
|
||||
def lightness(self):
|
||||
return self._lightness
|
||||
|
||||
@lightness.setter
|
||||
def lightness(self, value):
|
||||
self._lightness = value
|
||||
|
||||
@property
|
||||
def resistMode(self):
|
||||
return self.__resistMode
|
||||
|
||||
Reference in New Issue
Block a user