Skip to content

Commit 830a8c2

Browse files
committed
Enhance readonly state handling in range selection items
1 parent 8895222 commit 830a8c2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

plotpy/items/annotation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ def draw(
170170
if self.label.isVisible():
171171
self.label.draw(painter, xMap, yMap, canvasRect)
172172

173+
# ----AbstractShape API------------------------------------------------------
174+
def set_readonly(self, state: bool) -> None:
175+
"""Set object readonly state
176+
177+
Args:
178+
state: True if object is readonly, False otherwise
179+
"""
180+
super().set_readonly(state)
181+
self.shape.set_readonly(state)
182+
173183
# ----Public API-------------------------------------------------------------
174184
def create_shape(self):
175185
"""Return the shape object associated to this annotated shape object"""
@@ -185,6 +195,8 @@ def create_label(self) -> DataInfoLabel:
185195
label_param = LabelParam(_("Label"), icon="label.png")
186196
label_param.read_config(CONF, "plot", "shape/label")
187197
label_param.anchor = self.LABEL_ANCHOR
198+
if self.LABEL_ANCHOR == "C":
199+
label_param.xc = label_param.yc = 0
188200
return DataInfoLabel(label_param, [self])
189201

190202
def is_label_visible(self) -> bool:

plotpy/items/shape/range.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def draw(
319319
cx = rct.center().x()
320320
painter.drawLine(QC.QPointF(cx, rct.top()), QC.QPointF(cx, rct.bottom()))
321321

322-
if self.can_resize():
322+
if self.can_resize() and not self.is_readonly():
323323
painter.setPen(pen)
324324
x0, x1, y = self.get_handles_pos()
325325
sym.drawSymbol(painter, QC.QPointF(x0, y))
@@ -481,7 +481,7 @@ def draw(
481481
cy = rct.center().y()
482482
painter.drawLine(QC.QPointF(rct.left(), cy), QC.QPointF(rct.right(), cy))
483483

484-
if self.can_resize():
484+
if self.can_resize() and not self.is_readonly():
485485
painter.setPen(pen)
486486
y0, y1, x = self.get_handles_pos()
487487
sym.drawSymbol(painter, QC.QPointF(x, y0))

0 commit comments

Comments
 (0)