Fix: Move on_draw method to base Plugin

This commit is contained in:
Tony S Yu
2012-07-20 18:19:37 -05:00
parent afd33afc5e
commit 47d5f028e5
2 changed files with 14 additions and 11 deletions
+13 -11
View File
@@ -46,6 +46,8 @@ class Plugin(QtGui.QDialog):
overlay : array
Image used in measurement/manipulation.
"""
draws_on_image = False
def __init__(self, image_viewer, callback=None, height=100, width=400,
useblit=None):
self.image_viewer = image_viewer
@@ -72,7 +74,17 @@ class Plugin(QtGui.QDialog):
self.cids = []
self.artists = []
self.connect_event('draw_event', self.on_draw)
if self.draws_on_image:
self.connect_event('draw_event', self.on_draw)
def on_draw(self, event):
"""Save image background when blitting.
The saved image is used to "clear" the figure before redrawing artists.
"""
if self.useblit:
bbox = self.image_viewer.ax.bbox
self.img_background = self.image_viewer.canvas.copy_from_bbox(bbox)
def caller(self, *args):
arguments = [self._get_value(a) for a in self.arguments]
@@ -162,16 +174,6 @@ class PlotPlugin(Plugin):
Plugin.__init__(self, image_viewer, **kwargs)
# Add plot for displaying intensity profile.
self.add_plot()
self.connect_event('draw_event', self.on_draw)
def on_draw(self, event):
"""Save image background when blitting.
The saved image is used to "clear" the figure before redrawing artists.
"""
if self.useblit:
bbox = self.image_viewer.ax.bbox
self.img_background = self.image_viewer.canvas.copy_from_bbox(bbox)
def add_plot(self, height=4, width=4):
self.canvas = PlotCanvas(self, height, width)
+1
View File
@@ -30,6 +30,7 @@ class LineProfile(PlotPlugin):
'image' : fixed scale based on min/max intensity in image.
'dtype' : fixed scale based on min/max intensity of image dtype.
"""
draws_on_image = True
def __init__(self, image_viewer, useblit=None,
linewidth=1, epsilon=5, limits='image'):