Moved plot commands from hooke_cli -> hooke.ui.gui.plotcommands stub.
authorW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 18:53:45 +0000 (14:53 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 18:53:45 +0000 (14:53 -0400)
hooke/hooke_cli.py
hooke/ui/gui/plotcommands.py [new file with mode: 0644]

index fddb6487d5506cc1ce8bdf34a09833aa5318aa32..51e56a8c9268373bb9f2d7a6ade59989febc2b98 100644 (file)
@@ -290,112 +290,3 @@ Syntax: previous, p
         self.do_previous(args)
 
 
-#PLOT INTERACTION COMMANDS
-#-------------------------------
-    def help_plot(self):
-        print '''
-PLOT
-Plots the current force curve
--------
-Syntax: plot
-        '''
-    def do_plot(self,args):
-        if self.current.identify(self.drivers) == False:
-            return
-        self.plots=self.current.curve.default_plots()
-        try:
-            self.plots=self.current.curve.default_plots()
-        except Exception, e:
-            print 'Unexpected error occurred in do_plot().'
-            print e
-            return
-
-        #apply the plotmanip functions eventually present
-        nplots=len(self.plots)
-        c=0
-        while c<nplots:
-            for function in self.plotmanip: #FIXME: something strange happens about self.plotmanip[0]
-                self.plots[c]=function(self.plots[c], self.current)
-
-            self.plots[c].xaxes=self.config['xaxes'] #FIXME: in the future, xaxes and yaxes should be set per-plot
-            self.plots[c].yaxes=self.config['yaxes']
-
-            c+=1
-
-        self._send_plot(self.plots)
-
-    def _delta(self, set=1):
-        '''
-        calculates the difference between two clicked points
-        '''
-        print 'Click two points'
-        points=self._measure_N_points(N=2, whatset=set)
-        dx=abs(points[0].graph_coords[0]-points[1].graph_coords[0])
-        dy=abs(points[0].graph_coords[1]-points[1].graph_coords[1])
-        unitx=self.plots[points[0].dest].units[0]
-        unity=self.plots[points[0].dest].units[1]
-        return dx,unitx,dy,unity
-
-    def do_delta(self,args):
-        '''
-        DELTA
-
-        Measures the delta X and delta Y between two points.
-        ----
-        Syntax: delta
-        '''
-        dx,unitx,dy,unity=self._delta()
-        print str(dx)+' '+unitx
-        print str(dy)+' '+unity
-
-    def _point(self, set=1):
-        '''calculates the coordinates of a single clicked point'''
-
-        print 'Click one point'
-        point=self._measure_N_points(N=1, whatset=set)
-
-        x=point[0].graph_coords[0]
-        y=point[0].graph_coords[1]
-        unitx=self.plots[point[0].dest].units[0]
-        unity=self.plots[point[0].dest].units[1]
-        return x,unitx,y,unity
-
-    def do_point(self,args):
-        '''
-        POINT
-
-        Returns the coordinates of a point on the graph.
-        ----
-        Syntax: point
-        '''
-        x,unitx,y,unity=self._point()
-        print str(x)+' '+unitx
-        print str(y)+' '+unity
-        to_dump='point '+self.current.path+' '+str(x)+' '+unitx+', '+str(y)+' '+unity
-        self.outlet.push(to_dump)
-
-
-    def do_close(self,args=None):
-        '''
-        CLOSE
-        Closes one of the two plots. If no arguments are given, the bottom plot is closed.
-        ------
-        Syntax: close [top,bottom]
-        '''
-        if args=='top':
-            to_close=0
-        elif args=='bottom':
-            to_close=1
-        else:
-            to_close=1
-
-        close_plot=self.list_of_events['close_plot']
-        wx.PostEvent(self.frame, close_plot(to_close=to_close))
-
-    def do_show(self,args=None):
-        '''
-        SHOW
-        Shows both plots.
-        '''
-        show_plots=self.list_of_events['show_plots']
-        wx.PostEvent(self.frame, show_plots())
diff --git a/hooke/ui/gui/plotcommands.py b/hooke/ui/gui/plotcommands.py
new file mode 100644 (file)
index 0000000..4991994
--- /dev/null
@@ -0,0 +1,109 @@
+#PLOT INTERACTION COMMANDS
+#-------------------------------
+    def help_plot(self):
+        print '''
+PLOT
+Plots the current force curve
+-------
+Syntax: plot
+        '''
+    def do_plot(self,args):
+        if self.current.identify(self.drivers) == False:
+            return
+        self.plots=self.current.curve.default_plots()
+        try:
+            self.plots=self.current.curve.default_plots()
+        except Exception, e:
+            print 'Unexpected error occurred in do_plot().'
+            print e
+            return
+
+        #apply the plotmanip functions eventually present
+        nplots=len(self.plots)
+        c=0
+        while c<nplots:
+            for function in self.plotmanip: #FIXME: something strange happens about self.plotmanip[0]
+                self.plots[c]=function(self.plots[c], self.current)
+
+            self.plots[c].xaxes=self.config['xaxes'] #FIXME: in the future, xaxes and yaxes should be set per-plot
+            self.plots[c].yaxes=self.config['yaxes']
+
+            c+=1
+
+        self._send_plot(self.plots)
+
+    def _delta(self, set=1):
+        '''
+        calculates the difference between two clicked points
+        '''
+        print 'Click two points'
+        points=self._measure_N_points(N=2, whatset=set)
+        dx=abs(points[0].graph_coords[0]-points[1].graph_coords[0])
+        dy=abs(points[0].graph_coords[1]-points[1].graph_coords[1])
+        unitx=self.plots[points[0].dest].units[0]
+        unity=self.plots[points[0].dest].units[1]
+        return dx,unitx,dy,unity
+
+    def do_delta(self,args):
+        '''
+        DELTA
+
+        Measures the delta X and delta Y between two points.
+        ----
+        Syntax: delta
+        '''
+        dx,unitx,dy,unity=self._delta()
+        print str(dx)+' '+unitx
+        print str(dy)+' '+unity
+
+    def _point(self, set=1):
+        '''calculates the coordinates of a single clicked point'''
+
+        print 'Click one point'
+        point=self._measure_N_points(N=1, whatset=set)
+
+        x=point[0].graph_coords[0]
+        y=point[0].graph_coords[1]
+        unitx=self.plots[point[0].dest].units[0]
+        unity=self.plots[point[0].dest].units[1]
+        return x,unitx,y,unity
+
+    def do_point(self,args):
+        '''
+        POINT
+
+        Returns the coordinates of a point on the graph.
+        ----
+        Syntax: point
+        '''
+        x,unitx,y,unity=self._point()
+        print str(x)+' '+unitx
+        print str(y)+' '+unity
+        to_dump='point '+self.current.path+' '+str(x)+' '+unitx+', '+str(y)+' '+unity
+        self.outlet.push(to_dump)
+
+
+    def do_close(self,args=None):
+        '''
+        CLOSE
+        Closes one of the two plots. If no arguments are given, the bottom plot is closed.
+        ------
+        Syntax: close [top,bottom]
+        '''
+        if args=='top':
+            to_close=0
+        elif args=='bottom':
+            to_close=1
+        else:
+            to_close=1
+
+        close_plot=self.list_of_events['close_plot']
+        wx.PostEvent(self.frame, close_plot(to_close=to_close))
+
+    def do_show(self,args=None):
+        '''
+        SHOW
+        Shows both plots.
+        '''
+        show_plots=self.list_of_events['show_plots']
+        wx.PostEvent(self.frame, show_plots())