[3c44c66] | 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 |
---|
[3feed3e] | 15 | import warnings |
---|
[3c44c66] | 16 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
[3feed3e] | 17 | import wx.lib.agw.customtreectrl as CT |
---|
| 18 | from sans.guiframe.dataFitting import Data1D |
---|
| 19 | from sans.guiframe.dataFitting import Data2D |
---|
[52725d6] | 20 | from sans.guiframe.panel_base import PanelBase |
---|
[3feed3e] | 21 | |
---|
[1b1bbf9] | 22 | PANEL_WIDTH = 180 |
---|
[5c4b674] | 23 | #PANEL_HEIGHT = 560 |
---|
[1b1bbf9] | 24 | PANEL_HEIGHT = 700 |
---|
| 25 | STYLE_FLAG =wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\ |
---|
[91bdf87] | 26 | wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT |
---|
| 27 | |
---|
| 28 | |
---|
[3feed3e] | 29 | class DataTreeCtrl(CT.CustomTreeCtrl): |
---|
[3c44c66] | 30 | """ |
---|
| 31 | Check list control to be used for Data Panel |
---|
| 32 | """ |
---|
[6db811e] | 33 | def __init__(self, parent,*args, **kwds): |
---|
[73581ce] | 34 | #agwstyle is introduced in wx.2.8.11 but is not working for mac |
---|
| 35 | if sys.platform.count("darwin") != 0: |
---|
[91bdf87] | 36 | try: |
---|
| 37 | kwds['style'] = STYLE_FLAG |
---|
| 38 | except: |
---|
| 39 | raise |
---|
[73581ce] | 40 | else: |
---|
| 41 | #agwstyle is introduced in wx.2.8.11 .argument working only for windows |
---|
| 42 | try: |
---|
| 43 | kwds['agwStyle'] = STYLE_FLAG |
---|
| 44 | except: |
---|
| 45 | try: |
---|
| 46 | kwds['style'] = STYLE_FLAG |
---|
| 47 | except: |
---|
| 48 | raise |
---|
[91bdf87] | 49 | |
---|
[3feed3e] | 50 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
| 51 | self.root = self.AddRoot("Available Data") |
---|
[3c44c66] | 52 | |
---|
[52725d6] | 53 | class DataPanel(ScrolledPanel, PanelBase): |
---|
[3c44c66] | 54 | """ |
---|
| 55 | This panel displays data available in the application and widgets to |
---|
| 56 | interact with data. |
---|
| 57 | """ |
---|
[3feed3e] | 58 | ## Internal name for the AUI manager |
---|
| 59 | window_name = "Data Panel" |
---|
| 60 | ## Title to appear on top of the window |
---|
[1b1bbf9] | 61 | window_caption = "Data Explorer" |
---|
[3feed3e] | 62 | #type of window |
---|
| 63 | window_type = "Data Panel" |
---|
| 64 | ## Flag to tell the GUI manager that this panel is not |
---|
| 65 | # tied to any perspective |
---|
| 66 | #ALWAYS_ON = True |
---|
| 67 | def __init__(self, parent, list=[],list_of_perspective=[], |
---|
[5c4b674] | 68 | size=(PANEL_WIDTH,PANEL_HEIGHT), manager=None, *args, **kwds): |
---|
[3feed3e] | 69 | kwds['size']= size |
---|
[1b1bbf9] | 70 | kwds['style'] = STYLE_FLAG |
---|
[3c44c66] | 71 | ScrolledPanel.__init__(self, parent=parent, *args, **kwds) |
---|
[52725d6] | 72 | PanelBase.__init__(self) |
---|
[3c44c66] | 73 | self.SetupScrolling() |
---|
[ee2b492] | 74 | self.all_data1d = True |
---|
[3c44c66] | 75 | self.parent = parent |
---|
[3feed3e] | 76 | self.manager = manager |
---|
[3c44c66] | 77 | self.list_of_data = list |
---|
[3feed3e] | 78 | self.list_of_perspective = list_of_perspective |
---|
| 79 | self.list_rb_perspectives= [] |
---|
[c70eb7c] | 80 | self.list_cb_data = {} |
---|
| 81 | self.list_cb_theory = {} |
---|
| 82 | |
---|
[3feed3e] | 83 | self.owner = None |
---|
| 84 | self.do_layout() |
---|
[1b1bbf9] | 85 | self.Bind(wx.EVT_SHOW, self.on_close_page) |
---|
| 86 | |
---|
[3feed3e] | 87 | def do_layout(self): |
---|
[6db811e] | 88 | """ |
---|
| 89 | """ |
---|
[3c44c66] | 90 | self.define_panel_structure() |
---|
| 91 | self.layout_selection() |
---|
[5c4b674] | 92 | self.layout_data_list() |
---|
[3c44c66] | 93 | self.layout_button() |
---|
[3feed3e] | 94 | self.layout_batch() |
---|
| 95 | |
---|
[3c44c66] | 96 | def define_panel_structure(self): |
---|
| 97 | """ |
---|
| 98 | Define the skeleton of the panel |
---|
| 99 | """ |
---|
[3feed3e] | 100 | w, h = self.parent.GetSize() |
---|
[3c44c66] | 101 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 102 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
[1b1bbf9] | 103 | self.sizer1.SetMinSize((w/13, h*2/5)) |
---|
[cc061c3] | 104 | |
---|
[3feed3e] | 105 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
| 106 | self.sizer3 = wx.GridBagSizer(5,5) |
---|
[3c44c66] | 107 | self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) |
---|
[18ec684] | 108 | self.sizer5 = wx.BoxSizer(wx.VERTICAL) |
---|
| 109 | |
---|
[3feed3e] | 110 | self.vbox.Add(self.sizer5, 0,wx.EXPAND|wx.ALL,10) |
---|
| 111 | self.vbox.Add(self.sizer1, 0,wx.EXPAND|wx.ALL,0) |
---|
| 112 | self.vbox.Add(self.sizer2, 0,wx.EXPAND|wx.ALL,10) |
---|
| 113 | self.vbox.Add(self.sizer3, 0,wx.EXPAND|wx.ALL,10) |
---|
| 114 | self.vbox.Add(self.sizer4, 0,wx.EXPAND|wx.ALL,10) |
---|
| 115 | |
---|
[3c44c66] | 116 | self.SetSizer(self.vbox) |
---|
| 117 | |
---|
[3feed3e] | 118 | def layout_selection(self): |
---|
[3c44c66] | 119 | """ |
---|
| 120 | """ |
---|
[3feed3e] | 121 | select_txt = wx.StaticText(self, -1, 'Selection Options') |
---|
[bffa3d0] | 122 | select_txt.SetForegroundColour('blue') |
---|
[3feed3e] | 123 | self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
| 124 | list_of_options = ['Select all Data', |
---|
| 125 | 'Unselect all Data', |
---|
| 126 | 'Select all Data 1D', |
---|
| 127 | 'Unselect all Data 1D', |
---|
| 128 | 'Select all Data 2D', |
---|
| 129 | 'Unselect all Data 2D' ] |
---|
| 130 | for option in list_of_options: |
---|
| 131 | self.selection_cbox.Append(str(option)) |
---|
[18ec684] | 132 | self.selection_cbox.SetValue('Select all Data') |
---|
[3feed3e] | 133 | wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type) |
---|
| 134 | self.sizer5.AddMany([(select_txt,0, wx.ALL,5), |
---|
| 135 | (self.selection_cbox,0, wx.ALL,5)]) |
---|
| 136 | def layout_perspective(self, list_of_perspective=[]): |
---|
[3c44c66] | 137 | """ |
---|
| 138 | Layout widgets related to the list of plug-ins of the gui_manager |
---|
| 139 | """ |
---|
[3feed3e] | 140 | if len(list_of_perspective)==0: |
---|
| 141 | return |
---|
| 142 | w, h = self.parent.GetSize() |
---|
| 143 | box_description_2= wx.StaticBox(self, -1, "Set Active Perspective") |
---|
| 144 | self.boxsizer_2 = wx.StaticBoxSizer(box_description_2, wx.HORIZONTAL) |
---|
| 145 | self.sizer_perspective = wx.GridBagSizer(5,5) |
---|
| 146 | self.boxsizer_2.Add(self.sizer_perspective) |
---|
| 147 | self.sizer2.Add(self.boxsizer_2,1, wx.ALL, 10) |
---|
| 148 | self.list_of_perspective = list_of_perspective |
---|
| 149 | self.sizer_perspective.Clear(True) |
---|
| 150 | self.list_rb_perspectives = [] |
---|
| 151 | |
---|
| 152 | nb_active_perspective = 0 |
---|
[3c44c66] | 153 | if list_of_perspective: |
---|
| 154 | ix = 0 |
---|
| 155 | iy = 0 |
---|
[3feed3e] | 156 | for perspective_name, is_active in list_of_perspective: |
---|
| 157 | |
---|
| 158 | if is_active: |
---|
| 159 | nb_active_perspective += 1 |
---|
| 160 | if nb_active_perspective == 1: |
---|
[ea5692d] | 161 | rb = wx.RadioButton(self, -1, perspective_name, |
---|
| 162 | style=wx.RB_GROUP) |
---|
[3feed3e] | 163 | rb.SetToolTipString("Data will be applied to this perspective") |
---|
| 164 | rb.SetValue(is_active) |
---|
| 165 | else: |
---|
| 166 | rb = wx.RadioButton(self, -1, perspective_name) |
---|
| 167 | rb.SetToolTipString("Data will be applied to this perspective") |
---|
| 168 | #only one perpesctive can be active |
---|
| 169 | rb.SetValue(False) |
---|
| 170 | |
---|
| 171 | self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective, |
---|
| 172 | id=rb.GetId()) |
---|
| 173 | self.list_rb_perspectives.append(rb) |
---|
| 174 | self.sizer_perspective.Add(rb,(iy, ix),(1,1), |
---|
| 175 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
[3c44c66] | 176 | iy += 1 |
---|
| 177 | else: |
---|
| 178 | rb = wx.RadioButton(self, -1, 'No Perspective', |
---|
| 179 | style=wx.RB_GROUP) |
---|
| 180 | rb.SetValue(True) |
---|
| 181 | rb.Disable() |
---|
| 182 | ix = 0 |
---|
| 183 | iy = 0 |
---|
[3feed3e] | 184 | self.sizer_perspective.Add(rb,(iy, ix),(1,1), |
---|
[3c44c66] | 185 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
[3feed3e] | 186 | |
---|
| 187 | def _on_selection_type(self, event): |
---|
[3c44c66] | 188 | """ |
---|
[3feed3e] | 189 | Select data according to patterns |
---|
[3c44c66] | 190 | """ |
---|
[18ec684] | 191 | |
---|
| 192 | list_of_options = ['Select all Data', |
---|
| 193 | 'Unselect all Data', |
---|
| 194 | 'Select all Data 1D', |
---|
| 195 | 'Unselect all Data 1D', |
---|
| 196 | 'Select all Data 2D', |
---|
| 197 | 'Unselect all Data 2D' ] |
---|
[3feed3e] | 198 | option = self.selection_cbox.GetValue() |
---|
[18ec684] | 199 | |
---|
| 200 | pos = self.selection_cbox.GetSelection() |
---|
| 201 | if pos == wx.NOT_FOUND: |
---|
| 202 | return |
---|
| 203 | option = self.selection_cbox.GetString(pos) |
---|
[b5e79f7] | 204 | for item in self.list_cb_data.values(): |
---|
| 205 | data_ctrl, _, _, _,_, _ = item |
---|
| 206 | data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) |
---|
[18ec684] | 207 | if option == 'Select all Data': |
---|
[b5e79f7] | 208 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 209 | elif option == 'Unselect all Data': |
---|
[b5e79f7] | 210 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[18ec684] | 211 | elif option == 'Select all Data 1D': |
---|
| 212 | if data_class == 'Data1D': |
---|
[b5e79f7] | 213 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 214 | elif option == 'Unselect all Data 1D': |
---|
[c70eb7c] | 215 | if data_class == 'Data1D': |
---|
[b5e79f7] | 216 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[18ec684] | 217 | elif option == 'Select all Data 1D': |
---|
[c70eb7c] | 218 | if data_class == 'Data1D': |
---|
[b5e79f7] | 219 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 220 | elif option == 'Select all Data 2D': |
---|
| 221 | if data_class == 'Data2D': |
---|
[b5e79f7] | 222 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 223 | elif option == 'Unselect all Data 2D': |
---|
| 224 | if data_class == 'Data2D': |
---|
[b5e79f7] | 225 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[18ec684] | 226 | |
---|
[3feed3e] | 227 | def on_set_active_perspective(self, event): |
---|
[3c44c66] | 228 | """ |
---|
[3feed3e] | 229 | Select the active perspective |
---|
| 230 | """ |
---|
| 231 | ctrl = event.GetEventObject() |
---|
[3c44c66] | 232 | |
---|
| 233 | def layout_button(self): |
---|
| 234 | """ |
---|
| 235 | Layout widgets related to buttons |
---|
| 236 | """ |
---|
[3feed3e] | 237 | self.bt_import = wx.Button(self, wx.NewId(), "Send To") |
---|
| 238 | self.bt_import.SetToolTipString("Send set of Data to active perspective") |
---|
[3c44c66] | 239 | wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) |
---|
| 240 | |
---|
[3feed3e] | 241 | self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To") |
---|
[213892bc] | 242 | self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") |
---|
| 243 | wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) |
---|
[3feed3e] | 244 | |
---|
| 245 | self.bt_plot = wx.Button(self, wx.NewId(), "New Plot") |
---|
[3c44c66] | 246 | self.bt_plot.SetToolTipString("To trigger plotting") |
---|
| 247 | wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) |
---|
| 248 | |
---|
[48665ed] | 249 | self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory") |
---|
| 250 | self.bt_freeze.SetToolTipString("To trigger freeze a theory") |
---|
[c70eb7c] | 251 | wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) |
---|
| 252 | |
---|
[d828481] | 253 | self.bt_remove = wx.Button(self, wx.NewId(), "Remove Data") |
---|
| 254 | self.bt_remove.SetToolTipString("Remove data from the application") |
---|
[3feed3e] | 255 | wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) |
---|
| 256 | |
---|
[0a2fdca] | 257 | self.tctrl_perspective = wx.StaticText(self, -1, |
---|
| 258 | 'No Active Application', |
---|
| 259 | style=wx.SUNKEN_BORDER|wx.ALIGN_LEFT) |
---|
[3feed3e] | 260 | self.tctrl_perspective.SetToolTipString("Active Application") |
---|
[0a2fdca] | 261 | perspective_font = self.tctrl_perspective.GetFont() |
---|
| 262 | perspective_font.SetWeight(wx.BOLD) |
---|
| 263 | self.tctrl_perspective.SetFont(perspective_font) |
---|
| 264 | self.tctrl_perspective.SetClientSize((80,20)) |
---|
| 265 | self.cb_plotpanel = wx.ComboBox(self, -1, |
---|
| 266 | style=wx.CB_READONLY|wx.CB_SORT) |
---|
| 267 | wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection) |
---|
| 268 | self.cb_plotpanel.Append('None') |
---|
| 269 | self.cb_plotpanel.SetStringSelection('None') |
---|
| 270 | |
---|
| 271 | #self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus') |
---|
| 272 | #self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") |
---|
[18ec684] | 273 | |
---|
[3feed3e] | 274 | ix = 0 |
---|
| 275 | iy = 0 |
---|
| 276 | self.sizer3.Add(self.bt_import,( iy, ix),(1,1), |
---|
| 277 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 278 | ix += 1 |
---|
| 279 | self.sizer3.Add(self.tctrl_perspective,(iy, ix),(1,1), |
---|
| 280 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 281 | ix = 0 |
---|
| 282 | iy += 1 |
---|
| 283 | self.sizer3.Add(self.bt_append_plot,( iy, ix),(1,1), |
---|
| 284 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 285 | ix += 1 |
---|
[0a2fdca] | 286 | self.sizer3.Add(self.cb_plotpanel,(iy, ix),(1,1), |
---|
[3feed3e] | 287 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 288 | ix = 0 |
---|
| 289 | iy += 1 |
---|
| 290 | self.sizer3.Add(self.bt_plot,( iy, ix),(1,1), |
---|
| 291 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 292 | ix = 0 |
---|
| 293 | iy += 1 |
---|
[c70eb7c] | 294 | self.sizer3.Add(self.bt_freeze,( iy, ix),(1,1), |
---|
| 295 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 296 | ix = 0 |
---|
| 297 | iy += 1 |
---|
[3feed3e] | 298 | self.sizer3.Add(self.bt_remove,( iy, ix),(1,1), |
---|
| 299 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 300 | |
---|
[18ec684] | 301 | |
---|
[3feed3e] | 302 | |
---|
| 303 | def layout_batch(self): |
---|
[3c44c66] | 304 | """ |
---|
| 305 | """ |
---|
[3feed3e] | 306 | |
---|
| 307 | self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', |
---|
| 308 | style=wx.RB_GROUP) |
---|
| 309 | self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') |
---|
| 310 | |
---|
| 311 | self.rb_single_mode.SetValue(True) |
---|
| 312 | self.rb_batch_mode.SetValue(False) |
---|
| 313 | self.sizer4.AddMany([(self.rb_single_mode,0, wx.ALL,5), |
---|
| 314 | (self.rb_batch_mode,0, wx.ALL,5)]) |
---|
| 315 | |
---|
[91bdf87] | 316 | def old_layout_data_list(self): |
---|
[3c44c66] | 317 | """ |
---|
[3feed3e] | 318 | Add a listcrtl in the panel |
---|
[3c44c66] | 319 | """ |
---|
[6db811e] | 320 | self.tree_ctrl = DataTreeCtrl(parent=self) |
---|
[ee2b492] | 321 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
[ea5692d] | 322 | self.sizer1.Add(self.tree_ctrl,1, wx.EXPAND|wx.ALL, 10) |
---|
[71bd773] | 323 | self.theory_root = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, |
---|
| 324 | "THEORIES", ct_type=0) |
---|
[bffa3d0] | 325 | |
---|
[91bdf87] | 326 | def layout_data_list(self): |
---|
[bffa3d0] | 327 | """ |
---|
| 328 | Add a listcrtl in the panel |
---|
| 329 | """ |
---|
| 330 | tree_ctrl_label = wx.StaticText(self, -1, "Data") |
---|
| 331 | tree_ctrl_label.SetForegroundColour('blue') |
---|
| 332 | self.tree_ctrl = DataTreeCtrl(parent=self) |
---|
| 333 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
| 334 | tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory") |
---|
| 335 | tree_ctrl_theory_label.SetForegroundColour('blue') |
---|
| 336 | self.tree_ctrl_theory = DataTreeCtrl(parent=self) |
---|
| 337 | self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
| 338 | self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10) |
---|
| 339 | self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10) |
---|
| 340 | self.sizer1.Add(tree_ctrl_theory_label, 0, wx.LEFT, 10) |
---|
| 341 | self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND|wx.ALL, 10) |
---|
| 342 | |
---|
[3feed3e] | 343 | def onContextMenu(self, event): |
---|
[3c44c66] | 344 | """ |
---|
[3feed3e] | 345 | Retrieve the state selected state |
---|
[3c44c66] | 346 | """ |
---|
[3feed3e] | 347 | # Skipping the save state functionality for release 0.9.0 |
---|
| 348 | #return |
---|
| 349 | pos = event.GetPosition() |
---|
| 350 | pos = self.ScreenToClient(pos) |
---|
| 351 | self.PopupMenu(self.popUpMenu, pos) |
---|
| 352 | |
---|
[ee2b492] | 353 | |
---|
[3feed3e] | 354 | def on_check_item(self, event): |
---|
[3c44c66] | 355 | """ |
---|
| 356 | """ |
---|
[3feed3e] | 357 | item = event.GetItem() |
---|
[ee2b492] | 358 | item.Check(not item.IsChecked()) |
---|
| 359 | self.enable_button(item) |
---|
| 360 | event.Skip() |
---|
| 361 | |
---|
| 362 | def enable_button(self, item): |
---|
| 363 | """ |
---|
| 364 | """ |
---|
[48665ed] | 365 | # Not implemented |
---|
| 366 | return |
---|
| 367 | """ |
---|
[ee2b492] | 368 | _, data_class, _= self.tree_ctrl.GetItemPyData(item) |
---|
| 369 | if item.IsChecked(): |
---|
| 370 | self.all_data1d &= (data_class != "Data2D") |
---|
| 371 | if self.all_data1d: |
---|
| 372 | self.bt_freeze.Enable() |
---|
| 373 | else: |
---|
| 374 | self.bt_freeze.Disable() |
---|
| 375 | else: |
---|
| 376 | self.all_data1d |= True |
---|
| 377 | self.all_data1d &= (data_class != "Data2D") |
---|
| 378 | if self.all_data1d: |
---|
| 379 | self.bt_freeze.Enable() |
---|
| 380 | else: |
---|
| 381 | self.bt_freeze.Disable() |
---|
[48665ed] | 382 | """ |
---|
[3feed3e] | 383 | def load_data_list(self, list): |
---|
[3c44c66] | 384 | """ |
---|
[c70eb7c] | 385 | add need data with its theory under the tree |
---|
[3c44c66] | 386 | """ |
---|
[3feed3e] | 387 | if not list: |
---|
| 388 | return |
---|
[48665ed] | 389 | # uncheck previous items |
---|
[3b11d0d] | 390 | #self._uncheck_all() |
---|
[48665ed] | 391 | |
---|
[c70eb7c] | 392 | for state_id, dstate in list.iteritems(): |
---|
[3feed3e] | 393 | data = dstate.get_data() |
---|
[71bd773] | 394 | theory_list = dstate.get_theory() |
---|
| 395 | if data is not None: |
---|
[3feed3e] | 396 | data_name = data.name |
---|
[c70eb7c] | 397 | data_class = data.__class__.__name__ |
---|
| 398 | path = dstate.get_path() |
---|
| 399 | process_list = data.process |
---|
| 400 | data_id = data.id |
---|
[3feed3e] | 401 | |
---|
[71bd773] | 402 | if state_id not in self.list_cb_data: |
---|
| 403 | #new state |
---|
| 404 | data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, |
---|
| 405 | data_name, ct_type=1, |
---|
| 406 | data=(data_id, data_class, state_id)) |
---|
| 407 | data_c.Check(True) |
---|
| 408 | self.enable_button(data_c) |
---|
| 409 | d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') |
---|
| 410 | i_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
| 411 | 'Type: %s' % data_class) |
---|
| 412 | p_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
| 413 | 'Path: %s' % str(path)) |
---|
| 414 | d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') |
---|
| 415 | |
---|
| 416 | for process in process_list: |
---|
| 417 | i_t_c = self.tree_ctrl.AppendItem(d_p_c, |
---|
| 418 | process.__str__()) |
---|
| 419 | theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") |
---|
| 420 | |
---|
| 421 | self.list_cb_data[state_id] = [data_c, |
---|
| 422 | d_i_c, |
---|
| 423 | i_c_c, |
---|
| 424 | p_c_c, |
---|
| 425 | d_p_c, |
---|
| 426 | theory_child] |
---|
| 427 | else: |
---|
| 428 | data_ctrl_list = self.list_cb_data[state_id] |
---|
| 429 | #This state is already display replace it contains |
---|
| 430 | data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list |
---|
| 431 | self.tree_ctrl.SetItemText(data_c, data_name) |
---|
| 432 | temp = (data_id, data_class, state_id) |
---|
| 433 | self.tree_ctrl.SetItemPyData(data_c, temp) |
---|
| 434 | self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) |
---|
| 435 | self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % str(path)) |
---|
| 436 | self.tree_ctrl.DeleteChildren(d_p_c) |
---|
| 437 | for process in process_list: |
---|
| 438 | i_t_c = self.tree_ctrl.AppendItem(d_p_c, |
---|
| 439 | process.__str__()) |
---|
[c70eb7c] | 440 | self.append_theory(state_id, theory_list) |
---|
[91bdf87] | 441 | |
---|
[48665ed] | 442 | def _uncheck_all(self): |
---|
| 443 | """ |
---|
| 444 | Uncheck all check boxes |
---|
| 445 | """ |
---|
| 446 | for item in self.list_cb_data.values(): |
---|
| 447 | data_ctrl, _, _, _,_, _ = item |
---|
| 448 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
| 449 | |
---|
[91bdf87] | 450 | def old_append_theory(self, state_id, theory_list): |
---|
[c70eb7c] | 451 | """ |
---|
| 452 | append theory object under data from a state of id = state_id |
---|
| 453 | replace that theory if already displayed |
---|
| 454 | """ |
---|
| 455 | if not theory_list: |
---|
| 456 | return |
---|
| 457 | if state_id not in self.list_cb_data.keys(): |
---|
[71bd773] | 458 | root = self.theory_root |
---|
| 459 | else: |
---|
| 460 | item = self.list_cb_data[state_id] |
---|
| 461 | data_c, _, _, _, _, _ = item |
---|
| 462 | root = data_c |
---|
| 463 | if root is not None: |
---|
| 464 | self.append_theory_helper(root=root, |
---|
| 465 | state_id=state_id, |
---|
| 466 | theory_list=theory_list) |
---|
[91bdf87] | 467 | def append_theory(self, state_id, theory_list): |
---|
[bffa3d0] | 468 | """ |
---|
| 469 | append theory object under data from a state of id = state_id |
---|
| 470 | replace that theory if already displayed |
---|
| 471 | """ |
---|
| 472 | if not theory_list: |
---|
| 473 | return |
---|
| 474 | if state_id not in self.list_cb_data.keys(): |
---|
| 475 | root = self.tree_ctrl_theory.root |
---|
[91bdf87] | 476 | tree = self.tree_ctrl_theory |
---|
[bffa3d0] | 477 | else: |
---|
| 478 | item = self.list_cb_data[state_id] |
---|
| 479 | data_c, _, _, _, _, _ = item |
---|
| 480 | root = data_c |
---|
[91bdf87] | 481 | tree = self.tree_ctrl |
---|
[bffa3d0] | 482 | if root is not None: |
---|
[91bdf87] | 483 | self.append_theory_helper(tree=tree, root=root, |
---|
[bffa3d0] | 484 | state_id=state_id, |
---|
| 485 | theory_list=theory_list) |
---|
| 486 | |
---|
[71bd773] | 487 | |
---|
[91bdf87] | 488 | def append_theory_helper(self, tree, root, state_id, theory_list): |
---|
[71bd773] | 489 | """ |
---|
| 490 | """ |
---|
| 491 | if state_id in self.list_cb_theory.keys(): |
---|
[c70eb7c] | 492 | #update current list of theory for this data |
---|
[71bd773] | 493 | theory_list_ctrl = self.list_cb_theory[state_id] |
---|
[c70eb7c] | 494 | |
---|
| 495 | for theory_id, item in theory_list.iteritems(): |
---|
[e88ebfd] | 496 | theory_data, theory_state = item |
---|
[c70eb7c] | 497 | if theory_data is None: |
---|
| 498 | name = "Unknown" |
---|
| 499 | theory_class = "Unknown" |
---|
| 500 | theory_id = "Unknown" |
---|
| 501 | temp = (None, None, None) |
---|
| 502 | else: |
---|
| 503 | name = theory_data.name |
---|
| 504 | theory_class = theory_data.__class__.__name__ |
---|
| 505 | theory_id = theory_data.id |
---|
[ee2b492] | 506 | #if theory_state is not None: |
---|
| 507 | # name = theory_state.model.name |
---|
[c70eb7c] | 508 | temp = (theory_id, theory_class, state_id) |
---|
| 509 | if theory_id not in theory_list_ctrl: |
---|
| 510 | #add new theory |
---|
[91bdf87] | 511 | t_child = tree.AppendItem(root, |
---|
[c70eb7c] | 512 | name, ct_type=1, data=temp) |
---|
[91bdf87] | 513 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
| 514 | i_c_c = tree.AppendItem(t_i_c, |
---|
[c70eb7c] | 515 | 'Type: %s' % theory_class) |
---|
[91bdf87] | 516 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
[c70eb7c] | 517 | |
---|
| 518 | for process in theory_data.process: |
---|
[91bdf87] | 519 | i_t_c = tree.AppendItem(t_p_c, |
---|
[c70eb7c] | 520 | process.__str__()) |
---|
| 521 | theory_list_ctrl[theory_id] = [t_child, |
---|
| 522 | i_c_c, |
---|
| 523 | t_p_c] |
---|
| 524 | else: |
---|
| 525 | #replace theory |
---|
| 526 | t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] |
---|
[91bdf87] | 527 | tree.SetItemText(t_child, name) |
---|
| 528 | tree.SetItemPyData(t_child, temp) |
---|
| 529 | tree.SetItemText(i_c_c, 'Type: %s' % theory_class) |
---|
| 530 | tree.DeleteChildren(t_p_c) |
---|
[c70eb7c] | 531 | for process in theory_data.process: |
---|
[91bdf87] | 532 | i_t_c = tree.AppendItem(t_p_c, |
---|
[c70eb7c] | 533 | process.__str__()) |
---|
| 534 | |
---|
| 535 | else: |
---|
| 536 | #data didn't have a theory associated it before |
---|
| 537 | theory_list_ctrl = {} |
---|
| 538 | for theory_id, item in theory_list.iteritems(): |
---|
[e88ebfd] | 539 | theory_data, theory_state = item |
---|
[c70eb7c] | 540 | if theory_data is not None: |
---|
[e88ebfd] | 541 | name = theory_data.name |
---|
[c70eb7c] | 542 | theory_class = theory_data.__class__.__name__ |
---|
[e88ebfd] | 543 | theory_id = theory_data.id |
---|
[ee2b492] | 544 | #if theory_state is not None: |
---|
| 545 | # name = theory_state.model.name |
---|
[e88ebfd] | 546 | temp = (theory_id, theory_class, state_id) |
---|
[91bdf87] | 547 | t_child = tree.AppendItem(root, |
---|
[e88ebfd] | 548 | name, ct_type=1, |
---|
[c70eb7c] | 549 | data=(theory_data.id, theory_class, state_id)) |
---|
[91bdf87] | 550 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
| 551 | i_c_c = tree.AppendItem(t_i_c, |
---|
[c70eb7c] | 552 | 'Type: %s' % theory_class) |
---|
[91bdf87] | 553 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
[c70eb7c] | 554 | |
---|
| 555 | for process in theory_data.process: |
---|
[91bdf87] | 556 | i_t_c = tree.AppendItem(t_p_c, |
---|
[c70eb7c] | 557 | process.__str__()) |
---|
| 558 | |
---|
| 559 | theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] |
---|
[71bd773] | 560 | #self.list_cb_theory[data_id] = theory_list_ctrl |
---|
| 561 | self.list_cb_theory[state_id] = theory_list_ctrl |
---|
[91bdf87] | 562 | |
---|
[c70eb7c] | 563 | |
---|
[ee2b492] | 564 | |
---|
[3feed3e] | 565 | def set_data_helper(self): |
---|
[3c44c66] | 566 | """ |
---|
| 567 | """ |
---|
[3feed3e] | 568 | data_to_plot = [] |
---|
[e88ebfd] | 569 | state_to_plot = [] |
---|
| 570 | theory_to_plot = [] |
---|
[c70eb7c] | 571 | for value in self.list_cb_data.values(): |
---|
| 572 | item, _, _, _, _, _ = value |
---|
[3feed3e] | 573 | if item.IsChecked(): |
---|
[3658717e] | 574 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
| 575 | data_to_plot.append(data_id) |
---|
| 576 | if state_id not in state_to_plot: |
---|
| 577 | state_to_plot.append(state_id) |
---|
| 578 | |
---|
[c70eb7c] | 579 | for theory_dict in self.list_cb_theory.values(): |
---|
| 580 | for key, value in theory_dict.iteritems(): |
---|
| 581 | item, _, _ = value |
---|
| 582 | if item.IsChecked(): |
---|
[e88ebfd] | 583 | theory_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
[c70eb7c] | 584 | theory_to_plot.append(theory_id) |
---|
[e88ebfd] | 585 | if state_id not in state_to_plot: |
---|
| 586 | state_to_plot.append(state_id) |
---|
| 587 | return data_to_plot, theory_to_plot, state_to_plot |
---|
[3feed3e] | 588 | |
---|
[c70eb7c] | 589 | def remove_by_id(self, id): |
---|
| 590 | """ |
---|
| 591 | """ |
---|
| 592 | for item in self.list_cb_data.values(): |
---|
| 593 | data_c, _, _, _, _, theory_child = item |
---|
| 594 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) |
---|
| 595 | if id == data_id: |
---|
| 596 | self.tree_ctrl.Delete(data_c) |
---|
| 597 | del self.list_cb_data[state_id] |
---|
| 598 | del self.list_cb_theory[data_id] |
---|
[ae83ad3] | 599 | |
---|
[3feed3e] | 600 | def on_remove(self, event): |
---|
[18ec684] | 601 | """ |
---|
[3658717e] | 602 | Get a list of item checked and remove them from the treectrl |
---|
| 603 | Ask the parent to remove reference to this item |
---|
[18ec684] | 604 | """ |
---|
[665c083] | 605 | data_to_remove, theory_to_remove, _ = self.set_data_helper() |
---|
| 606 | data_key = [] |
---|
| 607 | theory_key = [] |
---|
[3658717e] | 608 | #remove data from treectrl |
---|
| 609 | for d_key, item in self.list_cb_data.iteritems(): |
---|
[665c083] | 610 | data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = item |
---|
| 611 | if data_c.IsChecked(): |
---|
| 612 | self.tree_ctrl.Delete(data_c) |
---|
[3658717e] | 613 | data_key.append(d_key) |
---|
| 614 | if d_key in self.list_cb_theory.keys(): |
---|
| 615 | theory_list_ctrl = self.list_cb_theory[d_key] |
---|
| 616 | theory_to_remove += theory_list_ctrl.keys() |
---|
| 617 | # Remove theory from treectrl |
---|
| 618 | for t_key, theory_dict in self.list_cb_theory.iteritems(): |
---|
| 619 | for key, value in theory_dict.iteritems(): |
---|
[665c083] | 620 | item, _, _ = value |
---|
| 621 | if item.IsChecked(): |
---|
| 622 | self.tree_ctrl.Delete(item) |
---|
| 623 | theory_key.append(key) |
---|
[3658717e] | 624 | #Remove data and related theory references |
---|
[665c083] | 625 | for key in data_key: |
---|
| 626 | del self.list_cb_data[key] |
---|
[3658717e] | 627 | if key in theory_key: |
---|
| 628 | del self.list_cb_theory[key] |
---|
| 629 | #remove theory references independently of data |
---|
[665c083] | 630 | for key in theory_key: |
---|
[3658717e] | 631 | for t_key, theory_dict in self.list_cb_theory.iteritems(): |
---|
[71bd773] | 632 | if key in theory_dict: |
---|
| 633 | del theory_dict[key] |
---|
[3658717e] | 634 | |
---|
[18ec684] | 635 | self.parent.remove_data(data_id=data_to_remove, |
---|
[665c083] | 636 | theory_id=theory_to_remove) |
---|
[3c44c66] | 637 | |
---|
[3feed3e] | 638 | def on_import(self, event=None): |
---|
[3c44c66] | 639 | """ |
---|
[3feed3e] | 640 | Get all select data and set them to the current active perspetive |
---|
[3c44c66] | 641 | """ |
---|
[e88ebfd] | 642 | data_id, theory_id, state_id = self.set_data_helper() |
---|
| 643 | self.parent.set_data(data_id) |
---|
[210e21f] | 644 | self.parent.set_data(data_id=state_id, theory_id=theory_id) |
---|
[e88ebfd] | 645 | |
---|
[213892bc] | 646 | def on_append_plot(self, event=None): |
---|
| 647 | """ |
---|
| 648 | append plot to plot panel on focus |
---|
| 649 | """ |
---|
[0a2fdca] | 650 | self._on_plot_selection() |
---|
[e88ebfd] | 651 | data_id, theory_id, state_id = self.set_data_helper() |
---|
| 652 | self.parent.plot_data(data_id=data_id, |
---|
| 653 | state_id=state_id, |
---|
| 654 | theory_id=theory_id, |
---|
| 655 | append=True) |
---|
[213892bc] | 656 | |
---|
[3feed3e] | 657 | def on_plot(self, event=None): |
---|
[3c44c66] | 658 | """ |
---|
[3feed3e] | 659 | Send a list of data names to plot |
---|
[3c44c66] | 660 | """ |
---|
[e88ebfd] | 661 | data_id, theory_id, state_id = self.set_data_helper() |
---|
| 662 | self.parent.plot_data(data_id=data_id, |
---|
| 663 | state_id=state_id, |
---|
| 664 | theory_id=theory_id, |
---|
| 665 | append=False) |
---|
[48665ed] | 666 | |
---|
[1b1bbf9] | 667 | def on_close_page(self, event=None): |
---|
| 668 | """ |
---|
| 669 | On close |
---|
| 670 | """ |
---|
| 671 | if event != None: |
---|
| 672 | event.Skip() |
---|
| 673 | |
---|
| 674 | # send parent to update menu with no show nor hide action |
---|
| 675 | self.parent.show_data_panel(action=False) |
---|
| 676 | |
---|
| 677 | |
---|
[c70eb7c] | 678 | def on_freeze(self, event): |
---|
| 679 | """ |
---|
| 680 | """ |
---|
[e88ebfd] | 681 | _, theory_id, state_id = self.set_data_helper() |
---|
[ee2b492] | 682 | self.parent.freeze(data_id=state_id, theory_id=theory_id) |
---|
[c70eb7c] | 683 | |
---|
[3feed3e] | 684 | def set_active_perspective(self, name): |
---|
[3c44c66] | 685 | """ |
---|
[3feed3e] | 686 | set the active perspective |
---|
[3c44c66] | 687 | """ |
---|
[3feed3e] | 688 | self.tctrl_perspective.SetLabel(str(name)) |
---|
[0a2fdca] | 689 | #perspective_font = self.tctrl_perspective.GetFont() |
---|
| 690 | #perspective_font.SetWeight(wx.BOLD) |
---|
| 691 | self.tctrl_perspective.SetClientSize((80,20))#SetFont(perspective_font) |
---|
[c5e84fb] | 692 | |
---|
[3feed3e] | 693 | def set_panel_on_focus(self, name): |
---|
[3c44c66] | 694 | """ |
---|
[3feed3e] | 695 | set the plot panel on focus |
---|
[3c44c66] | 696 | """ |
---|
[0a2fdca] | 697 | for key, value in self.parent.plot_panels.iteritems(): |
---|
| 698 | name_plot_panel = str(value.window_caption) |
---|
| 699 | if name_plot_panel not in self.cb_plotpanel.GetItems(): |
---|
| 700 | self.cb_plotpanel.Append(name_plot_panel, value) |
---|
| 701 | self.cb_plotpanel.SetStringSelection(name_plot_panel) |
---|
| 702 | |
---|
[e88ebfd] | 703 | |
---|
[0a2fdca] | 704 | def _on_plot_selection(self, event = None): |
---|
| 705 | """ |
---|
| 706 | On source combobox selection |
---|
| 707 | """ |
---|
| 708 | if event != None: |
---|
| 709 | combo = event.GetEventObject() |
---|
| 710 | event.Skip() |
---|
| 711 | else: |
---|
| 712 | combo = self.cb_plotpanel |
---|
| 713 | selection = combo.GetSelection() |
---|
| 714 | |
---|
| 715 | if combo.GetValue() != 'None': |
---|
| 716 | panel = combo.GetClientData(selection) |
---|
| 717 | self.parent.on_set_plot_focus(panel) |
---|
| 718 | |
---|
[c70eb7c] | 719 | |
---|
[3feed3e] | 720 | |
---|
[3c44c66] | 721 | |
---|
| 722 | class DataFrame(wx.Frame): |
---|
[3feed3e] | 723 | ## Internal name for the AUI manager |
---|
| 724 | window_name = "Data Panel" |
---|
| 725 | ## Title to appear on top of the window |
---|
| 726 | window_caption = "Data Panel" |
---|
| 727 | ## Flag to tell the GUI manager that this panel is not |
---|
| 728 | # tied to any perspective |
---|
| 729 | ALWAYS_ON = True |
---|
| 730 | |
---|
[1b1bbf9] | 731 | def __init__(self, parent=None, owner=None, manager=None,size=(200, 800), |
---|
[3feed3e] | 732 | list_of_perspective=[],list=[], *args, **kwds): |
---|
[cc061c3] | 733 | kwds['size'] = size |
---|
[3c44c66] | 734 | kwds['id'] = -1 |
---|
[3feed3e] | 735 | kwds['title']= "Loaded Data" |
---|
[3c44c66] | 736 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
| 737 | self.parent = parent |
---|
| 738 | self.owner = owner |
---|
| 739 | self.manager = manager |
---|
[32c0841] | 740 | self.panel = DataPanel(parent=self, |
---|
[cc061c3] | 741 | #size=size, |
---|
[32c0841] | 742 | list_of_perspective=list_of_perspective) |
---|
[3feed3e] | 743 | |
---|
| 744 | def load_data_list(self, list=[]): |
---|
[3c44c66] | 745 | """ |
---|
| 746 | Fill the list inside its panel |
---|
| 747 | """ |
---|
[3feed3e] | 748 | self.panel.load_data_list(list=list) |
---|
[3c44c66] | 749 | |
---|
[3feed3e] | 750 | def layout_perspective(self, list_of_perspective=[]): |
---|
[3c44c66] | 751 | """ |
---|
| 752 | """ |
---|
| 753 | self.panel.layout_perspective(list_of_perspective=list_of_perspective) |
---|
[c70eb7c] | 754 | |
---|
| 755 | |
---|
[32c0841] | 756 | |
---|
[3feed3e] | 757 | |
---|
| 758 | from dataFitting import Data1D |
---|
| 759 | from dataFitting import Data2D, Theory1D |
---|
| 760 | from data_state import DataState |
---|
| 761 | import sys |
---|
| 762 | class State(): |
---|
| 763 | def __init__(self): |
---|
| 764 | self.msg = "" |
---|
| 765 | def __str__(self): |
---|
| 766 | self.msg = "model mane : model1\n" |
---|
| 767 | self.msg += "params : \n" |
---|
| 768 | self.msg += "name value\n" |
---|
| 769 | return msg |
---|
[71bd773] | 770 | def set_data_state(data=None, path=None, theory=None, state=None): |
---|
[3feed3e] | 771 | dstate = DataState(data=data) |
---|
| 772 | dstate.set_path(path=path) |
---|
[c70eb7c] | 773 | dstate.set_theory(theory, state) |
---|
| 774 | |
---|
[3feed3e] | 775 | return dstate |
---|
| 776 | """' |
---|
| 777 | data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), |
---|
| 778 | ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), |
---|
| 779 | ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), |
---|
| 780 | ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), |
---|
| 781 | ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] |
---|
| 782 | """ |
---|
[3c44c66] | 783 | if __name__ == "__main__": |
---|
[3feed3e] | 784 | |
---|
[3c44c66] | 785 | app = wx.App() |
---|
[3feed3e] | 786 | try: |
---|
| 787 | list_of_perspective = [('perspective2', False), ('perspective1', True)] |
---|
| 788 | data_list = {} |
---|
[c70eb7c] | 789 | # state 1 |
---|
[ee2b492] | 790 | data = Data2D() |
---|
| 791 | data.name = "data2" |
---|
[584c4c4] | 792 | data.id = 1 |
---|
[c70eb7c] | 793 | data.append_empty_process() |
---|
| 794 | process = data.process[len(data.process)-1] |
---|
| 795 | process.data = "07/01/2010" |
---|
[ee2b492] | 796 | theory = Data2D() |
---|
[584c4c4] | 797 | theory.id = 34 |
---|
[c70eb7c] | 798 | theory.name = "theory1" |
---|
[3feed3e] | 799 | path = "path1" |
---|
| 800 | state = State() |
---|
| 801 | data_list['1']=set_data_state(data, path,theory, state) |
---|
[c70eb7c] | 802 | #state 2 |
---|
[ee2b492] | 803 | data = Data2D() |
---|
[3feed3e] | 804 | data.name = "data2" |
---|
[584c4c4] | 805 | data.id = 76 |
---|
[ee2b492] | 806 | theory = Data2D() |
---|
[584c4c4] | 807 | theory.id = 78 |
---|
[3feed3e] | 808 | theory.name = "CoreShell 07/24/25" |
---|
| 809 | path = "path2" |
---|
[c70eb7c] | 810 | #state3 |
---|
[3feed3e] | 811 | state = State() |
---|
| 812 | data_list['2']=set_data_state(data, path,theory, state) |
---|
| 813 | data = Data1D() |
---|
[584c4c4] | 814 | data.id = 3 |
---|
[3feed3e] | 815 | data.name = "data2" |
---|
| 816 | theory = Theory1D() |
---|
| 817 | theory.name = "CoreShell" |
---|
[584c4c4] | 818 | theory.id = 4 |
---|
[c70eb7c] | 819 | theory.append_empty_process() |
---|
| 820 | process = theory.process[len(theory.process)-1] |
---|
| 821 | process.description = "this is my description" |
---|
[3feed3e] | 822 | path = "path3" |
---|
[c70eb7c] | 823 | data.append_empty_process() |
---|
| 824 | process = data.process[len(data.process)-1] |
---|
| 825 | process.data = "07/22/2010" |
---|
[3feed3e] | 826 | data_list['4']=set_data_state(data, path,theory, state) |
---|
[c70eb7c] | 827 | #state 4 |
---|
| 828 | temp_data_list = {} |
---|
| 829 | data.name = "data5 erasing data2" |
---|
| 830 | temp_data_list['4'] = set_data_state(data, path,theory, state) |
---|
| 831 | #state 5 |
---|
[3feed3e] | 832 | data = Data2D() |
---|
| 833 | data.name = "data3" |
---|
[584c4c4] | 834 | data.id = 5 |
---|
[c70eb7c] | 835 | data.append_empty_process() |
---|
| 836 | process = data.process[len(data.process)-1] |
---|
| 837 | process.data = "07/01/2010" |
---|
[3feed3e] | 838 | theory = Theory1D() |
---|
[c70eb7c] | 839 | theory.name = "Cylinder" |
---|
[3feed3e] | 840 | path = "path2" |
---|
| 841 | state = State() |
---|
| 842 | dstate= set_data_state(data, path,theory, state) |
---|
| 843 | theory = Theory1D() |
---|
[584c4c4] | 844 | theory.id = 6 |
---|
[c70eb7c] | 845 | theory.name = "CoreShell" |
---|
| 846 | dstate.set_theory(theory) |
---|
| 847 | theory = Theory1D() |
---|
| 848 | theory.id = 6 |
---|
| 849 | theory.name = "CoreShell replacing coreshell in data3" |
---|
[3feed3e] | 850 | dstate.set_theory(theory) |
---|
[c70eb7c] | 851 | data_list['3'] = dstate |
---|
| 852 | #state 6 |
---|
| 853 | data_list['6']=set_data_state(None, path,theory, state) |
---|
[71bd773] | 854 | data_list['6']=set_data_state(theory=theory, state=None) |
---|
| 855 | theory = Theory1D() |
---|
| 856 | theory.id = 7 |
---|
| 857 | data_list['6']=set_data_state(theory=theory, state=None) |
---|
| 858 | data_list['7']=set_data_state(theory=theory, state=None) |
---|
[3feed3e] | 859 | window = DataFrame(list=data_list) |
---|
[c70eb7c] | 860 | window.load_data_list(list=data_list) |
---|
| 861 | #window.layout_perspective(list_of_perspective=list_of_perspective) |
---|
[3feed3e] | 862 | window.Show(True) |
---|
[c70eb7c] | 863 | window.load_data_list(list=temp_data_list) |
---|
[3feed3e] | 864 | except: |
---|
| 865 | #raise |
---|
| 866 | print "error",sys.exc_value |
---|
[c70eb7c] | 867 | |
---|
[3c44c66] | 868 | app.MainLoop() |
---|
| 869 | |
---|
| 870 | |
---|