6 ClickedPoint class for Hooke.
8 Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada)
10 This program is released under the GNU General Public License version 2.
13 from scipy import arange
15 class ClickedPoint(object):
17 This class defines what a clicked point on the curve plot is.
21 self.is_marker = None #boolean ; decides if it is a marker
22 self.is_line_edge = None #boolean ; decides if it is the edge of a line (unused)
23 self.absolute_coords = (None, None) #(float,float) ; the absolute coordinates of the clicked point on the graph
24 self.graph_coords = (None, None) #(float,float) ; the coordinates of the plot that are nearest in X to the clicked point
25 self.index = None #integer ; the index of the clicked point with respect to the vector selected
26 self.dest = None #0 or 1 ; 0=top plot 1=bottom plot
28 def find_graph_coords(self, xvector, yvector):
30 Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
31 corresponds to the clicked point.
34 for index in arange(1, len(xvector), 1):
35 dists.append(((self.absolute_coords[0] - xvector[index]) ** 2)+((self.absolute_coords[1] - yvector[index]) ** 2))
37 self.index=dists.index(min(dists))
38 self.graph_coords=(xvector[self.index], yvector[self.index])