diff options
author | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2020-07-21 14:45:14 +0200 |
---|---|---|
committer | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2020-07-21 14:45:14 +0200 |
commit | 328032e2317e3ac4859196bbf12bdb71795302fe (patch) | |
tree | 8cd13462beab109e3cb53410c42335b6d1e00ee6 /silx/gui/plot/MaskToolsWidget.py | |
parent | 33ed2a64c92b0311ae35456c016eb284e426afc2 (diff) |
New upstream version 0.13.0+dfsg
Diffstat (limited to 'silx/gui/plot/MaskToolsWidget.py')
-rw-r--r-- | silx/gui/plot/MaskToolsWidget.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/silx/gui/plot/MaskToolsWidget.py b/silx/gui/plot/MaskToolsWidget.py index 9d727e7..a95e277 100644 --- a/silx/gui/plot/MaskToolsWidget.py +++ b/silx/gui/plot/MaskToolsWidget.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2017-2018 European Synchrotron Radiation Facility +# Copyright (c) 2017-2020 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -187,6 +187,8 @@ class ImageMask(BaseMask): :param bool mask: True to mask (default), False to unmask. """ assert 0 < level < 256 + if row + height <= 0 or col + width <= 0: + return # Rectangle outside image, avoid negative indices selection = self._mask[max(0, row):row + height + 1, max(0, col):col + width + 1] if mask: @@ -319,7 +321,7 @@ class MaskToolsWidget(BaseMaskToolsWidget): # ensure all mask attributes are synchronized with the active image # and connect listener activeImage = self.plot.getActiveImage() - if activeImage is not None and activeImage.getLegend() != self._maskName: + if activeImage is not None and activeImage.getName() != self._maskName: self._activeImageChanged() self.plot.sigActiveImageChanged.connect(self._activeImageChanged) @@ -351,7 +353,7 @@ class MaskToolsWidget(BaseMaskToolsWidget): mustBeAdded = maskItem is None if mustBeAdded: maskItem = items.MaskImageData() - maskItem._setLegend(self._maskName) + maskItem.setName(self._maskName) # update the items maskItem.setData(mask, copy=False) maskItem.setColormap(self._colormap) @@ -360,7 +362,7 @@ class MaskToolsWidget(BaseMaskToolsWidget): maskItem.setZValue(self._z) if mustBeAdded: - self.plot._add(maskItem) + self.plot.addItem(maskItem) elif self.plot.getImage(self._maskName): self.plot.remove(self._maskName, kind='image') @@ -407,7 +409,7 @@ class MaskToolsWidget(BaseMaskToolsWidget): removed, otherwise it is adjusted to origin, scale and z. """ activeImage = self.plot.getActiveImage() - if activeImage is None or activeImage.getLegend() == self._maskName: + if activeImage is None or activeImage.getName() == self._maskName: # No active image or active image is the mask... self._data = numpy.zeros((0, 0), dtype=numpy.uint8) self._mask.setDataItem(None) @@ -443,7 +445,7 @@ class MaskToolsWidget(BaseMaskToolsWidget): def _activeImageChanged(self, *args): """Update widget and mask according to active image changes""" activeImage = self.plot.getActiveImage() - if (activeImage is None or activeImage.getLegend() == self._maskName or + if (activeImage is None or activeImage.getName() == self._maskName or activeImage.getData(copy=False).size == 0): # No active image or active image is the mask or image has no data... self.setEnabled(False) @@ -770,7 +772,7 @@ class MaskToolsWidget(BaseMaskToolsWidget): """Set range from active image colormap range""" activeImage = self.plot.getActiveImage() if (isinstance(activeImage, items.ColormapMixIn) and - activeImage.getLegend() != self._maskName): + activeImage.getName() != self._maskName): # Update thresholds according to colormap colormap = activeImage.getColormap() if colormap['autoscale']: |