Skip to content

Commit

Permalink
Fix contrast range update issue when changing image Z axis bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Jun 26, 2024
1 parent 5cd7937 commit e030a9c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ In this release, test coverage is 79%.
using the "Minimum value" or "Maximum value" buttons (which have been renamed to
"Min." and "Max." in this release)
* Histogram range was not updated when the "Set full range" button was clicked
* Image parameters: contrast range was not updated when the image Z axis bounds were
changed using the "Parameters" dialog

🧹 API cleanup:

Expand Down
13 changes: 13 additions & 0 deletions plotpy/panels/contrastadjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def connect_plot(self, plot: BasePlot) -> None:
plot.SIG_ITEM_SELECTION_CHANGED.connect(self.selection_changed)
plot.SIG_ITEM_REMOVED.connect(self.item_removed)
plot.SIG_ACTIVE_ITEM_CHANGED.connect(self.active_item_changed)
plot.SIG_AXIS_PARAMETERS_CHANGED.connect(
lambda axis_id: self.axis_parameters_changed(plot=plot, axis_id=axis_id)
)

def tracked_items_gen(
self,
Expand Down Expand Up @@ -242,6 +245,16 @@ def active_item_changed(self, plot: BasePlot) -> None:
self.range.set_range(_m, _M, dosignal=False)
self.replot()

def axis_parameters_changed(self, plot: BasePlot, axis_id: int) -> None:
"""Plot axis parameters changed callback
Args:
axis_id: axis ID
"""
if axis_id == BasePlot.Y_RIGHT:
# Colormap bounds changed, we need to update the range accordingly:
self.active_item_changed(plot)

def set_range_style(self, multiple_ranges: bool) -> None:
"""Set range style
Expand Down
2 changes: 2 additions & 0 deletions plotpy/styles/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def update_item(self, item: BaseImageItem) -> None:
plot.set_plot_limits(self.xmin, self.xmax, self.ymin, self.ymax)
item.set_lut_range([self.zmin, self.zmax])
plot.update_colormap_axis(item)
for axis_id in (plot.X_BOTTOM, plot.Y_LEFT, plot.Y_RIGHT):
plot.SIG_AXIS_PARAMETERS_CHANGED.emit(axis_id)

# TODO: remove this method in a future release
def update_axes(self, obj: BaseImageItem) -> None:
Expand Down

0 comments on commit e030a9c

Please sign in to comment.