Skip to content

Commit a82cae5

Browse files
committed
Fix issue with "No available data" message in Image Statistics tool
1 parent b438381 commit a82cae5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ In this release, test coverage is 75%.
1010

1111
🛠️ Bug fixes:
1212

13+
* Image statistics tool: fixed "No available data" message when the tool rectangular
14+
region top Y coordinate is above the image top Y coordinate
1315
* Label items (`LabelItem`, `LegendBoxItem`, `DataInfoLabel`, ...) were not emitting
1416
the `SIG_ITEM_MOVED` signal when moved interactively (with the mouse) if the item
1517
anchor was attached to the canvas

plotpy/tools/image.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from plotpy import io
1717
from plotpy.config import _
1818
from plotpy.constants import ID_CONTRAST, PlotType
19+
from plotpy.coords import axes_to_canvas
1920
from plotpy.events import QtDragHandler, setup_standard_tool_filter
2021
from plotpy.interfaces import (
2122
IColormapImageItemType,
@@ -114,13 +115,10 @@ def get_infos(self) -> str | None:
114115
plot = self.image_item.plot()
115116
if plot is None:
116117
return None
117-
p0y = plot.transform(0, self.shape.get_points()[0][1])
118-
p0x = plot.transform(2, self.shape.get_points()[0][0])
119-
p1y = plot.transform(0, self.shape.get_points()[1][1])
120-
p1x = plot.transform(2, self.shape.get_points()[1][0])
121-
p0 = QC.QPointF(p0x, p0y)
122-
p1 = QC.QPointF(p1x, p1y)
123-
items = get_items_in_rectangle(plot, p0, p1)
118+
x0, y0, x1, y1 = self.shape.get_rect()
119+
p0x, p0y = axes_to_canvas(self, x0, y0)
120+
p1x, p1y = axes_to_canvas(self, x1, y1)
121+
items = get_items_in_rectangle(plot, QC.QPointF(p0x, p0y), QC.QPointF(p1x, p1y))
124122
if len(items) >= 1:
125123
sorted_items = [
126124
it for it in sorted(items, key=lambda obj: obj.z()) if it.isVisible()

0 commit comments

Comments
 (0)