mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 05:17:50 +08:00
Fix: Move on_draw method to base Plugin
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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'):
|
||||
|
||||
Reference in New Issue
Block a user