Skip to content

Commit 15f86cc

Browse files
committed
Add "Lock LUT range" option for image items
Fix Add option to update LUT range automatically #18
1 parent 9f4b781 commit 15f86cc

File tree

12 files changed

+486
-220
lines changed

12 files changed

+486
-220
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog #
22

3+
## Version 2.5.0 ##
4+
5+
In this release, test coverage is 79%.
6+
7+
💥 New features / Enhancements:
8+
9+
* Added "Lock LUT range" option for image items:
10+
* This new option is disabled by default, which matches the previous behavior:
11+
when updating an image item data, the LUT range is automatically adjusted to
12+
the new data range (if not passed as an argument to the `BaseImageItem.set_data`
13+
method)
14+
* When enabled, the LUT range is locked and the LUT range is not adjusted when
15+
updating the image item data
16+
* The option is available in image parameters dialog
17+
* A new tool `LockLUTRangeTool` has been implemented to toggle the option from the
18+
plot context menu: the tool is not registered by default in the plot widget, but
19+
can be added by the host application if needed
20+
* See test script `tests.features.test_image_data_update` for an example of usage
21+
of the new option and tool
22+
323
## Version 2.4.2 ##
424

525
In this release, test coverage is 79%.

doc/features/tools/reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Image tools
118118
:members:
119119
.. autoclass:: plotpy.tools.ReverseColormapTool
120120
:members:
121+
.. autoclass:: plotpy.tools.LockLUTRangeTool
122+
:members:
121123
.. autoclass:: plotpy.tools.XCSPanelTool
122124
:members:
123125
.. autoclass:: plotpy.tools.YCSPanelTool

plotpy/items/image/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,16 @@ def set_data(
333333
data: 2D NumPy array
334334
lut_range: LUT range -- tuple (levelmin, levelmax) (Default value = None)
335335
"""
336-
if lut_range is not None:
337-
_min, _max = lut_range
338-
else:
339-
_min, _max = get_nan_range(data)
340-
341336
self.data = data
342337
self.histogram_cache = None
343338
self.update_bounds()
344339
self.update_border()
345-
self.set_lut_range((_min, _max))
340+
if not self.param.keep_lut_range:
341+
if lut_range is not None:
342+
_min, _max = lut_range
343+
else:
344+
_min, _max = get_nan_range(data)
345+
self.set_lut_range((_min, _max))
346346

347347
def get_data(
348348
self, x0: float, y0: float, x1: float | None = None, y1: float | None = None
695 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)