BUG: Fix line thickness change call back

This commit is contained in:
Tony S Yu
2012-12-13 21:21:36 -05:00
parent 25b9f5d5aa
commit 34de6d323a
2 changed files with 12 additions and 2 deletions
+10 -1
View File
@@ -134,6 +134,8 @@ class ThickLineTool(LineTool):
Function called whenever the control handle is released.
on_enter : function
Function called whenever the "enter" key is pressed.
on_change : function
Function called whenever the line thickness is changed.
maxdist : float
Maximum pixel distance allowed when selecting control handle.
line_props : dict
@@ -146,7 +148,7 @@ class ThickLineTool(LineTool):
"""
def __init__(self, ax, on_move=None, on_enter=None, on_release=None,
maxdist=10, line_props=None):
on_change=None, maxdist=10, line_props=None):
super(ThickLineTool, self).__init__(ax,
on_move=on_move,
on_enter=on_enter,
@@ -154,6 +156,11 @@ class ThickLineTool(LineTool):
maxdist=maxdist,
line_props=line_props)
if on_change is None:
def on_change(*args):
pass
self.callback_on_change = on_change
self.connect_event('scroll_event', self.on_scroll)
self.connect_event('key_press_event', self.on_key_press)
@@ -174,11 +181,13 @@ class ThickLineTool(LineTool):
def _thicken_scan_line(self):
self.linewidth += 1
self.update(None, None)
self.callback_on_change(self.geometry)
def _shrink_scan_line(self):
if self.linewidth > 1:
self.linewidth -= 1
self.update(None, None)
self.callback_on_change(self.geometry)
if __name__ == '__main__':
+2 -1
View File
@@ -66,7 +66,8 @@ class LineProfile(PlotPlugin):
self.line_tool = ThickLineTool(self.image_viewer.ax,
maxdist=self.maxdist,
on_move=self.line_changed)
on_move=self.line_changed,
on_change=self.line_changed)
self.line_tool.end_points = np.transpose([x, y])
scan_data = profile_line(image, self.line_tool.end_points)