Skip to content

Commit 0ff3c05

Browse files
committed
Item list: refresh tree when item parameters are changed
1 parent 019d56d commit 0ff3c05

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* This allows the tools to work properly when no image item is selected, but there are image items in the plot
1818
* This closes [Issue #47](https://github.com/PlotPyStack/PlotPy/issues/47) - Intensity profile tools do not work when no image item is selected
1919
* [Issue #46](https://github.com/PlotPyStack/PlotPy/issues/46) - Contrast adjustment with 'Eliminate outliers' failed for float images with high dynamic range
20+
* Item list: refresh tree when item parameters are changed:
21+
* Added `SIG_ITEM_PARAMETERS_CHANGED` signal to `BasePlot` class
22+
* This signal is emitted when the parameters of an item are changed using the parameters dialog, or a specific tool (e.g. the colormap selection tool, or the lock/unlock tool for image items)
23+
* The signal is emitted with the item as argument
24+
* The `ItemListWidget` now listens to this signal and refreshes the item list accordingly
2025

2126
Other changes:
2227

plotpy/panels/itemlist.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
from plotpy.interfaces import IPanel
2626
from plotpy.interfaces import items as itf
2727
from plotpy.panels.base import PanelWidget
28+
from plotpy.plot import BasePlot, PlotManager
2829
from plotpy.styles.base import ItemParameters
2930

3031
if TYPE_CHECKING:
3132
from qtpy.QtGui import QContextMenuEvent, QIcon
3233
from qtpy.QtWidgets import QListWidgetItem, QWidget
3334

34-
from plotpy.plot import BasePlot, PlotManager
35-
3635

3736
class ItemListWidget(QW.QListWidget):
3837
"""
@@ -73,6 +72,7 @@ def register_panel(self, manager: PlotManager) -> None:
7372
for plot in self.manager.get_plots():
7473
plot.SIG_ITEMS_CHANGED.connect(self.items_changed)
7574
plot.SIG_ACTIVE_ITEM_CHANGED.connect(self.active_item_changed)
75+
plot.SIG_ITEM_PARAMETERS_CHANGED.connect(self.item_parameters_changed)
7676
self.plot = self.manager.get_plot()
7777

7878
def contextMenuEvent(self, event: QContextMenuEvent) -> None:
@@ -230,6 +230,17 @@ def active_item_changed(self, plot: BasePlot) -> None:
230230
self.refresh_actions()
231231
self.blockSignals(_block)
232232

233+
def item_parameters_changed(self, item: itf.IBasePlotItem) -> None:
234+
"""Item parameters have changed
235+
236+
Args:
237+
item: item
238+
"""
239+
if not isinstance(item, BasePlot):
240+
plot = item.plot()
241+
if plot is not None:
242+
self.items_changed(plot)
243+
233244
def current_row_changed(self, index: int) -> None:
234245
"""QListWidget current row has changed
235246

0 commit comments

Comments
 (0)