Skip to content

Commit ea1787c

Browse files
committed
Attempt to fix OverflowError with Contrast Adjustment panel for constant images
Fix #25
1 parent 38e3d95 commit ea1787c

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
🛠️ Bug fixes:
66

7+
* [Issue #25](https://github.com/PlotPyStack/PlotPy/issues/25) - `OverflowError` with Contrast Adjustment panel for constant images
78
* When updating image parameters (`ImageParam`) from the associated item object:
89
* If `xmin`, `xmax`, `ymin`, `ymax` attributes are not yet set (i.e. `None`), do not update them with the image data bounds
910
* 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

plotpy/items/shape/range.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import qwt.scale_map
2323
from qtpy.QtCore import QPointF, QRectF
2424
from qtpy.QtGui import QPainter
25+
from qwt import QwtSymbol
2526

27+
from plotpy.plot import BasePlot
2628
from plotpy.styles.base import ItemParameters
2729

2830

@@ -137,34 +139,31 @@ def draw(
137139
yMap: Y axis scale map
138140
canvasRect: Canvas rectangle
139141
"""
140-
plot = self.plot()
142+
plot: BasePlot = self.plot()
141143
if not plot:
142144
return
143145
if self.selected:
144-
pen = self.sel_pen
145-
sym = self.sel_symbol
146+
pen: QG.QPen = self.sel_pen
147+
sym: QwtSymbol = self.sel_symbol
146148
else:
147-
pen = self.pen
148-
sym = self.symbol
149+
pen: QG.QPen = self.pen
150+
sym: QwtSymbol = self.symbol
149151

150-
rct = plot.canvas().contentsRect()
151-
rct2 = QC.QRectF(rct)
152-
rct2.setLeft(xMap.transform(self._min))
153-
rct2.setRight(xMap.transform(self._max))
152+
rct = QC.QRectF(plot.canvas().contentsRect())
153+
rct.setLeft(xMap.transform(self._min))
154+
rct.setRight(xMap.transform(self._max))
154155

155-
painter.fillRect(rct2, self.brush)
156+
painter.fillRect(rct, self.brush)
156157
painter.setPen(pen)
157-
painter.drawLine(rct2.topLeft(), rct2.bottomLeft())
158-
painter.drawLine(rct2.topRight(), rct2.bottomRight())
158+
painter.drawLine(rct.topLeft(), rct.bottomLeft())
159+
painter.drawLine(rct.topRight(), rct.bottomRight())
160+
159161
dash = QG.QPen(pen)
160162
dash.setStyle(QC.Qt.DashLine)
161163
dash.setWidth(1)
162164
painter.setPen(dash)
163-
164-
center_x = int(rct2.center().x())
165-
top = int(rct2.top())
166-
bottom = int(rct2.bottom())
167-
painter.drawLine(center_x, top, center_x, bottom)
165+
cx = rct.center().x()
166+
painter.drawLine(QC.QPointF(cx, rct.top()), QC.QPointF(cx, rct.bottom()))
168167

169168
painter.setPen(pen)
170169
x0, x1, y = self.get_handles_pos()

0 commit comments

Comments
 (0)