pCluster ver.1 ... working! oneClick style. Updated with automatic filter calculation.
[hooke.git] / hooke.py
index 5c7dc06186ce06e095850909ba5099070b9f1c32..3a90baa85b853aa648345e0ec1dcea24e97014e2 100755 (executable)
--- a/hooke.py
+++ b/hooke.py
@@ -275,8 +275,8 @@ class MainWindow(wx.Frame):
             self.click_plot=0
                         
             #FIXME: These could become a single flag with different (string?) values
-            self.on_measure_distance=False
-            self.on_measure_force=False
+            #self.on_measure_distance=False
+            #self.on_measure_force=False
             
             self.plot_fit=False
             
@@ -284,13 +284,16 @@ class MainWindow(wx.Frame):
             self.num_of_points = 2
             
             #Data.
+            '''
             self.current_x_ext=[[],[]]
             self.current_y_ext=[[],[]]
             self.current_x_ret=[[],[]]
             self.current_y_ret=[[],[]]
             
+            
             self.current_x_unit=[None,None]
             self.current_y_unit=[None,None]
+            '''
                         
             #Initialize xaxes, yaxes
             #FIXME: should come from config
@@ -322,7 +325,7 @@ class MainWindow(wx.Frame):
             
             self.click_flags_functions={'measure_points':[False, 'MeasurePoints']}
             
-            #Custom events from CLI --> GUI functions!                       
+            #Binding of custom events from CLI --> GUI functions!                       
             #FIXME: Should use the self.Bind() syntax
             EVT_PLOT(self, self.PlotCurve)
             EVT_PLOT_CONTACT(self, self.PlotContact)
@@ -456,6 +459,8 @@ class MainWindow(wx.Frame):
             for plot in self.plots:
                 if self.plots[c].styles==[]:
                     self.plots[c].styles=[None for item in plot.vectors] 
+                if self.plots[c].colors==[]:
+                    self.plots[c].colors=[None for item in plot.vectors] 
             
             for plot in self.plots:
                 '''
@@ -474,10 +479,33 @@ class MainWindow(wx.Frame):
                 self.current_plot_dest=dest #let's try this way to take into account the destination plot...
                 
                 c=0
+                            
+                if len(plot.colors)==0:
+                    plot.colors=[None] * len(plot.vectors)
+                if len(plot.styles)==0:
+                    plot.styles=[None] * len(plot.vectors)     
+                
+                for vectors_to_plot in self.current_vectors: 
+                    if plot.styles[c]=='scatter':
+                        if plot.colors[c]==None:
+                            self.axes[dest].scatter(vectors_to_plot[0], vectors_to_plot[1])
+                        else:
+                            self.axes[dest].scatter(vectors_to_plot[0], vectors_to_plot[1],color=plot.colors[c])
+                    else:
+                        if plot.colors[c]==None:
+                            self.axes[dest].plot(vectors_to_plot[0], vectors_to_plot[1])
+                        else:
+                            self.axes[dest].plot(vectors_to_plot[0], vectors_to_plot[1], color=plot.colors[c])
+                    self.axes[dest].hold(True)
+                    c+=1
+                    
+                '''
                 for vectors_to_plot in self.current_vectors:
                     if len(vectors_to_plot)==2: #3d plots are to come...
                         if len(plot.styles) > 0 and plot.styles[c] == 'scatter':
                             self.axes[dest].scatter(vectors_to_plot[0],vectors_to_plot[1])
+                        elif len(plot.styles) > 0 and plot.styles[c] == 'scatter_red':
+                            self.axes[dest].scatter(vectors_to_plot[0],vectors_to_plot[1],color='red')
                         else:
                             self.axes[dest].plot(vectors_to_plot[0],vectors_to_plot[1])
                             
@@ -485,7 +513,7 @@ class MainWindow(wx.Frame):
                         c+=1
                     else:
                         pass
-               
+                '''               
                 #FIXME: tackles only 2d plots
                 self.axes[dest].set_xlabel(plot.units[0])
                 self.axes[dest].set_ylabel(plot.units[1])
@@ -508,6 +536,7 @@ class MainWindow(wx.Frame):
         def PlotContact(self,event):
             '''
             plots the contact point
+            DEPRECATED!
             '''
             self.axes[0].hold(True)
             self.current_contact_index=event.contact_index
@@ -520,6 +549,15 @@ class MainWindow(wx.Frame):
             self._replot()
             self.clicked_points=[]
             
+        def OnMeasurePoints(self,event):
+            '''
+            trigger flags to measure N points
+            '''
+            self.click_flags_functions['measure_points'][0]=True
+            if 'num_of_points' in dir(event):
+                self.num_of_points=event.num_of_points
+            if 'set' in dir(event):    
+                self.measure_set=event.set            
         
         def ClickPoint0(self,event):
             self.current_plot_dest=0
@@ -540,15 +578,7 @@ class MainWindow(wx.Frame):
                 if value[0]:
                     eval('self.'+value[1]+'(event)')
                                       
-        def OnMeasurePoints(self,event):
-            '''
-            trigger flags to measure N points
-            '''
-            self.click_flags_functions['measure_points'][0]=True
-            if 'num_of_points' in dir(event):
-                self.num_of_points=event.num_of_points
-            if 'set' in dir(event):    
-                self.measure_set=event.set
+
      
         def MeasurePoints(self,event,current_set=1):
             dest=self.current_plot_dest
@@ -604,12 +634,13 @@ class MainWindow(wx.Frame):
             dest=event.dest
             filename=event.name
             self.figures[dest].savefig(filename)
-                
+               
+        '''
         def _find_nearest_point(self, mypoint, dataset=1):
-            '''
-            Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
-            corresponds to the clicked point.
-            '''
+            
+            #Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
+            #corresponds to the clicked point.
+            
             dest=self.current_plot_dest
             
             xvector=plot.vectors[dataset][0]
@@ -628,7 +659,7 @@ class MainWindow(wx.Frame):
                 index+=1
             
             return best_index,xvector[best_index],yvector[best_index]
-              
+         '''   
         
         def _plot_of_dest(self,dest=None):
             '''
@@ -661,12 +692,30 @@ class MainWindow(wx.Frame):
             #find the current plot matching the clicked destination
             plot=self._plot_of_dest()
             #plot all superimposed plots 
-            c=0      
+            c=0 
+            if len(plot.colors)==0:
+                    plot.colors=[None] * len(plot.vectors)
+            if len(plot.styles)==0:
+                    plot.styles=[None] * len(plot.vectors)     
             for plotset in plot.vectors: 
+                if plot.styles[c]=='scatter':
+                    if plot.colors[c]==None:
+                        self.axes[dest].scatter(plotset[0], plotset[1])
+                    else:
+                        self.axes[dest].scatter(plotset[0], plotset[1],color=plot.colors[c])
+                else:
+                    if plot.colors[c]==None:
+                        self.axes[dest].plot(plotset[0], plotset[1])
+                    else:
+                        self.axes[dest].plot(plotset[0], plotset[1], color=plot.colors[c])
+                '''    
                 if len(plot.styles) > 0 and plot.styles[c]=='scatter':
-                    self.axes[dest].scatter(plotset[0], plotset[1])
+                    self.axes[dest].scatter(plotset[0], plotset[1],color=plot.colors[c])
+                elif len(plot.styles) > 0 and plot.styles[c] == 'scatter_red':
+                    self.axes[dest].scatter(plotset[0],plotset[1],color='red')
                 else:
                     self.axes[dest].plot(plotset[0], plotset[1])
+                '''
                 c+=1
             #plot points we have clicked
             for item in self.clicked_points: