source: sasview/guiframe/data_panel.py @ 7a8faf8

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 7a8faf8 was c0a690c, checked in by Gervaise Alina <gervyh@…>, 13 years ago

remove unused code

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