source: sasview/guiframe/data_panel.py @ 70114ff9

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 70114ff9 was 603fb0f, checked in by Jae Cho <jhjcho@…>, 13 years ago

more constrained path string

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