ENH: filter image when Plugin is attached to ImageViewer

This commit is contained in:
Tony S Yu
2012-07-24 00:35:26 -04:00
parent 0e8f444fbb
commit 1ae662f712
2 changed files with 5 additions and 7 deletions
+5 -2
View File
@@ -32,8 +32,7 @@ class Plugin(QtGui.QDialog):
super(Plugin, self).__init__()
self.image_viewer = None
if image_filter is not None:
self.image_filter = image_filter
self.image_filter = image_filter
self.setWindowTitle(self.name)
self.layout = QtGui.QGridLayout(self)
@@ -70,6 +69,8 @@ class Plugin(QtGui.QDialog):
if self.draws_on_image:
self.connect_image_event('draw_event', self.on_draw)
# Call filter so that filtered image matches widget values
self.filter_image()
def on_draw(self, event):
"""Save image background when blitting.
@@ -81,6 +82,8 @@ class Plugin(QtGui.QDialog):
self.img_background = self.image_viewer.canvas.copy_from_bbox(bbox)
def filter_image(self, *args):
if self.image_filter is None:
return
arguments = [self._get_value(a) for a in self.arguments]
kwargs = dict([(name, self._get_value(a))
for name, a in self.keyword_arguments.iteritems()])
-5
View File
@@ -15,8 +15,3 @@ class CannyPlugin(OverlayPlugin):
self.add_widget(Slider('low threshold', 0, 255, update_on='release'))
self.add_widget(Slider('high threshold', 0, 255, update_on='release'))
self.add_widget(ComboBox('color', self.color_names, ptype='plugin'))
def attach(self, image_viewer):
super(CannyPlugin, self).attach(image_viewer)
# Update image overlay to default slider values.
self.filter_image()