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