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