|
21 | 21 | from qtpy import QtWidgets as QW
|
22 | 22 |
|
23 | 23 | from plotpy.config import _
|
24 |
| -from plotpy.constants import ID_ITEMLIST |
| 24 | +from plotpy.constants import ID_ITEMLIST, PARAMETERS_TITLE_ICON |
25 | 25 | from plotpy.interfaces import IPanel
|
26 | 26 | from plotpy.interfaces import items as itf
|
27 | 27 | from plotpy.panels.base import PanelWidget
|
| 28 | +from plotpy.styles.base import ItemParameters |
28 | 29 |
|
29 | 30 | if TYPE_CHECKING:
|
30 | 31 | from qtpy.QtGui import QContextMenuEvent, QIcon
|
@@ -106,7 +107,35 @@ def setup_actions(self) -> None:
|
106 | 107 |
|
107 | 108 | def edit_plot_parameters(self) -> None:
|
108 | 109 | """Edit plot parameters"""
|
109 |
| - self.plot.edit_plot_parameters("item") |
| 110 | + # In order to support non-selectable items, we have to reimplement the |
| 111 | + # `BasePlot.edit_plot_parameters` method. This is because we can select items |
| 112 | + # using the `PlotItemList` widget, but we can't select them using the plot |
| 113 | + # widget. Thus we can't rely on the `BasePlot.get_selected_items` method and |
| 114 | + # other methods that rely on it. |
| 115 | + # |
| 116 | + # This can be tested for example by uncommenting the line containing |
| 117 | + # `item.set_selectable(False)` in the `tests/items/test_transform.py` file. |
| 118 | + |
| 119 | + # === Reimplementing the `BasePlot.edit_plot_parameters`: |
| 120 | + sel_items = self.get_selected_items() |
| 121 | + multiselection = len(sel_items) > 1 |
| 122 | + itemparams = ItemParameters(multiselection=multiselection) |
| 123 | + # === === Reimplementing the `BasePlot.get_plot_parameters`: |
| 124 | + for item in sel_items: |
| 125 | + item.get_item_parameters(itemparams) |
| 126 | + sel_items[0].get_item_parameters(itemparams) |
| 127 | + Param = self.plot.get_axesparam_class(sel_items[0]) |
| 128 | + axesparam = Param( |
| 129 | + title=_("Axes"), |
| 130 | + icon="lin_lin.png", |
| 131 | + comment=_("Axes associated to selected item"), |
| 132 | + ) |
| 133 | + axesparam.update_param(sel_items[0]) |
| 134 | + itemparams.add("AxesParam", self.plot, axesparam) |
| 135 | + # === === |
| 136 | + title, icon = PARAMETERS_TITLE_ICON["item"] |
| 137 | + itemparams.edit(self.plot, title, icon) |
| 138 | + # === |
110 | 139 |
|
111 | 140 | def __is_selection_contiguous(self) -> bool:
|
112 | 141 | """Check if selected items are contiguous"""
|
|
0 commit comments