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