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