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_import.SetToolTipString("Plot the selected data in the active panel") |
---|
195 | #wx.EVT_BUTTON(self, self.bt_import.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, 'Plot panel on focus') |
---|
208 | self.tctrl_plotpanel.SetToolTipString("Active Plotting 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 | print "list", list |
---|
299 | if not list: |
---|
300 | return |
---|
301 | |
---|
302 | for dstate in list.values(): |
---|
303 | data = dstate.get_data() |
---|
304 | if data is None: |
---|
305 | data_name = str(data) |
---|
306 | data_class = "unkonwn" |
---|
307 | else: |
---|
308 | data_name = data.name |
---|
309 | data_class = data.__class__.__name__ |
---|
310 | path = dstate.get_path() |
---|
311 | theory_list = dstate.get_theory() |
---|
312 | theory = None |
---|
313 | if theory_list: |
---|
314 | theory = theory_list[len(theory_list)-1] |
---|
315 | data_child = None |
---|
316 | for item in self.list_cb_data: |
---|
317 | if self.tree_ctrl.GetItemText(item) == data_name: |
---|
318 | data_child = item |
---|
319 | for process in data.process: |
---|
320 | theory_child = self.tree_ctrl.FindItem(data_child, |
---|
321 | "Available Theories")#, |
---|
322 | if theory is not None: |
---|
323 | av_theory_child =self.tree_ctrl.AppendItem(theory_child, |
---|
324 | theory.name,ct_type=1, data=theory.id) |
---|
325 | self.list_cb_theory.append(av_theory_child) |
---|
326 | av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, |
---|
327 | 'info') |
---|
328 | for process in theory.process: |
---|
329 | info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, |
---|
330 | process.__str__()) |
---|
331 | |
---|
332 | break |
---|
333 | if data_child is None: |
---|
334 | data_child =self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, |
---|
335 | data_name,ct_type=1, data=data.id) |
---|
336 | cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root) |
---|
337 | item, id = cb_data |
---|
338 | item.Check(True) |
---|
339 | self.list_cb_data.append(item) |
---|
340 | data_info_child =self.tree_ctrl.AppendItem(data_child, 'info')#, |
---|
341 | #wnd=data_info_txt) |
---|
342 | info_class_child =self.tree_ctrl.AppendItem(data_info_child, |
---|
343 | 'Type: %s'%data_class) |
---|
344 | path_class_child =self.tree_ctrl.AppendItem(data_info_child, |
---|
345 | 'Path: %s'%str(path)) |
---|
346 | for process in data.process: |
---|
347 | info_time_child =self.tree_ctrl.AppendItem(data_info_child,process.__str__()) |
---|
348 | theory_child =self.tree_ctrl.AppendItem(data_child, "Available Theories") |
---|
349 | |
---|
350 | if theory_list: |
---|
351 | theory = theory_list[len(theory_list)-1] |
---|
352 | if theory is not None: |
---|
353 | av_theory_child =self.tree_ctrl.AppendItem(theory_child, |
---|
354 | theory.name,ct_type=1) |
---|
355 | self.list_cb_theory.append(av_theory_child) |
---|
356 | av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, |
---|
357 | 'info') |
---|
358 | for process in theory.process: |
---|
359 | info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, |
---|
360 | process.__str__()) |
---|
361 | |
---|
362 | def set_data_helper(self): |
---|
363 | """ |
---|
364 | """ |
---|
365 | data_to_plot = [] |
---|
366 | for item in self.list_cb_data: |
---|
367 | if item.IsChecked(): |
---|
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 i 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 | self.manager.delete_data(data_name=data_to_remove, |
---|
386 | theory_name=theory_to_remove) |
---|
387 | |
---|
388 | def on_import(self, event=None): |
---|
389 | """ |
---|
390 | Get all select data and set them to the current active perspetive |
---|
391 | """ |
---|
392 | self.post_helper(plot=False) |
---|
393 | |
---|
394 | def on_plot(self, event=None): |
---|
395 | """ |
---|
396 | Send a list of data names to plot |
---|
397 | """ |
---|
398 | self.post_helper(plot=True) |
---|
399 | |
---|
400 | def set_active_perspective(self, name): |
---|
401 | """ |
---|
402 | set the active perspective |
---|
403 | """ |
---|
404 | self.tctrl_perspective.SetLabel(str(name)) |
---|
405 | |
---|
406 | def set_panel_on_focus(self, name): |
---|
407 | """ |
---|
408 | set the plot panel on focus |
---|
409 | """ |
---|
410 | self.tctrl_plotpanel.SetLabel(str(name)) |
---|
411 | |
---|
412 | def post_helper(self, plot=False): |
---|
413 | """ |
---|
414 | """ |
---|
415 | data_to_plot, theory_to_plot = self.set_data_helper() |
---|
416 | |
---|
417 | if self.parent is not None: |
---|
418 | self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot) |
---|
419 | |
---|
420 | |
---|
421 | class DataFrame(wx.Frame): |
---|
422 | ## Internal name for the AUI manager |
---|
423 | window_name = "Data Panel" |
---|
424 | ## Title to appear on top of the window |
---|
425 | window_caption = "Data Panel" |
---|
426 | ## Flag to tell the GUI manager that this panel is not |
---|
427 | # tied to any perspective |
---|
428 | ALWAYS_ON = True |
---|
429 | |
---|
430 | def __init__(self, parent=None, owner=None, manager=None,size=(600, 600), |
---|
431 | list_of_perspective=[],list=[], *args, **kwds): |
---|
432 | #kwds['size'] = size |
---|
433 | kwds['id'] = -1 |
---|
434 | kwds['title']= "Loaded Data" |
---|
435 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
436 | self.parent = parent |
---|
437 | self.owner = owner |
---|
438 | self.manager = manager |
---|
439 | self.panel = DataPanel(parent=self, |
---|
440 | size=size, |
---|
441 | list_of_perspective=list_of_perspective) |
---|
442 | |
---|
443 | def load_data_list(self, list=[]): |
---|
444 | """ |
---|
445 | Fill the list inside its panel |
---|
446 | """ |
---|
447 | self.panel.load_data_list(list=list) |
---|
448 | |
---|
449 | def layout_perspective(self, list_of_perspective=[]): |
---|
450 | """ |
---|
451 | """ |
---|
452 | self.panel.layout_perspective(list_of_perspective=list_of_perspective) |
---|
453 | |
---|
454 | |
---|
455 | from dataFitting import Data1D |
---|
456 | from dataFitting import Data2D, Theory1D |
---|
457 | from data_state import DataState |
---|
458 | import sys |
---|
459 | class State(): |
---|
460 | def __init__(self): |
---|
461 | self.msg = "" |
---|
462 | def __str__(self): |
---|
463 | self.msg = "model mane : model1\n" |
---|
464 | self.msg += "params : \n" |
---|
465 | self.msg += "name value\n" |
---|
466 | return msg |
---|
467 | def set_data_state(data, path, theory, state): |
---|
468 | dstate = DataState(data=data) |
---|
469 | dstate.set_path(path=path) |
---|
470 | dstate.set_theory(theory) |
---|
471 | dstate.set_state(state) |
---|
472 | return dstate |
---|
473 | """' |
---|
474 | data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), |
---|
475 | ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), |
---|
476 | ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), |
---|
477 | ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), |
---|
478 | ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] |
---|
479 | """ |
---|
480 | if __name__ == "__main__": |
---|
481 | |
---|
482 | app = wx.App() |
---|
483 | try: |
---|
484 | list_of_perspective = [('perspective2', False), ('perspective1', True)] |
---|
485 | data_list = {} |
---|
486 | data = Data1D() |
---|
487 | data.name = "data1" |
---|
488 | data.id = 1 |
---|
489 | #data.append_process() |
---|
490 | #process = data.process[len(data.process)-1] |
---|
491 | #process.data = "07/01/2010" |
---|
492 | theory = Theory1D() |
---|
493 | theory.id = 34 |
---|
494 | theory.pseudo_name = "theory1" |
---|
495 | path = "path1" |
---|
496 | state = State() |
---|
497 | data_list['1']=set_data_state(data, path,theory, state) |
---|
498 | |
---|
499 | data = Data1D() |
---|
500 | data.name = "data2" |
---|
501 | data.id = 76 |
---|
502 | theory = Theory1D() |
---|
503 | theory.id = 78 |
---|
504 | theory.name = "CoreShell 07/24/25" |
---|
505 | theory.pseudo_name = "CoreShell" |
---|
506 | path = "path2" |
---|
507 | state = State() |
---|
508 | data_list['2']=set_data_state(data, path,theory, state) |
---|
509 | data = Data1D() |
---|
510 | data.id = 3 |
---|
511 | data.name = "data2" |
---|
512 | theory = Theory1D() |
---|
513 | theory.name = "CoreShell" |
---|
514 | theory.pseudo_name = "CoreShell" |
---|
515 | theory.id = 4 |
---|
516 | #theory.append_process() |
---|
517 | #process = theory.process[len(theory.process)-1] |
---|
518 | #process.description = "this is my description" |
---|
519 | path = "path3" |
---|
520 | #data.append_process() |
---|
521 | #process = data.process[len(data.process)-1] |
---|
522 | #process.data = "07/22/2010" |
---|
523 | data_list['4']=set_data_state(data, path,theory, state) |
---|
524 | |
---|
525 | data = Data2D() |
---|
526 | data.name = "data3" |
---|
527 | data.id = 5 |
---|
528 | #data.append_process() |
---|
529 | #process = data.process[len(data.process)-1] |
---|
530 | #process.data = "07/01/2010" |
---|
531 | theory = Theory1D() |
---|
532 | theory.pseudo_name = "Cylinder" |
---|
533 | path = "path2" |
---|
534 | state = State() |
---|
535 | dstate= set_data_state(data, path,theory, state) |
---|
536 | theory = Theory1D() |
---|
537 | theory.id = 6 |
---|
538 | theory.pseudo_name = "Sphere" |
---|
539 | dstate.set_theory(theory) |
---|
540 | data_list['3']=dstate |
---|
541 | |
---|
542 | window = DataFrame(list=data_list) |
---|
543 | window.load_data_list(list=data_list) |
---|
544 | window.layout_perspective(list_of_perspective=list_of_perspective) |
---|
545 | window.Show(True) |
---|
546 | except: |
---|
547 | #raise |
---|
548 | print "error",sys.exc_value |
---|
549 | app.MainLoop() |
---|
550 | |
---|
551 | |
---|