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