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