Skip to content

Commit 4fe5af9

Browse files
committed
Squashed commit of the following:
commit cde2a3e9b493ea4f94c001f5d639332f953006c0 Author: vld-codra <v.ledu@codra.fr> Date: Mon Jan 8 13:35:46 2024 +0100 final touches, test and small bugs fixes commit b82e9fd36c72e2444cadfa2ee2893bf89c0ec416 Author: vld-codra <v.ledu@codra.fr> Date: Fri Jan 5 14:47:47 2024 +0100 fixes and new user safety features commit 967f33580fcbd0ffca61efb443814184e4562449 Author: vld-codra <v.ledu@codra.fr> Date: Fri Jan 5 11:50:25 2024 +0100 added tooltip and translated contextual menu commit bb13f71a3ccd6f0ffd5b02e2cc5ecedbe7efe421 Author: vld-codra <v.ledu@codra.fr> Date: Fri Jan 5 11:44:55 2024 +0100 more documentation commit f3a8e8323131a646b85d53876ece8124d09da63c Author: vld-codra <v.ledu@codra.fr> Date: Fri Jan 5 11:31:23 2024 +0100 documented code and slight optimizations commit 1e88fbae5aba79bd102298e95a3922b8809c78b6 Author: vld-codra <v.ledu@codra.fr> Date: Thu Jan 4 17:23:59 2024 +0100 full implementation of the colormap widgets commit 4d9f2e9b2420b4be2ed657f7a11687a837d61025 Author: vld-codra <v.ledu@codra.fr> Date: Wed Jan 3 16:31:28 2024 +0100 many fixes and optimizations, starting work on colormaps conf commit daae8c8a306d28a7ee2ff2d1a23f90a244fdf2a9 Author: vld-codra <v.ledu@codra.fr> Date: Tue Jan 2 10:57:27 2024 +0100 displayed handles position increments by 0.01 commit 20767fae28f77b5dea5f41aca4152580d42b07f8 Author: vld-codra <v.ledu@codra.fr> Date: Fri Dec 29 17:06:18 2023 +0100 new features and small fixes commit d7a3e998d7c329e88c845efd713ca3f530094961 Author: vld-codra <v.ledu@codra.fr> Date: Fri Dec 29 16:19:24 2023 +0100 colormap v2 (float range slider) commit 131a8dca3d9c3b7ca9979aba1642923efe3f708c Author: vld-codra <v.ledu@codra.fr> Date: Fri Dec 29 11:22:04 2023 +0100 missing changes commit 3adc6ea7542e2448ec9ab79d4403d5bc9ff9087b Author: vld-codra <v.ledu@codra.fr> Date: Fri Dec 29 11:21:45 2023 +0100 first working version commit 92398fca19efd89c7204ee5d67fcc948176986cf Author: vld-codra <v.ledu@codra.fr> Date: Fri Dec 29 11:20:17 2023 +0100 Squashed commit of the following: commit 2acc393c5087961ef5627293ed7549580f1969c5 Author: vld-codra <v.ledu@codra.fr> Date: Fri Dec 29 11:17:17 2023 +0100 edit point tool commit dceec0513f95316d3c3ac6cf6f83a92c720ad8fa Author: vld-codra <v.ledu@codra.fr> Date: Thu Dec 21 18:05:41 2023 +0100 remove file after name change commit cd11fe68c28aeaf0773b6bc9084e889b45f401e0 Author: vld-codra <v.ledu@codra.fr> Date: Thu Dec 21 18:05:10 2023 +0100 Numerous updates, still work in progress commit c8c6f47406cd1aca9364d287b13d4999ad0714b3 Author: vld-codra <v.ledu@codra.fr> Date: Mon Dec 18 16:17:26 2023 +0100 basic imlementation of curve decimation commit 72f293f87cfe3f9730f6a3d6b22c03aa91807c09 Author: vld-codra <v.ledu@codra.fr> Date: Mon Dec 18 14:34:12 2023 +0100 reduce number of points for editing points commit 6b06799b1b1706049aacf45d04efd7c52ef19769 Author: vld-codra <v.ledu@codra.fr> Date: Mon Dec 18 14:26:49 2023 +0100 new edit point tool
1 parent afb380e commit 4fe5af9

38 files changed

Lines changed: 13564 additions & 314 deletions

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"[python]": {
2626
"editor.codeActionsOnSave": {
27-
"source.organizeImports": true
27+
"source.organizeImports": "explicit"
2828
},
2929
"editor.defaultFormatter": "ms-python.black-formatter"
3030
},

