mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-31 12:41:20 +08:00
Add plugin return values for ImageViewer
The model supported is that plugins can return an overlay, some data, or both. Each plugin therefore returns an `(overlay, data)` tuple in which each element can be `None`. To allow return values, the plugin need only override the `output` method defined in the base Plugin class. See discussions here: https://groups.google.com/d/msg/scikit-image/0nkJM-WguXA/iqogBABa748J and here: https://github.com/scikit-image/scikit-image/pull/805
This commit is contained in:
@@ -235,3 +235,20 @@ class Plugin(QtGui.QDialog):
|
||||
"""Remove artists that are connected to the image viewer."""
|
||||
for a in self.artists:
|
||||
a.remove()
|
||||
|
||||
def output(self):
|
||||
"""Return the plugin's representation and data.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
None
|
||||
|
||||
Returns
|
||||
-------
|
||||
overlay : array, same shape as ``self.image_viewer.image``, or None
|
||||
The filtered image.
|
||||
data : array, arbitrary shape and type, or None
|
||||
Any data associated with the plugin.
|
||||
"""
|
||||
return (self.image_viewer.image, None)
|
||||
|
||||
|
||||
@@ -228,6 +228,7 @@ class ImageViewer(QtGui.QMainWindow):
|
||||
self._show()
|
||||
if main_window:
|
||||
utils.start_qtapp()
|
||||
return [p.output() for p in self.plugins]
|
||||
|
||||
def redraw(self):
|
||||
self.canvas.draw_idle()
|
||||
|
||||
Reference in New Issue
Block a user