Changeset 5e5704d in sasview for sansguiframe
- Timestamp:
- Jul 12, 2012 1:55:30 PM (12 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d4d4c8a
- Parents:
- 67fb83b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_panel.py
r38226d26 r5e5704d 156 156 self.data_menu = None 157 157 self.popUpMenu = None 158 158 self.plot3d_id = None 159 self.editmask_id = None 160 # Default attr 161 self.vbox = None 162 self.sizer1 = None 163 self.sizer2 = None 164 self.sizer3 = None 165 self.sizer4 = None 166 self.sizer5 = None 167 self.selection_cbox = None 168 self.bt_add = None 169 self.bt_remove = None 170 self.bt_import = None 171 self.bt_append_plot = None 172 self.bt_plot = None 173 self.bt_freeze = None 174 self.cb_plotpanel = None 175 self.rb_single_mode = None 176 self.rb_batch_mode = None 177 159 178 self.owner = None 160 179 self.do_layout() … … 176 195 def disable_app_combo(self, enable): 177 196 """ 197 Disable app combo box 178 198 """ 179 199 self.perspective_cbox.Enable(enable) … … 217 237 self.selection_cbox.Append(str(option)) 218 238 self.selection_cbox.SetValue('Select all Data') 219 wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type)220 self.sizer5.AddMany([(select_txt, 0, wx.ALL,5),239 wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type) 240 self.sizer5.AddMany([(select_txt, 0, wx.ALL,5), 221 241 (self.selection_cbox,0, wx.ALL,5)]) 222 242 self.enable_selection() … … 235 255 option = self.selection_cbox.GetString(pos) 236 256 for item in self.list_cb_data.values(): 237 data_ctrl, _, _, _, _, _, _, _ = item238 data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl)257 data_ctrl, _, _, _, _, _, _, _ = item 258 _, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) 239 259 if option == 'Select all Data': 240 260 self.tree_ctrl.CheckItem(data_ctrl, True) … … 266 286 Layout widgets related to buttons 267 287 """ 268 w, _ = self.GetSize()269 270 288 self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 271 289 size=(BUTTON_WIDTH, -1)) … … 278 296 self.bt_import = wx.Button(self, wx.NewId(), "Send To", 279 297 size=(BUTTON_WIDTH, -1)) 280 self.bt_import.SetToolTipString("Send set of Datato active perspective")298 self.bt_import.SetToolTipString("Send Data set to active perspective") 281 299 wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 282 300 self.perspective_cbox = wx.ComboBox(self, -1, … … 289 307 self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", 290 308 size=(BUTTON_WIDTH, -1)) 291 self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") 309 self.bt_append_plot.SetToolTipString( \ 310 "Plot the selected data in the active panel") 292 311 wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 293 312 … … 311 330 self.cb_plotpanel = wx.ComboBox(self, -1, 312 331 style=wx.CB_READONLY|wx.CB_SORT) 313 wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection)332 wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection) 314 333 self.cb_plotpanel.Disable() 315 334 … … 323 342 ((10, 10)), 324 343 (self.bt_append_plot), 325 (self.cb_plotpanel, wx.EXPAND|wx.ADJUST_MINSIZE, 5), 344 (self.cb_plotpanel, 345 wx.EXPAND|wx.ADJUST_MINSIZE, 5), 326 346 ((5, 5)), 327 347 ((5, 5)), 328 348 (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5), 329 (self.perspective_cbox, wx.EXPAND|wx.ADJUST_MINSIZE, 5), 349 (self.perspective_cbox, 350 wx.EXPAND|wx.ADJUST_MINSIZE, 5), 330 351 ((10, 10)), 331 352 (self.sizer4), … … 365 386 """ 366 387 if self.parent is not None: 367 wx.PostEvent(self.parent, 368 NewBatchEvent(enable=False)) 388 wx.PostEvent(self.parent, NewBatchEvent(enable=False)) 369 389 370 390 def on_batch_mode(self, event): … … 386 406 id, _, _ = self.FindFocus().GetSelection().GetData() 387 407 data_list, theory_list = \ 388 self.parent._data_manager.get_by_id(id_list=[id])408 self.parent.get_data_manager().get_by_id(id_list=[id]) 389 409 if data_list: 390 410 data = data_list.values()[0] … … 483 503 wx.EVT_MENU(self, id, self.on_save_as) 484 504 485 self.quickplot_id = wx.NewId()505 quickplot_id = wx.NewId() 486 506 name = "Quick Plot" 487 507 msg = "Plot the current Data" 488 self.data_menu.Append( self.quickplot_id, name, msg)489 wx.EVT_MENU(self, self.quickplot_id, self.on_quick_plot)508 self.data_menu.Append(quickplot_id, name, msg) 509 wx.EVT_MENU(self, quickplot_id, self.on_quick_plot) 490 510 491 511 self.plot3d_id = wx.NewId() … … 522 542 self.tree_ctrl_theory.GetSelection().GetData() 523 543 data_list, _ = \ 524 self.parent. _data_manager.get_by_id(id_list=[id])544 self.parent.get_data_manager().get_by_id(id_list=[id]) 525 545 except: 526 546 return … … 535 555 Allow Editing Data 536 556 """ 537 selection = event.GetSelection()557 #selection = event.GetSelection() 538 558 is_data = True 539 559 try: 540 560 id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() 541 561 data_list, _ = \ 542 self.parent. _data_manager.get_by_id(id_list=[id])562 self.parent.get_data_manager().get_by_id(id_list=[id]) 543 563 if not data_list: 544 564 is_data = False … … 565 585 def on_check_item(self, event): 566 586 """ 587 On check item 567 588 """ 568 589 item = event.GetItem() … … 613 634 if state_id not in self.list_cb_data: 614 635 #new state 615 data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root, 0,616 617 636 data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root, 637 0, data_name, ct_type=1, 638 data=(data_id, data_class, state_id)) 618 639 data_c.Check(True) 619 640 d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') … … 632 653 if len(process_str)>20: 633 654 process_str = process_str[:20]+' [...]' 634 i_t_c = self.tree_ctrl.AppendItem(d_p_c, 635 process_str) 636 theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") 637 655 self.tree_ctrl.AppendItem(d_p_c, process_str) 656 theory_child = self.tree_ctrl.AppendItem(data_c, 657 "THEORIES") 638 658 self.list_cb_data[state_id] = [data_c, 639 659 d_i_c, … … 641 661 r_n_c, 642 662 i_c_c, 643 644 645 663 p_c_c, 664 d_p_c, 665 theory_child] 646 666 else: 647 667 data_ctrl_list = self.list_cb_data[state_id] 648 668 #This state is already display replace it contains 649 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 669 data_c, d_i_c, d_t_c, r_n_c, i_c_c, p_c_c, d_p_c, t_c \ 670 = data_ctrl_list 650 671 self.tree_ctrl.SetItemText(data_c, data_name) 651 672 temp = (data_id, data_class, state_id) 652 673 self.tree_ctrl.SetItemPyData(data_c, temp) 653 self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) 654 self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % s_path) 674 self.tree_ctrl.SetItemText(i_c_c, 675 'Type: %s' % data_class) 676 self.tree_ctrl.SetItemText(p_c_c, 677 'Path: %s' % s_path) 655 678 self.tree_ctrl.DeleteChildren(d_p_c) 656 679 for process in process_list: … … 672 695 """ 673 696 for item in self.list_cb_data.values(): 674 data_ctrl, _, _, _, _, _, _, _ = item697 data_ctrl, _, _, _, _, _, _, _ = item 675 698 self.tree_ctrl.CheckItem(data_ctrl, False) 676 699 self.enable_append() … … 696 719 tree = self.tree_ctrl 697 720 if root is not None: 698 721 wx.CallAfter(self.append_theory_helper, tree=tree, root=root, 699 722 state_id=state_id, 700 723 theory_list=theory_list) … … 703 726 def append_theory_helper(self, tree, root, state_id, theory_list): 704 727 """ 728 Append theory helper 705 729 """ 706 730 if state_id in self.list_cb_theory.keys(): … … 709 733 710 734 for theory_id, item in theory_list.iteritems(): 711 theory_data, theory_state= item735 theory_data, _ = item 712 736 if theory_data is None: 713 737 name = "Unknown" … … 732 756 733 757 for process in theory_data.process: 734 i_t_c = tree.AppendItem(t_p_c, 735 process.__str__()) 758 tree.AppendItem(t_p_c, process.__str__()) 736 759 theory_list_ctrl[theory_id] = [t_child, 737 760 i_c_c, … … 745 768 tree.DeleteChildren(t_p_c) 746 769 for process in theory_data.process: 747 i_t_c = tree.AppendItem(t_p_c, 748 process.__str__()) 770 tree.AppendItem(t_p_c, process.__str__()) 749 771 750 772 else: … … 769 791 770 792 for process in theory_data.process: 771 i_t_c = tree.AppendItem(t_p_c, 772 process.__str__()) 793 tree.AppendItem(t_p_c, process.__str__()) 773 794 774 795 theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] … … 780 801 def set_data_helper(self): 781 802 """ 803 Set data helper 782 804 """ 783 805 data_to_plot = [] … … 793 815 794 816 for theory_dict in self.list_cb_theory.values(): 795 for key, value in theory_dict.iteritems():817 for _, value in theory_dict.iteritems(): 796 818 item, _, _ = value 797 819 if item.IsChecked(): … … 804 826 def remove_by_id(self, id): 805 827 """ 828 Remove_dat by id 806 829 """ 807 830 for item in self.list_cb_data.values(): 808 data_c, _, _, _, _, _, _, theory_child= item831 data_c, _, _, _, _, _, _, _ = item 809 832 data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) 810 833 if id == data_id: … … 820 843 """ 821 844 if error is not None or str(error).strip() != "": 822 dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', 823 wx.OK | wx.ICON_EXCLAMATION) 845 dial = wx.MessageDialog(self.parent, str(error), 846 'Error Loading File', 847 wx.OK | wx.ICON_EXCLAMATION) 824 848 dial.ShowModal() 825 849 … … 848 872 #remove data from treectrl 849 873 for d_key, item in self.list_cb_data.iteritems(): 850 data_c, d_i_c, d_t_c, r_n_c, i_c_c, p_c_c, d_p_c, t_c= item874 data_c, _, _, _, _, _, _, _ = item 851 875 if data_c.IsChecked(): 852 876 self.tree_ctrl.Delete(data_c) … … 856 880 theory_to_remove += theory_list_ctrl.keys() 857 881 # Remove theory from treectrl 858 for t_key, theory_dict in self.list_cb_theory.iteritems():882 for _, theory_dict in self.list_cb_theory.iteritems(): 859 883 for key, value in theory_dict.iteritems(): 860 884 item, _, _ = value … … 957 981 from the combobox of the current panel 958 982 """ 959 name = event.name983 #name = event.name 960 984 caption = event.caption 961 985 if self.cb_plotpanel is not None: … … 969 993 set the plot panel on focus 970 994 """ 971 for key, value in self.parent.plot_panels.iteritems():995 for _, value in self.parent.plot_panels.iteritems(): 972 996 name_plot_panel = str(value.window_caption) 973 997 if name_plot_panel not in self.cb_plotpanel.GetItems(): … … 1087 1111 self.cb_plotpanel.Disable() 1088 1112 elif self.cb_plotpanel.GetCount() <= 0: 1089 1090 1113 self.cb_plotpanel.Disable() 1114 self.bt_append_plot.Disable() 1091 1115 else: 1092 1116 self.bt_append_plot.Enable() … … 1183 1207 iy = 0 1184 1208 ix = 0 1185 data_count = 01209 #data_count = 0 1186 1210 for (data_name, in_use, sub_menu) in range(len(data_list)): 1187 1211 if in_use == True: … … 1189 1213 ctrl_in_use = wx.StaticBox(self, -1, " is used by ") 1190 1214 plug_name = str(sub_menu) + "\n" 1191 ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)1215 #ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) 1192 1216 self.sizer.Add(ctrl_name, (iy, ix), 1193 1217 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 1232 1256 1233 1257 class DataFrame(wx.Frame): 1258 """ 1259 Data Frame 1260 """ 1234 1261 ## Internal name for the AUI manager 1235 1262 window_name = "Data Panel" … … 1240 1267 ALWAYS_ON = True 1241 1268 1242 def __init__(self, parent=None, owner=None, manager=None, size=(300, 800),1243 list_of_perspective=[], list=[], *args, **kwds):1269 def __init__(self, parent=None, owner=None, manager=None, size=(300, 800), 1270 list_of_perspective=[], list=[], *args, **kwds): 1244 1271 kwds['size'] = size 1245 1272 kwds['id'] = -1 1246 kwds['title'] = "Loaded Data"1273 kwds['title'] = "Loaded Data" 1247 1274 wx.Frame.__init__(self, parent=parent, *args, **kwds) 1248 1275 self.parent = parent … … 1261 1288 1262 1289 1263 from dataFitting import Data1D1264 from dataFitting import Data2D, Theory1D1265 from data_state import DataState1266 import sys 1290 from sans.guiframe.dataFitting import Data1D 1291 from sans.guiframe.dataFitting import Data2D, Theory1D 1292 from sans.guiframe.data_state import DataState 1293 1267 1294 class State(): 1295 """ 1296 DataPanel State 1297 """ 1268 1298 def __init__(self): 1269 1299 self.msg = "" … … 1275 1305 1276 1306 def set_data_state(data=None, path=None, theory=None, state=None): 1307 """ 1308 Set data state 1309 """ 1277 1310 dstate = DataState(data=data) 1278 1311 dstate.set_path(path=path) … … 1280 1313 1281 1314 return dstate 1282 """' 1283 data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), 1284 ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), 1285 ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), 1286 ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), 1287 ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] 1288 """ 1315 1289 1316 if __name__ == "__main__": 1290 1317 1291 1318 app = wx.App() 1292 1319 try: 1293 list_of_perspective = [('perspective2', False), ('perspective1', True)]1294 data_list = {}1320 #list_of_perspective = [('perspective2', False), ('perspective1', True)] 1321 data_list1 = {} 1295 1322 # state 1 1296 data = Data2D()1297 data .name = "data2"1298 data .id = 11299 data .append_empty_process()1300 process = data.process[len(data.process)-1]1301 process .data = "07/01/2010"1323 data1 = Data2D() 1324 data1.name = "data2" 1325 data1.id = 1 1326 data1.append_empty_process() 1327 process1 = data1.process[len(data1.process)-1] 1328 process1.data = "07/01/2010" 1302 1329 theory = Data2D() 1303 1330 theory.id = 34 1304 1331 theory.name = "theory1" 1305 1332 path = "path1" 1306 state = State()1307 data_list ['1']=set_data_state(data, path,theory, state)1333 state1 = State() 1334 data_list1['1'] = set_data_state(data1, path,theory, state1) 1308 1335 #state 2 1309 data = Data2D()1310 data .name = "data2"1311 data .id = 761336 data1 = Data2D() 1337 data1.name = "data2" 1338 data1.id = 76 1312 1339 theory = Data2D() 1313 1340 theory.id = 78 … … 1315 1342 path = "path2" 1316 1343 #state3 1317 state = State()1318 data_list ['2']=set_data_state(data, path,theory, state)1319 data = Data1D()1320 data .id = 31321 data .name = "data2"1344 state1 = State() 1345 data_list1['2'] = set_data_state(data1, path,theory, state1) 1346 data1 = Data1D() 1347 data1.id = 3 1348 data1.name = "data2" 1322 1349 theory = Theory1D() 1323 1350 theory.name = "CoreShell" 1324 1351 theory.id = 4 1325 1352 theory.append_empty_process() 1326 process = theory.process[len(theory.process)-1]1327 process .description = "this is my description"1353 process1 = theory.process[len(theory.process)-1] 1354 process1.description = "this is my description" 1328 1355 path = "path3" 1329 data .append_empty_process()1330 process = data.process[len(data.process)-1]1331 process .data = "07/22/2010"1332 data_list ['4']=set_data_state(data, path,theory, state)1356 data1.append_empty_process() 1357 process1 = data1.process[len(data1.process)-1] 1358 process1.data = "07/22/2010" 1359 data_list1['4'] = set_data_state(data1, path,theory, state1) 1333 1360 #state 4 1334 1361 temp_data_list = {} 1335 data .name = "data5 erasing data2"1336 temp_data_list['4'] = set_data_state(data , path,theory, state)1362 data1.name = "data5 erasing data2" 1363 temp_data_list['4'] = set_data_state(data1, path,theory, state1) 1337 1364 #state 5 1338 data = Data2D()1339 data .name = "data3"1340 data .id = 51341 data .append_empty_process()1342 process = data.process[len(data.process)-1]1343 process .data = "07/01/2010"1365 data1 = Data2D() 1366 data1.name = "data3" 1367 data1.id = 5 1368 data1.append_empty_process() 1369 process1 = data.process[len(data1.process)-1] 1370 process1.data = "07/01/2010" 1344 1371 theory = Theory1D() 1345 1372 theory.name = "Cylinder" 1346 1373 path = "path2" 1347 state = State()1348 dstate= set_data_state(data, path,theory, state )1374 state1 = State() 1375 dstate= set_data_state(data, path,theory, state1) 1349 1376 theory = Theory1D() 1350 1377 theory.id = 6 … … 1355 1382 theory.name = "CoreShell replacing coreshell in data3" 1356 1383 dstate.set_theory(theory) 1357 data_list ['3'] = dstate1384 data_list1['3'] = dstate 1358 1385 #state 6 1359 data_list ['6']=set_data_state(None, path,theory, state)1360 data_list ['6']=set_data_state(theory=theory, state=None)1386 data_list1['6'] = set_data_state(None, path, theory, state1) 1387 data_list1['6'] = set_data_state(theory=theory, state=None) 1361 1388 theory = Theory1D() 1362 1389 theory.id = 7 1363 data_list ['6']=set_data_state(theory=theory, state=None)1364 data_list ['7']=set_data_state(theory=theory, state=None)1365 window = DataFrame(list=data_list )1366 window.load_data_list(list=data_list )1390 data_list1['6'] = set_data_state(theory=theory, state=None) 1391 data_list1['7'] = set_data_state(theory=theory, state=None) 1392 window = DataFrame(list=data_list1) 1393 window.load_data_list(list=data_list1) 1367 1394 window.Show(True) 1368 1395 window.load_data_list(list=temp_data_list) 1369 1396 except: 1370 1397 #raise 1371 print "error", sys.exc_value1398 print "error", sys.exc_value 1372 1399 1373 1400 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.