Skip to content

Commit

Permalink
Image parameters: do not override x/y bounds when undefined
Browse files Browse the repository at this point in the history
(avoid interfering with automatic bound settings)
  • Loading branch information
PierreRaybaut committed Oct 1, 2024
1 parent a37af8a commit 38e3d95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

🛠️ Bug fixes:

* When updating image parameters (`ImageParam`) from the associated item object:
* If `xmin`, `xmax`, `ymin`, `ymax` attributes are not yet set (i.e. `None`), do not update them with the image data bounds
* Previous behavior was to update them with the image data bounds, which was leading to breaking the automatic bounds update when the image data is updated
* [Issue #24](https://github.com/PlotPyStack/PlotPy/issues/24) - Colormap: side effect on image axes when changing the colormap
* [Issue #23](https://github.com/PlotPyStack/PlotPy/issues/23) - Windows: Image `_scaler` engine performance regression
* PySide6 compatibility issues:
Expand Down
20 changes: 4 additions & 16 deletions plotpy/styles/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ class ImageParam(RawImageParam):
help=_("Locked images are not movable with the mouse"),
)
_xdata = BeginGroup(_("Image placement along X-axis"))
xmin = FloatItem(_("x|min"), default=None)
xmax = FloatItem(_("x|max"), default=None)
xmin = FloatItem(_("x|min"), default=None, check=False)
xmax = FloatItem(_("x|max"), default=None, check=False)
_end_xdata = EndGroup(_("Image placement along X-axis"))
_ydata = BeginGroup(_("Image placement along Y-axis"))
ymin = FloatItem(_("y|min"), default=None)
ymax = FloatItem(_("y|max"), default=None)
ymin = FloatItem(_("y|min"), default=None, check=False)
ymax = FloatItem(_("y|max"), default=None, check=False)
_end_ydata = EndGroup(_("Image placement along Y-axis"))

def update_param(self, item: ImageItem) -> None:
Expand All @@ -366,21 +366,9 @@ def update_param(self, item: ImageItem) -> None:
"""
super().update_param(item)
self.xmin = item.xmin
if self.xmin is None:
self.xmin = 0.0
self.ymin = item.ymin
if self.ymin is None:
self.ymin = 0.0
if item.is_empty():
shape = (0, 0)
else:
shape = item.data.shape
self.xmax = item.xmax
if self.xmax is None:
self.xmax = float(shape[1])
self.ymax = item.ymax
if self.ymax is None:
self.ymax = float(shape[0])

def update_item(self, item: ImageItem) -> None:
"""Update the given image item from the parameters.
Expand Down

0 comments on commit 38e3d95

Please sign in to comment.