Changeset 7ad194fa in sasview


Ignore:
Timestamp:
Sep 6, 2011 5:04:48 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:
55bb249c
Parents:
edcb00bd
Message:

working on data processor

File:
1 edited

Legend:

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

    r49ad00b r7ad194fa  
    55import numpy 
    66import sys 
     7import copy 
    78from wx.lib.scrolledpanel import ScrolledPanel 
    89import  wx.grid as  Grid 
     
    4445        self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.on_selected_cell) 
    4546         
    46         
    4747    def on_selected_cell(self, event): 
    4848        """ 
     
    9595        self.PopupMenu(slicerpop, pos) 
    9696         
    97          
    9897    def on_set_x_axis(self, event): 
    9998        """ 
     
    113112            data = {} 
    114113        if  len(data) > 0: 
    115             
    116114            self._cols = self.GetNumberCols() 
    117115            self._rows = self.GetNumberRows() 
     
    154152        """ 
    155153        nb.__init__(self, parent, -1, 
    156                     style= wx.aui.AUI_BUTTON_DOWN|wx.aui.AUI_NB_WINDOWLIST_BUTTON| 
     154                    style= wx.aui.AUI_BUTTON_DOWN| 
     155                    wx.aui.AUI_NB_WINDOWLIST_BUTTON| 
    157156                    wx.aui.AUI_NB_DEFAULT_STYLE| 
    158157                    wx.CLIP_CHILDREN) 
     
    163162        self.data = data 
    164163        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) 
    165          
    166          
     164     
    167165    def enable_close_button(self): 
    168166        """ 
     
    196194        if len(grid.selected_cols) == 1: 
    197195            col = grid.selected_cols[0] 
     196            if len(grid.selected_cells) > 0: 
     197                cell_row, cell_col = grid.selected_cells[0] 
     198                if cell_col  != col: 
     199                    msg = "Edit axis doesn't understand this selection.\n" 
     200                    msg += "Please select element of the same col" 
     201                    raise ValueError, msg 
    198202            for row in range(grid.GetNumberRows()): 
    199                 list_of_cells.append((row, col)) 
    200                  
    201         print "selected cell",  grid.selected_cells.sort(), grid.selected_cells 
    202    
    203          
     203                list_of_cells.append((row + 1 , col)) 
     204            for item in grid.selected_cells: 
     205                if item in list_of_cells: 
     206                    list_of_cells.remove(item) 
     207        elif len(grid.selected_cols) == 0: 
     208            list_of_cells = [(row + 1, col) for row, col in grid.selected_cells] 
     209        return list_of_cells 
     210     
     211    def create_axis_label(self, cell_list): 
     212        """ 
     213        Receive a list of cells and  create a string presenting the selected  
     214        cells.  
     215        :param cell_list: list of tuple 
     216         
     217        """ 
     218        pos = self.GetSelection() 
     219        grid = self.GetPage(pos) 
     220        label = "" 
     221        col_name = "" 
     222        if len(cell_list) > 0: 
     223            temp_list = copy.deepcopy(cell_list) 
     224            temp_list.sort() 
     225            temp = [] 
     226            for item in temp_list: 
     227                if item[0] <= 1: 
     228                    temp.append(item) 
     229            for element in temp: 
     230                temp_list.remove(element) 
     231            row_min, _  = temp_list[0]     
     232            row_max = row_min 
     233            label += str(col_name) + "[" + str(row_min) + ":" 
     234            print "temp_list", temp_list 
     235            for index in xrange(len(temp_list)): 
     236                prev = index - 1 
     237                row, _ = temp_list[index] 
     238                if row > row_max + 1 : 
     239                    if prev > 0: 
     240                        row_max, _ = temp_list[prev] 
     241                        label += str(row_max) + "]" + "," 
     242                        row_min = row 
     243                        label  += "[" + str(row_min) + ":" 
     244                row_max = row 
     245                
     246                if (index == len(temp_list)- 1): 
     247                    label +=  str(row_max) + "]" 
     248                    print "here" 
     249        print "label ", label              
     250        return label  
     251     
    204252    def on_close_page(self, event): 
    205253        """ 
     
    210258        self.enable_close_button() 
    211259         
    212   
    213              
    214260    def set_data(self, data): 
    215261        if data is None: 
     
    254300         
    255301        self.plotting_sizer = wx.FlexGridSizer(3, 7, 10, 5) 
    256         w, h = self.GetSize() 
    257         #self.panel_grid = SPanel(self, -1, size=(w, -1)) 
    258302        self.grid_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    259303        self.vbox.AddMany([(self.grid_sizer, 1, wx.EXPAND, 0), 
     
    264308        self.x = [] 
    265309        self.y  = [] 
    266          
    267310        self.x_axis_label = None 
    268311        self.y_axis_label = None 
     
    297340        self.y_axis_label.SetValue(str(label)) 
    298341         
    299    
    300              
    301342    def on_plot(self, event): 
    302343        """ 
     
    319360        self.grid.set_data(self._data) 
    320361        self.grid_sizer.Add(self.grid, 1, wx.EXPAND, 0) 
    321      
    322          
    323     def layout_grid1(self): 
    324         """ 
    325         Draw the area related to the grid 
    326         """ 
    327         self.grid = Table(parent=self.panel_grid, data=self._data) 
    328         vbox = wx.BoxSizer(wx.HORIZONTAL) 
    329         vbox.Add(self.grid, 1, wx.EXPAND, 0) 
    330         self.panel_grid.SetSizer(vbox) 
    331362        
    332363    def layout_plotting_area(self): 
     
    375406        Get the selected column on  the visible grid and set values for axis 
    376407        """ 
    377         self.grid.on_edit_axis() 
    378          
     408        cell_list = self.grid.on_edit_axis() 
     409        self.create_axis_label(cell_list) 
     410         
     411    def create_axis_label(self, cell_list): 
     412        """ 
     413        Receive a list of cells and  create a string presenting the selected  
     414        cells.  
     415        :param cell_list: list of tuple 
     416         
     417        """ 
     418        if self.grid is not None: 
     419            return self.grid.create_axis_label(cell_list) 
     420     
    379421    def edit_axis_helper(self, tcrtl_label, tcrtl_value): 
    380422        """ 
     
    394436         
    395437class GridFrame(wx.Frame): 
    396     def __init__(self, parent=None, data=None, id=-1, title="Batch Results", size=(700, 400)): 
     438    def __init__(self, parent=None, data=None, id=-1,  
     439                 title="Batch Results", size=(700, 400)): 
    397440        wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 
    398441        self.parent = parent 
Note: See TracChangeset for help on using the changeset viewer.