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 wx |
---|
14 | import sys |
---|
15 | import warnings |
---|
16 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
17 | import wx.lib.agw.customtreectrl as CT |
---|
18 | from sans.guiframe.dataFitting import Data1D |
---|
19 | from sans.guiframe.dataFitting import Data2D |
---|
20 | |
---|
21 | PANEL_WIDTH = 200 |
---|
22 | |
---|
23 | class DataTreeCtrl(CT.CustomTreeCtrl): |
---|
24 | """ |
---|
25 | Check list control to be used for Data Panel |
---|
26 | """ |
---|
27 | def __init__(self, parent, size=(PANEL_WIDTH, 200), *args, **kwds): |
---|
28 | kwds['style']= wx.SUNKEN_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT| \ |
---|
29 | CT.TR_HAS_VARIABLE_ROW_HEIGHT|wx.WANTS_CHARS |
---|
30 | kwds['size'] = size |
---|
31 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
32 | self.root = self.AddRoot("Available Data") |
---|
33 | |
---|
34 | class DataPanel(ScrolledPanel): |
---|
35 | """ |
---|
36 | This panel displays data available in the application and widgets to |
---|
37 | interact with data. |
---|
38 | """ |
---|
39 | ## Internal name for the AUI manager |
---|
40 | window_name = "Data Panel" |
---|
41 | ## Title to appear on top of the window |
---|
42 | window_caption = "Data Panel" |
---|
43 | #type of window |
---|
44 | window_type = "Data Panel" |
---|
45 | ## Flag to tell the GUI manager that this panel is not |
---|
46 | # tied to any perspective |
---|
47 | #ALWAYS_ON = True |
---|
48 | def __init__(self, parent, list=[],list_of_perspective=[], |
---|
49 | size=(PANEL_WIDTH,560), manager=None, *args, **kwds): |
---|
50 | kwds['size']= size |
---|
51 | ScrolledPanel.__init__(self, parent=parent, *args, **kwds) |
---|
52 | self.SetupScrolling() |
---|
53 | |
---|
54 | self.parent = parent |
---|
55 | self.manager = manager |
---|
56 | self.list_of_data = list |
---|
57 | self.list_of_perspective = list_of_perspective |
---|
58 | self.list_rb_perspectives= [] |
---|
59 | self.list_cb_data =[] |
---|
60 | self.list_cb_theory =[] |
---|
61 | self.owner = None |
---|
62 | self.do_layout() |
---|
63 | #self._default_data1d = Data1D() |
---|
64 | #self._default_data1d.set_default_data() |
---|
65 | #self._default_data2d = Data2D() |
---|
66 | #self._default_data2d.set_default_data() |
---|
67 | #data_list =[] |
---|
68 | #data_list.append((self._default_data1d, None,None, None)) |
---|
69 | #data_list.append((self._default_data2d, None,None, None)) |
---|
70 | #if self.manager is not None: |
---|
71 | # self.manager.set_loaded_data(data_list) |
---|
72 | # list = self.manager.get_selected_data() |
---|
73 | # self.load_data_list(list) |
---|
74 | def do_layout(self): |
---|
75 | self.define_panel_structure() |
---|
76 | self.layout_selection() |
---|
77 | self.layout_list() |
---|
78 | self.layout_button() |
---|
79 | self.layout_batch() |
---|
80 | |
---|
81 | def define_panel_structure(self): |
---|
82 | """ |
---|
83 | Define the skeleton of the panel |
---|
84 | """ |
---|
85 | print self.parent.GetSize(), self.GetSize() |
---|
86 | w, h = self.parent.GetSize() |
---|
87 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
88 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
89 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
90 | self.sizer3 = wx.GridBagSizer(5,5) |
---|
91 | self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) |
---|
92 | self.sizer5 = wx.BoxSizer(wx.HORIZONTAL) |
---|
93 | self.sizer3.SetMinSize((w-60, -1)) |
---|
94 | |
---|
95 | self.vbox.Add(self.sizer5, 0,wx.EXPAND|wx.ALL,10) |
---|
96 | self.vbox.Add(self.sizer1, 0,wx.EXPAND|wx.ALL,0) |
---|
97 | self.vbox.Add(self.sizer2, 0,wx.EXPAND|wx.ALL,10) |
---|
98 | self.vbox.Add(self.sizer3, 0,wx.EXPAND|wx.ALL,10) |
---|
99 | self.vbox.Add(self.sizer4, 0,wx.EXPAND|wx.ALL,10) |
---|
100 | |
---|
101 | self.SetSizer(self.vbox) |
---|
102 | |
---|
103 | def layout_selection(self): |
---|
104 | """ |
---|
105 | """ |
---|
106 | select_txt = wx.StaticText(self, -1, 'Selection Options') |
---|
107 | self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
108 | list_of_options = ['Select all Data', |
---|
109 | 'Unselect all Data', |
---|
110 | 'Select all Data 1D', |
---|
111 | 'Unselect all Data 1D', |
---|
112 | 'Select all Data 2D', |
---|
113 | 'Unselect all Data 2D' ] |
---|
114 | for option in list_of_options: |
---|
115 | self.selection_cbox.Append(str(option)) |
---|
116 | self.selection_cbox.SetValue('None') |
---|
117 | wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type) |
---|
118 | self.sizer5.AddMany([(select_txt,0, wx.ALL,5), |
---|
119 | (self.selection_cbox,0, wx.ALL,5)]) |
---|
120 | def layout_perspective(self, list_of_perspective=[]): |
---|
121 | """ |
---|
122 | Layout widgets related to the list of plug-ins of the gui_manager |
---|
123 | """ |
---|
124 | if len(list_of_perspective)==0: |
---|
125 | return |
---|
126 | w, h = self.parent.GetSize() |
---|
127 | box_description_2= wx.StaticBox(self, -1, "Set Active Perspective") |
---|
128 | self.boxsizer_2 = wx.StaticBoxSizer(box_description_2, wx.HORIZONTAL) |
---|
129 | self.boxsizer_2.SetMinSize((w-60, -1)) |
---|
130 | self.sizer_perspective = wx.GridBagSizer(5,5) |
---|
131 | self.boxsizer_2.Add(self.sizer_perspective) |
---|
132 | self.sizer2.Add(self.boxsizer_2,1, wx.ALL, 10) |
---|
133 | self.list_of_perspective = list_of_perspective |
---|
134 | self.sizer_perspective.Clear(True) |
---|
135 | self.list_rb_perspectives = [] |
---|
136 | |
---|
137 | nb_active_perspective = 0 |
---|
138 | if list_of_perspective: |
---|
139 | ix = 0 |
---|
140 | iy = 0 |
---|
141 | for perspective_name, is_active in list_of_perspective: |
---|
142 | |
---|
143 | if is_active: |
---|
144 | nb_active_perspective += 1 |
---|
145 | if nb_active_perspective == 1: |
---|
146 | rb = wx.RadioButton(self, -1, perspective_name, style=wx.RB_GROUP) |
---|
147 | rb.SetToolTipString("Data will be applied to this perspective") |
---|
148 | rb.SetValue(is_active) |
---|
149 | else: |
---|
150 | rb = wx.RadioButton(self, -1, perspective_name) |
---|
151 | rb.SetToolTipString("Data will be applied to this perspective") |
---|
152 | #only one perpesctive can be active |
---|
153 | rb.SetValue(False) |
---|
154 | |
---|
155 | self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective, |
---|
156 | id=rb.GetId()) |
---|
157 | self.list_rb_perspectives.append(rb) |
---|
158 | self.sizer_perspective.Add(rb,(iy, ix),(1,1), |
---|
159 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
160 | iy += 1 |
---|
161 | else: |
---|
162 | rb = wx.RadioButton(self, -1, 'No Perspective', |
---|
163 | style=wx.RB_GROUP) |
---|
164 | rb.SetValue(True) |
---|
165 | rb.Disable() |
---|
166 | ix = 0 |
---|
167 | iy = 0 |
---|
168 | self.sizer_perspective.Add(rb,(iy, ix),(1,1), |
---|
169 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
170 | |
---|
171 | def _on_selection_type(self, event): |
---|
172 | """ |
---|
173 | Select data according to patterns |
---|
174 | """ |
---|
175 | option = self.selection_cbox.GetValue() |
---|
176 | if option == 'Select all Data': |
---|
177 | #for item in self.tree_ctrl. |
---|
178 | print "_on_selection_type" |
---|
179 | def on_set_active_perspective(self, event): |
---|
180 | """ |
---|
181 | Select the active perspective |
---|
182 | """ |
---|
183 | ctrl = event.GetEventObject() |
---|
184 | |
---|
185 | def layout_button(self): |
---|
186 | """ |
---|
187 | Layout widgets related to buttons |
---|
188 | """ |
---|
189 | self.bt_import = wx.Button(self, wx.NewId(), "Send To") |
---|
190 | self.bt_import.SetToolTipString("Send set of Data to active perspective") |
---|
191 | wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) |
---|
192 | |
---|
193 | self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To") |
---|
194 | self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") |
---|
195 | wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) |
---|
196 | |
---|
197 | self.bt_plot = wx.Button(self, wx.NewId(), "New Plot") |
---|
198 | self.bt_plot.SetToolTipString("To trigger plotting") |
---|
199 | wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) |
---|
200 | |
---|
201 | self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data") |
---|
202 | self.bt_remove.SetToolTipString("Delete data from the application") |
---|
203 | wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) |
---|
204 | |
---|
205 | self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application') |
---|
206 | self.tctrl_perspective.SetToolTipString("Active Application") |
---|
207 | self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus') |
---|
208 | self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") |
---|
209 | #self.sizer3.AddMany([(self.bt_import,0, wx.ALL,5), |
---|
210 | # (self.bt_append_plot,0, wx.ALL,5), |
---|
211 | # (self.bt_plot, 0, wx.ALL,5), |
---|
212 | # (self.bt_remove,0, wx.ALL,5)]) |
---|
213 | ix = 0 |
---|
214 | iy = 0 |
---|
215 | self.sizer3.Add(self.bt_import,( iy, ix),(1,1), |
---|
216 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
217 | ix += 1 |
---|
218 | self.sizer3.Add(self.tctrl_perspective,(iy, ix),(1,1), |
---|
219 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
220 | ix = 0 |
---|
221 | iy += 1 |
---|
222 | self.sizer3.Add(self.bt_append_plot,( iy, ix),(1,1), |
---|
223 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
224 | ix += 1 |
---|
225 | self.sizer3.Add(self.tctrl_plotpanel,(iy, ix),(1,1), |
---|
226 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
227 | ix = 0 |
---|
228 | iy += 1 |
---|
229 | self.sizer3.Add(self.bt_plot,( iy, ix),(1,1), |
---|
230 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
231 | ix = 0 |
---|
232 | iy += 1 |
---|
233 | self.sizer3.Add(self.bt_remove,( iy, ix),(1,1), |
---|
234 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
235 | |
---|
236 | |
---|
237 | def layout_batch(self): |
---|
238 | """ |
---|
239 | """ |
---|
240 | |
---|
241 | self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', |
---|
242 | style=wx.RB_GROUP) |
---|
243 | self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') |
---|
244 | |
---|
245 | self.rb_single_mode.SetValue(True) |
---|
246 | self.rb_batch_mode.SetValue(False) |
---|
247 | self.sizer4.AddMany([(self.rb_single_mode,0, wx.ALL,5), |
---|
248 | (self.rb_batch_mode,0, wx.ALL,5)]) |
---|
249 | |
---|
250 | def layout_list(self): |
---|
251 | """ |
---|
252 | Add a listcrtl in the panel |
---|
253 | """ |
---|
254 | w, h = self.GetSize() |
---|
255 | self.tree_ctrl = DataTreeCtrl(parent=self, size=(w-10, -1)) |
---|
256 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKED, self.on_check_item) |
---|
257 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click) |
---|
258 | self.sizer1.Add(self.tree_ctrl,0, wx.EXPAND|wx.ALL, 20) |
---|
259 | |
---|
260 | def on_right_click(self, event): |
---|
261 | """ |
---|
262 | """ |
---|
263 | ## Create context menu for data |
---|
264 | self.popUpMenu = wx.Menu() |
---|
265 | msg = "Edit %s"%str(self.tree_ctrl.GetItemText(event.GetItem())) |
---|
266 | id = wx.NewId() |
---|
267 | self.edit_data_mitem = wx.MenuItem(self.popUpMenu,id,msg, |
---|
268 | "Edit meta data") |
---|
269 | wx.EVT_MENU(self, id, self.on_edit_data) |
---|
270 | self.popUpMenu.AppendItem(self.edit_data_mitem) |
---|
271 | self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) |
---|
272 | |
---|
273 | def on_edit_data(self, event): |
---|
274 | """ |
---|
275 | """ |
---|
276 | print "editing data" |
---|
277 | |
---|
278 | def onContextMenu(self, event): |
---|
279 | """ |
---|
280 | Retrieve the state selected state |
---|
281 | """ |
---|
282 | # Skipping the save state functionality for release 0.9.0 |
---|
283 | #return |
---|
284 | pos = event.GetPosition() |
---|
285 | pos = self.ScreenToClient(pos) |
---|
286 | self.PopupMenu(self.popUpMenu, pos) |
---|
287 | |
---|
288 | def on_check_item(self, event): |
---|
289 | """ |
---|
290 | """ |
---|
291 | item = event.GetItem() |
---|
292 | name = self.tree_ctrl.GetItemText(item) |
---|
293 | |
---|
294 | def load_data_list(self, list): |
---|
295 | """ |
---|
296 | |
---|
297 | """ |
---|
298 | if not list: |
---|
299 | return |
---|
300 | |
---|
301 | for dstate in list.values(): |
---|
302 | data = dstate.get_data() |
---|
303 | if data is None: |
---|
304 | data_name = str(data) |
---|
305 | data_class = "unkonwn" |
---|
306 | else: |
---|
307 | data_name = data.name |
---|
308 | data_class = data.__class__.__name__ |
---|
309 | path = dstate.get_path() |
---|
310 | theory_list = dstate.get_theory() |
---|
311 | theory = None |
---|
312 | if theory_list: |
---|
313 | theory = theory_list[len(theory_list)-1] |
---|
314 | data_child = None |
---|
315 | for item in self.list_cb_data: |
---|
316 | if self.tree_ctrl.GetItemText(item) == data_name: |
---|
317 | data_child = item |
---|
318 | for process in data.process: |
---|
319 | theory_child = self.tree_ctrl.FindItem(data_child, |
---|
320 | "Available Theories")#, |
---|
321 | if theory is not None: |
---|
322 | av_theory_child =self.tree_ctrl.AppendItem(theory_child, |
---|
323 | theory.name,ct_type=1, data=theory.id) |
---|
324 | self.list_cb_theory.append(av_theory_child) |
---|
325 | av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, |
---|
326 | 'info') |
---|
327 | for process in theory.process: |
---|
328 | info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, |
---|
329 | process.__str__()) |
---|
330 | |
---|
331 | break |
---|
332 | if data_child is None: |
---|
333 | data_child =self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, |
---|
334 | data_name,ct_type=1, data=data.id) |
---|
335 | cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root) |
---|
336 | item, id = cb_data |
---|
337 | item.Check(True) |
---|
338 | self.list_cb_data.append(item) |
---|
339 | data_info_child =self.tree_ctrl.AppendItem(data_child, 'info')#, |
---|
340 | #wnd=data_info_txt) |
---|
341 | info_class_child =self.tree_ctrl.AppendItem(data_info_child, |
---|
342 | 'Type: %s'%data_class) |
---|
343 | path_class_child =self.tree_ctrl.AppendItem(data_info_child, |
---|
344 | 'Path: %s'%str(path)) |
---|
345 | for process in data.process: |
---|
346 | info_time_child =self.tree_ctrl.AppendItem(data_info_child,process.__str__()) |
---|
347 | theory_child =self.tree_ctrl.AppendItem(data_child, "Available Theories") |
---|
348 | |
---|
349 | if theory_list: |
---|
350 | theory = theory_list[len(theory_list)-1] |
---|
351 | if theory is not None: |
---|
352 | av_theory_child =self.tree_ctrl.AppendItem(theory_child, |
---|
353 | theory.name,ct_type=1) |
---|
354 | self.list_cb_theory.append(av_theory_child) |
---|
355 | av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, |
---|
356 | 'info') |
---|
357 | for process in theory.process: |
---|
358 | info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, |
---|
359 | process.__str__()) |
---|
360 | |
---|
361 | def set_data_helper(self): |
---|
362 | """ |
---|
363 | """ |
---|
364 | data_to_plot = [] |
---|
365 | for item in self.list_cb_data: |
---|
366 | if item.IsChecked(): |
---|
367 | |
---|
368 | data_to_plot.append(self.tree_ctrl.GetItemPyData(item)) |
---|
369 | theory_to_plot = [] |
---|
370 | for item in self.list_cb_theory: |
---|
371 | if item.IsChecked(): |
---|
372 | theory_to_plot.append(self.tree_ctrl.GetItemPyData(item)) |
---|
373 | return data_to_plot, theory_to_plot |
---|
374 | |
---|
375 | def on_remove(self, event): |
---|
376 | data_to_remove, theory_to_remove = self.set_data_helper() |
---|
377 | for item in self.list_cb_data: |
---|
378 | if item.IsChecked()and \ |
---|
379 | self.tree_ctrl.GetItemText(item) in data_to_remove: |
---|
380 | self.tree_ctrl.Delete(item) |
---|
381 | for item in self.list_cb_theory: |
---|
382 | if item.IsChecked()and \ |
---|
383 | self.tree_ctrl.GetItemText(item) in theory_to_remove: |
---|
384 | self.tree_ctrl.Delete(item) |
---|
385 | delete_all = False |
---|
386 | if data_to_remove: |
---|
387 | delete_all = True |
---|
388 | self.parent.delete_data(data_id=data_to_remove, |
---|
389 | theory_id=theory_to_remove, |
---|
390 | delete_all=delete_all) |
---|
391 | |
---|
392 | def on_import(self, event=None): |
---|
393 | """ |
---|
394 | Get all select data and set them to the current active perspetive |
---|
395 | """ |
---|
396 | self.post_helper(plot=False) |
---|
397 | |
---|
398 | def on_append_plot(self, event=None): |
---|
399 | """ |
---|
400 | append plot to plot panel on focus |
---|
401 | """ |
---|
402 | self.post_helper(plot=True, append=True) |
---|
403 | |
---|
404 | def on_plot(self, event=None): |
---|
405 | """ |
---|
406 | Send a list of data names to plot |
---|
407 | """ |
---|
408 | self.post_helper(plot=True) |
---|
409 | |
---|
410 | def set_active_perspective(self, name): |
---|
411 | """ |
---|
412 | set the active perspective |
---|
413 | """ |
---|
414 | self.tctrl_perspective.SetLabel(str(name)) |
---|
415 | |
---|
416 | def set_panel_on_focus(self, name): |
---|
417 | """ |
---|
418 | set the plot panel on focus |
---|
419 | """ |
---|
420 | self.tctrl_plotpanel.SetLabel(str(name)) |
---|
421 | |
---|
422 | def post_helper(self, plot=False, append=False): |
---|
423 | """ |
---|
424 | """ |
---|
425 | data_to_plot, theory_to_plot = self.set_data_helper() |
---|
426 | |
---|
427 | if self.parent is not None: |
---|
428 | self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot, |
---|
429 | append=append) |
---|
430 | |
---|
431 | |
---|
432 | class DataFrame(wx.Frame): |
---|
433 | ## Internal name for the AUI manager |
---|
434 | window_name = "Data Panel" |
---|
435 | ## Title to appear on top of the window |
---|
436 | window_caption = "Data Panel" |
---|
437 | ## Flag to tell the GUI manager that this panel is not |
---|
438 | # tied to any perspective |
---|
439 | ALWAYS_ON = True |
---|
440 | |
---|
441 | def __init__(self, parent=None, owner=None, manager=None,size=(600, 600), |
---|
442 | list_of_perspective=[],list=[], *args, **kwds): |
---|
443 | #kwds['size'] = size |
---|
444 | kwds['id'] = -1 |
---|
445 | kwds['title']= "Loaded Data" |
---|
446 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
447 | self.parent = parent |
---|
448 | self.owner = owner |
---|
449 | self.manager = manager |
---|
450 | self.panel = DataPanel(parent=self, |
---|
451 | size=size, |
---|
452 | list_of_perspective=list_of_perspective) |
---|
453 | |
---|
454 | def load_data_list(self, list=[]): |
---|
455 | """ |
---|
456 | Fill the list inside its panel |
---|
457 | """ |
---|
458 | self.panel.load_data_list(list=list) |
---|
459 | |
---|
460 | def layout_perspective(self, list_of_perspective=[]): |
---|
461 | """ |
---|
462 | """ |
---|
463 | self.panel.layout_perspective(list_of_perspective=list_of_perspective) |
---|
464 | |
---|
465 | |
---|
466 | from dataFitting import Data1D |
---|
467 | from dataFitting import Data2D, Theory1D |
---|
468 | from data_state import DataState |
---|
469 | import sys |
---|
470 | class State(): |
---|
471 | def __init__(self): |
---|
472 | self.msg = "" |
---|
473 | def __str__(self): |
---|
474 | self.msg = "model mane : model1\n" |
---|
475 | self.msg += "params : \n" |
---|
476 | self.msg += "name value\n" |
---|
477 | return msg |
---|
478 | def set_data_state(data, path, theory, state): |
---|
479 | dstate = DataState(data=data) |
---|
480 | dstate.set_path(path=path) |
---|
481 | dstate.set_theory(theory) |
---|
482 | dstate.set_state(state) |
---|
483 | return dstate |
---|
484 | """' |
---|
485 | data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), |
---|
486 | ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), |
---|
487 | ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), |
---|
488 | ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), |
---|
489 | ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] |
---|
490 | """ |
---|
491 | if __name__ == "__main__": |
---|
492 | |
---|
493 | app = wx.App() |
---|
494 | try: |
---|
495 | list_of_perspective = [('perspective2', False), ('perspective1', True)] |
---|
496 | data_list = {} |
---|
497 | data = Data1D() |
---|
498 | data.name = "data1" |
---|
499 | data.id = 1 |
---|
500 | #data.append_process() |
---|
501 | #process = data.process[len(data.process)-1] |
---|
502 | #process.data = "07/01/2010" |
---|
503 | theory = Theory1D() |
---|
504 | theory.id = 34 |
---|
505 | theory.pseudo_name = "theory1" |
---|
506 | path = "path1" |
---|
507 | state = State() |
---|
508 | data_list['1']=set_data_state(data, path,theory, state) |
---|
509 | |
---|
510 | data = Data1D() |
---|
511 | data.name = "data2" |
---|
512 | data.id = 76 |
---|
513 | theory = Theory1D() |
---|
514 | theory.id = 78 |
---|
515 | theory.name = "CoreShell 07/24/25" |
---|
516 | theory.pseudo_name = "CoreShell" |
---|
517 | path = "path2" |
---|
518 | state = State() |
---|
519 | data_list['2']=set_data_state(data, path,theory, state) |
---|
520 | data = Data1D() |
---|
521 | data.id = 3 |
---|
522 | data.name = "data2" |
---|
523 | theory = Theory1D() |
---|
524 | theory.name = "CoreShell" |
---|
525 | theory.pseudo_name = "CoreShell" |
---|
526 | theory.id = 4 |
---|
527 | #theory.append_process() |
---|
528 | #process = theory.process[len(theory.process)-1] |
---|
529 | #process.description = "this is my description" |
---|
530 | path = "path3" |
---|
531 | #data.append_process() |
---|
532 | #process = data.process[len(data.process)-1] |
---|
533 | #process.data = "07/22/2010" |
---|
534 | data_list['4']=set_data_state(data, path,theory, state) |
---|
535 | |
---|
536 | data = Data2D() |
---|
537 | data.name = "data3" |
---|
538 | data.id = 5 |
---|
539 | #data.append_process() |
---|
540 | #process = data.process[len(data.process)-1] |
---|
541 | #process.data = "07/01/2010" |
---|
542 | theory = Theory1D() |
---|
543 | theory.pseudo_name = "Cylinder" |
---|
544 | path = "path2" |
---|
545 | state = State() |
---|
546 | dstate= set_data_state(data, path,theory, state) |
---|
547 | theory = Theory1D() |
---|
548 | theory.id = 6 |
---|
549 | theory.pseudo_name = "Sphere" |
---|
550 | dstate.set_theory(theory) |
---|
551 | data_list['3']=dstate |
---|
552 | |
---|
553 | window = DataFrame(list=data_list) |
---|
554 | window.load_data_list(list=data_list) |
---|
555 | window.layout_perspective(list_of_perspective=list_of_perspective) |
---|
556 | window.Show(True) |
---|
557 | except: |
---|
558 | #raise |
---|
559 | print "error",sys.exc_value |
---|
560 | app.MainLoop() |
---|
561 | |
---|
562 | |
---|