source: sasview/guiframe/data_panel.py @ 944b1a6

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 944b1a6 was 37e0e5d, checked in by Jae Cho <jhjcho@…>, 13 years ago

removed setfocusignoringchild

  • Property mode set to 100644
File size: 45.0 KB
RevLine 
[3c44c66]1################################################################################
2#This software was developed by the University of Tennessee as part of the
3#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4#project funded by the US National Science Foundation.
5#
6#See the license text in license.txt
7#
8#copyright 2010, University of Tennessee
9################################################################################
10"""
11This module provides Graphic interface for the data_manager module.
12"""
[2a62d5c]13import os
[3c44c66]14import wx
[af7ba61]15# Check version
16toks = wx.__version__.split('.')
17if int(toks[1]) < 9:
[228a8bb]18    if int(toks[2]) < 12:
19        wx_version = 811
20    else:
21        wx_version = 812
[af7ba61]22else:
[228a8bb]23    wx_version = 900
[3c44c66]24import sys
[3feed3e]25import warnings
[13a63ab]26import logging
[3c44c66]27from wx.lib.scrolledpanel import ScrolledPanel
[3feed3e]28import  wx.lib.agw.customtreectrl as CT
29from sans.guiframe.dataFitting import Data1D
30from sans.guiframe.dataFitting import Data2D
[52725d6]31from sans.guiframe.panel_base import PanelBase
[2a62d5c]32from sans.guiframe.events import StatusEvent
[13a63ab]33from sans.guiframe.events import EVT_DELETE_PLOTPANEL
[a03d419]34from sans.guiframe.events import NewLoadDataEvent
[e26d0db]35from sans.guiframe.events import NewPlotEvent
[a03d419]36from sans.guiframe.gui_style import GUIFRAME
[2a62d5c]37from DataLoader.loader import Loader
38
39try:
40    # Try to find a local config
41    import imp
42    path = os.getcwd()
43    if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \
44        (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))):
45        fObj, path, descr = imp.find_module('local_config', [path])
46        config = imp.load_module('local_config', fObj, path, descr) 
47    else:
48        # Try simply importing local_config
49        import local_config as config
50except:
51    # Didn't find local config, load the default
52    import config
53 
54extension_list = []
55if config.APPLICATION_STATE_EXTENSION is not None:
56    extension_list.append(config.APPLICATION_STATE_EXTENSION)
57EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list   
[99f9ecf]58PLUGINS_WLIST = config.PLUGINS_WLIST
59APPLICATION_WLIST = config.APPLICATION_WLIST
[3f0c330]60
61#Control panel width
62if sys.platform.count("win32") > 0:
63    PANEL_WIDTH = 235
64    PANEL_HEIGHT = 700
65    CBOX_WIDTH = 140
66    BUTTON_WIDTH = 80
67    FONT_VARIANT = 0
[234a3fa]68    IS_MAC = False
[3f0c330]69else:
70    PANEL_WIDTH = 255
71    PANEL_HEIGHT = 750
72    CBOX_WIDTH = 155
73    BUTTON_WIDTH = 100
74    FONT_VARIANT = 1
[234a3fa]75    IS_MAC = True
[3f0c330]76
[1b1bbf9]77STYLE_FLAG =wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\
[91bdf87]78                    wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT
79                   
80                   
[3feed3e]81class DataTreeCtrl(CT.CustomTreeCtrl):
[3c44c66]82    """
83    Check list control to be used for Data Panel
84    """
[6db811e]85    def __init__(self, parent,*args, **kwds):
[73581ce]86        #agwstyle is introduced in wx.2.8.11 but is not working for mac
[228a8bb]87        if IS_MAC and wx_version < 812:
[91bdf87]88            try:
89                kwds['style'] = STYLE_FLAG
[d34f9f6]90                CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds)
[91bdf87]91            except:
[af7ba61]92                del kwds['style']
[d34f9f6]93                CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds)
[73581ce]94        else:
95            #agwstyle is introduced in wx.2.8.11 .argument working only for windows
96            try:
97                kwds['agwStyle'] = STYLE_FLAG
[d34f9f6]98                CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds)
[73581ce]99            except:
100                try:
[d34f9f6]101                    del kwds['agwStyle']
[73581ce]102                    kwds['style'] = STYLE_FLAG
[d34f9f6]103                    CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds)
[73581ce]104                except:
[d34f9f6]105                    del kwds['style']
106                    CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds)
[3feed3e]107        self.root = self.AddRoot("Available Data")
[3c44c66]108       
[52725d6]109class DataPanel(ScrolledPanel, PanelBase):
[3c44c66]110    """
111    This panel displays data available in the application and widgets to
112    interact with data.
113    """
[3feed3e]114    ## Internal name for the AUI manager
115    window_name = "Data Panel"
116    ## Title to appear on top of the window
[1b1bbf9]117    window_caption = "Data Explorer"
[3feed3e]118    #type of window
119    window_type = "Data Panel"
120    ## Flag to tell the GUI manager that this panel is not
121    #  tied to any perspective
122    #ALWAYS_ON = True
[600eca2]123    def __init__(self, parent, 
124                 list=None,
[ea4dfe0]125                 size=(PANEL_WIDTH, PANEL_HEIGHT),
126                 list_of_perspective=None, manager=None, *args, **kwds):
[3feed3e]127        kwds['size']= size
[1b1bbf9]128        kwds['style'] = STYLE_FLAG
[3c44c66]129        ScrolledPanel.__init__(self, parent=parent, *args, **kwds)
[52725d6]130        PanelBase.__init__(self)
[3c44c66]131        self.SetupScrolling()
[3f0c330]132        #Set window's font size
133        self.SetWindowVariant(variant=FONT_VARIANT)
[2a62d5c]134        self.loader = Loader() 
135        #Default location
136        self._default_save_location = None 
[ee2b492]137        self.all_data1d = True
[3c44c66]138        self.parent = parent
[3feed3e]139        self.manager = manager
[600eca2]140        if list is None:
141            list = []
[3c44c66]142        self.list_of_data = list
[600eca2]143        if list_of_perspective is None:
144            list_of_perspective = []
[3feed3e]145        self.list_of_perspective = list_of_perspective
146        self.list_rb_perspectives= []
[c70eb7c]147        self.list_cb_data = {}
148        self.list_cb_theory = {}
[61ffd1e]149        self.tree_ctrl = None
150        self.tree_ctrl_theory = None
[600eca2]151        self.perspective_cbox = None
[5e8e615]152       
[3feed3e]153        self.owner = None
154        self.do_layout()
[600eca2]155        self.fill_cbox_analysis(self.list_of_perspective)
[1b1bbf9]156        self.Bind(wx.EVT_SHOW, self.on_close_page)
[13a63ab]157        if self.parent is not None:
158            self.parent.Bind(EVT_DELETE_PLOTPANEL, self._on_delete_plot_panel)
[c31fd9f]159     
[3feed3e]160    def do_layout(self):
[6db811e]161        """
162        """
[3c44c66]163        self.define_panel_structure()
164        self.layout_selection()
[5c4b674]165        self.layout_data_list()
[3c44c66]166        self.layout_button()
[600eca2]167        #self.layout_batch()
[3feed3e]168   
[3c44c66]169    def define_panel_structure(self):
170        """
171        Define the skeleton of the panel
172        """
[3feed3e]173        w, h = self.parent.GetSize()
[3c44c66]174        self.vbox  = wx.BoxSizer(wx.VERTICAL)
175        self.sizer1 = wx.BoxSizer(wx.VERTICAL)
[1b1bbf9]176        self.sizer1.SetMinSize((w/13, h*2/5))
[cc061c3]177     
[3feed3e]178        self.sizer2 = wx.BoxSizer(wx.VERTICAL)
[c6f2291]179        self.sizer3 = wx.FlexGridSizer(7, 2, 4, 1)
[3c44c66]180        self.sizer4 = wx.BoxSizer(wx.HORIZONTAL)
[18ec684]181        self.sizer5 = wx.BoxSizer(wx.VERTICAL)
182       
[2a62d5c]183        self.vbox.Add(self.sizer5, 0, wx.EXPAND|wx.ALL,1)
184        self.vbox.Add(self.sizer1, 0, wx.EXPAND|wx.ALL,0)
185        self.vbox.Add(self.sizer2, 0, wx.EXPAND|wx.ALL,1)
[026041c]186        self.vbox.Add(self.sizer3, 0, wx.EXPAND|wx.ALL,5)
[2a62d5c]187        self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5)
[3feed3e]188       
[3c44c66]189        self.SetSizer(self.vbox)
190       
[3feed3e]191    def layout_selection(self):
[3c44c66]192        """
193        """
[3feed3e]194        select_txt = wx.StaticText(self, -1, 'Selection Options')
[bffa3d0]195        select_txt.SetForegroundColour('blue')
[3feed3e]196        self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
197        list_of_options = ['Select all Data',
198                            'Unselect all Data',
199                           'Select all Data 1D',
200                           'Unselect all Data 1D',
201                           'Select all Data 2D',
202                           'Unselect all Data 2D' ]
203        for option in list_of_options:
204            self.selection_cbox.Append(str(option))
[18ec684]205        self.selection_cbox.SetValue('Select all Data')
[3feed3e]206        wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type)
207        self.sizer5.AddMany([(select_txt,0, wx.ALL,5),
208                            (self.selection_cbox,0, wx.ALL,5)])
[61ffd1e]209        self.enable_selection()
210       
[5e8e615]211   
[3feed3e]212    def _on_selection_type(self, event):
[3c44c66]213        """
[3feed3e]214        Select data according to patterns
[3c44c66]215        """
[18ec684]216       
217        list_of_options = ['Select all Data',
218                            'Unselect all Data',
219                           'Select all Data 1D',
220                           'Unselect all Data 1D',
221                           'Select all Data 2D',
222                           'Unselect all Data 2D' ]
[3feed3e]223        option = self.selection_cbox.GetValue()
[18ec684]224       
225        pos = self.selection_cbox.GetSelection()
226        if pos == wx.NOT_FOUND:
227            return 
228        option = self.selection_cbox.GetString(pos)
[b5e79f7]229        for item in self.list_cb_data.values():
230            data_ctrl, _, _, _,_, _ = item
231            data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) 
[18ec684]232            if option == 'Select all Data':
[b5e79f7]233                self.tree_ctrl.CheckItem(data_ctrl, True) 
[18ec684]234            elif option == 'Unselect all Data':
[b5e79f7]235                self.tree_ctrl.CheckItem(data_ctrl, False)
[18ec684]236            elif option == 'Select all Data 1D':
237                if data_class == 'Data1D':
[b5e79f7]238                    self.tree_ctrl.CheckItem(data_ctrl, True) 
[18ec684]239            elif option == 'Unselect all Data 1D':
[c70eb7c]240                if data_class == 'Data1D':
[b5e79f7]241                    self.tree_ctrl.CheckItem(data_ctrl, False) 
[18ec684]242            elif option == 'Select all Data 1D':
[c70eb7c]243                if data_class == 'Data1D':
[b5e79f7]244                    self.tree_ctrl.CheckItem(data_ctrl, True) 
[18ec684]245            elif option == 'Select all Data 2D':
246                if data_class == 'Data2D':
[b5e79f7]247                    self.tree_ctrl.CheckItem(data_ctrl, True) 
[18ec684]248            elif option == 'Unselect all Data 2D':
249                if data_class == 'Data2D':
[b5e79f7]250                    self.tree_ctrl.CheckItem(data_ctrl, False) 
[1e3394f]251        self.enable_append()
252        self.enable_freeze()
253        self.enable_plot()
254        self.enable_import()
[248b918]255        self.enable_remove()
[18ec684]256               
[3c44c66]257    def layout_button(self):
258        """
259        Layout widgets related to buttons
260        """
[ea4dfe0]261        w, _ = self.GetSize()
[a03d419]262       
[2567003]263        self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 
264                                size=(BUTTON_WIDTH, -1))
[c461ebe]265        self.bt_add.SetToolTipString("Load data files")
[2a62d5c]266        wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data)
[c5a769e]267        self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data",
[248b918]268         size=(BUTTON_WIDTH, -1))
[c5a769e]269        self.bt_remove.SetToolTipString("Delete data from the application")
[248b918]270        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove)
[2567003]271        self.bt_import = wx.Button(self, wx.NewId(), "Send To",
272                                    size=(BUTTON_WIDTH, -1))
[3feed3e]273        self.bt_import.SetToolTipString("Send set of Data to active perspective")
[3c44c66]274        wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import)
[df58ecab]275        self.perspective_cbox = wx.ComboBox(self, -1,
[600eca2]276                                style=wx.CB_READONLY)
[df58ecab]277        #self.perspective_cbox.SetMinSize((CBOX_WIDTH, -1))
[600eca2]278        wx.EVT_COMBOBOX(self.perspective_cbox,-1, 
279                        self._on_perspective_selection)
280   
[2567003]281        self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To",
282                                        size=(BUTTON_WIDTH, -1))
[213892bc]283        self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel")
284        wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot)
[3feed3e]285       
[2567003]286        self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", 
287                                 size=(BUTTON_WIDTH, -1))
[3c44c66]288        self.bt_plot.SetToolTipString("To trigger plotting")
289        wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot)
290       
[2567003]291        self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", 
292                                   size=(BUTTON_WIDTH, -1))
[48665ed]293        self.bt_freeze.SetToolTipString("To trigger freeze a theory")
[c70eb7c]294        wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze)
[e26d0db]295        #hide plot
[c5a769e]296        #self.bt_close_plot = wx.Button(self, wx.NewId(), "Delete Plot",
297        #                           size=(BUTTON_WIDTH, -1))
298        #self.bt_close_plot.SetToolTipString("Delete the plot panel on focus")
299        #wx.EVT_BUTTON(self, self.bt_close_plot.GetId(), self.on_close_plot)
[600eca2]300       
[df58ecab]301        self.cb_plotpanel = wx.ComboBox(self, -1, 
[0a2fdca]302                                style=wx.CB_READONLY|wx.CB_SORT)
[df58ecab]303        #self.cb_plotpanel.SetMinSize((CBOX_WIDTH, -1))
[0a2fdca]304        wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection)
[5e8e615]305        self.cb_plotpanel.Disable()
[0a2fdca]306
[600eca2]307        self.sizer3.AddMany([(self.bt_add),
308                             ((10, 10)),
[248b918]309                             (self.bt_remove),
310                             ((10, 10)),
[2567003]311                             (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5),
[df58ecab]312                              (self.perspective_cbox, wx.EXPAND|wx.ADJUST_MINSIZE, 5),
[600eca2]313                              (self.bt_append_plot),
[df58ecab]314                              (self.cb_plotpanel, wx.EXPAND|wx.ADJUST_MINSIZE, 5),
[600eca2]315                              (self.bt_plot),
316                              ((10, 10)),
[c461ebe]317                              (self.bt_freeze),
[c5a769e]318                              #((10, 10)),
319                              #(self.bt_close_plot),
[c461ebe]320                              ((10, 10))])
321
[600eca2]322        self.sizer3.AddGrowableCol(1, 1)
[a03d419]323        self.show_data_button()
[248b918]324        self.enable_remove()
[f7d0b74]325        self.enable_import()
326        self.enable_plot()
327        self.enable_append()
328        self.enable_freeze()
[e26d0db]329        self.enable_remove_plot()
[3feed3e]330       
331    def layout_batch(self):
[3c44c66]332        """
333        """
[3feed3e]334        self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode',
335                                             style=wx.RB_GROUP)
336        self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode')
337       
338        self.rb_single_mode.SetValue(True)
339        self.rb_batch_mode.SetValue(False)
340        self.sizer4.AddMany([(self.rb_single_mode,0, wx.ALL,5),
341                            (self.rb_batch_mode,0, wx.ALL,5)])
342     
[91bdf87]343    def layout_data_list(self):
[bffa3d0]344        """
345        Add a listcrtl in the panel
346        """
347        tree_ctrl_label = wx.StaticText(self, -1, "Data")
348        tree_ctrl_label.SetForegroundColour('blue')
349        self.tree_ctrl = DataTreeCtrl(parent=self)
350        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item)
351        tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory")
352        tree_ctrl_theory_label.SetForegroundColour('blue')
353        self.tree_ctrl_theory = DataTreeCtrl(parent=self)
354        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item)
355        self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10)
356        self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10)
357        self.sizer1.Add(tree_ctrl_theory_label, 0,  wx.LEFT, 10)
358        self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND|wx.ALL, 10)
359           
[3feed3e]360    def onContextMenu(self, event): 
[3c44c66]361        """
[3feed3e]362        Retrieve the state selected state
[3c44c66]363        """
[3feed3e]364        # Skipping the save state functionality for release 0.9.0
365        #return
366        pos = event.GetPosition()
367        pos = self.ScreenToClient(pos)
368        self.PopupMenu(self.popUpMenu, pos) 
369     
[ee2b492]370 
[3feed3e]371    def on_check_item(self, event):
[3c44c66]372        """
373        """
[3feed3e]374        item = event.GetItem()
[ee2b492]375        item.Check(not item.IsChecked()) 
[1e3394f]376        self.enable_append()
377        self.enable_freeze()
378        self.enable_plot()
379        self.enable_import()
[248b918]380        self.enable_remove()
[ee2b492]381        event.Skip()
382       
[600eca2]383    def fill_cbox_analysis(self, plugin):
[ee2b492]384        """
[600eca2]385        fill the combobox with analysis name
[ee2b492]386        """
[600eca2]387        self.list_of_perspective = plugin
388        if self.parent is None or \
389            not hasattr(self.parent, "get_current_perspective") or \
390            len(self.list_of_perspective) == 0:
391            return
392        if self.parent is not None and self.perspective_cbox  is not None:
393            for plug in self.list_of_perspective:
394                if plug.get_perspective():
395                    self.perspective_cbox.Append(plug.sub_menu, plug)
396           
397            curr_pers = self.parent.get_current_perspective()
398            self.perspective_cbox.SetStringSelection(curr_pers.sub_menu)
399        self.enable_import()
400                       
[3feed3e]401    def load_data_list(self, list):
[3c44c66]402        """
[c70eb7c]403        add need data with its theory under the tree
[3c44c66]404        """
[61ffd1e]405        if list:
406            for state_id, dstate in list.iteritems():
407                data = dstate.get_data()
408                theory_list = dstate.get_theory()
409                if data is not None:
[755cac4]410                    data_name = str(data.name)
[61ffd1e]411                    data_class = data.__class__.__name__
412                    path = dstate.get_path() 
413                    process_list = data.process
414                    data_id = data.id
[76703da]415                    s_path = str(path)
[61ffd1e]416                    if state_id not in self.list_cb_data:
417                        #new state
418                        data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0,
419                                                           data_name, ct_type=1, 
420                                             data=(data_id, data_class, state_id))
421                        data_c.Check(True)
422                        d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info')
423                        i_c_c = self.tree_ctrl.AppendItem(d_i_c, 
424                                                      'Type: %s' % data_class)
425                        p_c_c = self.tree_ctrl.AppendItem(d_i_c,
[603fb0f]426                                                      "Path: '%s'" % s_path)
[61ffd1e]427                        d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process')
428                       
429                        for process in process_list:
430                            i_t_c = self.tree_ctrl.AppendItem(d_p_c,
431                                                              process.__str__())
432                        theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES")
433                       
434                        self.list_cb_data[state_id] = [data_c, 
435                                                       d_i_c,
436                                                       i_c_c,
437                                                        p_c_c,
438                                                         d_p_c,
439                                                         theory_child]
440                    else:
441                        data_ctrl_list =  self.list_cb_data[state_id]
442                        #This state is already display replace it contains
443                        data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list
444                        self.tree_ctrl.SetItemText(data_c, data_name) 
445                        temp = (data_id, data_class, state_id)
446                        self.tree_ctrl.SetItemPyData(data_c, temp) 
447                        self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class)
[76703da]448                        self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % s_path) 
[61ffd1e]449                        self.tree_ctrl.DeleteChildren(d_p_c) 
450                        for process in process_list:
451                            i_t_c = self.tree_ctrl.AppendItem(d_p_c,
452                                                              process.__str__())
453                self.append_theory(state_id, theory_list)
[248b918]454        self.enable_remove()
[f7d0b74]455        self.enable_import()
456        self.enable_plot()
457        self.enable_freeze()
[61ffd1e]458        self.enable_selection()
[91bdf87]459       
[48665ed]460    def _uncheck_all(self):
461        """
462        Uncheck all check boxes
463        """
464        for item in self.list_cb_data.values():
465            data_ctrl, _, _, _,_, _ = item
466            self.tree_ctrl.CheckItem(data_ctrl, False) 
[1e3394f]467        self.enable_append()
468        self.enable_freeze()
469        self.enable_plot()
470        self.enable_import()
[248b918]471        self.enable_remove()
[600eca2]472   
[91bdf87]473    def append_theory(self, state_id, theory_list):
[bffa3d0]474        """
475        append theory object under data from a state of id = state_id
476        replace that theory if  already displayed
477        """
478        if not theory_list:
479            return 
480        if state_id not in self.list_cb_data.keys():
481            root = self.tree_ctrl_theory.root
[91bdf87]482            tree = self.tree_ctrl_theory
[bffa3d0]483        else:
484            item = self.list_cb_data[state_id]
485            data_c, _, _, _, _, _ = item
486            root = data_c
[91bdf87]487            tree = self.tree_ctrl
[bffa3d0]488        if root is not None:
[91bdf87]489             self.append_theory_helper(tree=tree, root=root, 
[bffa3d0]490                                       state_id=state_id, 
491                                       theory_list=theory_list)
492     
[71bd773]493     
[91bdf87]494    def append_theory_helper(self, tree, root, state_id, theory_list):
[71bd773]495        """
496        """
497        if state_id in self.list_cb_theory.keys():
[c70eb7c]498            #update current list of theory for this data
[71bd773]499            theory_list_ctrl = self.list_cb_theory[state_id]
[c70eb7c]500
501            for theory_id, item in theory_list.iteritems():
[e88ebfd]502                theory_data, theory_state = item
[c70eb7c]503                if theory_data is None:
504                    name = "Unknown"
505                    theory_class = "Unknown"
506                    theory_id = "Unknown"
507                    temp = (None, None, None)
508                else:
509                    name = theory_data.name
510                    theory_class = theory_data.__class__.__name__
511                    theory_id = theory_data.id
[ee2b492]512                    #if theory_state is not None:
513                    #    name = theory_state.model.name
[c70eb7c]514                    temp = (theory_id, theory_class, state_id)
515                if theory_id not in theory_list_ctrl:
516                    #add new theory
[91bdf87]517                    t_child = tree.AppendItem(root,
[c70eb7c]518                                                    name, ct_type=1, data=temp)
[91bdf87]519                    t_i_c = tree.AppendItem(t_child, 'Info')
520                    i_c_c = tree.AppendItem(t_i_c, 
[c70eb7c]521                                                  'Type: %s' % theory_class)
[91bdf87]522                    t_p_c = tree.AppendItem(t_i_c, 'Process')
[c70eb7c]523                   
524                    for process in theory_data.process:
[91bdf87]525                        i_t_c = tree.AppendItem(t_p_c,
[c70eb7c]526                                                          process.__str__())
527                    theory_list_ctrl[theory_id] = [t_child, 
528                                                   i_c_c, 
529                                                   t_p_c]
530                else:
531                    #replace theory
532                    t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id]
[91bdf87]533                    tree.SetItemText(t_child, name) 
534                    tree.SetItemPyData(t_child, temp) 
535                    tree.SetItemText(i_c_c, 'Type: %s' % theory_class) 
536                    tree.DeleteChildren(t_p_c) 
[c70eb7c]537                    for process in theory_data.process:
[91bdf87]538                        i_t_c = tree.AppendItem(t_p_c,
[c70eb7c]539                                                          process.__str__())
540             
541        else:
542            #data didn't have a theory associated it before
543            theory_list_ctrl = {}
544            for theory_id, item in theory_list.iteritems():
[e88ebfd]545                theory_data, theory_state = item
[c70eb7c]546                if theory_data is not None:
[e88ebfd]547                    name = theory_data.name
[c70eb7c]548                    theory_class = theory_data.__class__.__name__
[e88ebfd]549                    theory_id = theory_data.id
[ee2b492]550                    #if theory_state is not None:
551                    #    name = theory_state.model.name
[e88ebfd]552                    temp = (theory_id, theory_class, state_id)
[91bdf87]553                    t_child = tree.AppendItem(root,
[e88ebfd]554                            name, ct_type=1, 
[c70eb7c]555                            data=(theory_data.id, theory_class, state_id))
[91bdf87]556                    t_i_c = tree.AppendItem(t_child, 'Info')
557                    i_c_c = tree.AppendItem(t_i_c, 
[c70eb7c]558                                                  'Type: %s' % theory_class)
[91bdf87]559                    t_p_c = tree.AppendItem(t_i_c, 'Process')
[c70eb7c]560                   
561                    for process in theory_data.process:
[91bdf87]562                        i_t_c = tree.AppendItem(t_p_c,
[c70eb7c]563                                                          process.__str__())
564           
565                    theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c]
[71bd773]566                #self.list_cb_theory[data_id] = theory_list_ctrl
567                self.list_cb_theory[state_id] = theory_list_ctrl
[91bdf87]568       
[c70eb7c]569           
[ee2b492]570   
[3feed3e]571    def set_data_helper(self):
[3c44c66]572        """
573        """
[3feed3e]574        data_to_plot = []
[e88ebfd]575        state_to_plot = []
576        theory_to_plot = []
[c70eb7c]577        for value in self.list_cb_data.values():
578            item, _, _, _, _, _ = value
[3feed3e]579            if item.IsChecked():
[3658717e]580                data_id, _, state_id = self.tree_ctrl.GetItemPyData(item)
581                data_to_plot.append(data_id)
582                if state_id not in state_to_plot:
583                    state_to_plot.append(state_id)
584           
[c70eb7c]585        for theory_dict in self.list_cb_theory.values():
586            for key, value in theory_dict.iteritems():
587                item, _, _ = value
588                if item.IsChecked():
[e88ebfd]589                    theory_id, _, state_id = self.tree_ctrl.GetItemPyData(item)
[c70eb7c]590                    theory_to_plot.append(theory_id)
[e88ebfd]591                    if state_id not in state_to_plot:
592                        state_to_plot.append(state_id)
593        return data_to_plot, theory_to_plot, state_to_plot
[3feed3e]594   
[c70eb7c]595    def remove_by_id(self, id):
596        """
597        """
598        for item in self.list_cb_data.values():
599            data_c, _, _, _, _, theory_child = item
600            data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) 
601            if id == data_id:
602                self.tree_ctrl.Delete(data_c)
603                del self.list_cb_data[state_id]
604                del self.list_cb_theory[data_id]
[ae83ad3]605             
[2a62d5c]606    def load_error(self, error=None):
607        """
608        Pop up an error message.
609       
610        :param error: details error message to be displayed
611        """
[8cb8c89]612        if error is not None or str(error).strip() != "":
613            dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File',
[2a62d5c]614                                wx.OK | wx.ICON_EXCLAMATION)
[8cb8c89]615            dial.ShowModal() 
[2a62d5c]616       
617    def _load_data(self, event):
618        """
[a03d419]619        send an event to the parent to trigger load from plugin module
[2a62d5c]620        """
621        if self.parent is not None:
[a03d419]622            wx.PostEvent(self.parent, NewLoadDataEvent())
[2a62d5c]623           
[a03d419]624
[3feed3e]625    def on_remove(self, event):
[18ec684]626        """
[3658717e]627        Get a list of item checked and remove them from the treectrl
628        Ask the parent to remove reference to this item
[18ec684]629        """
[665c083]630        data_to_remove, theory_to_remove, _ = self.set_data_helper()
631        data_key = []
632        theory_key = []
[3658717e]633        #remove  data from treectrl
634        for d_key, item in self.list_cb_data.iteritems():
[665c083]635            data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = item
636            if data_c.IsChecked():
637                self.tree_ctrl.Delete(data_c)
[3658717e]638                data_key.append(d_key)
639                if d_key in self.list_cb_theory.keys():
640                    theory_list_ctrl = self.list_cb_theory[d_key]
641                    theory_to_remove += theory_list_ctrl.keys()
642        # Remove theory from treectrl       
643        for t_key, theory_dict in self.list_cb_theory.iteritems():
644            for  key, value in theory_dict.iteritems():
[665c083]645                item, _, _ = value
646                if item.IsChecked():
[e26d0db]647                    try:
648                        self.tree_ctrl.Delete(item)
649                    except:
650                        pass
[665c083]651                    theory_key.append(key)
[e26d0db]652                   
[3658717e]653        #Remove data and related theory references
[665c083]654        for key in data_key:
655            del self.list_cb_data[key]
[3658717e]656            if key in theory_key:
657                del self.list_cb_theory[key]
658        #remove theory  references independently of data
[665c083]659        for key in theory_key:
[3658717e]660            for t_key, theory_dict in self.list_cb_theory.iteritems():
[71bd773]661                if key in theory_dict:
[e26d0db]662                    for  key, value in theory_dict.iteritems():
663                        item, _, _ = value
664                        if item.IsChecked():
665                            try:
666                                self.tree_ctrl_theory.Delete(item)
667                            except:
668                                pass
[71bd773]669                    del theory_dict[key]
[e26d0db]670                   
[3658717e]671           
[18ec684]672        self.parent.remove_data(data_id=data_to_remove,
[665c083]673                                  theory_id=theory_to_remove)
[248b918]674        self.enable_remove()
[f7d0b74]675        self.enable_freeze()
[e26d0db]676        self.enable_remove_plot()
[3c44c66]677       
[3feed3e]678    def on_import(self, event=None):
[3c44c66]679        """
[3feed3e]680        Get all select data and set them to the current active perspetive
[3c44c66]681        """
[e88ebfd]682        data_id, theory_id, state_id = self.set_data_helper()
[248b918]683        temp = data_id + state_id
684        self.parent.set_data(data_id=temp, theory_id=theory_id)
[e88ebfd]685       
[213892bc]686    def on_append_plot(self, event=None):
687        """
688        append plot to plot panel on focus
689        """
[0a2fdca]690        self._on_plot_selection()
[e88ebfd]691        data_id, theory_id, state_id = self.set_data_helper()
692        self.parent.plot_data(data_id=data_id, 
693                              state_id=state_id,
694                              theory_id=theory_id,
695                              append=True)
[213892bc]696   
[3feed3e]697    def on_plot(self, event=None):
[3c44c66]698        """
[3feed3e]699        Send a list of data names to plot
[3c44c66]700        """
[e88ebfd]701        data_id, theory_id, state_id = self.set_data_helper()
702        self.parent.plot_data(data_id=data_id, 
703                              state_id=state_id,
704                              theory_id=theory_id,
705                              append=False)
[e26d0db]706        self.enable_remove_plot()
[48665ed]707         
[1b1bbf9]708    def on_close_page(self, event=None):
709        """
710        On close
711        """
712        if event != None:
713            event.Skip()
714        # send parent to update menu with no show nor hide action
715        self.parent.show_data_panel(action=False)
716   
[c70eb7c]717    def on_freeze(self, event):
718        """
719        """
[e88ebfd]720        _, theory_id, state_id = self.set_data_helper()
[ee2b492]721        self.parent.freeze(data_id=state_id, theory_id=theory_id)
[c70eb7c]722       
[3feed3e]723    def set_active_perspective(self, name):
[3c44c66]724        """
[3feed3e]725        set the active perspective
[3c44c66]726        """
[600eca2]727        self.perspective_cbox.SetStringSelection(name)
[2a62d5c]728        self.enable_import()
729       
[13a63ab]730    def _on_delete_plot_panel(self, event):
731        """
732        get an event with attribute name and caption to delete existing name
733        from the combobox of the current panel
734        """
735        name = event.name
736        caption = event.caption
737        if self.cb_plotpanel is not None:
738            pos = self.cb_plotpanel.FindString(str(caption)) 
739            if pos != wx.NOT_FOUND:
740                self.cb_plotpanel.Delete(pos)
741        self.enable_append()
742       
[83a75c5]743    def set_panel_on_focus(self, name=None):
[3c44c66]744        """
[3feed3e]745        set the plot panel on focus
[3c44c66]746        """
[0a2fdca]747        for key, value in self.parent.plot_panels.iteritems():
748            name_plot_panel = str(value.window_caption)
749            if name_plot_panel not in self.cb_plotpanel.GetItems():
750                self.cb_plotpanel.Append(name_plot_panel, value)
[83a75c5]751            if name != None and name == name_plot_panel:
752                self.cb_plotpanel.SetStringSelection(name_plot_panel)
753                break
[f7d0b74]754        self.enable_append()
[e26d0db]755        self.enable_remove_plot()
[5e8e615]756       
[600eca2]757    def _on_perspective_selection(self, event=None):
758        """
759        select the current perspective for guiframe
760        """
761        selection = self.perspective_cbox.GetSelection()
762
763        if self.perspective_cbox.GetValue() != 'None':
764            perspective = self.perspective_cbox.GetClientData(selection)
765            perspective.on_perspective(event=None)
766       
[e26d0db]767    def _on_plot_selection(self, event=None):
[0a2fdca]768        """
769        On source combobox selection
770        """
771        if event != None:
772            combo = event.GetEventObject()
[b113128]773            event.Skip()
[0a2fdca]774        else:
775            combo = self.cb_plotpanel
776        selection = combo.GetSelection()
777
778        if combo.GetValue() != 'None':
779            panel = combo.GetClientData(selection)
780            self.parent.on_set_plot_focus(panel)   
[2a62d5c]781           
[e26d0db]782    def on_close_plot(self, event):
783        """
784        clseo the panel on focus
785        """ 
786        self.enable_append()
787        selection = self.cb_plotpanel.GetSelection()
788        if self.cb_plotpanel.GetValue() != 'None':
789            panel = self.cb_plotpanel.GetClientData(selection)
790            if self.parent is not None and panel is not None:
791                wx.PostEvent(self.parent, 
792                             NewPlotEvent(group_id=panel.group_id,
793                                          action="delete"))
794        self.enable_remove_plot()
795       
796    def enable_remove_plot(self):
797        """
798        enable remove plot button if there is a plot panel on focus
799        """
[c5a769e]800        pass
801        #if self.cb_plotpanel.GetCount() == 0:
802        #    self.bt_close_plot.Disable()
803        #else:
804        #    self.bt_close_plot.Enable()
[e26d0db]805           
[2a62d5c]806    def enable_remove(self):
807        """
808        enable or disable remove button
809        """
810        n_t = self.tree_ctrl.GetCount()
811        n_t_t = self.tree_ctrl_theory.GetCount()
812        if n_t + n_t_t <= 0:
813            self.bt_remove.Disable()
814        else:
815            self.bt_remove.Enable()
816           
817    def enable_import(self):
818        """
819        enable or disable send button
820        """
[61ffd1e]821        n_t = 0
822        if self.tree_ctrl != None:
823            n_t = self.tree_ctrl.GetCount()
[600eca2]824        if n_t > 0 and len(self.list_of_perspective) > 0:
825            self.bt_import.Enable()
826        else:
[2a62d5c]827            self.bt_import.Disable()
[600eca2]828        if len(self.list_of_perspective) <= 0 or \
829            self.perspective_cbox.GetValue()  in ["None",
830                                                "No Active Application"]:
831            self.perspective_cbox.Disable()
[2a62d5c]832        else:
[600eca2]833            self.perspective_cbox.Enable()
[f7d0b74]834           
835    def enable_plot(self):
836        """
837        enable or disable plot button
838        """
[600eca2]839        n_t = 0 
840        n_t_t = 0
841        if self.tree_ctrl != None:
842            n_t = self.tree_ctrl.GetCount()
843        if self.tree_ctrl_theory != None:
844            n_t_t = self.tree_ctrl_theory.GetCount()
[f7d0b74]845        if n_t + n_t_t <= 0:
846            self.bt_plot.Disable()
847        else:
848            self.bt_plot.Enable()
[5e8e615]849        self.enable_append()
850       
[f7d0b74]851    def enable_append(self):
852        """
853        enable or disable append button
854        """
[600eca2]855        n_t = 0 
856        n_t_t = 0
857        if self.tree_ctrl != None:
858            n_t = self.tree_ctrl.GetCount()
859        if self.tree_ctrl_theory != None:
860            n_t_t = self.tree_ctrl_theory.GetCount()
861        if n_t + n_t_t <= 0: 
[f7d0b74]862            self.bt_append_plot.Disable()
[600eca2]863            self.cb_plotpanel.Disable()
[5e8e615]864        elif self.cb_plotpanel.GetCount() <= 0:
[600eca2]865                self.cb_plotpanel.Disable()
[5e8e615]866                self.bt_append_plot.Disable()
[f7d0b74]867        else:
868            self.bt_append_plot.Enable()
[df8cc63]869            self.cb_plotpanel.Enable()
[f7d0b74]870           
[1e3394f]871    def check_theory_to_freeze(self):
872        """
873        """
[f7d0b74]874    def enable_freeze(self):
875        """
876        enable or disable the freeze button
877        """
[61ffd1e]878        n_t_t = 0
879        n_l = 0
880        if self.tree_ctrl_theory != None:
881            n_t_t = self.tree_ctrl_theory.GetCount()
[f7d0b74]882        n_l = len(self.list_cb_theory)
[5e8e615]883        if (n_t_t + n_l > 0):
[f7d0b74]884            self.bt_freeze.Enable()
[1e3394f]885        else:
886            self.bt_freeze.Disable()
[f7d0b74]887       
[61ffd1e]888    def enable_selection(self):
889        """
890        enable or disable combobo box selection
891        """
892        n_t = 0
893        n_t_t = 0
894        if self.tree_ctrl != None:
895            n_t = self.tree_ctrl.GetCount()
896        if self.tree_ctrl_theory != None:
897            n_t_t = self.tree_ctrl_theory.GetCount()
898        if n_t + n_t_t > 0 and self.selection_cbox != None:
899            self.selection_cbox.Enable()
900        else:
901            self.selection_cbox.Disable()
902           
[a03d419]903    def show_data_button(self):
904        """
905        show load data and remove data button if
906        dataloader on else hide them
907        """
908        try:
909            gui_style = self.parent.get_style()
910            style = gui_style & GUIFRAME.DATALOADER_ON
911            if style == GUIFRAME.DATALOADER_ON: 
912                #self.bt_remove.Show(True)
913                self.bt_add.Show(True) 
914            else:
915                #self.bt_remove.Hide()
916                self.bt_add.Hide()
917        except: 
918            #self.bt_remove.Hide()
919            self.bt_add.Hide() 
[e26d0db]920   
[60fff67]921
922
923WIDTH = 400
924HEIGHT = 300
925
926
927class DataDialog(wx.Dialog):
928    """
929    Allow file selection at loading time
930    """
931    def __init__(self, data_list, parent=None, text='', *args, **kwds):
932        wx.Dialog.__init__(self, parent, *args, **kwds)
933        self.SetTitle("Data Selection")
934        self.SetSize((WIDTH, HEIGHT))
935        self.list_of_ctrl = []
936        if not data_list:
937            return 
938        self._sizer_main = wx.BoxSizer(wx.VERTICAL)
939        self._sizer_txt = wx.BoxSizer(wx.VERTICAL)
940        self._sizer_button = wx.BoxSizer(wx.HORIZONTAL)
941        self.sizer = wx.GridBagSizer(5, 5)
942        self._panel = ScrolledPanel(self, style=wx.RAISED_BORDER,
943                               size=(WIDTH-20, HEIGHT-50))
944        self._panel.SetupScrolling()
945        self.__do_layout(data_list, text=text)
946       
947    def __do_layout(self, data_list, text=''):
948        """
949        layout the dialog
950        """
951        if not data_list or len(data_list) <= 1:
952            return 
953        #add text
954       
955        text = "Deleting these file reset some panels.\n"
956        text += "Do you want to proceed?\n"
957        text_ctrl = wx.StaticText(self, -1, str(text))
958        self._sizer_txt.Add(text_ctrl)
959        iy = 0
960        ix = 0
961        data_count = 0
962        for (data_name, in_use, sub_menu) in range(len(data_list)):
963            if in_use == True:
964                ctrl_name = wx.StaticBox(self, -1, str(data_name))
965                ctrl_in_use = wx.StaticBox(self, -1, " is used by ")
966                plug_name = str(sub_menu) + "\n"
967                ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)
968                self.sizer.Add(ctrl_name, (iy, ix),
969                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
970                ix += 1
971                self._sizer_button.Add(ctrl_in_use, 1,
972                                        wx.EXPAND|wx.ADJUST_MINSIZE, 0)
973                ix += 1
974                self._sizer_button.Add(plug_name, 1,
975                                        wx.EXPAND|wx.ADJUST_MINSIZE, 0)
976            iy += 1
977        self._panel.SetSizer(self.sizer)
978        #add sizer
979        self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
980        button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
981        self._sizer_button.Add(button_cancel, 0,
982                          wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
983        button_OK = wx.Button(self, wx.ID_OK, "Ok")
984        button_OK.SetFocus()
985        self._sizer_button.Add(button_OK, 0,
986                                wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
987        static_line = wx.StaticLine(self, -1)
988       
989        self._sizer_txt.Add(self._panel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
990        self._sizer_main.Add(self._sizer_txt, 1, wx.EXPAND|wx.ALL, 10)
991        self._sizer_main.Add(self._data_text_ctrl, 0, 
992                             wx.EXPAND|wx.LEFT|wx.RIGHT, 10)
993        self._sizer_main.Add(static_line, 0, wx.EXPAND, 0)
994        self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10)
995        self.SetSizer(self._sizer_main)
996        self.Layout()
997       
998    def get_data(self):
999        """
1000        return the selected data
1001        """
1002        temp = []
1003        for item in self.list_of_ctrl:
1004            cb, data = item
1005            if cb.GetValue():
1006                temp.append(data)
1007        return temp
1008   
1009    def _count_selected_data(self, event):
1010        """
1011        count selected data
1012        """
1013        if event.GetEventObject().GetValue():
1014            self._nb_selected_data += 1
1015        else:
1016            self._nb_selected_data -= 1
1017        select_data_text = " %s Data selected.\n" % str(self._nb_selected_data)
1018        self._data_text_ctrl.SetLabel(select_data_text)
1019        if self._nb_selected_data <= self._max_data:
1020            self._data_text_ctrl.SetForegroundColour('blue')
1021        else:
1022            self._data_text_ctrl.SetForegroundColour('red')
1023       
1024                 
[f7d0b74]1025       
[3c44c66]1026class DataFrame(wx.Frame):
[3feed3e]1027    ## Internal name for the AUI manager
1028    window_name = "Data Panel"
1029    ## Title to appear on top of the window
1030    window_caption = "Data Panel"
1031    ## Flag to tell the GUI manager that this panel is not
1032    #  tied to any perspective
1033    ALWAYS_ON = True
1034   
[ea4dfe0]1035    def __init__(self, parent=None, owner=None, manager=None,size=(300, 800),
[3feed3e]1036                         list_of_perspective=[],list=[], *args, **kwds):
[cc061c3]1037        kwds['size'] = size
[3c44c66]1038        kwds['id'] = -1
[3feed3e]1039        kwds['title']= "Loaded Data"
[3c44c66]1040        wx.Frame.__init__(self, parent=parent, *args, **kwds)
1041        self.parent = parent
1042        self.owner = owner
1043        self.manager = manager
[32c0841]1044        self.panel = DataPanel(parent=self, 
[cc061c3]1045                               #size=size,
[32c0841]1046                               list_of_perspective=list_of_perspective)
[3feed3e]1047     
1048    def load_data_list(self, list=[]):
[3c44c66]1049        """
1050        Fill the list inside its panel
1051        """
[3feed3e]1052        self.panel.load_data_list(list=list)
[3c44c66]1053       
[5e8e615]1054   
[3feed3e]1055   
1056from dataFitting import Data1D
1057from dataFitting import Data2D, Theory1D
1058from data_state import DataState
1059import sys
1060class State():
1061    def __init__(self):
1062        self.msg = ""
1063    def __str__(self):
1064        self.msg = "model mane : model1\n"
1065        self.msg += "params : \n"
1066        self.msg += "name  value\n"
1067        return msg
[71bd773]1068def set_data_state(data=None, path=None, theory=None, state=None):
[3feed3e]1069    dstate = DataState(data=data)
1070    dstate.set_path(path=path)
[c70eb7c]1071    dstate.set_theory(theory, state)
1072 
[3feed3e]1073    return dstate
1074"""'
1075data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"),
1076            ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"),
1077            ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"),
1078            ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"),
1079            ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")]
1080"""     
[3c44c66]1081if __name__ == "__main__":
[3feed3e]1082   
[3c44c66]1083    app = wx.App()
[3feed3e]1084    try:
1085        list_of_perspective = [('perspective2', False), ('perspective1', True)]
1086        data_list = {}
[c70eb7c]1087        # state 1
[ee2b492]1088        data = Data2D()
1089        data.name = "data2"
[584c4c4]1090        data.id = 1
[c70eb7c]1091        data.append_empty_process()
1092        process = data.process[len(data.process)-1]
1093        process.data = "07/01/2010"
[ee2b492]1094        theory = Data2D()
[584c4c4]1095        theory.id = 34
[c70eb7c]1096        theory.name = "theory1"
[3feed3e]1097        path = "path1"
1098        state = State()
1099        data_list['1']=set_data_state(data, path,theory, state)
[c70eb7c]1100        #state 2
[ee2b492]1101        data = Data2D()
[3feed3e]1102        data.name = "data2"
[584c4c4]1103        data.id = 76
[ee2b492]1104        theory = Data2D()
[584c4c4]1105        theory.id = 78
[3feed3e]1106        theory.name = "CoreShell 07/24/25"
1107        path = "path2"
[c70eb7c]1108        #state3
[3feed3e]1109        state = State()
1110        data_list['2']=set_data_state(data, path,theory, state)
1111        data = Data1D()
[584c4c4]1112        data.id = 3
[3feed3e]1113        data.name = "data2"
1114        theory = Theory1D()
1115        theory.name = "CoreShell"
[584c4c4]1116        theory.id = 4
[c70eb7c]1117        theory.append_empty_process()
1118        process = theory.process[len(theory.process)-1]
1119        process.description = "this is my description"
[3feed3e]1120        path = "path3"
[c70eb7c]1121        data.append_empty_process()
1122        process = data.process[len(data.process)-1]
1123        process.data = "07/22/2010"
[3feed3e]1124        data_list['4']=set_data_state(data, path,theory, state)
[c70eb7c]1125        #state 4
1126        temp_data_list = {}
1127        data.name = "data5 erasing data2"
1128        temp_data_list['4'] = set_data_state(data, path,theory, state)
1129        #state 5
[3feed3e]1130        data = Data2D()
1131        data.name = "data3"
[584c4c4]1132        data.id = 5
[c70eb7c]1133        data.append_empty_process()
1134        process = data.process[len(data.process)-1]
1135        process.data = "07/01/2010"
[3feed3e]1136        theory = Theory1D()
[c70eb7c]1137        theory.name = "Cylinder"
[3feed3e]1138        path = "path2"
1139        state = State()
1140        dstate= set_data_state(data, path,theory, state)
1141        theory = Theory1D()
[584c4c4]1142        theory.id = 6
[c70eb7c]1143        theory.name = "CoreShell"
1144        dstate.set_theory(theory)
1145        theory = Theory1D()
1146        theory.id = 6
1147        theory.name = "CoreShell replacing coreshell in data3"
[3feed3e]1148        dstate.set_theory(theory)
[c70eb7c]1149        data_list['3'] = dstate
1150        #state 6
1151        data_list['6']=set_data_state(None, path,theory, state)
[71bd773]1152        data_list['6']=set_data_state(theory=theory, state=None)
1153        theory = Theory1D()
1154        theory.id = 7
1155        data_list['6']=set_data_state(theory=theory, state=None)
1156        data_list['7']=set_data_state(theory=theory, state=None)
[3feed3e]1157        window = DataFrame(list=data_list)
[c70eb7c]1158        window.load_data_list(list=data_list)
[3feed3e]1159        window.Show(True)
[c70eb7c]1160        window.load_data_list(list=temp_data_list)
[3feed3e]1161    except:
1162        #raise
1163        print "error",sys.exc_value
[c70eb7c]1164       
[3c44c66]1165    app.MainLoop() 
1166   
1167   
Note: See TracBrowser for help on using the repository browser.