diff options
Diffstat (limited to 'silx/gui/plot/actions/control.py')
-rwxr-xr-x | silx/gui/plot/actions/control.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/silx/gui/plot/actions/control.py b/silx/gui/plot/actions/control.py index e2fa6b1..ba69748 100755 --- a/silx/gui/plot/actions/control.py +++ b/silx/gui/plot/actions/control.py @@ -391,9 +391,8 @@ class ColormapAction(PlotAction): elif isinstance(image, items.ColormapMixIn): # Set dialog from active image colormap = image.getColormap() - data = image.getData(copy=False) # Set histogram and range if any - self._dialog.setData(data) + self._dialog.setItem(image) else: # No active image or active image is RGBA, @@ -401,8 +400,7 @@ class ColormapAction(PlotAction): scatter = self.plot._getActiveItem(kind='scatter') if scatter is not None: colormap = scatter.getColormap() - data = scatter.getValueData(copy=False) - self._dialog.setData(data) + self._dialog.setItem(scatter) else: # No active data image nor scatter, @@ -605,3 +603,32 @@ class ShowAxisAction(PlotAction): def _actionTriggered(self, checked=False): self.plot.setAxesDisplayed(checked) + +class ClosePolygonInteractionAction(PlotAction): + """QAction controlling closure of a polygon in draw interaction mode + if the :class:`.PlotWidget`. + + :param plot: :class:`.PlotWidget` instance on which to operate + :param parent: See :class:`QAction` + """ + + def __init__(self, plot, parent=None): + tooltip = 'Close the current polygon drawn' + PlotAction.__init__(self, + plot, + icon='add-shape-polygon', + text='Close the polygon', + tooltip=tooltip, + triggered=self._actionTriggered, + checkable=True, + parent=parent) + self.plot.sigInteractiveModeChanged.connect(self._modeChanged) + self._modeChanged(None) + + def _modeChanged(self, source): + mode = self.plot.getInteractiveMode() + enabled = "shape" in mode and mode["shape"] == "polygon" + self.setEnabled(enabled) + + def _actionTriggered(self, checked=False): + self.plot._eventHandler.validate() |