Merge pull request #1382 from arve0/ImageViewer.update_image

move CollectionViewer `update_image` to parent class
This commit is contained in:
Steven Silvester
2015-02-20 08:18:25 -06:00
+11 -11
View File
@@ -153,6 +153,9 @@ class ImageViewer(QtWidgets.QMainWindow):
for showing images. `ImageViewer` doesn't subclass the Matplotlib axes (or
figure) because of the high probability of name collisions.
Subclasses and plugins will likely extend the `update_image` method to add
custom overlays or filter the displayed image.
Parameters
----------
image : array
@@ -283,6 +286,14 @@ class ImageViewer(QtWidgets.QMainWindow):
image = io.imread(filename)
self._update_original_image(image)
def update_image(self, image):
"""Update displayed image.
This method can be overridden or extended in subclasses and plugins to
react to image changes.
"""
self._update_original_image(image)
def _update_original_image(self, image):
self.original_image = image # update saved image
self.image = image.copy() # update displayed image
@@ -423,9 +434,6 @@ class CollectionViewer(ImageViewer):
home/end keys
First/last image in collection.
Subclasses and plugins will likely extend the `update_image` method to add
custom overlays or filter the displayed image.
Parameters
----------
image_collection : list of images
@@ -472,14 +480,6 @@ class CollectionViewer(ImageViewer):
self.slider.val = index
self.update_image(self.image_collection[index])
def update_image(self, image):
"""Update displayed image.
This method can be overridden or extended in subclasses and plugins to
react to image changes.
"""
self._update_original_image(image)
def keyPressEvent(self, event):
if type(event) == QtWidgets.QKeyEvent:
key = event.key()