3 class ClickedPoint(object):
5 this class defines what a clicked point on the curve plot is
9 self.is_marker=None #boolean ; decides if it is a marker
10 self.is_line_edge=None #boolean ; decides if it is the edge of a line (unused)
11 self.absolute_coords=(None,None) #(float,float) ; the absolute coordinates of the clicked point on the graph
12 self.graph_coords=(None,None) #(float,float) ; the coordinates of the plot that are nearest in X to the clicked point
13 self.index=None #integer ; the index of the clicked point with respect to the vector selected
14 self.dest=None #0 or 1 ; 0=top plot 1=bottom plot
17 def find_graph_coords_old(self, xvector, yvector):
19 Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
20 corresponds to the clicked point.
21 OLD & DEPRECATED - to be removed
24 #FIXME: a general algorithm using min() is needed!
26 best_dist=10**9 #should be more than enough given the scale
28 for index in scipy.arange(1,len(xvector),1):
29 dist=((self.absolute_coords[0]-xvector[index])**2)+(100*((self.absolute_coords[1]-yvector[index])))**2
30 #TODO, generalize? y coordinate is multiplied by 100 due to scale differences in the plot
36 self.graph_coords=(xvector[best_index],yvector[best_index])
39 def find_graph_coords(self,xvector,yvector):
41 Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
42 corresponds to the clicked point.
45 for index in scipy.arange(1,len(xvector),1):
46 dists.append(((self.absolute_coords[0]-xvector[index])**2)+((self.absolute_coords[1]-yvector[index])**2))
48 self.index=dists.index(min(dists))
49 self.graph_coords=(xvector[self.index],yvector[self.index])