Changeset 75790dc in sasview


Ignore:
Timestamp:
Oct 3, 2011 3:31:20 PM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
18a6556
Parents:
140fad00
Message:

make sure residuals can be plotted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansguiframe/src/sans/guiframe/data_processor.py

    r63dc6e5 r75790dc  
    3333        self.col = -1 
    3434        self.row = -1 
    35         self.object = None 
     35        self.object = [] 
    3636         
    3737 
     
    110110        self.selected_cells = [] 
    111111        self.selected_cols = [] 
    112         self.selected_row = [] 
    113         self.plottable_list = [] 
     112        self.selected_rows = [] 
     113        self.plottable_cells = [] 
    114114        self.plottable_flag = False 
    115115        self.SetColMinimalAcceptableWidth(col_with) 
     
    156156                self.axis_value.append(self.GetCellValue(cell_row, cell_col)) 
    157157         
    158     def set_plottable_list(self, prev_row, next_row, prev_col, next_col): 
    159         """ 
    160         """ 
    161         if (prev_col == -1  and next_col != -1 and prev_row != -1 ) or \ 
    162             (prev_row == -1 and  next_row !=-1 and prev_col != -1): 
    163             self.plottable_flag = True 
    164         if self.plottable_flag: 
    165             print "special case" 
     158     
    166159                 
    167160    def on_left_click(self, event): 
     
    173166        col = event.GetCol() 
    174167        row = event.GetRow() 
    175         print "on left click", row, col, flag 
    176      
    177168        if not flag: 
    178169            self.selected_cols = [] 
     170            self.selected_rows = [] 
    179171            self.selected_cells = [] 
    180172            self.axis_label = "" 
    181173            self.plottable_list = [] 
     174            self.plottable_cells = [] 
    182175            self.plottable_flag = False 
    183         else: 
    184             self.set_plottable_list(prev_row=self.last_selected_row, 
    185                                      next_row=row,  
    186                                      prev_col=self.last_selected_col, 
    187                                       next_col=col) 
    188              
     176        
    189177        self.last_selected_col = col 
    190178        self.last_selected_row = row 
     179        if row != -1 and row not in self.selected_rows: 
     180             self.selected_rows.append(row) 
     181              
    191182        if col != -1: 
    192183            for row in range(1, self.GetNumberRows()+ 1): 
     
    200191                self.axis_value.append(self.GetCellValue(cell_row, cell_col)) 
    201192            self.axis_label = self.GetCellValue(0, col) 
     193         
     194             
     195             
     196             
     197             
    202198        
    203199 
     
    586582         
    587583        self.plotting_sizer = wx.FlexGridSizer(3, 7, 10, 5) 
     584        self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    588585        self.grid_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    589586        self.vbox.AddMany([(self.grid_sizer, 1, wx.EXPAND, 0), 
    590587                           (wx.StaticLine(self, -1), 0, wx.EXPAND, 0), 
    591                            (self.plotting_sizer)]) 
     588                           (self.plotting_sizer), 
     589                           (self.button_sizer)]) 
    592590        self.parent = parent 
    593591        self._data_inputs = data_inputs 
     
    601599        self.x_axis_unit = None 
    602600        self.y_axis_unit = None 
     601        self.view_button = None 
    603602        self.plot_button = None 
    604603        self.notebook = None 
     
    645644                                                                    str(col)) 
    646645                        wx.PostEvent(self.parent.parent,  
    647                              SatusEvent(status=msg, info="error"))  
     646                             StatusEvent(status=msg, info="error"))  
    648647            else: 
    649648                axis.append(None)  
     
    660659                                               details=self.details) 
    661660         
     661    def on_view(self, event): 
     662        """ 
     663        Get object represented buy the given cell and plot them. 
     664        """ 
     665        pos = self.notebook.GetSelection() 
     666        grid = self.notebook.GetPage(pos) 
     667        title = self.notebook.GetPageText(pos) 
     668         
     669         
     670        group_id = wx.NewId() 
     671        for cell in grid.selected_cells: 
     672            row, col = cell 
     673            label_row = 0 
     674            label = grid.GetCellValue(label_row, col) 
     675            if label in grid.data: 
     676                values = grid.data[label] 
     677                value = values[row -1] 
     678                if issubclass(value.__class__, BatchCell): 
     679                    for new_plot in value.object: 
     680                        if new_plot is None: 
     681                            msg = "Row %s , " % str(row) 
     682                            msg += "Column %s doesn't have a view" % str(label) 
     683                            #raise ValueError, msg 
     684                            wx.PostEvent(self.parent.parent,  
     685                                 StatusEvent(status=msg, info="error"))  
     686                            return 
     687                        if issubclass(new_plot.__class__, Data1D): 
     688                            new_plot.group_id = group_id 
     689                            new_plot.list_group_id .append(group_id) 
     690                        else: 
     691                            if label.lower() == "data": 
     692                                if len(grid.selected_cells) != 1: 
     693                                    msg = "Can only view one" 
     694                                    msg += " selected data at once" 
     695                                    wx.PostEvent(self.parent.parent,  
     696                                                 StatusEvent(status=msg, 
     697                                                              info="error"))  
     698                                    return 
     699                                 
     700                        wx.PostEvent(self.parent.parent,  
     701                                     NewPlotEvent(plot=new_plot,  
     702                                  group_id=str(new_plot.group_id), 
     703                                   title =title))   
     704                else: 
     705                    
     706                    msg = "Row %s , " % str(row) 
     707                    msg += "Column %s doesn't have a view" % str(label) 
     708                    #raise ValueError, msg 
     709                    wx.PostEvent(self.parent.parent,  
     710                         StatusEvent(status=msg, info="error"))  
     711                    return 
     712     
     713         
     714      
     715     
    662716    def on_plot(self, event): 
    663717        """ 
     
    713767        except: 
    714768             wx.PostEvent(self.parent.parent,  
    715                              SatusEvent(status=msg, info="error"))  
     769                             StatusEvent(status=msg, info="error"))  
    716770         
    717771    def layout_grid(self): 
     
    727781        Draw area containing options to plot 
    728782        """ 
     783        
    729784        self.x_axis_title = wx.TextCtrl(self, -1) 
    730785        self.y_axis_title = wx.TextCtrl(self, -1) 
     
    739794        self.x_axis_unit = wx.TextCtrl(self, -1) 
    740795        self.y_axis_unit = wx.TextCtrl(self, -1) 
     796        self.view_button = wx.Button(self, -1, "View") 
     797        wx.EVT_BUTTON(self, self.view_button.GetId(), self.on_view) 
    741798        self.plot_button = wx.Button(self, -1, "Plot") 
     799        self.button_sizer.AddMany( [ (500, 30), 
     800                                (self.view_button, 0, wx.RIGHT|wx.BOTTOM, 10), 
     801                                (self.plot_button, 0, wx.RIGHT|wx.BOTTOM, 10)]) 
     802         
    742803        wx.EVT_BUTTON(self, self.plot_button.GetId(), self.on_plot) 
    743804        self.plotting_sizer.AddMany([ 
     
    767828                      (-1, -1), 
    768829                      (-1, -1), 
    769                       (self.plot_button, 1, wx.LEFT|wx.BOTTOM, 10)]) 
     830                      (-1, 1)]) 
    770831    
    771832    def on_edit_axis(self, event): 
Note: See TracChangeset for help on using the changeset viewer.