Skip to content

Commit 13b22b1

Browse files
committed
Enhance RangeShapeParam: add title support and update parameter handling
1 parent d3098e0 commit 13b22b1

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* Item list:
1212
* Added a new "Rename" context menu entry to rename the selected item
1313
* This entry is only available for editable items
14+
* X and Y range selection items:
15+
* Added support for item title in parameters data set (`RangeShapeParam`)
16+
* This concerns the `XRangeSelection` and `YRangeSelection` items
1417

1518
🛠️ Bug fixes:
1619

plotpy/styles/shape.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ class AnnotationParam_MS(AnnotationParam):
397397
class RangeShapeParam(DataSet):
398398
"""Parameters for a range selection item"""
399399

400+
label = StringItem(_("Title"), default="")
400401
_styles = BeginTabGroup("Styles")
401402
# ------------------------------------------------------------------ Line tab
402403
___line = BeginGroup(_("Line")).set_prop("display", icon="dashdot.png")
@@ -416,29 +417,31 @@ class RangeShapeParam(DataSet):
416417
# ----------------------------------------------------------------------- End
417418
_endstyles = EndTabGroup("Styles")
418419

419-
def update_param(self, range: XRangeSelection) -> None:
420+
def update_param(self, obj: XRangeSelection) -> None:
420421
"""Update parameters from object
421422
422423
Args:
423-
range: XRangeSelection object
424+
obj: XRangeSelection object
424425
"""
426+
self.label = str(obj.title().text())
425427
self.line: LineStyleParam
426428
self.sel_line: LineStyleParam
427429
self.symbol: SymbolParam
428430
self.sel_symbol: SymbolParam
429-
self.line.update_param(range.pen)
430-
self.sel_line.update_param(range.sel_pen)
431-
self.fill = range.brush.color().name()
432-
self.shade = range.brush.color().alphaF()
433-
self.symbol.update_param(range.symbol)
434-
self.sel_symbol.update_param(range.sel_symbol)
431+
self.line.update_param(obj.pen)
432+
self.sel_line.update_param(obj.sel_pen)
433+
self.fill = obj.brush.color().name()
434+
self.shade = obj.brush.color().alphaF()
435+
self.symbol.update_param(obj.symbol)
436+
self.sel_symbol.update_param(obj.sel_symbol)
435437

436438
def update_item(self, item: XRangeSelection) -> None:
437439
"""Update object from parameters
438440
439441
Args:
440442
range: XRangeSelection object
441443
"""
444+
item.setTitle(self.label)
442445
item.pen = self.line.build_pen()
443446
item.sel_pen = self.sel_line.build_pen()
444447
col = QG.QColor(self.fill)

0 commit comments

Comments
 (0)