Changeset 3feed3e in sasview


Ignore:
Timestamp:
Jan 28, 2011 1:50:04 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:
c5e84fb
Parents:
7a67e075
Message:

working on guiframe data loader

Location:
guiframe
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_panel.py

    r52b8b74 r3feed3e  
    1313import wx 
    1414import sys 
    15 #import warnings 
     15import warnings 
    1616from wx.lib.scrolledpanel import ScrolledPanel 
    17 import  wx.lib.mixins.listctrl  as  listmix 
    18 #from sans.guicomm.events import NewPlotEvent 
     17import  wx.lib.agw.customtreectrl as CT 
     18from sans.guiframe.dataFitting import Data1D 
     19from sans.guiframe.dataFitting import Data2D 
    1920 
    20 class CheckListCtrl(wx.ListCtrl, listmix.CheckListCtrlMixin,  
    21                     listmix.ListCtrlAutoWidthMixin): 
     21PANEL_WIDTH = 200 
     22 
     23class DataTreeCtrl(CT.CustomTreeCtrl): 
    2224    """ 
    2325    Check list control to be used for Data Panel 
    2426    """ 
    25     def __init__(self, parent, *args, **kwds): 
    26         kwds['style'] = wx.LC_REPORT|wx.SUNKEN_BORDER 
    27         wx.ListCtrl.__init__(self, parent, -1, *args, **kwds) 
    28         listmix.CheckListCtrlMixin.__init__(self) 
    29         listmix.ListCtrlAutoWidthMixin.__init__(self) 
     27    def __init__(self, parent, size=(PANEL_WIDTH, 200), *args, **kwds): 
     28        kwds['style']= wx.SUNKEN_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|   \ 
     29                    CT.TR_HAS_VARIABLE_ROW_HEIGHT|wx.WANTS_CHARS 
     30        kwds['size'] = size 
     31        CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) 
     32        self.root = self.AddRoot("Available Data") 
    3033         
    3134class DataPanel(ScrolledPanel): 
     
    3437    interact with data. 
    3538    """ 
    36     def __init__(self, parent, list=None, list_of_perspective=[], 
    37                     *args, **kwds): 
     39    ## Internal name for the AUI manager 
     40    window_name = "Data Panel" 
     41    ## Title to appear on top of the window 
     42    window_caption = "Data Panel" 
     43    #type of window  
     44    window_type = "Data Panel" 
     45    ## Flag to tell the GUI manager that this panel is not 
     46    #  tied to any perspective 
     47    #ALWAYS_ON = True 
     48    def __init__(self, parent, list=[],list_of_perspective=[], 
     49                 size=(PANEL_WIDTH,560), manager=None, *args, **kwds): 
     50        kwds['size']= size 
    3851        ScrolledPanel.__init__(self, parent=parent, *args, **kwds) 
    3952        self.SetupScrolling() 
     53       
    4054        self.parent = parent 
    41         self.manager = None 
     55        self.manager = manager 
     56        self.list_of_data = list 
     57        self.list_of_perspective = list_of_perspective 
     58        self.list_rb_perspectives= [] 
     59        self.list_cb_data =[] 
     60        self.list_cb_theory =[] 
    4261        self.owner = None 
    43         if list is None: 
    44             list = [] 
    45         self.list_of_data = list 
    46         self.perspectives = [] 
    47         #layout widgets 
    48         self.sizer4 = None 
    49         self.sizer5 = None 
    50         self.sizer1 = None 
    51         self.sizer2 = None 
    52         self.sizer3 = None 
    53         self.sizer4 = None 
    54         self.sizer5 = None 
    55         self.vbox = None 
    56         self.list_ctrl = None 
    57         self.boxsizer_2_2 = None 
    58         self.cb_select_data1d = None 
    59         self.cb_select_data2d = None 
    60         self.cb_select_all = None 
    61         self.cb_theory = None 
    62         self.bt_import = None 
    63         self.bt_plot = None 
    64         self.bt_close = None 
    65          
     62        self.do_layout() 
     63        #self._default_data1d = Data1D() 
     64        #self._default_data1d.set_default_data() 
     65        #self._default_data2d = Data2D() 
     66        #self._default_data2d.set_default_data() 
     67        #data_list =[] 
     68        #data_list.append((self._default_data1d, None,None, None)) 
     69        #data_list.append((self._default_data2d, None,None, None)) 
     70        #if self.manager is not None: 
     71        #    self.manager.set_loaded_data(data_list) 
     72        #    list = self.manager.get_selected_data() 
     73        #    self.load_data_list(list) 
     74    def do_layout(self): 
    6675        self.define_panel_structure() 
     76        self.layout_selection() 
    6777        self.layout_list() 
    68         self.layout_selection() 
    69         self.layout_perspective(list_of_perspective=list_of_perspective) 
    70         self.load_list() 
    71         self.layout_theory() 
    7278        self.layout_button() 
    73          
     79        self.layout_batch() 
     80    
    7481    def define_panel_structure(self): 
    7582        """ 
    7683        Define the skeleton of the panel 
    7784        """ 
     85        print self.parent.GetSize(), self.GetSize() 
     86        w, h = self.parent.GetSize() 
    7887        self.vbox  = wx.BoxSizer(wx.VERTICAL) 
    7988        self.sizer1 = wx.BoxSizer(wx.VERTICAL) 
    80          
    81         box_description_2 = wx.StaticBox(self, -1, "Selection Patterns") 
    82         self.boxsizer_2 = wx.StaticBoxSizer(box_description_2, wx.HORIZONTAL) 
    83         box_description_2_2 = wx.StaticBox(self, -1, "Set Active Perspective") 
    84         self.boxsizer_2_2 = wx.StaticBoxSizer(box_description_2_2, 
    85                                               wx.HORIZONTAL) 
    86         
    87         w, h = self.parent.GetSize() 
    88         self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) 
    89         self.sizer2.Add(self.boxsizer_2, 1, wx.ALL, 10) 
    90         self.sizer2.Add(self.boxsizer_2_2, 1, wx.ALL, 10) 
    91          
    92         box_description_3 = wx.StaticBox(self, -1, 
    93                                          "Import to Active perspective") 
    94         self.boxsizer_3 = wx.StaticBoxSizer(box_description_3, wx.HORIZONTAL) 
    95         self.sizer3 = wx.BoxSizer(wx.HORIZONTAL) 
    96         self.sizer3.Add(self.boxsizer_3, 1, wx.ALL, 10) 
    97          
     89        self.sizer2 = wx.BoxSizer(wx.VERTICAL) 
     90        self.sizer3 = wx.GridBagSizer(5,5) 
    9891        self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) 
    9992        self.sizer5 = wx.BoxSizer(wx.HORIZONTAL) 
    100         self.sizer1.SetMinSize((w-10, h/3)) 
    101         self.sizer2.SetMinSize((w-10, -1)) 
    102         self.sizer3.SetMinSize((w-10, -1)) 
    103         self.sizer4.SetMinSize((w-10, -1)) 
    104         self.sizer5.SetMinSize((w-10, -1)) 
    105         self.vbox.Add(self.sizer1) 
    106         self.vbox.Add(self.sizer2) 
    107         self.vbox.Add(self.sizer3) 
    108         self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
    109         self.vbox.Add(self.sizer4) 
    110         self.vbox.Add(self.sizer5) 
     93        self.sizer3.SetMinSize((w-60, -1)) 
     94         
     95        self.vbox.Add(self.sizer5, 0,wx.EXPAND|wx.ALL,10) 
     96        self.vbox.Add(self.sizer1, 0,wx.EXPAND|wx.ALL,0) 
     97        self.vbox.Add(self.sizer2, 0,wx.EXPAND|wx.ALL,10) 
     98        self.vbox.Add(self.sizer3, 0,wx.EXPAND|wx.ALL,10) 
     99        self.vbox.Add(self.sizer4, 0,wx.EXPAND|wx.ALL,10) 
     100         
    111101        self.SetSizer(self.vbox) 
    112102         
    113     def GetListCtrl(self): 
    114         """ 
    115         """ 
    116         return self.list_ctrl 
    117      
    118     def layout_list(self): 
    119         """ 
    120         Add a listcrtl in the panel 
    121         """ 
    122         self.list_ctrl = CheckListCtrl(parent=self) 
    123          
    124         self.list_ctrl.InsertColumn(0, 'Name') 
    125         self.list_ctrl.InsertColumn(1, 'Type') 
    126         self.list_ctrl.InsertColumn(2, 'Date Modified') 
    127         self.sizer1.Add(self.list_ctrl, 1, wx.EXPAND|wx.ALL, 10) 
    128          
    129     def layout_perspective(self, list_of_perspective=None): 
     103    def layout_selection(self): 
     104        """ 
     105        """ 
     106        select_txt = wx.StaticText(self, -1, 'Selection Options') 
     107        self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     108        list_of_options = ['Select all Data', 
     109                            'Unselect all Data', 
     110                           'Select all Data 1D', 
     111                           'Unselect all Data 1D', 
     112                           'Select all Data 2D', 
     113                           'Unselect all Data 2D' ] 
     114        for option in list_of_options: 
     115            self.selection_cbox.Append(str(option)) 
     116        self.selection_cbox.SetValue('None') 
     117        wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type) 
     118        self.sizer5.AddMany([(select_txt,0, wx.ALL,5), 
     119                            (self.selection_cbox,0, wx.ALL,5)]) 
     120    def layout_perspective(self, list_of_perspective=[]): 
    130121        """ 
    131122        Layout widgets related to the list of plug-ins of the gui_manager  
    132123        """ 
    133         if list_of_perspective is None: 
    134             list_of_perspective = [] 
    135         self.boxsizer_2_2.Clear(True) 
    136         self.perspectives = [] 
    137         sizer = wx.GridBagSizer(5, 5) 
    138          
     124        if len(list_of_perspective)==0: 
     125            return 
     126        w, h = self.parent.GetSize() 
     127        box_description_2= wx.StaticBox(self, -1, "Set Active Perspective") 
     128        self.boxsizer_2 = wx.StaticBoxSizer(box_description_2, wx.HORIZONTAL) 
     129        self.boxsizer_2.SetMinSize((w-60, -1)) 
     130        self.sizer_perspective = wx.GridBagSizer(5,5) 
     131        self.boxsizer_2.Add(self.sizer_perspective) 
     132        self.sizer2.Add(self.boxsizer_2,1, wx.ALL, 10) 
     133        self.list_of_perspective = list_of_perspective 
     134        self.sizer_perspective.Clear(True) 
     135        self.list_rb_perspectives = [] 
     136        
     137        nb_active_perspective = 0 
    139138        if list_of_perspective: 
    140             item = list_of_perspective[0].sub_menu 
    141             rb = wx.RadioButton(self, -1, item, style=wx.RB_GROUP) 
    142             rb.SetToolTipString("Data will be applied to this perspective") 
    143             if hasattr(item, "set_default_perspective"): 
    144                 if item.set_default_perspective(): 
    145                     rb.SetValue(item.set_default_perspective()) 
    146             self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective, 
    147                                                  id=rb.GetId()) 
    148             self.perspectives.append(rb) 
    149139            ix = 0  
    150140            iy = 0 
    151             sizer.Add(rb, (iy, ix), (1, 1), 
    152                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    153             for index in range(1, len(list_of_perspective)): 
    154                 item = list_of_perspective[index].sub_menu 
    155                 rb = wx.RadioButton(self, -1, item) 
    156                 rb.SetToolTipString("Data will be applied to this perspective") 
    157                 self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective,  
    158                                         id=rb.GetId()) 
    159                 self.perspectives.append(rb) 
     141            for perspective_name, is_active in list_of_perspective: 
     142                 
     143                if is_active: 
     144                    nb_active_perspective += 1 
     145                if nb_active_perspective == 1: 
     146                    rb = wx.RadioButton(self, -1, perspective_name, style=wx.RB_GROUP) 
     147                    rb.SetToolTipString("Data will be applied to this perspective") 
     148                    rb.SetValue(is_active) 
     149                else: 
     150                    rb = wx.RadioButton(self, -1, perspective_name) 
     151                    rb.SetToolTipString("Data will be applied to this perspective") 
     152                    #only one perpesctive can be active 
     153                    rb.SetValue(False) 
     154                 
     155                self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective, 
     156                                                     id=rb.GetId()) 
     157                self.list_rb_perspectives.append(rb) 
     158                self.sizer_perspective.Add(rb,(iy, ix),(1,1), 
     159                               wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    160160                iy += 1 
    161                 sizer.Add(rb, (iy, ix), (1, 1), 
    162                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    163                 if hasattr(item,"set_default_perspective"): 
    164                     if item.set_default_perspective(): 
    165                         rb.SetValue(item.set_default_perspective()) 
    166161        else: 
    167162            rb = wx.RadioButton(self, -1, 'No Perspective', 
     
    171166            ix = 0  
    172167            iy = 0 
    173             sizer.Add(rb, (iy, ix), (1, 1), 
     168            self.sizer_perspective.Add(rb,(iy, ix),(1,1), 
    174169                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    175         self.boxsizer_2_2.Add(sizer) 
    176        
    177     def layout_selection(self): 
    178         """ 
    179         Layout widgets related to selection patterns 
    180         """ 
    181         sizer = wx.GridBagSizer(5, 5) 
    182         self.cb_select_data1d = wx.CheckBox(self, -1,  
    183                                 "Select/Unselect Data 1D", (10, 10)) 
    184         msg_data1d = "To check/uncheck to select/unselect all Data 1D" 
    185         self.cb_select_data1d.SetToolTipString(msg_data1d) 
    186         wx.EVT_CHECKBOX(self, self.cb_select_data1d.GetId(), 
    187                                         self.on_select_all_data1d) 
    188         self.cb_select_data2d = wx.CheckBox(self, -1,  
    189                                "Select/Unselect all Data 2D", (10, 10)) 
    190         msg_data2d = "To check/uncheck to select/unselect all Data 2D" 
    191         self.cb_select_data2d.SetToolTipString(msg_data2d) 
    192         wx.EVT_CHECKBOX(self, self.cb_select_data2d.GetId(), 
    193                          self.on_select_all_data2d) 
    194         self.cb_select_theory1d = wx.CheckBox(self, -1,  
    195                                     "Select/Unselect all Theory 1D", (10, 10)) 
    196         msg_theory1d = "To check/uncheck to select/unselect all Theory 1D" 
    197         self.cb_select_theory1d.SetToolTipString(msg_theory1d) 
    198         wx.EVT_CHECKBOX(self, self.cb_select_theory1d.GetId(), 
    199                          self.on_select_all_theory1d) 
    200         self.cb_select_theory2d = wx.CheckBox(self, -1,  
    201                                     "Select/Unselect all Theory 2D", (10, 10)) 
    202         msg_theory2d = "To check/uncheck to select/unselect all Theory 2D" 
    203         self.cb_select_theory2d.SetToolTipString(msg_theory2d) 
    204         wx.EVT_CHECKBOX(self, self.cb_select_theory2d.GetId(), 
    205                                 self.on_select_all_theory2d) 
    206         self.cb_select_all = wx.CheckBox(self, -1, "Select/Unselect all", 
    207                                          (10, 10)) 
    208         msg_select_all = "To check/uncheck to  select/unselect all" 
    209         self.cb_select_all.SetToolTipString(msg_select_all) 
    210         wx.EVT_CHECKBOX(self, self.cb_select_all.GetId(), self.on_select_all) 
    211         iy = 0 
    212         ix = 0 
    213         sizer.Add(self.cb_select_data1d, (iy, ix), (1, 1), 
    214                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    215         iy += 1 
    216         sizer.Add(self.cb_select_data2d, (iy, ix), (1, 1), 
    217                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    218         iy += 1 
    219         sizer.Add(self.cb_select_theory1d, (iy, ix), (1, 1), 
    220                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    221         iy += 1 
    222         sizer.Add( self.cb_select_theory2d, (iy, ix), (1, 1), 
    223                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    224         iy += 1 
    225         sizer.Add(self.cb_select_all,(iy, ix), (1, 1), 
    226                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    227         self.boxsizer_2.Add(sizer) 
    228         
    229     def layout_theory(self): 
    230         """ 
    231         Layout widget related to theory to import 
    232         """ 
    233         msg = "Import the Selected Theory\n" 
    234         msg += "to active perspective." 
    235         st_description = wx.StaticText(self, -1, msg) 
    236         self.cb_theory = wx.ComboBox(self, -1) 
    237         wx.EVT_COMBOBOX(self.cb_theory,-1, self.on_select_theory)  
    238          
    239         self.boxsizer_3.AddMany([(st_description, 0, wx.ALL, 10), 
    240                              (self.cb_theory, 0, wx.ALL, 10)]) 
    241         self.load_theory(list=[]) 
     170             
     171    def _on_selection_type(self, event): 
     172        """ 
     173        Select data according to patterns 
     174        """ 
     175        option = self.selection_cbox.GetValue() 
     176        if option == 'Select all Data': 
     177            #for item in self.tree_ctrl. 
     178            print "_on_selection_type" 
     179    def on_set_active_perspective(self, event): 
     180        """ 
     181        Select the active perspective 
     182        """ 
     183        ctrl = event.GetEventObject() 
    242184         
    243185    def layout_button(self): 
     
    245187        Layout widgets related to buttons 
    246188        """ 
    247         self.bt_import = wx.Button(self, wx.NewId(), "Import", (30, 10)) 
    248         hint_msg = "Import set of Data to active perspective" 
    249         self.bt_import.SetToolTipString(hint_msg) 
     189        self.bt_import = wx.Button(self, wx.NewId(), "Send To") 
     190        self.bt_import.SetToolTipString("Send set of Data to active perspective") 
    250191        wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 
    251192         
    252         self.bt_plot = wx.Button(self, wx.NewId(), "Plot", (30, 10)) 
     193        self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To") 
     194        self.bt_import.SetToolTipString("Plot the selected data in the active panel") 
     195        #wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_append_plot) 
     196         
     197        self.bt_plot = wx.Button(self, wx.NewId(), "New Plot") 
    253198        self.bt_plot.SetToolTipString("To trigger plotting") 
    254199        wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) 
    255200         
    256         self.bt_close = wx.Button(self, wx.NewId(), "Close", (30, 10)) 
    257         self.bt_close.SetToolTipString("close the current window") 
    258         wx.EVT_BUTTON(self, self.bt_close.GetId(), self.on_close) 
    259          
    260         self.sizer5.AddMany([((40, 40), 0, wx.LEFT|wx.ADJUST_MINSIZE, 180), 
    261                              (self.bt_import, 0, wx.ALL,5), 
    262                              (self.bt_plot, 0, wx.ALL,5), 
    263                              (self.bt_close, 0, wx.ALL, 5 )]) 
    264          
    265     def set_manager(self, manager): 
    266         """ 
    267         :param manager: object responsible of filling on empty the listcrtl of  
    268         this panel. for sansview manager is data_manager 
    269         """ 
    270         self.manager = manager 
    271          
    272     def set_owner(self, owner): 
    273         """ 
    274          :param owner: is the main widget creating this frame 
    275          for sansview owner is gui_manager 
    276         """ 
    277         self.owner = owner 
    278          
    279     def load_theory(self, list=None): 
    280         """ 
    281         Recieve a list of theory name and fill the combobox with that list 
    282         """ 
    283         if list is None: 
    284             list = [] 
    285         for theory in list: 
    286             self.cb_theory.Append(theory) 
    287         if list: 
    288             self.cb_theory.Enable() 
    289         else: 
    290             self.cb_theory.Disable() 
    291              
    292     def load_list(self, list=None): 
    293         """ 
    294         Get a list of turple and store each string in these turples in  
    295         the column of the listctrl. 
    296          
    297         :param list: list of turples containing string only.  
    298         """ 
    299         if list is None: 
     201        self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data") 
     202        self.bt_remove.SetToolTipString("Delete data from the application") 
     203        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 
     204         
     205        self.tctrl_perspective = wx.StaticText(self, -1, 'Active Application') 
     206        self.tctrl_perspective.SetToolTipString("Active Application") 
     207        self.tctrl_plotpanel = wx.StaticText(self, -1, 'Plot panel on focus') 
     208        self.tctrl_plotpanel.SetToolTipString("Active Plotting Panel") 
     209        #self.sizer3.AddMany([(self.bt_import,0, wx.ALL,5), 
     210        #                     (self.bt_append_plot,0, wx.ALL,5), 
     211        #                     (self.bt_plot, 0, wx.ALL,5), 
     212        # (self.bt_remove,0, wx.ALL,5)]) 
     213        ix = 0 
     214        iy = 0 
     215        self.sizer3.Add(self.bt_import,( iy, ix),(1,1),   
     216                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     217        ix += 1 
     218        self.sizer3.Add(self.tctrl_perspective,(iy, ix),(1,1), 
     219                          wx.EXPAND|wx.ADJUST_MINSIZE, 0)       
     220        ix = 0           
     221        iy += 1  
     222        self.sizer3.Add(self.bt_append_plot,( iy, ix),(1,1),   
     223                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     224        ix += 1 
     225        self.sizer3.Add(self.tctrl_plotpanel,(iy, ix),(1,1), 
     226                          wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
     227        ix = 0           
     228        iy += 1  
     229        self.sizer3.Add(self.bt_plot,( iy, ix),(1,1),   
     230                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     231        ix = 0           
     232        iy += 1  
     233        self.sizer3.Add(self.bt_remove,( iy, ix),(1,1),   
     234                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     235         
     236      
     237    def layout_batch(self): 
     238        """ 
     239        """ 
     240        
     241        self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', 
     242                                             style=wx.RB_GROUP) 
     243        self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') 
     244         
     245        self.rb_single_mode.SetValue(True) 
     246        self.rb_batch_mode.SetValue(False) 
     247        self.sizer4.AddMany([(self.rb_single_mode,0, wx.ALL,5), 
     248                            (self.rb_batch_mode,0, wx.ALL,5)]) 
     249       
     250    def layout_list(self): 
     251        """ 
     252        Add a listcrtl in the panel 
     253        """ 
     254        w, h = self.GetSize() 
     255        self.tree_ctrl = DataTreeCtrl(parent=self, size=(w-10, -1)) 
     256        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKED, self.on_check_item) 
     257        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click) 
     258        self.sizer1.Add(self.tree_ctrl,0, wx.EXPAND|wx.ALL, 20) 
     259 
     260    def on_right_click(self, event): 
     261        """ 
     262        """ 
     263        ## Create context menu for data  
     264        self.popUpMenu = wx.Menu() 
     265        msg = "Edit %s"%str(self.tree_ctrl.GetItemText(event.GetItem())) 
     266        id = wx.NewId() 
     267        self.edit_data_mitem = wx.MenuItem(self.popUpMenu,id,msg, 
     268                                 "Edit meta data") 
     269        wx.EVT_MENU(self, id, self.on_edit_data) 
     270        self.popUpMenu.AppendItem(self.edit_data_mitem) 
     271        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
     272         
     273    def on_edit_data(self, event): 
     274        """ 
     275        """ 
     276        print "editing data" 
     277    def onContextMenu(self, event):  
     278        """ 
     279        Retrieve the state selected state 
     280        """ 
     281        # Skipping the save state functionality for release 0.9.0 
     282        #return 
     283     
     284        pos = event.GetPosition() 
     285        pos = self.ScreenToClient(pos) 
     286        self.PopupMenu(self.popUpMenu, pos)  
     287       
     288    def on_check_item(self, event): 
     289        """ 
     290        """ 
     291        item = event.GetItem() 
     292        name =self.tree_ctrl.GetItemText(item) 
     293   
     294    def load_data_list(self, list): 
     295        """ 
     296         
     297        """ 
     298        if not list: 
    300299            return 
    301         for i in list: 
    302             index = self.list_ctrl.InsertStringItem(sys.maxint, i[0]) 
    303             self.list_ctrl.SetStringItem(index, 1, i[1]) 
    304             self.list_ctrl.SetStringItem(index, 2, i[2]) 
     300         
     301        for dstate in list.values(): 
     302            data = dstate.get_data() 
     303            if data is None: 
     304                data_name = str(data) 
     305                data_class = "unkonwn" 
     306            else: 
     307                data_name = data.name 
     308         
     309            data_class = data.__class__.__name__ 
     310            path = dstate.get_path()  
     311            theory_list = dstate.get_theory() 
     312            theory = None 
     313            if  theory_list: 
     314                theory = theory_list[len(theory_list)-1] 
     315            data_child = None 
     316            for item in self.list_cb_data: 
     317                if self.tree_ctrl.GetItemText(item) == data_name: 
     318                    data_child = item 
     319                    for process in data.process: 
     320                        theory_child = self.tree_ctrl.FindItem(data_child, 
     321                                                        "Available Theories")#, 
     322                        if theory is not None: 
     323                            av_theory_child =self.tree_ctrl.AppendItem(theory_child, 
     324                                                theory.name,ct_type=1) 
     325                            self.list_cb_theory.append(av_theory_child) 
     326                            av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 
     327                                                     'info') 
     328                            for process in theory.process: 
     329                                info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, 
     330                                         process.__str__()) 
     331                    
     332                    break 
     333            if data_child is None: 
     334                data_child =self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
     335                                                   data_name,ct_type=1) 
     336                cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root)  
     337                item, id = cb_data 
     338                item.Check(True) 
     339                self.list_cb_data.append(item)                          
     340                data_info_child =self.tree_ctrl.AppendItem(data_child, 'info')#, 
     341                                                            #wnd=data_info_txt) 
     342                info_class_child =self.tree_ctrl.AppendItem(data_info_child,  
     343                                                            'Type: %s'%data_class) 
     344                path_class_child =self.tree_ctrl.AppendItem(data_info_child, 
     345                                                             'Path: %s'%str(path)) 
     346                for process in data.process: 
     347                    info_time_child =self.tree_ctrl.AppendItem(data_info_child,process.__str__()) 
     348                theory_child =self.tree_ctrl.AppendItem(data_child, "Available Theories") 
     349                 
     350                if  theory_list: 
     351                    theory = theory_list[len(theory_list)-1] 
     352                    if theory is not None: 
     353                        av_theory_child =self.tree_ctrl.AppendItem(theory_child, 
     354                                                    theory.name,ct_type=1) 
     355                        self.list_cb_theory.append(av_theory_child) 
     356                        av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 
     357                                                         'info') 
     358                        for process in theory.process: 
     359                            info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, 
     360                                             process.__str__()) 
     361                    
     362    def set_data_helper(self): 
     363        """ 
     364        """ 
     365        data_to_plot = [] 
     366        #num = self.tree_ctrl.GetCount() 
     367        #print num, self.tree_ctrl 
     368        for item in self.list_cb_data: 
     369            print "set_data_helper",self.tree_ctrl.GetItemText(item), item.IsChecked() 
     370            if item.IsChecked(): 
     371               data_to_plot.append(self.tree_ctrl.GetItemText(item)) 
     372         
     373        theory_to_plot =[] 
     374        for item in self.list_cb_theory: 
     375            if item.IsChecked(): 
     376               theory_to_plot.append(self.tree_ctrl.GetItemText(item)) 
     377         
     378        return data_to_plot, theory_to_plot 
     379     
     380    def on_remove(self, event): 
     381        data_to_remove, theory_to_remove = self.set_data_helper() 
     382        for item in self.list_cb_data: 
     383            if item.IsChecked()and \ 
     384                self.tree_ctrl.GetItemText(item) in data_to_remove: 
     385                self.tree_ctrl.Delete(item) 
     386        for i in self.list_cb_theory: 
     387            if item.IsChecked()and \ 
     388                self.tree_ctrl.GetItemText(item) in theory_to_remove: 
     389                self.tree_ctrl.Delete(item) 
     390        self.manager.delete_data(data_name=data_to_remove, 
     391                                  theory_name=theory_to_remove) 
     392         
     393    def on_import(self, event=None): 
     394        """ 
     395        Get all select data and set them to the current active perspetive 
     396        """ 
     397        self.post_helper(plot=False) 
     398         
     399    def on_plot(self, event=None): 
     400        """ 
     401        Send a list of data names to plot 
     402        """ 
     403        self.post_helper(plot=True) 
    305404        
    306     def set_perspective(self, sub_menu): 
    307         """ 
    308         Receive the name of the current perspective and set  
    309         the active perspective 
    310         """ 
    311         for item in self.perspectives: 
    312             if item.GetLabelText()== sub_menu: 
    313                 item.SetValue(True) 
    314             else: 
    315                 item.SetValue(False) 
    316                  
    317     def select_data_type(self, type='Data1D', check=False): 
    318         """ 
    319         check item in the list according to a type. 
    320         :param check: if check true set checkboxes toTrue else to False 
    321         :param type: type of data to select 
    322         """ 
    323         num = self.list_ctrl.GetItemCount() 
    324         for index in range(num): 
    325             if self.list_ctrl.GetItem(index, 1).GetText() == type: 
    326                 self.list_ctrl.CheckItem(index, check) 
    327                  
    328     def on_select_all_data1d(self, event): 
    329         """ 
    330         check/ uncheck list of all data 1D 
    331         """ 
    332         ctrl = event.GetEventObject() 
    333         self.select_data_type(type='Data1D', check=ctrl.GetValue()) 
    334          
    335     def on_select_all_data2d(self, event): 
    336         """ 
    337         check/ uncheck list of all data 2D 
    338         """ 
    339         ctrl = event.GetEventObject() 
    340         self.select_data_type(type='Data2D', check=ctrl.GetValue()) 
    341          
    342     def on_select_all_theory1d(self, event): 
    343         """ 
    344         check/ uncheck list of all theory 1D 
    345         """ 
    346         ctrl = event.GetEventObject() 
    347         self.select_data_type(type='Theory1D', check=ctrl.GetValue()) 
    348          
    349     def on_select_all_theory2d(self, event): 
    350         """ 
    351         check/ uncheck list of all theory 2D 
    352         """ 
    353         ctrl = event.GetEventObject() 
    354         self.select_data_type(type='Theory2D', check=ctrl.GetValue()) 
    355          
    356     def on_select_all(self, event): 
    357         """ 
    358         Check or uncheck all data listed  
    359         """ 
    360         ctrl = event.GetEventObject() 
    361         self.cb_select_data1d.SetValue(ctrl.GetValue()) 
    362         self.cb_select_data2d.SetValue(ctrl.GetValue()) 
    363         self.cb_select_theory1d.SetValue(ctrl.GetValue()) 
    364         self.cb_select_theory2d.SetValue(ctrl.GetValue()) 
    365         num = self.list_ctrl.GetItemCount() 
    366         for i in range(num): 
    367             self.list_ctrl.CheckItem(i, ctrl.GetValue()) 
    368        
    369     def on_select_theory(self, event): 
    370         """ 
    371         Select the theory to import in the active perspective 
    372         """ 
    373          
    374     def on_set_active_perspective(self, event): 
    375         """ 
    376         Select the active perspective 
    377         """ 
    378         ctrl = event.GetEventObject() 
    379          
    380     def set_data_helper(self): 
    381         """ 
    382         """ 
    383         data_to_plot = [] 
    384          
    385         num = self.list_ctrl.GetItemCount() 
    386         for index in range(num): 
    387             if self.list_ctrl.IsChecked(index): 
    388                 data_to_plot.append(self.list_ctrl.GetItemText(index)) 
    389         return data_to_plot 
    390      
    391     def on_import(self, event=None): 
    392         """ 
    393         Get all select data and set them to the current active perspetive 
    394         """ 
    395         data_to_plot = self.set_data_helper() 
     405    def set_active_perspective(self, name): 
     406        """ 
     407        set the active perspective 
     408        """ 
     409        self.tctrl_perspective.SetLabel(str(name)) 
     410     
     411    def set_panel_on_focus(self, name): 
     412        """ 
     413        set the plot panel on focus 
     414        """ 
     415        self.tctrl_plotpanel.SetLabel(str(name)) 
     416         
     417    def get_active_perspective(self): 
     418        """ 
     419        """ 
    396420        current_perspective = None 
    397         if self.perspectives: 
    398             for item in self.perspectives: 
     421        if self.list_rb_perspectives: 
     422            for item in self.list_rb_perspectives: 
    399423                if item.GetValue(): 
    400424                    current_perspective = item.GetLabelText() 
     425        return current_perspective 
     426     
     427    def post_helper(self, plot=False): 
     428        """ 
     429        """ 
     430        data_to_plot, theory_to_plot = self.set_data_helper() 
     431        #print "data_to_plot",data_to_plot 
     432        current_perspective = self.get_active_perspective() 
     433         
    401434        if self.manager is not None: 
    402             self.manager.post_data(data_name_list=data_to_plot, 
    403                         perspective=current_perspective, plot=False) 
    404         
    405     def on_plot(self, event=None): 
    406         """ 
    407         Send a list of data names to plot 
    408         """ 
    409         data_to_plot = self.set_data_helper() 
    410         if self.manager is not None: 
    411             self.manager.post_data(data_name_list=data_to_plot, plot=True) 
    412        
    413     def on_close(self, event): 
    414         """ 
    415         Close the current panel's parent 
    416         """ 
    417         self.parent._onClose() 
    418          
    419      
    420 from sans.guiframe.dataFitting import Data1D 
    421 from DataLoader.loader import Loader 
    422              
    423 list  = Loader().load('latex_smeared.xml') 
    424 data_list = [('Data1', list[0], '07/01/2010'),  
    425             ('Data2', list[1], '07/03/2011'), 
    426             ('Data3', 'Theory1D', '06/01/2010'), 
    427             ('Data4', 'Theory2D', '07/01/2010'), 
    428             ('Data5', 'Theory2D', '07/02/2010')] 
     435            self.parent.post_data_helper(data_name=data_to_plot, 
     436                                 perspective=current_perspective, plot=plot) 
     437 
    429438 
    430439class DataFrame(wx.Frame): 
    431     def __init__(self, parent=None, owner=None, 
    432                  list_of_perspective=None, list=None, 
    433                   manager=None, *args, **kwds): 
    434         kwds['size'] = (500, 500) 
     440    ## Internal name for the AUI manager 
     441    window_name = "Data Panel" 
     442    ## Title to appear on top of the window 
     443    window_caption = "Data Panel" 
     444    ## Flag to tell the GUI manager that this panel is not 
     445    #  tied to any perspective 
     446    ALWAYS_ON = True 
     447     
     448    def __init__(self, parent=None, owner=None, manager=None,size=(600, 600), 
     449                         list_of_perspective=[],list=[], *args, **kwds): 
     450        #kwds['size'] = size 
    435451        kwds['id'] = -1 
    436         kwds['title'] = "Loaded Data" 
     452        kwds['title']= "Loaded Data" 
    437453        wx.Frame.__init__(self, parent=parent, *args, **kwds) 
    438454        self.parent = parent 
     
    440456        self.manager = manager 
    441457        self.panel = DataPanel(parent=self,  
     458                               size=size, 
    442459                               list_of_perspective=list_of_perspective) 
    443         self.panel.load_list(list=list) 
    444         wx.EVT_CLOSE(self, self._onClose) 
    445          
    446     def set_owner(self, owner): 
    447         """ 
    448         :param owner: is the main widget creating this frame 
    449          for sansview owner is gui_manager 
    450         """ 
    451         self.owner = owner 
    452         self.panel.set_owner(owner=self.owner) 
    453          
    454     def set_manager(self, manager): 
    455         """ 
    456         :param manager: object responsible of filling on empty the listcrtl of  
    457          this panel. for sansview manager is data_manager 
    458           
    459         """ 
    460         self.manager = manager 
    461         self.panel.set_manager(manager=self.manager) 
    462          
    463     def load_list(self, list=None): 
     460      
     461    def load_data_list(self, list=[]): 
    464462        """ 
    465463        Fill the list inside its panel 
    466464        """ 
    467         self.panel.load_list(list=list) 
    468          
    469     def layout_perspective(self, list_of_perspective=None): 
    470         """ 
    471         fill the panel with list of perspective 
     465        self.panel.load_data_list(list=list) 
     466         
     467    def layout_perspective(self, list_of_perspective=[]): 
     468        """ 
    472469        """ 
    473470        self.panel.layout_perspective(list_of_perspective=list_of_perspective) 
    474      
    475     def set_perspective(self, sub_menu): 
    476         """ 
    477         Receive the name of the current perspective and set  
    478         the active perspective 
    479         """ 
    480         self.panel.set_perspective(sub_menu=sub_menu) 
    481          
    482     def _onClose(self, event=None): 
    483         """ 
    484         this frame can only be hidden unless the application destroys it 
    485         """ 
    486         self.Hide() 
    487        
     471         
     472     
     473from dataFitting import Data1D 
     474from dataFitting import Data2D, Theory1D 
     475from data_state import DataState 
     476import sys 
     477class State(): 
     478    def __init__(self): 
     479        self.msg = "" 
     480    def __str__(self): 
     481        self.msg = "model mane : model1\n" 
     482        self.msg += "params : \n" 
     483        self.msg += "name  value\n" 
     484        return msg 
     485def set_data_state(data, path, theory, state): 
     486    dstate = DataState(data=data) 
     487    dstate.set_path(path=path) 
     488    dstate.set_theory(theory) 
     489    dstate.set_state(state) 
     490    return dstate 
     491"""' 
     492data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"),  
     493            ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"),  
     494            ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"),  
     495            ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"),  
     496            ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")]  
     497"""       
    488498if __name__ == "__main__": 
     499     
    489500    app = wx.App() 
    490     window = DataFrame(list=data_list) 
    491     window.Show(True) 
     501    try: 
     502        list_of_perspective = [('perspective2', False), ('perspective1', True)] 
     503        data_list = {} 
     504        data = Data1D() 
     505        data.name = "data1" 
     506        #data.append_process() 
     507        #process = data.process[len(data.process)-1] 
     508        #process.data = "07/01/2010" 
     509        theory = Theory1D() 
     510        theory.pseudo_name = "theory1" 
     511        path = "path1" 
     512        state = State() 
     513        data_list['1']=set_data_state(data, path,theory, state) 
     514         
     515        data = Data1D() 
     516        data.name = "data2" 
     517        theory = Theory1D() 
     518        theory.name = "CoreShell 07/24/25" 
     519        theory.pseudo_name = "CoreShell" 
     520        path = "path2" 
     521        state = State() 
     522        data_list['2']=set_data_state(data, path,theory, state) 
     523        data = Data1D() 
     524        data.name = "data2" 
     525        theory = Theory1D() 
     526        theory.name = "CoreShell" 
     527        theory.pseudo_name = "CoreShell" 
     528        #theory.append_process() 
     529        #process = theory.process[len(theory.process)-1] 
     530        #process.description = "this is my description" 
     531        path = "path3" 
     532        #data.append_process() 
     533        #process = data.process[len(data.process)-1] 
     534        #process.data = "07/22/2010" 
     535        data_list['4']=set_data_state(data, path,theory, state) 
     536         
     537        data = Data2D() 
     538        data.name = "data3" 
     539        #data.append_process() 
     540        #process = data.process[len(data.process)-1] 
     541        #process.data = "07/01/2010" 
     542        theory = Theory1D() 
     543        theory.pseudo_name = "Cylinder" 
     544        path = "path2" 
     545        state = State() 
     546        dstate= set_data_state(data, path,theory, state) 
     547        theory = Theory1D() 
     548        theory.pseudo_name = "Sphere" 
     549        dstate.set_theory(theory) 
     550        data_list['3']=dstate 
     551         
     552        window = DataFrame(list=data_list) 
     553        window.load_data_list(list=data_list) 
     554        window.layout_perspective(list_of_perspective=list_of_perspective) 
     555        window.Show(True) 
     556    except: 
     557        #raise 
     558        print "error",sys.exc_value 
    492559    app.MainLoop()   
    493560     
  • guiframe/gui_manager.py

    r7a67e075 r3feed3e  
    4343from sans.guiframe.gui_style import * 
    4444from sans.guiframe.events import NewLoadedDataEvent 
     45from sans.guiframe.data_panel import DataPanel 
     46 
    4547STATE_FILE_EXT = ['.inv', '.fitv', '.prv'] 
    46  
    4748DATA_MANAGER = False 
    4849AUTO_PLOT = False 
    4950AUTO_SET_DATA = True 
     51PLOPANEL_WIDTH = 400 
     52PLOPANEL_HEIGTH = 400 
     53 
    5054 
    5155class ViewerFrame(wx.Frame): 
     
    9094        from data_manager import DataManager 
    9195        self._data_manager = DataManager() 
    92         self._data_panel = None 
     96        self._data_panel = DataPanel(parent=self) 
     97        
    9398        #add current perpsective 
    9499        self._current_perspective = None 
     
    109114        self.plugins += self._get_local_plugins() 
    110115        self.plugins += self._find_plugins() 
    111        
     116        print "self.plugins", self.plugins 
    112117        ## List of panels 
    113118        self.panels = {} 
     
    206211        #check if the style contain guiframe.dataloader 
    207212        style1 = self.__gui_style & GUIFRAME.DATALOADER_ON 
    208         style2 = self.__gui_style & GUIFRAME.PLOTTIN_ON 
    209         style3 = self.__gui_style & (GUIFRAME.DATALOADER_ON|GUIFRAME.PLOTTIN_ON) 
    210         
     213        style2 = self.__gui_style & GUIFRAME.PLOTTING_ON 
    211214        if style1 == GUIFRAME.DATALOADER_ON: 
    212215            try: 
    213216                from sans.guiframe.local_perspectives.data_loader import data_loader 
    214                 self._data_plugin =data_loader.Plugin() 
     217                self._data_plugin = data_loader.Plugin() 
    215218                plugins.append(self._data_plugin) 
    216219            except: 
    217                 msg = "ViewerFrame._find_plugins:" 
     220                msg = "ViewerFrame._get_local_plugins:" 
    218221                msg += "cannot import dataloader plugin.\n %s" % sys.exc_value 
    219222                logging.error(msg) 
    220         elif style2 == GUIFRAME.PLOTTIN_ON: 
     223        if style2 == GUIFRAME.PLOTTING_ON: 
    221224            try: 
    222225                from sans.guiframe.local_perspectives.plotting import plotting 
     
    224227                plugins.append(self._plotting_plugin) 
    225228            except: 
    226                 msg = "ViewerFrame._find_plugins:" 
     229                msg = "ViewerFrame._get_local_plugins:" 
    227230                msg += "cannot import plotting plugin.\n %s" % sys.exc_value 
    228         elif style3 in (GUIFRAME.DATALOADER_ON|GUIFRAME.PLOTTIN_ON): 
    229             try: 
    230                 from sans.guiframe.local_perspectives.data_loader import data_loader 
    231                 self._data_plugin =data_loader.Plugin() 
    232                 plugins.append(self._data_plugin) 
    233                 from sans.guiframe.local_perspectives.plotting import plotting 
    234                 self._plotting_plugin = plotting.Plugin() 
    235                 plugins.append(self._plotting_plugin) 
    236             except: 
    237                 msg = "ViewerFrame._get_local_plugins: %s" % sys.exc_value 
    238231                logging.error(msg) 
     232      
    239233        return plugins 
    240234     
     
    285279                                config.printEVT(msg) 
    286280                    except: 
    287                         #print sys.exc_value 
     281                        print sys.exc_value 
    288282                        msg = "ViewerFrame._find_plugins: %s" % sys.exc_value 
    289283                        logging.error(msg) 
     
    306300        self.defaultPanel = panel_class(self, -1, style=wx.RAISED_BORDER) 
    307301         
     302    def _get_panels_size(self, p): 
     303        """ 
     304        find the proper size of the current panel 
     305        get the proper panel width and height 
     306        """ 
     307        panel_height_min = self._window_height 
     308        panel_width_min = self._window_width  
     309        style = self.__gui_style & (GUIFRAME.MANAGER_ON) 
     310        if self._data_panel is not None  and (p == self._data_panel): 
     311            panel_width_min = self._window_width * 4/25  
     312            return panel_width_min, panel_height_min 
     313        if hasattr(p, "CENTER_PANE") and p.CENTER_PANE: 
     314            style = self.__gui_style & (GUIFRAME.PLOTTING_ON|GUIFRAME.MANAGER_ON) 
     315            if style == (GUIFRAME.PLOTTING_ON|GUIFRAME.MANAGER_ON): 
     316                panel_width_min = self._window_width * 13/25  
     317            return panel_width_min, panel_height_min 
     318        return panel_width_min, panel_height_min 
     319     
    308320    def _load_panels(self): 
    309321        """ 
     
    317329                ps = item.get_panels(self) 
    318330                panels.extend(ps) 
    319  
     331        
    320332        # Show a default panel with some help information 
    321333        # It also sets the size of the application windows 
     
    323335        if self.defaultPanel is None: 
    324336            self.defaultPanel = DefaultPanel(self, -1, style=wx.RAISED_BORDER) 
    325              
     337        # add a blank default panel always present  
    326338        self.panels["default"] = self.defaultPanel 
    327          
    328339        self._mgr.AddPane(self.defaultPanel, wx.aui.AuiPaneInfo(). 
    329340                              Name("default"). 
    330                               CenterPane(). 
     341                              Center(). 
     342                              CloseButton(True). 
    331343                              # This is where we set the size of 
    332344                              # the application window 
    333345                              BestSize(wx.Size(self._window_width,  
    334346                                               self._window_height)). 
    335                               #MinSize(wx.Size(self._window_width,  
    336                               #self._window_height)). 
    337347                              Show()) 
    338       
     348        #add data panel  
     349        self.panels["data_panel"] = self._data_panel 
     350        w, h = self._get_panels_size(self._data_panel) 
     351        self._mgr.AddPane(self._data_panel, wx.aui.AuiPaneInfo(). 
     352                              Name(self._data_panel.window_name). 
     353                              Left(). 
     354                              MinimizeButton(). 
     355                              MinSize(wx.Size(w, h)). 
     356                              Show()) 
     357        style = self.__gui_style & GUIFRAME.MANAGER_ON 
     358        if style != GUIFRAME.MANAGER_ON: 
     359            self._mgr.GetPane(self.panels["data_panel"].window_name).Hide() 
     360             
    339361        # Add the panels to the AUI manager 
    340362        for panel_class in panels: 
    341363            p = panel_class 
    342364            id = wx.NewId() 
    343              
     365            w, h = self._get_panels_size(p) 
    344366            # Check whether we need to put this panel 
    345367            # in the center pane 
     
    349371                    self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 
    350372                                          Name(p.window_name).Caption(p.window_caption). 
    351                                           CenterPane(). 
    352                                           #BestSize(wx.Size(550,600)). 
    353                                  MinSize(wx.Size(self._window_width*3/5,-1)). 
    354                                           Hide()) 
     373                                           Center(). 
     374                                           CloseButton(True). 
     375                                           MinSize(wx.Size(w, h)). 
     376                                           Hide()) 
    355377            else: 
    356378                self.panels[str(id)] = p 
     
    364386                                  RightDockable(). 
    365387                                  MinimizeButton(). 
    366                                   Hide()) 
    367                                   #BestSize(wx.Size(550,600))) 
    368                                   #MinSize(wx.Size(500,500)))                  
     388                                  Hide())         
    369389       
    370390    def get_context_menu(self, graph=None): 
     
    408428            self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 
    409429                              Name(windowname).Caption(caption). 
    410                               Floatable(). 
    411                               Right(). 
    412                               Dock(). 
    413                               TopDockable(). 
    414                               BottomDockable(). 
    415                               LeftDockable(). 
    416                               RightDockable(). 
    417430                              MinimizeButton(). 
    418                               #Hide(). 
    419                               #Show(). 
    420431                              Resizable(True). 
    421432                              # Use a large best size to make sure the AUI manager 
    422433                              # takes all the available space 
    423                               BestSize(wx.Size(400,400))) 
     434                              BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 
     435            print "GUIFRAME.FIXED_PANEL" 
     436            self._popup_fixed_panel(p) 
     437             
    424438        elif style2 in GUIFRAME.FLOATING_PANEL: 
     439            print "GUIFRAME.Floating_PANEL" 
    425440            self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 
    426441                              Name(windowname).Caption(caption). 
    427                               Floatable(). 
    428                               Float(). 
    429                                
    430                               #FloatingPosition(wx.Size(self._window_width/5,self._window_height/3)). 
    431                               Right(). 
    432                               Dock(). 
    433                               TopDockable(). 
    434                               BottomDockable(). 
    435                               LeftDockable(). 
    436                               RightDockable(). 
    437442                              MinimizeButton(). 
    438                               #Hide(). 
    439                               #Show(). 
    440443                              Resizable(True). 
    441444                              # Use a large best size to make sure the AUI manager 
    442445                              # takes all the available space 
    443                               BestSize(wx.Size(400,400))) 
     446                              BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 
     447            self._popup_floating_panel(p) 
    444448             
    445449        pane = self._mgr.GetPane(windowname) 
     
    644648                         '&Load Data File(s)', data_file_hint) 
    645649        wx.EVT_MENU(self, data_file_id, self._load_data) 
    646         style = self.__gui_style & GUIFRAME.SINGLE_APPLICATION 
    647         if style == GUIFRAME.SINGLE_APPLICATION: 
    648             self._menubar.Append(self._data_menu, '&Data') 
    649             return  
    650         else: 
     650        style = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 
     651        style1 = self.__gui_style & GUIFRAME.SINGLE_APPLICATION 
     652        if style == GUIFRAME.MULTIPLE_APPLICATIONS: 
    651653            #menu for data from folder 
    652654            data_folder_id = wx.NewId() 
     
    655657                             '&Load Data Folder', data_folder_hint) 
    656658            wx.EVT_MENU(self, data_folder_id, self._load_folder) 
     659            self._menubar.Append(self._data_menu, '&Data') 
     660        elif style1 == GUIFRAME.SINGLE_APPLICATION: 
    657661            self._menubar.Append(self._data_menu, '&Data') 
    658662         
     
    968972                    self._mgr.GetPane(self.panels[item].window_name).Show() 
    969973            else: 
    970                 if self._mgr.GetPane(self.panels[item].window_name).IsShown(): 
    971                     self._mgr.GetPane(self.panels[item].window_name).Hide() 
     974                # always show the data panel if enable 
     975                style = self.__gui_style & GUIFRAME.MANAGER_ON 
     976                if (style == GUIFRAME.MANAGER_ON) and self.panels[item] == self._data_panel: 
     977                    if 'data_panel' in self.panels.keys(): 
     978                        flag = self._mgr.GetPane(self.panels['data_panel'].window_name).IsShown() 
     979                        self._mgr.GetPane(self.panels['data_panel'].window_name).Show(flag) 
     980                else: 
     981                    if self._mgr.GetPane(self.panels[item].window_name).IsShown(): 
     982                        self._mgr.GetPane(self.panels[item].window_name).Hide() 
    972983        self._mgr.Update() 
    973984         
     
    9911002    def show_data_panel(self, event): 
    9921003        """ 
    993         """ 
     1004        show the data panel 
     1005        """ 
     1006        pane = self._mgr.GetPane(self.panels["data_panel"].window_name) 
     1007        if not pane.IsShown(): 
     1008            pane.Show(True) 
     1009            self._mgr.Update() 
     1010             
    9941011    def show_welcome_panel(self, event): 
    9951012        """ 
     
    10071024            self._data_manager.add_data(data_list) 
    10081025            avalaible_data = self._data_manager.get_all_data() 
    1009         wx.PostEvent(self, NewLoadedDataEvent(data_to_add=avalaible_data, 
    1010                                               data_to_remove = []))  
    1011              
    1012         if AUTO_SET_DATA: 
    1013             if self._current_perspective is not None: 
    1014                 try: 
    1015                     self._current_perspective.set_data(data_list) 
    1016                 except: 
    1017                     msg = str(sys.exc_value) 
    1018                     wx.PostEvent(self, StatusEvent(status=msg, 
    1019                                               info="error")) 
    1020             else: 
    1021                 msg = "Guiframe does not have a current perspective" 
    1022                 logging.info(msg) 
    1023         if DATA_MANAGER: 
    1024             print "will show data panel" 
    1025         if AUTO_PLOT: 
    1026             self.plot_data(data_list) 
    1027         
    1028          
    1029          
     1026             
     1027        style = self.__gui_style & GUIFRAME.MANAGER_ON 
     1028        if style == GUIFRAME.MANAGER_ON: 
     1029            if self._data_panel is not None: 
     1030                self._mgr.GetPane(self._data_panel.window_name).Show(True) 
     1031                #wait for button press from the data panel to send data 
     1032        else: 
     1033            #automatically send that to the current perspective 
     1034            style = self.__gui_style & GUIFRAME.SINGLE_APPLICATION 
     1035            if style == GUIFRAME.SINGLE_APPLICATION: 
     1036                if self._current_perspective is not None: 
     1037                    try: 
     1038                        self._current_perspective.set_data(data_list) 
     1039                    except: 
     1040                        msg = str(sys.exc_value) 
     1041                        wx.PostEvent(self, StatusEvent(status=msg, 
     1042                                                  info="error")) 
     1043                else: 
     1044                    msg = "Guiframe does not have a current perspective" 
     1045                    logging.info(msg) 
     1046             
     1047  
    10301048    def plot_data(self, data_list): 
    10311049        """ 
     
    10331051        """ 
    10341052        for new_plot in data_list: 
     1053             
    10351054            wx.PostEvent(self, NewPlotEvent(plot=new_plot, 
    10361055                                                  title=str(new_plot.title))) 
     
    10461065        make the plot panel floatable 
    10471066        """ 
     1067        self.__gui_style |= GUIFRAME.FLOATING_PANEL 
     1068        for p in self.panels.values(): 
     1069            plot_panel = self._plotting_plugin.plot_panels 
     1070            for p in self.panels.values(): 
     1071                if p in plot_panel: 
     1072                    self._popup_floating_panel(p) 
     1073         
    10481074    def set_plotpanel_fixed(self, event): 
    10491075        """ 
    10501076        make the plot panel fixed 
    10511077        """ 
    1052  
     1078        self.__gui_style |= GUIFRAME.FIXED_PANEL 
     1079        plot_panel = [] 
     1080        if self._plotting_plugin is not None: 
     1081            plot_panel = self._plotting_plugin.plot_panels 
     1082            for p in self.panels.values(): 
     1083                if p in plot_panel: 
     1084                    self._popup_fixed_panel(p) 
     1085                     
     1086    def _popup_fixed_panel(self, p): 
     1087        """ 
     1088        """ 
     1089        style = self.__gui_style & GUIFRAME.FIXED_PANEL 
     1090        if style == GUIFRAME.FIXED_PANEL: 
     1091            self._mgr.GetPane(p.window_name).Floatable() 
     1092            self._mgr.GetPane(p.window_name).Right() 
     1093            self._mgr.GetPane(p.window_name).TopDockable(False) 
     1094            self._mgr.GetPane(p.window_name).BottomDockable(False) 
     1095            self._mgr.GetPane(p.window_name).LeftDockable(False) 
     1096            self._mgr.GetPane(p.window_name).RightDockable(True) 
     1097            flag = self._mgr.GetPane(p.window_name).IsShown() 
     1098            self._mgr.GetPane(p.window_name).Show(flag) 
     1099            self._mgr.Update() 
     1100             
     1101    def _popup_floating_panel(self, p): 
     1102        """ 
     1103        """ 
     1104        style = self.__gui_style &  GUIFRAME.FLOATING_PANEL 
     1105        if style == GUIFRAME.FLOATING_PANEL:  
     1106            self._mgr.GetPane(p.window_name).Floatable(True) 
     1107            self._mgr.GetPane(p.window_name).Float() 
     1108            self._mgr.GetPane(p.window_name).Dockable(False) 
     1109            flag = self._mgr.GetPane(p.window_name).IsShown() 
     1110            self._mgr.GetPane(p.window_name).Show(flag) 
     1111            self._mgr.Update() 
     1112         
    10531113class DefaultPanel(wx.Panel): 
    10541114    """ 
  • guiframe/gui_style.py

    r7a67e075 r3feed3e  
    88    FLOATING_PANEL = 2 
    99    FIXED_PANEL = 4 
    10     PLOTTIN_ON = 8 
     10    PLOTTING_ON = 8 
    1111    DATALOADER_ON = 16 
    1212    TOOL_ON = 32 
    1313    SINGLE_APPLICATION = 64 
    14     DEFAULT_STYLE = SINGLE_APPLICATION|DATALOADER_ON|PLOTTIN_ON|FIXED_PANEL 
     14    DEFAULT_STYLE = SINGLE_APPLICATION|DATALOADER_ON|PLOTTING_ON|FIXED_PANEL 
    1515    MULTIPLE_APPLICATIONS = DEFAULT_STYLE|MANAGER_ON 
    1616 
     
    2121    print GUIFRAME.SINGLE_APPLICATION 
    2222    style = GUIFRAME.MULTIPLE_APPLICATIONS 
    23     style &= GUIFRAME.PLOTTIN_ON 
    24     print style == GUIFRAME.PLOTTIN_ON 
     23    style &= GUIFRAME.PLOTTING_ON 
     24    print style == GUIFRAME.PLOTTING_ON 
    2525    style1 = GUIFRAME.MULTIPLE_APPLICATIONS 
    2626    style1 &= (~GUIFRAME.MANAGER_ON) 
  • guiframe/local_perspectives/plotting/plotting.py

    rf444b20 r3feed3e  
    1616from sans.guiframe.events import EVT_NEW_PLOT 
    1717from sans.guiframe.events import StatusEvent  
    18  
    1918from sans.guiframe.plugin_base import PluginBase 
    2019 
     
    7978        # Check whether we already have a graph with the same units 
    8079        # as the plottable we just received.  
    81          
    8280        is_available = False 
    8381        for panel in self.plot_panels: 
Note: See TracChangeset for help on using the changeset viewer.