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