Skip to content

Commit

Permalink
[_linkutils.ClickOnAxisListener] kdtree initializes on first click
Browse files Browse the repository at this point in the history
  • Loading branch information
gph82 committed Nov 20, 2017
1 parent c50a531 commit a8196c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions molpx/_linkutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, ngl_wdg, crosshairs, showclick_objs, ax, pos,
self.list_mpl_objects_to_update = list_mpl_objects_to_update
self.list_of_dots = [None]*self.pos.shape[0]
self.fig_size = self.ax.figure.get_size_inches()
self.build_tree()
self.kdtree = None

def build_tree(self):
# Use ax.transData to compute distance in pixels
Expand All @@ -106,8 +106,9 @@ def figure_changed_size(self):
return not _np.allclose(self.fig_size, self.ax.figure.get_size_inches())

def __call__(self, event):
# Re-build tree if there s been a figsize change
if self.figure_changed_size:
# Wait for the first click or a a figsize change
# to build the kdtree
if self.figure_changed_size or self.kdtree is None:
self.build_tree()
self.fig_size = self.ax.figure.get_size_inches()

Expand Down

0 comments on commit a8196c6

Please sign in to comment.