1 #PLOT INTERACTION COMMANDS
2 #-------------------------------
6 Plots the current force curve
10 def do_plot(self,args):
11 if self.current.identify(self.drivers) == False:
13 self.plots=self.current.curve.default_plots()
15 self.plots=self.current.curve.default_plots()
17 print 'Unexpected error occurred in do_plot().'
21 #apply the plotmanip functions eventually present
22 nplots=len(self.plots)
25 for function in self.plotmanip: #FIXME: something strange happens about self.plotmanip[0]
26 self.plots[c]=function(self.plots[c], self.current)
28 self.plots[c].xaxes=self.config['xaxes'] #FIXME: in the future, xaxes and yaxes should be set per-plot
29 self.plots[c].yaxes=self.config['yaxes']
33 self._send_plot(self.plots)
35 def _delta(self, set=1):
37 calculates the difference between two clicked points
39 print 'Click two points'
40 points=self._measure_N_points(N=2, whatset=set)
41 dx=abs(points[0].graph_coords[0]-points[1].graph_coords[0])
42 dy=abs(points[0].graph_coords[1]-points[1].graph_coords[1])
43 unitx=self.plots[points[0].dest].units[0]
44 unity=self.plots[points[0].dest].units[1]
45 return dx,unitx,dy,unity
47 def do_delta(self,args):
51 Measures the delta X and delta Y between two points.
55 dx,unitx,dy,unity=self._delta()
56 print str(dx)+' '+unitx
57 print str(dy)+' '+unity
59 def _point(self, set=1):
60 '''calculates the coordinates of a single clicked point'''
62 print 'Click one point'
63 point=self._measure_N_points(N=1, whatset=set)
65 x=point[0].graph_coords[0]
66 y=point[0].graph_coords[1]
67 unitx=self.plots[point[0].dest].units[0]
68 unity=self.plots[point[0].dest].units[1]
69 return x,unitx,y,unity
71 def do_point(self,args):
75 Returns the coordinates of a point on the graph.
79 x,unitx,y,unity=self._point()
80 print str(x)+' '+unitx
81 print str(y)+' '+unity
82 to_dump='point '+self.current.path+' '+str(x)+' '+unitx+', '+str(y)+' '+unity
83 self.outlet.push(to_dump)
86 def do_close(self,args=None):
89 Closes one of the two plots. If no arguments are given, the bottom plot is closed.
91 Syntax: close [top,bottom]
100 close_plot=self.list_of_events['close_plot']
101 wx.PostEvent(self.frame, close_plot(to_close=to_close))
103 def do_show(self,args=None):
108 show_plots=self.list_of_events['show_plots']
109 wx.PostEvent(self.frame, show_plots())
112 #Everything sending an event should be here
113 def _measure_N_points(self, N, whatset=1):
115 general helper function for N-points measures
117 wx.PostEvent(self.frame,self.list_of_events['measure_points'](num_of_points=N, set=whatset))
120 points=self.frame.events_from_gui.get()
126 def _get_displayed_plot(self,dest=0):
128 returns the currently displayed plot.
130 wx.PostEvent(self.frame, self.list_of_events['get_displayed_plot'](dest=dest))
133 displayed_plot=self.events_from_gui.get()
138 return displayed_plot
140 def _send_plot(self,plots):
142 sends a plot to the GUI
144 wx.PostEvent(self.frame, self.list_of_events['plot_graph'](plots=plots))
147 def _find_plotmanip(self, name):
149 returns a plot manipulator function from its name
151 return self.plotmanip[self.config['plotmanips'].index(name)]
153 def _clickize(self, xvector, yvector, index):
155 returns a ClickedPoint() object from an index and vectors of x, y coordinates
159 point.absolute_coords=xvector[index],yvector[index]
160 point.find_graph_coords(xvector,yvector)