3 #PLOT INTERACTION COMMANDS
4 #-------------------------------
8 Plots the current force curve
12 def do_plot(self,args):
13 if self.current.identify(self.drivers) == False:
15 self.plots=self.current.curve.default_plots()
17 self.plots=self.current.curve.default_plots()
19 print 'Unexpected error occurred in do_plot().'
23 #apply the plotmanip functions eventually present
24 nplots=len(self.plots)
27 for function in self.plotmanip: #FIXME: something strange happens about self.plotmanip[0]
28 self.plots[c]=function(self.plots[c], self.current)
30 self.plots[c].xaxes=self.config['xaxes'] #FIXME: in the future, xaxes and yaxes should be set per-plot
31 self.plots[c].yaxes=self.config['yaxes']
35 self._send_plot(self.plots)
37 def _delta(self, set=1):
39 calculates the difference between two clicked points
41 print 'Click two points'
42 points=self._measure_N_points(N=2, whatset=set)
43 dx=abs(points[0].graph_coords[0]-points[1].graph_coords[0])
44 dy=abs(points[0].graph_coords[1]-points[1].graph_coords[1])
45 unitx=self.plots[points[0].dest].units[0]
46 unity=self.plots[points[0].dest].units[1]
47 return dx,unitx,dy,unity
49 def do_delta(self,args):
53 Measures the delta X and delta Y between two points.
57 dx,unitx,dy,unity=self._delta()
58 print str(dx)+' '+unitx
59 print str(dy)+' '+unity
61 def _point(self, set=1):
62 '''calculates the coordinates of a single clicked point'''
64 print 'Click one point'
65 point=self._measure_N_points(N=1, whatset=set)
67 x=point[0].graph_coords[0]
68 y=point[0].graph_coords[1]
69 unitx=self.plots[point[0].dest].units[0]
70 unity=self.plots[point[0].dest].units[1]
71 return x,unitx,y,unity
73 def do_point(self,args):
77 Returns the coordinates of a point on the graph.
81 x,unitx,y,unity=self._point()
82 print str(x)+' '+unitx
83 print str(y)+' '+unity
84 to_dump='point '+self.current.path+' '+str(x)+' '+unitx+', '+str(y)+' '+unity
85 self.outlet.push(to_dump)
88 def do_close(self,args=None):
91 Closes one of the two plots. If no arguments are given, the bottom plot is closed.
93 Syntax: close [top,bottom]
102 close_plot=self.list_of_events['close_plot']
103 wx.PostEvent(self.frame, close_plot(to_close=to_close))
105 def do_show(self,args=None):
110 show_plots=self.list_of_events['show_plots']
111 wx.PostEvent(self.frame, show_plots())
114 #Everything sending an event should be here
115 def _measure_N_points(self, N, whatset=1):
117 general helper function for N-points measures
119 wx.PostEvent(self.frame,self.list_of_events['measure_points'](num_of_points=N, set=whatset))
122 points=self.frame.events_from_gui.get()
128 def _get_displayed_plot(self,dest=0):
130 returns the currently displayed plot.
132 wx.PostEvent(self.frame, self.list_of_events['get_displayed_plot'](dest=dest))
135 displayed_plot=self.events_from_gui.get()
140 return displayed_plot
142 def _send_plot(self,plots):
144 sends a plot to the GUI
146 wx.PostEvent(self.frame, self.list_of_events['plot_graph'](plots=plots))
149 def _find_plotmanip(self, name):
151 returns a plot manipulator function from its name
153 return self.plotmanip[self.config['plotmanips'].index(name)]
155 def _clickize(self, xvector, yvector, index):
157 returns a ClickedPoint() object from an index and vectors of x, y coordinates
161 point.absolute_coords=xvector[index],yvector[index]
162 point.find_graph_coords(xvector,yvector)