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