plotpy/builder/curvemarker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ def mcurve(self, *args, **kwargs) -> CurveItem | list[CurveItem]:
253253
global CURVE_COUNT
254254
CURVE_COUNT += 1
255255
param.label = make_title(basename, CURVE_COUNT)
256+
if "downsampling_factor" in kwargs:
257+
param.downsampling_factor = kwargs.pop("downsampling_factor")
258+
if "use_downsampling" in kwargs:
259+
param.use_downsampling = kwargs.pop("use_downsampling")
256260
update_style_attr(stylei, param)
257261
curves.append(self.pcurve(x, yi, param, **kwargs))
258262
if len(curves) == 1:

plotpy/colormaps/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This directory contains functions and data useful to generate default colormaps used
2+
in Plotpy. Launch `colormap.py` to create/overwrite the colormaps_default.json file.
Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@
4040

4141
from numpy import array, linspace, newaxis, uint8, zeros
4242
from qtpy import QtGui as QG
43-
from qwt import QwtInterval, QwtLinearColorMap, toQImage
44-
45-
from plotpy.mathutils import _cm # Reuse matplotlib data
43+
from qwt import QwtInterval, toQImage
44+
45+
from plotpy.colormaps import _cm
46+
from plotpy.mathutils.colormaps import (
47+
DEFAULT_COLORMAPS,
48+
DEFAULT_COLORMAPS_PATH,
49+
save_colormaps,
50+
)
51+
from plotpy.widgets.colormap_widget import (
52+
CustomQwtLinearColormap, # Reuse matplotlib data
53+
)
4654

4755
# usefull to obtain a full color map
4856
FULLRANGE = QwtInterval(0.0, 1.0)
@@ -60,8 +68,8 @@ def _interpolate(val, vmin, vmax):
6068
return (1 - interp) * vmin[1] + interp * vmax[2]
6169

6270

63-
def _setup_colormap(cmap, cmdata):
64-
"""Setup a QwtLinearColorMap according to
71+
def _setup_colormap(cmap: CustomQwtLinearColormap, cmdata):
72+
"""Setup a CustomQwtLinearColorMap according to
6573
matplotlib's data
6674
"""
6775
red = array(cmdata["red"])
@@ -85,7 +93,7 @@ def _setup_colormap(cmap, cmdata):
8593
cmap.addColorStop(i, col)
8694

8795

88-
def get_cmap(name: str) -> QwtLinearColorMap:
96+
def get_cmap(name: str) -> CustomQwtLinearColormap:
8997
"""Get a colormap from its name
9098
9199
Args:
@@ -98,15 +106,15 @@ def get_cmap(name: str) -> QwtLinearColorMap:
98106
if name in COLORMAPS:
99107
return COLORMAPS[name]
100108

101-
colormap = QwtLinearColorMap()
109+
colormap = CustomQwtLinearColormap()
102110
COLORMAPS[name] = colormap
103111
COLORMAPS[colormap] = name
104112
data = getattr(_cm, "_" + name + "_data")
105113
_setup_colormap(colormap, data)
106114
return colormap
107115

108116

109-
def get_cmap_name(cmap: QwtLinearColorMap) -> str:
117+
def get_cmap_name(cmap: CustomQwtLinearColormap) -> str:
110118
"""Return colormap's name
111119
112120
Args:
@@ -135,7 +143,7 @@ def get_colormap_list() -> list[str]:
135143

136144

137145
def build_icon_from_cmap(
138-
cmap: QwtLinearColorMap, width: int = 24, height: int = 24
146+
cmap: CustomQwtLinearColormap, width: int = 24, height: int = 24
139147
) -> QG.QIcon:
140148
"""Builds an icon representing the colormap
141149
@@ -168,7 +176,7 @@ def build_icon_from_cmap_name(cmap_name: str) -> QG.QIcon:
168176
return icon
169177

170178

171-
def register_extra_colormap(name: str, colormap: QwtLinearColorMap) -> None:
179+
def register_extra_colormap(name: str, colormap: CustomQwtLinearColormap) -> None:
172180
"""Add a custom colormap to the list of known colormaps
173181
must be done early in the import process because
174182
datasets will use get_color_map list at import time
@@ -180,3 +188,9 @@ def register_extra_colormap(name: str, colormap: QwtLinearColorMap) -> None:
180188
COLORMAPS[name] = colormap
181189
COLORMAPS[colormap] = name
182190
EXTRA_COLORMAPS.append(name)
191+
192+
193+
if __name__ == "__main__":
194+
for cmap in get_colormap_list():
195+
DEFAULT_COLORMAPS[cmap] = get_cmap(cmap)
196+
save_colormaps(DEFAULT_COLORMAPS_PATH, DEFAULT_COLORMAPS)

plotpy/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,10 @@ def make_title(basename, count):
742742
"marker/cross/pen/width": 1,
743743
"marker/cross/markerstyle": "Cross",
744744
},
745+
"colormaps": {
746+
"colormaps/default": "colormaps_default.json",
747+
"colormaps/custom": "colormaps_custom.json",
748+
},
745749
}
746750

747751
CONF = UserConfig(DEFAULTS)

0 commit comments

Comments
 (0)