[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 | """ |
---|
[2a62d5c] | 13 | import os |
---|
[3c44c66] | 14 | import wx |
---|
[31f3222b] | 15 | from wx.build import build_options |
---|
[af7ba61] | 16 | # Check version |
---|
| 17 | toks = wx.__version__.split('.') |
---|
| 18 | if int(toks[1]) < 9: |
---|
[228a8bb] | 19 | if int(toks[2]) < 12: |
---|
| 20 | wx_version = 811 |
---|
| 21 | else: |
---|
| 22 | wx_version = 812 |
---|
[af7ba61] | 23 | else: |
---|
[228a8bb] | 24 | wx_version = 900 |
---|
[3c44c66] | 25 | import sys |
---|
[3feed3e] | 26 | import warnings |
---|
[13a63ab] | 27 | import logging |
---|
[3c44c66] | 28 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
[3feed3e] | 29 | import wx.lib.agw.customtreectrl as CT |
---|
| 30 | from sans.guiframe.dataFitting import Data1D |
---|
| 31 | from sans.guiframe.dataFitting import Data2D |
---|
[52725d6] | 32 | from sans.guiframe.panel_base import PanelBase |
---|
[2a62d5c] | 33 | from sans.guiframe.events import StatusEvent |
---|
[13a63ab] | 34 | from sans.guiframe.events import EVT_DELETE_PLOTPANEL |
---|
[a03d419] | 35 | from sans.guiframe.events import NewLoadDataEvent |
---|
[e26d0db] | 36 | from sans.guiframe.events import NewPlotEvent |
---|
[a03d419] | 37 | from sans.guiframe.gui_style import GUIFRAME |
---|
[80ddbd0] | 38 | from sans.guiframe.events import NewBatchEvent |
---|
[c642155] | 39 | from sans.dataloader.loader import Loader |
---|
[2a62d5c] | 40 | |
---|
[6468fb2] | 41 | import sans.guiframe.config as config |
---|
[2a62d5c] | 42 | |
---|
| 43 | extension_list = [] |
---|
| 44 | if config.APPLICATION_STATE_EXTENSION is not None: |
---|
| 45 | extension_list.append(config.APPLICATION_STATE_EXTENSION) |
---|
| 46 | EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list |
---|
[99f9ecf] | 47 | PLUGINS_WLIST = config.PLUGINS_WLIST |
---|
| 48 | APPLICATION_WLIST = config.APPLICATION_WLIST |
---|
[3f0c330] | 49 | |
---|
| 50 | #Control panel width |
---|
[57f537a] | 51 | if sys.platform.count("win32") > 0: |
---|
[3f0c330] | 52 | PANEL_WIDTH = 235 |
---|
| 53 | PANEL_HEIGHT = 700 |
---|
| 54 | CBOX_WIDTH = 140 |
---|
| 55 | BUTTON_WIDTH = 80 |
---|
| 56 | FONT_VARIANT = 0 |
---|
[234a3fa] | 57 | IS_MAC = False |
---|
[3f0c330] | 58 | else: |
---|
| 59 | PANEL_WIDTH = 255 |
---|
| 60 | PANEL_HEIGHT = 750 |
---|
| 61 | CBOX_WIDTH = 155 |
---|
| 62 | BUTTON_WIDTH = 100 |
---|
| 63 | FONT_VARIANT = 1 |
---|
[234a3fa] | 64 | IS_MAC = True |
---|
[3f0c330] | 65 | |
---|
[1b1bbf9] | 66 | STYLE_FLAG =wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\ |
---|
[91bdf87] | 67 | wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT |
---|
| 68 | |
---|
| 69 | |
---|
[3feed3e] | 70 | class DataTreeCtrl(CT.CustomTreeCtrl): |
---|
[3c44c66] | 71 | """ |
---|
| 72 | Check list control to be used for Data Panel |
---|
| 73 | """ |
---|
[6db811e] | 74 | def __init__(self, parent,*args, **kwds): |
---|
[73581ce] | 75 | #agwstyle is introduced in wx.2.8.11 but is not working for mac |
---|
[228a8bb] | 76 | if IS_MAC and wx_version < 812: |
---|
[91bdf87] | 77 | try: |
---|
| 78 | kwds['style'] = STYLE_FLAG |
---|
[d34f9f6] | 79 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
[91bdf87] | 80 | except: |
---|
[af7ba61] | 81 | del kwds['style'] |
---|
[d34f9f6] | 82 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
[73581ce] | 83 | else: |
---|
| 84 | #agwstyle is introduced in wx.2.8.11 .argument working only for windows |
---|
| 85 | try: |
---|
| 86 | kwds['agwStyle'] = STYLE_FLAG |
---|
[d34f9f6] | 87 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
[73581ce] | 88 | except: |
---|
| 89 | try: |
---|
[d34f9f6] | 90 | del kwds['agwStyle'] |
---|
[73581ce] | 91 | kwds['style'] = STYLE_FLAG |
---|
[d34f9f6] | 92 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
[73581ce] | 93 | except: |
---|
[d34f9f6] | 94 | del kwds['style'] |
---|
| 95 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
[3feed3e] | 96 | self.root = self.AddRoot("Available Data") |
---|
[3c44c66] | 97 | |
---|
[52725d6] | 98 | class DataPanel(ScrolledPanel, PanelBase): |
---|
[3c44c66] | 99 | """ |
---|
| 100 | This panel displays data available in the application and widgets to |
---|
| 101 | interact with data. |
---|
| 102 | """ |
---|
[3feed3e] | 103 | ## Internal name for the AUI manager |
---|
| 104 | window_name = "Data Panel" |
---|
| 105 | ## Title to appear on top of the window |
---|
[1b1bbf9] | 106 | window_caption = "Data Explorer" |
---|
[3feed3e] | 107 | #type of window |
---|
| 108 | window_type = "Data Panel" |
---|
| 109 | ## Flag to tell the GUI manager that this panel is not |
---|
| 110 | # tied to any perspective |
---|
| 111 | #ALWAYS_ON = True |
---|
[600eca2] | 112 | def __init__(self, parent, |
---|
| 113 | list=None, |
---|
[ea4dfe0] | 114 | size=(PANEL_WIDTH, PANEL_HEIGHT), |
---|
| 115 | list_of_perspective=None, manager=None, *args, **kwds): |
---|
[3feed3e] | 116 | kwds['size']= size |
---|
[1b1bbf9] | 117 | kwds['style'] = STYLE_FLAG |
---|
[3c44c66] | 118 | ScrolledPanel.__init__(self, parent=parent, *args, **kwds) |
---|
[52725d6] | 119 | PanelBase.__init__(self) |
---|
[3c44c66] | 120 | self.SetupScrolling() |
---|
[3f0c330] | 121 | #Set window's font size |
---|
| 122 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
[2a62d5c] | 123 | self.loader = Loader() |
---|
| 124 | #Default location |
---|
| 125 | self._default_save_location = None |
---|
[ee2b492] | 126 | self.all_data1d = True |
---|
[3c44c66] | 127 | self.parent = parent |
---|
[3feed3e] | 128 | self.manager = manager |
---|
[600eca2] | 129 | if list is None: |
---|
| 130 | list = [] |
---|
[3c44c66] | 131 | self.list_of_data = list |
---|
[600eca2] | 132 | if list_of_perspective is None: |
---|
| 133 | list_of_perspective = [] |
---|
[3feed3e] | 134 | self.list_of_perspective = list_of_perspective |
---|
| 135 | self.list_rb_perspectives= [] |
---|
[c70eb7c] | 136 | self.list_cb_data = {} |
---|
| 137 | self.list_cb_theory = {} |
---|
[61ffd1e] | 138 | self.tree_ctrl = None |
---|
| 139 | self.tree_ctrl_theory = None |
---|
[600eca2] | 140 | self.perspective_cbox = None |
---|
[bf39777] | 141 | ## Create context menu for page |
---|
| 142 | self.data_menu = None |
---|
[5e8e615] | 143 | |
---|
[3feed3e] | 144 | self.owner = None |
---|
| 145 | self.do_layout() |
---|
[600eca2] | 146 | self.fill_cbox_analysis(self.list_of_perspective) |
---|
[1b1bbf9] | 147 | self.Bind(wx.EVT_SHOW, self.on_close_page) |
---|
[13a63ab] | 148 | if self.parent is not None: |
---|
| 149 | self.parent.Bind(EVT_DELETE_PLOTPANEL, self._on_delete_plot_panel) |
---|
[c31fd9f] | 150 | |
---|
[3feed3e] | 151 | def do_layout(self): |
---|
[6db811e] | 152 | """ |
---|
| 153 | """ |
---|
[3c44c66] | 154 | self.define_panel_structure() |
---|
| 155 | self.layout_selection() |
---|
[5c4b674] | 156 | self.layout_data_list() |
---|
[8f19b69] | 157 | self.layout_batch() |
---|
[64f9fa6] | 158 | self.layout_button() |
---|
| 159 | |
---|
[3feed3e] | 160 | |
---|
[3c44c66] | 161 | def define_panel_structure(self): |
---|
| 162 | """ |
---|
| 163 | Define the skeleton of the panel |
---|
| 164 | """ |
---|
[3feed3e] | 165 | w, h = self.parent.GetSize() |
---|
[3c44c66] | 166 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 167 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
[e095c3a9] | 168 | self.sizer1.SetMinSize(wx.Size(w/13, h*2/5)) |
---|
[cc061c3] | 169 | |
---|
[3feed3e] | 170 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
[c6f2291] | 171 | self.sizer3 = wx.FlexGridSizer(7, 2, 4, 1) |
---|
[64f9fa6] | 172 | self.sizer4 = wx.BoxSizer(wx.VERTICAL) |
---|
[18ec684] | 173 | self.sizer5 = wx.BoxSizer(wx.VERTICAL) |
---|
| 174 | |
---|
[2a62d5c] | 175 | self.vbox.Add(self.sizer5, 0, wx.EXPAND|wx.ALL,1) |
---|
[e095c3a9] | 176 | self.vbox.Add(self.sizer1, 1, wx.EXPAND|wx.ALL,0) |
---|
[2a62d5c] | 177 | self.vbox.Add(self.sizer2, 0, wx.EXPAND|wx.ALL,1) |
---|
[cd2209d] | 178 | self.vbox.Add(self.sizer3, 0, wx.EXPAND|wx.ALL,10) |
---|
[64f9fa6] | 179 | #self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5) |
---|
[3feed3e] | 180 | |
---|
[3c44c66] | 181 | self.SetSizer(self.vbox) |
---|
| 182 | |
---|
[3feed3e] | 183 | def layout_selection(self): |
---|
[3c44c66] | 184 | """ |
---|
| 185 | """ |
---|
[3feed3e] | 186 | select_txt = wx.StaticText(self, -1, 'Selection Options') |
---|
[bffa3d0] | 187 | select_txt.SetForegroundColour('blue') |
---|
[3feed3e] | 188 | self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
| 189 | list_of_options = ['Select all Data', |
---|
| 190 | 'Unselect all Data', |
---|
| 191 | 'Select all Data 1D', |
---|
| 192 | 'Unselect all Data 1D', |
---|
| 193 | 'Select all Data 2D', |
---|
| 194 | 'Unselect all Data 2D' ] |
---|
| 195 | for option in list_of_options: |
---|
| 196 | self.selection_cbox.Append(str(option)) |
---|
[18ec684] | 197 | self.selection_cbox.SetValue('Select all Data') |
---|
[3feed3e] | 198 | wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type) |
---|
| 199 | self.sizer5.AddMany([(select_txt,0, wx.ALL,5), |
---|
| 200 | (self.selection_cbox,0, wx.ALL,5)]) |
---|
[61ffd1e] | 201 | self.enable_selection() |
---|
| 202 | |
---|
[5e8e615] | 203 | |
---|
[3feed3e] | 204 | def _on_selection_type(self, event): |
---|
[3c44c66] | 205 | """ |
---|
[3feed3e] | 206 | Select data according to patterns |
---|
[3c44c66] | 207 | """ |
---|
[18ec684] | 208 | |
---|
| 209 | list_of_options = ['Select all Data', |
---|
| 210 | 'Unselect all Data', |
---|
| 211 | 'Select all Data 1D', |
---|
| 212 | 'Unselect all Data 1D', |
---|
| 213 | 'Select all Data 2D', |
---|
| 214 | 'Unselect all Data 2D' ] |
---|
[3feed3e] | 215 | option = self.selection_cbox.GetValue() |
---|
[18ec684] | 216 | |
---|
| 217 | pos = self.selection_cbox.GetSelection() |
---|
| 218 | if pos == wx.NOT_FOUND: |
---|
| 219 | return |
---|
| 220 | option = self.selection_cbox.GetString(pos) |
---|
[b5e79f7] | 221 | for item in self.list_cb_data.values(): |
---|
[ea4ed10] | 222 | data_ctrl, _, _, _,_, _,_,_= item |
---|
[b5e79f7] | 223 | data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) |
---|
[18ec684] | 224 | if option == 'Select all Data': |
---|
[b5e79f7] | 225 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 226 | elif option == 'Unselect all Data': |
---|
[b5e79f7] | 227 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[18ec684] | 228 | elif option == 'Select all Data 1D': |
---|
| 229 | if data_class == 'Data1D': |
---|
[b5e79f7] | 230 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 231 | elif option == 'Unselect all Data 1D': |
---|
[c70eb7c] | 232 | if data_class == 'Data1D': |
---|
[b5e79f7] | 233 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[18ec684] | 234 | elif option == 'Select all Data 1D': |
---|
[c70eb7c] | 235 | if data_class == 'Data1D': |
---|
[b5e79f7] | 236 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 237 | elif option == 'Select all Data 2D': |
---|
| 238 | if data_class == 'Data2D': |
---|
[b5e79f7] | 239 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
[18ec684] | 240 | elif option == 'Unselect all Data 2D': |
---|
| 241 | if data_class == 'Data2D': |
---|
[b5e79f7] | 242 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[1e3394f] | 243 | self.enable_append() |
---|
| 244 | self.enable_freeze() |
---|
| 245 | self.enable_plot() |
---|
| 246 | self.enable_import() |
---|
[248b918] | 247 | self.enable_remove() |
---|
[18ec684] | 248 | |
---|
[3c44c66] | 249 | def layout_button(self): |
---|
| 250 | """ |
---|
| 251 | Layout widgets related to buttons |
---|
| 252 | """ |
---|
[ea4dfe0] | 253 | w, _ = self.GetSize() |
---|
[a03d419] | 254 | |
---|
[2567003] | 255 | self.bt_add = wx.Button(self, wx.NewId(), "Load Data", |
---|
| 256 | size=(BUTTON_WIDTH, -1)) |
---|
[c461ebe] | 257 | self.bt_add.SetToolTipString("Load data files") |
---|
[2a62d5c] | 258 | wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data) |
---|
[c5a769e] | 259 | self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data", |
---|
[248b918] | 260 | size=(BUTTON_WIDTH, -1)) |
---|
[c5a769e] | 261 | self.bt_remove.SetToolTipString("Delete data from the application") |
---|
[248b918] | 262 | wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) |
---|
[2567003] | 263 | self.bt_import = wx.Button(self, wx.NewId(), "Send To", |
---|
| 264 | size=(BUTTON_WIDTH, -1)) |
---|
[3feed3e] | 265 | self.bt_import.SetToolTipString("Send set of Data to active perspective") |
---|
[3c44c66] | 266 | wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) |
---|
[df58ecab] | 267 | self.perspective_cbox = wx.ComboBox(self, -1, |
---|
[600eca2] | 268 | style=wx.CB_READONLY) |
---|
[66f7016] | 269 | if not IS_MAC: |
---|
| 270 | self.perspective_cbox.SetMinSize((BUTTON_WIDTH*1.6, -1)) |
---|
[600eca2] | 271 | wx.EVT_COMBOBOX(self.perspective_cbox,-1, |
---|
| 272 | self._on_perspective_selection) |
---|
| 273 | |
---|
[2567003] | 274 | self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", |
---|
| 275 | size=(BUTTON_WIDTH, -1)) |
---|
[213892bc] | 276 | self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") |
---|
| 277 | wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) |
---|
[3feed3e] | 278 | |
---|
[2567003] | 279 | self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", |
---|
| 280 | size=(BUTTON_WIDTH, -1)) |
---|
[3c44c66] | 281 | self.bt_plot.SetToolTipString("To trigger plotting") |
---|
| 282 | wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) |
---|
| 283 | |
---|
[2567003] | 284 | self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", |
---|
| 285 | size=(BUTTON_WIDTH, -1)) |
---|
[7360816] | 286 | freeze_tip = "To trigger freeze a theory: making a copy\n" |
---|
| 287 | freeze_tip += "of the theory checked to Data box,\n" |
---|
[2719255] | 288 | freeze_tip += " so that it can act like a real data set." |
---|
| 289 | self.bt_freeze.SetToolTipString(freeze_tip) |
---|
[c70eb7c] | 290 | wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) |
---|
[e26d0db] | 291 | #hide plot |
---|
[c5a769e] | 292 | #self.bt_close_plot = wx.Button(self, wx.NewId(), "Delete Plot", |
---|
| 293 | # size=(BUTTON_WIDTH, -1)) |
---|
| 294 | #self.bt_close_plot.SetToolTipString("Delete the plot panel on focus") |
---|
| 295 | #wx.EVT_BUTTON(self, self.bt_close_plot.GetId(), self.on_close_plot) |
---|
[600eca2] | 296 | |
---|
[31f3222b] | 297 | if sys.platform == 'darwin' and build_options.WXPORT == 'osx_cocoa': |
---|
| 298 | self.cb_plotpanel = wx.ComboBox(self, -1, |
---|
| 299 | style=wx.CB_READONLY) |
---|
| 300 | else: |
---|
| 301 | self.cb_plotpanel = wx.ComboBox(self, -1, |
---|
| 302 | style=wx.CB_READONLY|wx.CB_SORT) |
---|
[64f9fa6] | 303 | #self.cb_plotpanel.SetMinSize((BUTTON_WIDTH*2, -1)) |
---|
[0a2fdca] | 304 | wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection) |
---|
[5e8e615] | 305 | self.cb_plotpanel.Disable() |
---|
[0a2fdca] | 306 | |
---|
[600eca2] | 307 | self.sizer3.AddMany([(self.bt_add), |
---|
| 308 | ((10, 10)), |
---|
[248b918] | 309 | (self.bt_remove), |
---|
| 310 | ((10, 10)), |
---|
[7360816] | 311 | (self.bt_freeze), |
---|
| 312 | ((10, 10)), |
---|
| 313 | (self.bt_plot), |
---|
| 314 | ((10, 10)), |
---|
| 315 | (self.bt_append_plot), |
---|
| 316 | (self.cb_plotpanel, wx.EXPAND|wx.ADJUST_MINSIZE, 5), |
---|
[64f9fa6] | 317 | ((5, 5)), |
---|
| 318 | ((5, 5)), |
---|
[2567003] | 319 | (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5), |
---|
[64f9fa6] | 320 | (self.perspective_cbox, wx.EXPAND|wx.ADJUST_MINSIZE, 5), |
---|
| 321 | ((10, 10)), |
---|
| 322 | (self.sizer4), |
---|
| 323 | ((10, 40)), |
---|
| 324 | ((10, 40))]) |
---|
[c461ebe] | 325 | |
---|
[600eca2] | 326 | self.sizer3.AddGrowableCol(1, 1) |
---|
[a03d419] | 327 | self.show_data_button() |
---|
[248b918] | 328 | self.enable_remove() |
---|
[f7d0b74] | 329 | self.enable_import() |
---|
| 330 | self.enable_plot() |
---|
| 331 | self.enable_append() |
---|
| 332 | self.enable_freeze() |
---|
[e26d0db] | 333 | self.enable_remove_plot() |
---|
[3feed3e] | 334 | |
---|
| 335 | def layout_batch(self): |
---|
[3c44c66] | 336 | """ |
---|
| 337 | """ |
---|
[3feed3e] | 338 | self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', |
---|
| 339 | style=wx.RB_GROUP) |
---|
| 340 | self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') |
---|
[24adb89] | 341 | self.Bind(wx.EVT_RADIOBUTTON, self.on_single_mode, |
---|
| 342 | id=self.rb_single_mode.GetId()) |
---|
| 343 | self.Bind(wx.EVT_RADIOBUTTON, self.on_batch_mode, |
---|
| 344 | id=self.rb_batch_mode.GetId()) |
---|
[3feed3e] | 345 | |
---|
[d03a356] | 346 | self.rb_single_mode.SetValue(not self.parent.batch_on) |
---|
| 347 | self.rb_batch_mode.SetValue(self.parent.batch_on) |
---|
[64f9fa6] | 348 | self.sizer4.AddMany([(self.rb_single_mode,0, wx.ALL, 4), |
---|
| 349 | (self.rb_batch_mode,0, wx.ALL, 4)]) |
---|
[80ddbd0] | 350 | |
---|
| 351 | def on_single_mode(self, event): |
---|
| 352 | """ |
---|
| 353 | change guiframe to its single mode |
---|
| 354 | """ |
---|
| 355 | if self.parent is not None: |
---|
| 356 | wx.PostEvent(self.parent, |
---|
| 357 | NewBatchEvent(enable=False)) |
---|
[8f19b69] | 358 | |
---|
[80ddbd0] | 359 | def on_batch_mode(self, event): |
---|
| 360 | """ |
---|
| 361 | change guiframe to its batch mode |
---|
| 362 | """ |
---|
| 363 | if self.parent is not None: |
---|
| 364 | wx.PostEvent(self.parent, |
---|
| 365 | NewBatchEvent(enable=True)) |
---|
[3feed3e] | 366 | |
---|
[bf39777] | 367 | def on_edit_data(self, event): |
---|
| 368 | """ |
---|
| 369 | Pop Up Data Editor |
---|
| 370 | """ |
---|
[5cf5f51] | 371 | selection = event.GetSelection() |
---|
| 372 | id, _, _ = self.tree_ctrl.GetSelection().GetData() |
---|
| 373 | data_list, _= self.parent._data_manager.get_by_id(id_list=[id]) |
---|
| 374 | |
---|
| 375 | data = data_list.values()[0] |
---|
| 376 | from sans.guiframe.local_perspectives.plotting.masking \ |
---|
| 377 | import MaskPanel as MaskDialog |
---|
| 378 | |
---|
| 379 | panel = MaskDialog(base=self, data=data, id=wx.NewId()) |
---|
| 380 | #self.panel.Bind(wx.EVT_CLOSE, self._draw_masked_model) |
---|
| 381 | panel.ShowModal() |
---|
[bf39777] | 382 | |
---|
[91bdf87] | 383 | def layout_data_list(self): |
---|
[bffa3d0] | 384 | """ |
---|
| 385 | Add a listcrtl in the panel |
---|
| 386 | """ |
---|
| 387 | tree_ctrl_label = wx.StaticText(self, -1, "Data") |
---|
| 388 | tree_ctrl_label.SetForegroundColour('blue') |
---|
[e095c3a9] | 389 | self.tree_ctrl = DataTreeCtrl(parent=self, style=wx.SUNKEN_BORDER) |
---|
[bffa3d0] | 390 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
[bf39777] | 391 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click) |
---|
| 392 | ## Create context menu for page |
---|
| 393 | self.data_menu = wx.Menu() |
---|
| 394 | id = wx.NewId() |
---|
[5cf5f51] | 395 | name = "Edit Mask" |
---|
[bf39777] | 396 | msg = "Edit the current Data" |
---|
| 397 | self.data_menu.Append(id, name, msg) |
---|
| 398 | wx.EVT_MENU(self, id, self.on_edit_data) |
---|
| 399 | |
---|
[bffa3d0] | 400 | tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory") |
---|
| 401 | tree_ctrl_theory_label.SetForegroundColour('blue') |
---|
[e095c3a9] | 402 | self.tree_ctrl_theory = DataTreeCtrl(parent=self, |
---|
| 403 | style=wx.SUNKEN_BORDER) |
---|
| 404 | self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, |
---|
| 405 | self.on_check_item) |
---|
[bffa3d0] | 406 | self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10) |
---|
| 407 | self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10) |
---|
| 408 | self.sizer1.Add(tree_ctrl_theory_label, 0, wx.LEFT, 10) |
---|
| 409 | self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND|wx.ALL, 10) |
---|
| 410 | |
---|
[bf39777] | 411 | |
---|
| 412 | def on_right_click(self, event): |
---|
| 413 | """ |
---|
| 414 | Allow Editing Data |
---|
| 415 | """ |
---|
[5cf5f51] | 416 | selection = event.GetSelection() |
---|
| 417 | _, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() |
---|
| 418 | if data_class_name == "Data2D" and self.data_menu is not None: |
---|
[bf39777] | 419 | self.PopupMenu(self.data_menu) |
---|
| 420 | |
---|
[3feed3e] | 421 | def onContextMenu(self, event): |
---|
[3c44c66] | 422 | """ |
---|
[3feed3e] | 423 | Retrieve the state selected state |
---|
[3c44c66] | 424 | """ |
---|
[3feed3e] | 425 | # Skipping the save state functionality for release 0.9.0 |
---|
| 426 | #return |
---|
| 427 | pos = event.GetPosition() |
---|
| 428 | pos = self.ScreenToClient(pos) |
---|
| 429 | self.PopupMenu(self.popUpMenu, pos) |
---|
| 430 | |
---|
[ee2b492] | 431 | |
---|
[3feed3e] | 432 | def on_check_item(self, event): |
---|
[3c44c66] | 433 | """ |
---|
| 434 | """ |
---|
[3feed3e] | 435 | item = event.GetItem() |
---|
[ee2b492] | 436 | item.Check(not item.IsChecked()) |
---|
[1e3394f] | 437 | self.enable_append() |
---|
| 438 | self.enable_freeze() |
---|
| 439 | self.enable_plot() |
---|
| 440 | self.enable_import() |
---|
[248b918] | 441 | self.enable_remove() |
---|
[ee2b492] | 442 | event.Skip() |
---|
| 443 | |
---|
[600eca2] | 444 | def fill_cbox_analysis(self, plugin): |
---|
[ee2b492] | 445 | """ |
---|
[600eca2] | 446 | fill the combobox with analysis name |
---|
[ee2b492] | 447 | """ |
---|
[600eca2] | 448 | self.list_of_perspective = plugin |
---|
| 449 | if self.parent is None or \ |
---|
| 450 | not hasattr(self.parent, "get_current_perspective") or \ |
---|
| 451 | len(self.list_of_perspective) == 0: |
---|
| 452 | return |
---|
| 453 | if self.parent is not None and self.perspective_cbox is not None: |
---|
| 454 | for plug in self.list_of_perspective: |
---|
| 455 | if plug.get_perspective(): |
---|
| 456 | self.perspective_cbox.Append(plug.sub_menu, plug) |
---|
| 457 | |
---|
| 458 | curr_pers = self.parent.get_current_perspective() |
---|
| 459 | self.perspective_cbox.SetStringSelection(curr_pers.sub_menu) |
---|
| 460 | self.enable_import() |
---|
| 461 | |
---|
[3feed3e] | 462 | def load_data_list(self, list): |
---|
[3c44c66] | 463 | """ |
---|
[c70eb7c] | 464 | add need data with its theory under the tree |
---|
[3c44c66] | 465 | """ |
---|
[61ffd1e] | 466 | if list: |
---|
| 467 | for state_id, dstate in list.iteritems(): |
---|
| 468 | data = dstate.get_data() |
---|
| 469 | theory_list = dstate.get_theory() |
---|
| 470 | if data is not None: |
---|
[755cac4] | 471 | data_name = str(data.name) |
---|
[b2aef1c] | 472 | data_title = str(data.title) |
---|
| 473 | data_run = str(data.run) |
---|
[61ffd1e] | 474 | data_class = data.__class__.__name__ |
---|
| 475 | path = dstate.get_path() |
---|
| 476 | process_list = data.process |
---|
| 477 | data_id = data.id |
---|
[76703da] | 478 | s_path = str(path) |
---|
[61ffd1e] | 479 | if state_id not in self.list_cb_data: |
---|
| 480 | #new state |
---|
| 481 | data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, |
---|
| 482 | data_name, ct_type=1, |
---|
| 483 | data=(data_id, data_class, state_id)) |
---|
| 484 | data_c.Check(True) |
---|
| 485 | d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') |
---|
[b2aef1c] | 486 | d_t_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
| 487 | 'Title: %s' % data_title) |
---|
| 488 | r_n_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
| 489 | 'Run: %s' % data_run) |
---|
[61ffd1e] | 490 | i_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
| 491 | 'Type: %s' % data_class) |
---|
| 492 | p_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
[603fb0f] | 493 | "Path: '%s'" % s_path) |
---|
[61ffd1e] | 494 | d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') |
---|
| 495 | |
---|
| 496 | for process in process_list: |
---|
[0b0b7de] | 497 | process_str = str(process).replace('\n',' ') |
---|
| 498 | if len(process_str)>20: |
---|
| 499 | process_str = process_str[:20]+' [...]' |
---|
[61ffd1e] | 500 | i_t_c = self.tree_ctrl.AppendItem(d_p_c, |
---|
[0b0b7de] | 501 | process_str) |
---|
[61ffd1e] | 502 | theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") |
---|
| 503 | |
---|
| 504 | self.list_cb_data[state_id] = [data_c, |
---|
| 505 | d_i_c, |
---|
[b2aef1c] | 506 | d_t_c, |
---|
| 507 | r_n_c, |
---|
[61ffd1e] | 508 | i_c_c, |
---|
| 509 | p_c_c, |
---|
| 510 | d_p_c, |
---|
| 511 | theory_child] |
---|
| 512 | else: |
---|
| 513 | data_ctrl_list = self.list_cb_data[state_id] |
---|
| 514 | #This state is already display replace it contains |
---|
[b2aef1c] | 515 | data_c, d_i_c, d_t_c, r_n_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list |
---|
[61ffd1e] | 516 | self.tree_ctrl.SetItemText(data_c, data_name) |
---|
| 517 | temp = (data_id, data_class, state_id) |
---|
| 518 | self.tree_ctrl.SetItemPyData(data_c, temp) |
---|
| 519 | self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) |
---|
[76703da] | 520 | self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % s_path) |
---|
[61ffd1e] | 521 | self.tree_ctrl.DeleteChildren(d_p_c) |
---|
| 522 | for process in process_list: |
---|
| 523 | i_t_c = self.tree_ctrl.AppendItem(d_p_c, |
---|
| 524 | process.__str__()) |
---|
| 525 | self.append_theory(state_id, theory_list) |
---|
[248b918] | 526 | self.enable_remove() |
---|
[f7d0b74] | 527 | self.enable_import() |
---|
| 528 | self.enable_plot() |
---|
| 529 | self.enable_freeze() |
---|
[61ffd1e] | 530 | self.enable_selection() |
---|
[91bdf87] | 531 | |
---|
[48665ed] | 532 | def _uncheck_all(self): |
---|
| 533 | """ |
---|
| 534 | Uncheck all check boxes |
---|
| 535 | """ |
---|
| 536 | for item in self.list_cb_data.values(): |
---|
[b2aef1c] | 537 | data_ctrl, _, _, _, _, _,_, _ = item |
---|
[48665ed] | 538 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
[1e3394f] | 539 | self.enable_append() |
---|
| 540 | self.enable_freeze() |
---|
| 541 | self.enable_plot() |
---|
| 542 | self.enable_import() |
---|
[248b918] | 543 | self.enable_remove() |
---|
[600eca2] | 544 | |
---|
[91bdf87] | 545 | def append_theory(self, state_id, theory_list): |
---|
[bffa3d0] | 546 | """ |
---|
| 547 | append theory object under data from a state of id = state_id |
---|
| 548 | replace that theory if already displayed |
---|
| 549 | """ |
---|
| 550 | if not theory_list: |
---|
| 551 | return |
---|
| 552 | if state_id not in self.list_cb_data.keys(): |
---|
| 553 | root = self.tree_ctrl_theory.root |
---|
[91bdf87] | 554 | tree = self.tree_ctrl_theory |
---|
[bffa3d0] | 555 | else: |
---|
| 556 | item = self.list_cb_data[state_id] |
---|
[b2aef1c] | 557 | data_c, _, _, _, _, _, _, _ = item |
---|
[bffa3d0] | 558 | root = data_c |
---|
[91bdf87] | 559 | tree = self.tree_ctrl |
---|
[bffa3d0] | 560 | if root is not None: |
---|
[91bdf87] | 561 | self.append_theory_helper(tree=tree, root=root, |
---|
[bffa3d0] | 562 | state_id=state_id, |
---|
| 563 | theory_list=theory_list) |
---|
| 564 | |
---|
[71bd773] | 565 | |
---|
[91bdf87] | 566 | def append_theory_helper(self, tree, root, state_id, theory_list): |
---|
[71bd773] | 567 | """ |
---|
| 568 | """ |
---|
| 569 | if state_id in self.list_cb_theory.keys(): |
---|
[c70eb7c] | 570 | #update current list of theory for this data |
---|
[71bd773] | 571 | theory_list_ctrl = self.list_cb_theory[state_id] |
---|
[c70eb7c] | 572 | |
---|
| 573 | for theory_id, item in theory_list.iteritems(): |
---|
[e88ebfd] | 574 | theory_data, theory_state = item |
---|
[c70eb7c] | 575 | if theory_data is None: |
---|
| 576 | name = "Unknown" |
---|
| 577 | theory_class = "Unknown" |
---|
| 578 | theory_id = "Unknown" |
---|
| 579 | temp = (None, None, None) |
---|
| 580 | else: |
---|
| 581 | name = theory_data.name |
---|
| 582 | theory_class = theory_data.__class__.__name__ |
---|
| 583 | theory_id = theory_data.id |
---|
[ee2b492] | 584 | #if theory_state is not None: |
---|
| 585 | # name = theory_state.model.name |
---|
[c70eb7c] | 586 | temp = (theory_id, theory_class, state_id) |
---|
| 587 | if theory_id not in theory_list_ctrl: |
---|
| 588 | #add new theory |
---|
[91bdf87] | 589 | t_child = tree.AppendItem(root, |
---|
[c70eb7c] | 590 | name, ct_type=1, data=temp) |
---|
[91bdf87] | 591 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
| 592 | i_c_c = tree.AppendItem(t_i_c, |
---|
[c70eb7c] | 593 | 'Type: %s' % theory_class) |
---|
[91bdf87] | 594 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
[c70eb7c] | 595 | |
---|
| 596 | for process in theory_data.process: |
---|
[91bdf87] | 597 | i_t_c = tree.AppendItem(t_p_c, |
---|
[c70eb7c] | 598 | process.__str__()) |
---|
| 599 | theory_list_ctrl[theory_id] = [t_child, |
---|
| 600 | i_c_c, |
---|
| 601 | t_p_c] |
---|
| 602 | else: |
---|
| 603 | #replace theory |
---|
| 604 | t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] |
---|
[91bdf87] | 605 | tree.SetItemText(t_child, name) |
---|
| 606 | tree.SetItemPyData(t_child, temp) |
---|
| 607 | tree.SetItemText(i_c_c, 'Type: %s' % theory_class) |
---|
| 608 | tree.DeleteChildren(t_p_c) |
---|
[c70eb7c] | 609 | for process in theory_data.process: |
---|
[91bdf87] | 610 | i_t_c = tree.AppendItem(t_p_c, |
---|
[c70eb7c] | 611 | process.__str__()) |
---|
| 612 | |
---|
| 613 | else: |
---|
| 614 | #data didn't have a theory associated it before |
---|
| 615 | theory_list_ctrl = {} |
---|
| 616 | for theory_id, item in theory_list.iteritems(): |
---|
[e88ebfd] | 617 | theory_data, theory_state = item |
---|
[c70eb7c] | 618 | if theory_data is not None: |
---|
[e88ebfd] | 619 | name = theory_data.name |
---|
[c70eb7c] | 620 | theory_class = theory_data.__class__.__name__ |
---|
[e88ebfd] | 621 | theory_id = theory_data.id |
---|
[ee2b492] | 622 | #if theory_state is not None: |
---|
| 623 | # name = theory_state.model.name |
---|
[e88ebfd] | 624 | temp = (theory_id, theory_class, state_id) |
---|
[91bdf87] | 625 | t_child = tree.AppendItem(root, |
---|
[e88ebfd] | 626 | name, ct_type=1, |
---|
[c70eb7c] | 627 | data=(theory_data.id, theory_class, state_id)) |
---|
[91bdf87] | 628 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
| 629 | i_c_c = tree.AppendItem(t_i_c, |
---|
[c70eb7c] | 630 | 'Type: %s' % theory_class) |
---|
[91bdf87] | 631 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
[c70eb7c] | 632 | |
---|
| 633 | for process in theory_data.process: |
---|
[91bdf87] | 634 | i_t_c = tree.AppendItem(t_p_c, |
---|
[c70eb7c] | 635 | process.__str__()) |
---|
| 636 | |
---|
| 637 | theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] |
---|
[71bd773] | 638 | #self.list_cb_theory[data_id] = theory_list_ctrl |
---|
| 639 | self.list_cb_theory[state_id] = theory_list_ctrl |
---|
[91bdf87] | 640 | |
---|
[c70eb7c] | 641 | |
---|
[ee2b492] | 642 | |
---|
[3feed3e] | 643 | def set_data_helper(self): |
---|
[3c44c66] | 644 | """ |
---|
| 645 | """ |
---|
[3feed3e] | 646 | data_to_plot = [] |
---|
[e88ebfd] | 647 | state_to_plot = [] |
---|
| 648 | theory_to_plot = [] |
---|
[c70eb7c] | 649 | for value in self.list_cb_data.values(): |
---|
[b2aef1c] | 650 | item, _, _, _, _, _, _, _ = value |
---|
[3feed3e] | 651 | if item.IsChecked(): |
---|
[3658717e] | 652 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
| 653 | data_to_plot.append(data_id) |
---|
| 654 | if state_id not in state_to_plot: |
---|
| 655 | state_to_plot.append(state_id) |
---|
| 656 | |
---|
[c70eb7c] | 657 | for theory_dict in self.list_cb_theory.values(): |
---|
| 658 | for key, value in theory_dict.iteritems(): |
---|
| 659 | item, _, _ = value |
---|
| 660 | if item.IsChecked(): |
---|
[e88ebfd] | 661 | theory_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
[c70eb7c] | 662 | theory_to_plot.append(theory_id) |
---|
[e88ebfd] | 663 | if state_id not in state_to_plot: |
---|
| 664 | state_to_plot.append(state_id) |
---|
| 665 | return data_to_plot, theory_to_plot, state_to_plot |
---|
[3feed3e] | 666 | |
---|
[c70eb7c] | 667 | def remove_by_id(self, id): |
---|
| 668 | """ |
---|
| 669 | """ |
---|
| 670 | for item in self.list_cb_data.values(): |
---|
[b2aef1c] | 671 | data_c, _, _, _, _, _, _, theory_child = item |
---|
[c70eb7c] | 672 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) |
---|
| 673 | if id == data_id: |
---|
| 674 | self.tree_ctrl.Delete(data_c) |
---|
| 675 | del self.list_cb_data[state_id] |
---|
| 676 | del self.list_cb_theory[data_id] |
---|
[ae83ad3] | 677 | |
---|
[2a62d5c] | 678 | def load_error(self, error=None): |
---|
| 679 | """ |
---|
| 680 | Pop up an error message. |
---|
| 681 | |
---|
| 682 | :param error: details error message to be displayed |
---|
| 683 | """ |
---|
[8cb8c89] | 684 | if error is not None or str(error).strip() != "": |
---|
| 685 | dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', |
---|
[2a62d5c] | 686 | wx.OK | wx.ICON_EXCLAMATION) |
---|
[8cb8c89] | 687 | dial.ShowModal() |
---|
[2a62d5c] | 688 | |
---|
| 689 | def _load_data(self, event): |
---|
| 690 | """ |
---|
[a03d419] | 691 | send an event to the parent to trigger load from plugin module |
---|
[2a62d5c] | 692 | """ |
---|
| 693 | if self.parent is not None: |
---|
[a03d419] | 694 | wx.PostEvent(self.parent, NewLoadDataEvent()) |
---|
[2a62d5c] | 695 | |
---|
[a03d419] | 696 | |
---|
[3feed3e] | 697 | def on_remove(self, event): |
---|
[18ec684] | 698 | """ |
---|
[3658717e] | 699 | Get a list of item checked and remove them from the treectrl |
---|
| 700 | Ask the parent to remove reference to this item |
---|
[18ec684] | 701 | """ |
---|
[296b9c1] | 702 | msg = "This operation will delete the data sets checked " |
---|
[6a7cf2c] | 703 | msg += "and all the dependents." |
---|
[296b9c1] | 704 | msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) |
---|
| 705 | if msg_box.ShowModal() != wx.ID_OK: |
---|
| 706 | return |
---|
| 707 | |
---|
[665c083] | 708 | data_to_remove, theory_to_remove, _ = self.set_data_helper() |
---|
| 709 | data_key = [] |
---|
| 710 | theory_key = [] |
---|
[3658717e] | 711 | #remove data from treectrl |
---|
| 712 | for d_key, item in self.list_cb_data.iteritems(): |
---|
[b2aef1c] | 713 | data_c, d_i_c, d_t_c, r_n_c, i_c_c, p_c_c, d_p_c, t_c = item |
---|
[665c083] | 714 | if data_c.IsChecked(): |
---|
| 715 | self.tree_ctrl.Delete(data_c) |
---|
[3658717e] | 716 | data_key.append(d_key) |
---|
| 717 | if d_key in self.list_cb_theory.keys(): |
---|
| 718 | theory_list_ctrl = self.list_cb_theory[d_key] |
---|
| 719 | theory_to_remove += theory_list_ctrl.keys() |
---|
| 720 | # Remove theory from treectrl |
---|
| 721 | for t_key, theory_dict in self.list_cb_theory.iteritems(): |
---|
| 722 | for key, value in theory_dict.iteritems(): |
---|
[665c083] | 723 | item, _, _ = value |
---|
| 724 | if item.IsChecked(): |
---|
[e26d0db] | 725 | try: |
---|
| 726 | self.tree_ctrl.Delete(item) |
---|
| 727 | except: |
---|
| 728 | pass |
---|
[665c083] | 729 | theory_key.append(key) |
---|
[e26d0db] | 730 | |
---|
[3658717e] | 731 | #Remove data and related theory references |
---|
[665c083] | 732 | for key in data_key: |
---|
| 733 | del self.list_cb_data[key] |
---|
[3658717e] | 734 | if key in theory_key: |
---|
| 735 | del self.list_cb_theory[key] |
---|
| 736 | #remove theory references independently of data |
---|
[665c083] | 737 | for key in theory_key: |
---|
[3658717e] | 738 | for t_key, theory_dict in self.list_cb_theory.iteritems(): |
---|
[71bd773] | 739 | if key in theory_dict: |
---|
[e26d0db] | 740 | for key, value in theory_dict.iteritems(): |
---|
| 741 | item, _, _ = value |
---|
| 742 | if item.IsChecked(): |
---|
| 743 | try: |
---|
| 744 | self.tree_ctrl_theory.Delete(item) |
---|
| 745 | except: |
---|
| 746 | pass |
---|
[71bd773] | 747 | del theory_dict[key] |
---|
[e26d0db] | 748 | |
---|
[3658717e] | 749 | |
---|
[18ec684] | 750 | self.parent.remove_data(data_id=data_to_remove, |
---|
[665c083] | 751 | theory_id=theory_to_remove) |
---|
[248b918] | 752 | self.enable_remove() |
---|
[f7d0b74] | 753 | self.enable_freeze() |
---|
[e26d0db] | 754 | self.enable_remove_plot() |
---|
[3c44c66] | 755 | |
---|
[3feed3e] | 756 | def on_import(self, event=None): |
---|
[3c44c66] | 757 | """ |
---|
[3feed3e] | 758 | Get all select data and set them to the current active perspetive |
---|
[3c44c66] | 759 | """ |
---|
[3603b2e] | 760 | if event != None: |
---|
| 761 | event.Skip() |
---|
[e88ebfd] | 762 | data_id, theory_id, state_id = self.set_data_helper() |
---|
[248b918] | 763 | temp = data_id + state_id |
---|
| 764 | self.parent.set_data(data_id=temp, theory_id=theory_id) |
---|
[e88ebfd] | 765 | |
---|
[213892bc] | 766 | def on_append_plot(self, event=None): |
---|
| 767 | """ |
---|
| 768 | append plot to plot panel on focus |
---|
| 769 | """ |
---|
[0a2fdca] | 770 | self._on_plot_selection() |
---|
[e88ebfd] | 771 | data_id, theory_id, state_id = self.set_data_helper() |
---|
| 772 | self.parent.plot_data(data_id=data_id, |
---|
| 773 | state_id=state_id, |
---|
| 774 | theory_id=theory_id, |
---|
| 775 | append=True) |
---|
[213892bc] | 776 | |
---|
[3feed3e] | 777 | def on_plot(self, event=None): |
---|
[3c44c66] | 778 | """ |
---|
[3feed3e] | 779 | Send a list of data names to plot |
---|
[3c44c66] | 780 | """ |
---|
[e88ebfd] | 781 | data_id, theory_id, state_id = self.set_data_helper() |
---|
| 782 | self.parent.plot_data(data_id=data_id, |
---|
| 783 | state_id=state_id, |
---|
| 784 | theory_id=theory_id, |
---|
| 785 | append=False) |
---|
[e26d0db] | 786 | self.enable_remove_plot() |
---|
[48665ed] | 787 | |
---|
[1b1bbf9] | 788 | def on_close_page(self, event=None): |
---|
| 789 | """ |
---|
| 790 | On close |
---|
| 791 | """ |
---|
| 792 | if event != None: |
---|
| 793 | event.Skip() |
---|
| 794 | # send parent to update menu with no show nor hide action |
---|
| 795 | self.parent.show_data_panel(action=False) |
---|
| 796 | |
---|
[c70eb7c] | 797 | def on_freeze(self, event): |
---|
| 798 | """ |
---|
[2719255] | 799 | On freeze to make a theory to a data set |
---|
[c70eb7c] | 800 | """ |
---|
[e88ebfd] | 801 | _, theory_id, state_id = self.set_data_helper() |
---|
[2719255] | 802 | if len(theory_id) > 0: |
---|
| 803 | self.parent.freeze(data_id=state_id, theory_id=theory_id) |
---|
| 804 | msg = "Freeze Theory:" |
---|
| 805 | msg += " The theory(s) copied to the Data box as a data set." |
---|
| 806 | else: |
---|
| 807 | msg = "Freeze Theory: Requires at least one theory checked." |
---|
| 808 | wx.PostEvent(self.parent, StatusEvent(status=msg)) |
---|
| 809 | |
---|
[3feed3e] | 810 | def set_active_perspective(self, name): |
---|
[3c44c66] | 811 | """ |
---|
[3feed3e] | 812 | set the active perspective |
---|
[3c44c66] | 813 | """ |
---|
[600eca2] | 814 | self.perspective_cbox.SetStringSelection(name) |
---|
[2a62d5c] | 815 | self.enable_import() |
---|
| 816 | |
---|
[13a63ab] | 817 | def _on_delete_plot_panel(self, event): |
---|
| 818 | """ |
---|
| 819 | get an event with attribute name and caption to delete existing name |
---|
| 820 | from the combobox of the current panel |
---|
| 821 | """ |
---|
| 822 | name = event.name |
---|
| 823 | caption = event.caption |
---|
| 824 | if self.cb_plotpanel is not None: |
---|
| 825 | pos = self.cb_plotpanel.FindString(str(caption)) |
---|
| 826 | if pos != wx.NOT_FOUND: |
---|
| 827 | self.cb_plotpanel.Delete(pos) |
---|
| 828 | self.enable_append() |
---|
| 829 | |
---|
[83a75c5] | 830 | def set_panel_on_focus(self, name=None): |
---|
[3c44c66] | 831 | """ |
---|
[3feed3e] | 832 | set the plot panel on focus |
---|
[3c44c66] | 833 | """ |
---|
[0a2fdca] | 834 | for key, value in self.parent.plot_panels.iteritems(): |
---|
| 835 | name_plot_panel = str(value.window_caption) |
---|
| 836 | if name_plot_panel not in self.cb_plotpanel.GetItems(): |
---|
| 837 | self.cb_plotpanel.Append(name_plot_panel, value) |
---|
[83a75c5] | 838 | if name != None and name == name_plot_panel: |
---|
| 839 | self.cb_plotpanel.SetStringSelection(name_plot_panel) |
---|
| 840 | break |
---|
[f7d0b74] | 841 | self.enable_append() |
---|
[e26d0db] | 842 | self.enable_remove_plot() |
---|
[5e8e615] | 843 | |
---|
[600eca2] | 844 | def _on_perspective_selection(self, event=None): |
---|
| 845 | """ |
---|
| 846 | select the current perspective for guiframe |
---|
| 847 | """ |
---|
| 848 | selection = self.perspective_cbox.GetSelection() |
---|
| 849 | if self.perspective_cbox.GetValue() != 'None': |
---|
| 850 | perspective = self.perspective_cbox.GetClientData(selection) |
---|
| 851 | perspective.on_perspective(event=None) |
---|
[e4d790f] | 852 | self.parent.check_multimode(perspective=perspective) |
---|
[7360816] | 853 | |
---|
[e26d0db] | 854 | def _on_plot_selection(self, event=None): |
---|
[0a2fdca] | 855 | """ |
---|
| 856 | On source combobox selection |
---|
| 857 | """ |
---|
| 858 | if event != None: |
---|
| 859 | combo = event.GetEventObject() |
---|
[b113128] | 860 | event.Skip() |
---|
[0a2fdca] | 861 | else: |
---|
| 862 | combo = self.cb_plotpanel |
---|
| 863 | selection = combo.GetSelection() |
---|
| 864 | |
---|
| 865 | if combo.GetValue() != 'None': |
---|
| 866 | panel = combo.GetClientData(selection) |
---|
| 867 | self.parent.on_set_plot_focus(panel) |
---|
[2a62d5c] | 868 | |
---|
[e26d0db] | 869 | def on_close_plot(self, event): |
---|
| 870 | """ |
---|
| 871 | clseo the panel on focus |
---|
| 872 | """ |
---|
| 873 | self.enable_append() |
---|
| 874 | selection = self.cb_plotpanel.GetSelection() |
---|
| 875 | if self.cb_plotpanel.GetValue() != 'None': |
---|
| 876 | panel = self.cb_plotpanel.GetClientData(selection) |
---|
| 877 | if self.parent is not None and panel is not None: |
---|
| 878 | wx.PostEvent(self.parent, |
---|
| 879 | NewPlotEvent(group_id=panel.group_id, |
---|
| 880 | action="delete")) |
---|
| 881 | self.enable_remove_plot() |
---|
| 882 | |
---|
| 883 | def enable_remove_plot(self): |
---|
| 884 | """ |
---|
| 885 | enable remove plot button if there is a plot panel on focus |
---|
| 886 | """ |
---|
[c5a769e] | 887 | pass |
---|
| 888 | #if self.cb_plotpanel.GetCount() == 0: |
---|
| 889 | # self.bt_close_plot.Disable() |
---|
| 890 | #else: |
---|
| 891 | # self.bt_close_plot.Enable() |
---|
[e26d0db] | 892 | |
---|
[2a62d5c] | 893 | def enable_remove(self): |
---|
| 894 | """ |
---|
| 895 | enable or disable remove button |
---|
| 896 | """ |
---|
| 897 | n_t = self.tree_ctrl.GetCount() |
---|
| 898 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
| 899 | if n_t + n_t_t <= 0: |
---|
| 900 | self.bt_remove.Disable() |
---|
| 901 | else: |
---|
| 902 | self.bt_remove.Enable() |
---|
| 903 | |
---|
| 904 | def enable_import(self): |
---|
| 905 | """ |
---|
| 906 | enable or disable send button |
---|
| 907 | """ |
---|
[61ffd1e] | 908 | n_t = 0 |
---|
| 909 | if self.tree_ctrl != None: |
---|
| 910 | n_t = self.tree_ctrl.GetCount() |
---|
[600eca2] | 911 | if n_t > 0 and len(self.list_of_perspective) > 0: |
---|
| 912 | self.bt_import.Enable() |
---|
| 913 | else: |
---|
[2a62d5c] | 914 | self.bt_import.Disable() |
---|
[600eca2] | 915 | if len(self.list_of_perspective) <= 0 or \ |
---|
| 916 | self.perspective_cbox.GetValue() in ["None", |
---|
| 917 | "No Active Application"]: |
---|
| 918 | self.perspective_cbox.Disable() |
---|
[2a62d5c] | 919 | else: |
---|
[600eca2] | 920 | self.perspective_cbox.Enable() |
---|
[f7d0b74] | 921 | |
---|
| 922 | def enable_plot(self): |
---|
| 923 | """ |
---|
| 924 | enable or disable plot button |
---|
| 925 | """ |
---|
[600eca2] | 926 | n_t = 0 |
---|
| 927 | n_t_t = 0 |
---|
| 928 | if self.tree_ctrl != None: |
---|
| 929 | n_t = self.tree_ctrl.GetCount() |
---|
| 930 | if self.tree_ctrl_theory != None: |
---|
| 931 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
[f7d0b74] | 932 | if n_t + n_t_t <= 0: |
---|
| 933 | self.bt_plot.Disable() |
---|
| 934 | else: |
---|
| 935 | self.bt_plot.Enable() |
---|
[5e8e615] | 936 | self.enable_append() |
---|
| 937 | |
---|
[f7d0b74] | 938 | def enable_append(self): |
---|
| 939 | """ |
---|
| 940 | enable or disable append button |
---|
| 941 | """ |
---|
[600eca2] | 942 | n_t = 0 |
---|
| 943 | n_t_t = 0 |
---|
| 944 | if self.tree_ctrl != None: |
---|
| 945 | n_t = self.tree_ctrl.GetCount() |
---|
| 946 | if self.tree_ctrl_theory != None: |
---|
| 947 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
| 948 | if n_t + n_t_t <= 0: |
---|
[f7d0b74] | 949 | self.bt_append_plot.Disable() |
---|
[600eca2] | 950 | self.cb_plotpanel.Disable() |
---|
[5e8e615] | 951 | elif self.cb_plotpanel.GetCount() <= 0: |
---|
[600eca2] | 952 | self.cb_plotpanel.Disable() |
---|
[5e8e615] | 953 | self.bt_append_plot.Disable() |
---|
[f7d0b74] | 954 | else: |
---|
| 955 | self.bt_append_plot.Enable() |
---|
[df8cc63] | 956 | self.cb_plotpanel.Enable() |
---|
[f7d0b74] | 957 | |
---|
[1e3394f] | 958 | def check_theory_to_freeze(self): |
---|
| 959 | """ |
---|
| 960 | """ |
---|
[f7d0b74] | 961 | def enable_freeze(self): |
---|
| 962 | """ |
---|
| 963 | enable or disable the freeze button |
---|
| 964 | """ |
---|
[61ffd1e] | 965 | n_t_t = 0 |
---|
| 966 | n_l = 0 |
---|
| 967 | if self.tree_ctrl_theory != None: |
---|
| 968 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
[f7d0b74] | 969 | n_l = len(self.list_cb_theory) |
---|
[5e8e615] | 970 | if (n_t_t + n_l > 0): |
---|
[f7d0b74] | 971 | self.bt_freeze.Enable() |
---|
[1e3394f] | 972 | else: |
---|
| 973 | self.bt_freeze.Disable() |
---|
[f7d0b74] | 974 | |
---|
[61ffd1e] | 975 | def enable_selection(self): |
---|
| 976 | """ |
---|
| 977 | enable or disable combobo box selection |
---|
| 978 | """ |
---|
| 979 | n_t = 0 |
---|
| 980 | n_t_t = 0 |
---|
| 981 | if self.tree_ctrl != None: |
---|
| 982 | n_t = self.tree_ctrl.GetCount() |
---|
| 983 | if self.tree_ctrl_theory != None: |
---|
| 984 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
| 985 | if n_t + n_t_t > 0 and self.selection_cbox != None: |
---|
| 986 | self.selection_cbox.Enable() |
---|
| 987 | else: |
---|
| 988 | self.selection_cbox.Disable() |
---|
| 989 | |
---|
[a03d419] | 990 | def show_data_button(self): |
---|
| 991 | """ |
---|
| 992 | show load data and remove data button if |
---|
| 993 | dataloader on else hide them |
---|
| 994 | """ |
---|
| 995 | try: |
---|
| 996 | gui_style = self.parent.get_style() |
---|
| 997 | style = gui_style & GUIFRAME.DATALOADER_ON |
---|
| 998 | if style == GUIFRAME.DATALOADER_ON: |
---|
| 999 | #self.bt_remove.Show(True) |
---|
| 1000 | self.bt_add.Show(True) |
---|
| 1001 | else: |
---|
| 1002 | #self.bt_remove.Hide() |
---|
| 1003 | self.bt_add.Hide() |
---|
| 1004 | except: |
---|
| 1005 | #self.bt_remove.Hide() |
---|
| 1006 | self.bt_add.Hide() |
---|
[e26d0db] | 1007 | |
---|
[60fff67] | 1008 | |
---|
| 1009 | |
---|
| 1010 | WIDTH = 400 |
---|
| 1011 | HEIGHT = 300 |
---|
| 1012 | |
---|
| 1013 | |
---|
| 1014 | class DataDialog(wx.Dialog): |
---|
| 1015 | """ |
---|
| 1016 | Allow file selection at loading time |
---|
| 1017 | """ |
---|
| 1018 | def __init__(self, data_list, parent=None, text='', *args, **kwds): |
---|
| 1019 | wx.Dialog.__init__(self, parent, *args, **kwds) |
---|
| 1020 | self.SetTitle("Data Selection") |
---|
| 1021 | self.SetSize((WIDTH, HEIGHT)) |
---|
| 1022 | self.list_of_ctrl = [] |
---|
| 1023 | if not data_list: |
---|
| 1024 | return |
---|
| 1025 | self._sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
| 1026 | self._sizer_txt = wx.BoxSizer(wx.VERTICAL) |
---|
| 1027 | self._sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 1028 | self.sizer = wx.GridBagSizer(5, 5) |
---|
| 1029 | self._panel = ScrolledPanel(self, style=wx.RAISED_BORDER, |
---|
| 1030 | size=(WIDTH-20, HEIGHT-50)) |
---|
| 1031 | self._panel.SetupScrolling() |
---|
| 1032 | self.__do_layout(data_list, text=text) |
---|
| 1033 | |
---|
| 1034 | def __do_layout(self, data_list, text=''): |
---|
| 1035 | """ |
---|
| 1036 | layout the dialog |
---|
| 1037 | """ |
---|
| 1038 | if not data_list or len(data_list) <= 1: |
---|
| 1039 | return |
---|
| 1040 | #add text |
---|
| 1041 | |
---|
| 1042 | text = "Deleting these file reset some panels.\n" |
---|
| 1043 | text += "Do you want to proceed?\n" |
---|
| 1044 | text_ctrl = wx.StaticText(self, -1, str(text)) |
---|
| 1045 | self._sizer_txt.Add(text_ctrl) |
---|
| 1046 | iy = 0 |
---|
| 1047 | ix = 0 |
---|
| 1048 | data_count = 0 |
---|
| 1049 | for (data_name, in_use, sub_menu) in range(len(data_list)): |
---|
| 1050 | if in_use == True: |
---|
| 1051 | ctrl_name = wx.StaticBox(self, -1, str(data_name)) |
---|
| 1052 | ctrl_in_use = wx.StaticBox(self, -1, " is used by ") |
---|
| 1053 | plug_name = str(sub_menu) + "\n" |
---|
| 1054 | ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) |
---|
| 1055 | self.sizer.Add(ctrl_name, (iy, ix), |
---|
| 1056 | (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 1057 | ix += 1 |
---|
| 1058 | self._sizer_button.Add(ctrl_in_use, 1, |
---|
| 1059 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1060 | ix += 1 |
---|
| 1061 | self._sizer_button.Add(plug_name, 1, |
---|
| 1062 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1063 | iy += 1 |
---|
| 1064 | self._panel.SetSizer(self.sizer) |
---|
| 1065 | #add sizer |
---|
| 1066 | self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1067 | button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") |
---|
| 1068 | self._sizer_button.Add(button_cancel, 0, |
---|
| 1069 | wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
| 1070 | button_OK = wx.Button(self, wx.ID_OK, "Ok") |
---|
| 1071 | button_OK.SetFocus() |
---|
| 1072 | self._sizer_button.Add(button_OK, 0, |
---|
| 1073 | wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
| 1074 | static_line = wx.StaticLine(self, -1) |
---|
| 1075 | |
---|
| 1076 | self._sizer_txt.Add(self._panel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5) |
---|
| 1077 | self._sizer_main.Add(self._sizer_txt, 1, wx.EXPAND|wx.ALL, 10) |
---|
| 1078 | self._sizer_main.Add(self._data_text_ctrl, 0, |
---|
| 1079 | wx.EXPAND|wx.LEFT|wx.RIGHT, 10) |
---|
| 1080 | self._sizer_main.Add(static_line, 0, wx.EXPAND, 0) |
---|
| 1081 | self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10) |
---|
| 1082 | self.SetSizer(self._sizer_main) |
---|
| 1083 | self.Layout() |
---|
| 1084 | |
---|
| 1085 | def get_data(self): |
---|
| 1086 | """ |
---|
| 1087 | return the selected data |
---|
| 1088 | """ |
---|
| 1089 | temp = [] |
---|
| 1090 | for item in self.list_of_ctrl: |
---|
| 1091 | cb, data = item |
---|
| 1092 | if cb.GetValue(): |
---|
| 1093 | temp.append(data) |
---|
| 1094 | return temp |
---|
| 1095 | |
---|
| 1096 | def _count_selected_data(self, event): |
---|
| 1097 | """ |
---|
| 1098 | count selected data |
---|
| 1099 | """ |
---|
| 1100 | if event.GetEventObject().GetValue(): |
---|
| 1101 | self._nb_selected_data += 1 |
---|
| 1102 | else: |
---|
| 1103 | self._nb_selected_data -= 1 |
---|
| 1104 | select_data_text = " %s Data selected.\n" % str(self._nb_selected_data) |
---|
| 1105 | self._data_text_ctrl.SetLabel(select_data_text) |
---|
| 1106 | if self._nb_selected_data <= self._max_data: |
---|
| 1107 | self._data_text_ctrl.SetForegroundColour('blue') |
---|
| 1108 | else: |
---|
| 1109 | self._data_text_ctrl.SetForegroundColour('red') |
---|
| 1110 | |
---|
| 1111 | |
---|
[f7d0b74] | 1112 | |
---|
[3c44c66] | 1113 | class DataFrame(wx.Frame): |
---|
[3feed3e] | 1114 | ## Internal name for the AUI manager |
---|
| 1115 | window_name = "Data Panel" |
---|
| 1116 | ## Title to appear on top of the window |
---|
| 1117 | window_caption = "Data Panel" |
---|
| 1118 | ## Flag to tell the GUI manager that this panel is not |
---|
| 1119 | # tied to any perspective |
---|
| 1120 | ALWAYS_ON = True |
---|
| 1121 | |
---|
[ea4dfe0] | 1122 | def __init__(self, parent=None, owner=None, manager=None,size=(300, 800), |
---|
[3feed3e] | 1123 | list_of_perspective=[],list=[], *args, **kwds): |
---|
[cc061c3] | 1124 | kwds['size'] = size |
---|
[3c44c66] | 1125 | kwds['id'] = -1 |
---|
[3feed3e] | 1126 | kwds['title']= "Loaded Data" |
---|
[3c44c66] | 1127 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
| 1128 | self.parent = parent |
---|
| 1129 | self.owner = owner |
---|
| 1130 | self.manager = manager |
---|
[32c0841] | 1131 | self.panel = DataPanel(parent=self, |
---|
[cc061c3] | 1132 | #size=size, |
---|
[32c0841] | 1133 | list_of_perspective=list_of_perspective) |
---|
[3feed3e] | 1134 | |
---|
| 1135 | def load_data_list(self, list=[]): |
---|
[3c44c66] | 1136 | """ |
---|
| 1137 | Fill the list inside its panel |
---|
| 1138 | """ |
---|
[3feed3e] | 1139 | self.panel.load_data_list(list=list) |
---|
[3c44c66] | 1140 | |
---|
[5e8e615] | 1141 | |
---|
[3feed3e] | 1142 | |
---|
| 1143 | from dataFitting import Data1D |
---|
| 1144 | from dataFitting import Data2D, Theory1D |
---|
| 1145 | from data_state import DataState |
---|
| 1146 | import sys |
---|
| 1147 | class State(): |
---|
| 1148 | def __init__(self): |
---|
| 1149 | self.msg = "" |
---|
| 1150 | def __str__(self): |
---|
| 1151 | self.msg = "model mane : model1\n" |
---|
| 1152 | self.msg += "params : \n" |
---|
| 1153 | self.msg += "name value\n" |
---|
| 1154 | return msg |
---|
[71bd773] | 1155 | def set_data_state(data=None, path=None, theory=None, state=None): |
---|
[3feed3e] | 1156 | dstate = DataState(data=data) |
---|
| 1157 | dstate.set_path(path=path) |
---|
[c70eb7c] | 1158 | dstate.set_theory(theory, state) |
---|
| 1159 | |
---|
[3feed3e] | 1160 | return dstate |
---|
| 1161 | """' |
---|
| 1162 | data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), |
---|
| 1163 | ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), |
---|
| 1164 | ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), |
---|
| 1165 | ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), |
---|
| 1166 | ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] |
---|
| 1167 | """ |
---|
[3c44c66] | 1168 | if __name__ == "__main__": |
---|
[3feed3e] | 1169 | |
---|
[3c44c66] | 1170 | app = wx.App() |
---|
[3feed3e] | 1171 | try: |
---|
| 1172 | list_of_perspective = [('perspective2', False), ('perspective1', True)] |
---|
| 1173 | data_list = {} |
---|
[c70eb7c] | 1174 | # state 1 |
---|
[ee2b492] | 1175 | data = Data2D() |
---|
| 1176 | data.name = "data2" |
---|
[584c4c4] | 1177 | data.id = 1 |
---|
[c70eb7c] | 1178 | data.append_empty_process() |
---|
| 1179 | process = data.process[len(data.process)-1] |
---|
| 1180 | process.data = "07/01/2010" |
---|
[ee2b492] | 1181 | theory = Data2D() |
---|
[584c4c4] | 1182 | theory.id = 34 |
---|
[c70eb7c] | 1183 | theory.name = "theory1" |
---|
[3feed3e] | 1184 | path = "path1" |
---|
| 1185 | state = State() |
---|
| 1186 | data_list['1']=set_data_state(data, path,theory, state) |
---|
[c70eb7c] | 1187 | #state 2 |
---|
[ee2b492] | 1188 | data = Data2D() |
---|
[3feed3e] | 1189 | data.name = "data2" |
---|
[584c4c4] | 1190 | data.id = 76 |
---|
[ee2b492] | 1191 | theory = Data2D() |
---|
[584c4c4] | 1192 | theory.id = 78 |
---|
[3feed3e] | 1193 | theory.name = "CoreShell 07/24/25" |
---|
| 1194 | path = "path2" |
---|
[c70eb7c] | 1195 | #state3 |
---|
[3feed3e] | 1196 | state = State() |
---|
| 1197 | data_list['2']=set_data_state(data, path,theory, state) |
---|
| 1198 | data = Data1D() |
---|
[584c4c4] | 1199 | data.id = 3 |
---|
[3feed3e] | 1200 | data.name = "data2" |
---|
| 1201 | theory = Theory1D() |
---|
| 1202 | theory.name = "CoreShell" |
---|
[584c4c4] | 1203 | theory.id = 4 |
---|
[c70eb7c] | 1204 | theory.append_empty_process() |
---|
| 1205 | process = theory.process[len(theory.process)-1] |
---|
| 1206 | process.description = "this is my description" |
---|
[3feed3e] | 1207 | path = "path3" |
---|
[c70eb7c] | 1208 | data.append_empty_process() |
---|
| 1209 | process = data.process[len(data.process)-1] |
---|
| 1210 | process.data = "07/22/2010" |
---|
[3feed3e] | 1211 | data_list['4']=set_data_state(data, path,theory, state) |
---|
[c70eb7c] | 1212 | #state 4 |
---|
| 1213 | temp_data_list = {} |
---|
| 1214 | data.name = "data5 erasing data2" |
---|
| 1215 | temp_data_list['4'] = set_data_state(data, path,theory, state) |
---|
| 1216 | #state 5 |
---|
[3feed3e] | 1217 | data = Data2D() |
---|
| 1218 | data.name = "data3" |
---|
[584c4c4] | 1219 | data.id = 5 |
---|
[c70eb7c] | 1220 | data.append_empty_process() |
---|
| 1221 | process = data.process[len(data.process)-1] |
---|
| 1222 | process.data = "07/01/2010" |
---|
[3feed3e] | 1223 | theory = Theory1D() |
---|
[c70eb7c] | 1224 | theory.name = "Cylinder" |
---|
[3feed3e] | 1225 | path = "path2" |
---|
| 1226 | state = State() |
---|
| 1227 | dstate= set_data_state(data, path,theory, state) |
---|
| 1228 | theory = Theory1D() |
---|
[584c4c4] | 1229 | theory.id = 6 |
---|
[c70eb7c] | 1230 | theory.name = "CoreShell" |
---|
| 1231 | dstate.set_theory(theory) |
---|
| 1232 | theory = Theory1D() |
---|
| 1233 | theory.id = 6 |
---|
| 1234 | theory.name = "CoreShell replacing coreshell in data3" |
---|
[3feed3e] | 1235 | dstate.set_theory(theory) |
---|
[c70eb7c] | 1236 | data_list['3'] = dstate |
---|
| 1237 | #state 6 |
---|
| 1238 | data_list['6']=set_data_state(None, path,theory, state) |
---|
[71bd773] | 1239 | data_list['6']=set_data_state(theory=theory, state=None) |
---|
| 1240 | theory = Theory1D() |
---|
| 1241 | theory.id = 7 |
---|
| 1242 | data_list['6']=set_data_state(theory=theory, state=None) |
---|
| 1243 | data_list['7']=set_data_state(theory=theory, state=None) |
---|
[3feed3e] | 1244 | window = DataFrame(list=data_list) |
---|
[c70eb7c] | 1245 | window.load_data_list(list=data_list) |
---|
[3feed3e] | 1246 | window.Show(True) |
---|
[c70eb7c] | 1247 | window.load_data_list(list=temp_data_list) |
---|
[3feed3e] | 1248 | except: |
---|
| 1249 | #raise |
---|
| 1250 | print "error",sys.exc_value |
---|
[c70eb7c] | 1251 | |
---|
[3c44c66] | 1252 | app.MainLoop() |
---|
| 1253 | |
---|
| 1254 | |
---|