Changeset c70eb7c in sasview for guiframe/data_panel.py
- Timestamp:
- Mar 9, 2011 7:02:50 PM (13 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:
- 8b6f489
- Parents:
- 99abf5d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_panel.py
rcc061c3 rc70eb7c 59 59 self.list_of_perspective = list_of_perspective 60 60 self.list_rb_perspectives= [] 61 self.list_cb_data =[] 62 self.list_cb_theory =[] 61 self.list_cb_data = {} 62 self.list_cb_theory = {} 63 63 64 self.owner = None 64 65 self.do_layout() … … 181 182 option = self.selection_cbox.GetString(pos) 182 183 for item in self.list_cb_data: 183 data_id, data_class = self.tree_ctrl.GetItemPyData(item) 184 data_ctrl, _, _ = item 185 data_id, data_class = self.tree_ctrl.GetItemPyData(dta_ctrl) 184 186 if option == 'Select all Data': 185 187 self.tree_ctrl.CheckItem(item, True) … … 190 192 self.tree_ctrl.CheckItem(item, True) 191 193 elif option == 'Unselect all Data 1D': 192 if data_class in ['Data1D', 'Theory1D']:194 if data_class == 'Data1D': 193 195 self.tree_ctrl.CheckItem(item, False) 194 196 elif option == 'Select all Data 1D': 195 if data_class == ['Data1D', 'Theory1D']:197 if data_class == 'Data1D': 196 198 self.tree_ctrl.CheckItem(item, True) 197 199 elif option == 'Select all Data 2D': … … 223 225 self.bt_plot.SetToolTipString("To trigger plotting") 224 226 wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) 227 228 self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze") 229 self.bt_freeze.SetToolTipString("To trigger freeze") 230 wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) 225 231 226 232 self.bt_remove = wx.Button(self, wx.NewId(), "Remove Data") … … 253 259 ix = 0 254 260 iy += 1 261 self.sizer3.Add(self.bt_freeze,( iy, ix),(1,1), 262 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 263 ix = 0 264 iy += 1 255 265 self.sizer3.Add(self.bt_remove,( iy, ix),(1,1), 256 266 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 317 327 item = event.GetItem() 318 328 name = self.tree_ctrl.GetItemText(item) 319 329 320 330 def load_data_list(self, list): 321 331 """ 322 332 add need data with its theory under the tree 323 333 """ 324 334 if not list: 325 335 return 326 336 327 for dstate in list.values():337 for state_id, dstate in list.iteritems(): 328 338 data = dstate.get_data() 329 339 if data is None: 330 data_name = str(data) 331 data_class = "unkonwn" 340 data_name = "Unkonwn" 341 data_class = "Unkonwn" 342 path = "Unkonwn" 343 process_list = [] 344 data_id = "Unkonwn" 332 345 else: 333 346 data_name = data.name 334 data_class = data.__class__.__name__ 335 path = dstate.get_path() 347 data_class = data.__class__.__name__ 348 path = dstate.get_path() 349 process_list = data.process 350 data_id = data.id 336 351 theory_list = dstate.get_theory() 337 data_child = None 352 if state_id not in self.list_cb_data: 353 #new state 354 data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 355 data_name, ct_type=1, 356 data=(data_id, data_class, state_id)) 357 data_c.Check(True) 358 d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 359 i_c_c = self.tree_ctrl.AppendItem(d_i_c, 360 'Type: %s' % data_class) 361 p_c_c = self.tree_ctrl.AppendItem(d_i_c, 362 'Path: %s' % str(path)) 363 d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 364 365 for process in process_list: 366 i_t_c = self.tree_ctrl.AppendItem(d_p_c, 367 process.__str__()) 368 theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") 369 370 self.list_cb_data[state_id] = [data_c, 371 d_i_c, 372 i_c_c, 373 p_c_c, 374 d_p_c, 375 theory_child] 376 else: 377 data_ctrl_list = self.list_cb_data[state_id] 378 #This state is already display replace it contains 379 data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list 380 self.tree_ctrl.SetItemText(data_c, data_name) 381 temp = (data_id, data_class, state_id) 382 self.tree_ctrl.SetItemPyData(data_c, temp) 383 self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) 384 self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % str(path)) 385 self.tree_ctrl.DeleteChildren(d_p_c) 386 for process in process_list: 387 i_t_c = self.tree_ctrl.AppendItem(d_p_c, 388 process.__str__()) 389 self.append_theory(state_id, theory_list) 390 391 392 def append_theory(self, state_id, theory_list): 393 """ 394 append theory object under data from a state of id = state_id 395 replace that theory if already displayed 396 """ 397 if not theory_list: 398 return 399 if state_id not in self.list_cb_data.keys(): 400 msg = "Invalid state ID : %s requested for theory" % str(state_id) 401 raise ValueError, msg 338 402 339 if theory_list: 340 for theory_id,theory in theory_list.iteritems(): 341 for item in self.list_cb_data: 342 data_id, data_class = self.tree_ctrl.GetItemPyData(item) 343 if data_id == data.id: 344 data_child = item 345 for process in data.process: 346 theory_child = self.tree_ctrl.FindItem(data_child, 347 "CREATED DATA"), 348 if theory is not None: 349 av_theory_child =self.tree_ctrl.AppendItem(theory_child, 350 theory.name,ct_type=1, 351 data=(theory_id, theory)) 352 self.list_cb_theory.append(av_theory_child) 353 av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 354 'info') 355 for process in theory.process: 356 info_time_child = self.tree_ctrl.AppendItem(av_theory_child_info, 357 process.__str__()) 358 359 break 360 if data_child is None: 361 data_child = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 362 data_name, ct_type=1, 363 data=(data.id, data_class)) 364 cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root) 365 item, id = cb_data 366 item.Check(True) 367 self.list_cb_data.append(item) 368 data_info_child =self.tree_ctrl.AppendItem(data_child, 'info')#, 369 #wnd=data_info_txt) 370 info_class_child =self.tree_ctrl.AppendItem(data_info_child, 371 'Type: %s'%data_class) 372 path_class_child =self.tree_ctrl.AppendItem(data_info_child, 373 'Path: %s'%str(path)) 374 for process in data.process: 375 info_time_child =self.tree_ctrl.AppendItem(data_info_child,process.__str__()) 376 theory_child =self.tree_ctrl.AppendItem(data_child, "Available Theories") 377 378 if theory_list: 379 theory = theory_list[len(theory_list)-1] 380 if theory is not None: 381 av_theory_child =self.tree_ctrl.AppendItem(theory_child, 382 theory.name,ct_type=1) 383 self.list_cb_theory.append(av_theory_child) 384 av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 385 'info') 386 for process in theory.process: 387 info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, 388 process.__str__()) 389 403 item = self.list_cb_data[state_id] 404 data_c, _, _, _, _, theory_child = item 405 data_id, _, _ = self.tree_ctrl.GetItemPyData(data_c) 406 407 if data_id in self.list_cb_theory.keys(): 408 #update current list of theory for this data 409 theory_list_ctrl = self.list_cb_theory[data_id] 410 411 for theory_id, item in theory_list.iteritems(): 412 theory_data, _ = item 413 if theory_data is None: 414 name = "Unknown" 415 theory_class = "Unknown" 416 theory_id = "Unknown" 417 temp = (None, None, None) 418 else: 419 name = theory_data.name 420 theory_class = theory_data.__class__.__name__ 421 theory_id = theory_data.id 422 temp = (theory_id, theory_class, state_id) 423 if theory_id not in theory_list_ctrl: 424 #add new theory 425 t_child = self.tree_ctrl.AppendItem(theory_child, 426 name, ct_type=1, data=temp) 427 t_i_c = self.tree_ctrl.AppendItem(t_child, 'Info') 428 i_c_c = self.tree_ctrl.AppendItem(t_i_c, 429 'Type: %s' % theory_class) 430 t_p_c = self.tree_ctrl.AppendItem(t_i_c, 'Process') 431 432 for process in theory_data.process: 433 i_t_c = self.tree_ctrl.AppendItem(t_p_c, 434 process.__str__()) 435 theory_list_ctrl[theory_id] = [t_child, 436 i_c_c, 437 t_p_c] 438 else: 439 #replace theory 440 t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] 441 self.tree_ctrl.SetItemText(t_child, name) 442 self.tree_ctrl.SetItemPyData(t_child, temp) 443 self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % theory_class) 444 self.tree_ctrl.DeleteChildren(t_p_c) 445 for process in theory_data.process: 446 i_t_c = self.tree_ctrl.AppendItem(t_p_c, 447 process.__str__()) 448 449 else: 450 #data didn't have a theory associated it before 451 theory_list_ctrl = {} 452 for theory_id, item in theory_list.iteritems(): 453 theory_data, _ = item 454 if theory_data is not None: 455 theory_class = theory_data.__class__.__name__ 456 457 t_child = self.tree_ctrl.AppendItem(theory_child, 458 theory_data.name, ct_type=1, 459 data=(theory_data.id, theory_class, state_id)) 460 t_i_c = self.tree_ctrl.AppendItem(t_child, 'Info') 461 i_c_c = self.tree_ctrl.AppendItem(t_i_c, 462 'Type: %s' % theory_class) 463 t_p_c = self.tree_ctrl.AppendItem(t_i_c, 'Process') 464 465 for process in theory_data.process: 466 i_t_c = self.tree_ctrl.AppendItem(t_p_c, 467 process.__str__()) 468 469 theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 470 self.list_cb_theory[data_id] = theory_list_ctrl 471 472 390 473 def set_data_helper(self): 391 474 """ 392 475 """ 393 476 data_to_plot = [] 394 for item in self.list_cb_data: 477 for value in self.list_cb_data.values(): 478 item, _, _, _, _, _ = value 395 479 if item.IsChecked(): 396 data_id, data_class= self.tree_ctrl.GetItemPyData(item)480 data_id, _, _ = self.tree_ctrl.GetItemPyData(item) 397 481 data_to_plot.append(data_id) 398 482 theory_to_plot = [] 399 for item in self.list_cb_theory: 400 if item.IsChecked(): 401 data_id, data_class = self.tree_ctrl.GetItemPyData(item) 402 theory_to_plot.append(data_id) 483 for theory_dict in self.list_cb_theory.values(): 484 for key, value in theory_dict.iteritems(): 485 item, _, _ = value 486 if item.IsChecked(): 487 theory_id, _, _ = self.tree_ctrl.GetItemPyData(item) 488 theory_to_plot.append(theory_id) 403 489 return data_to_plot, theory_to_plot 404 490 491 def remove_by_id(self, id): 492 """ 493 """ 494 for item in self.list_cb_data.values(): 495 data_c, _, _, _, _, theory_child = item 496 data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) 497 if id == data_id: 498 self.tree_ctrl.Delete(data_c) 499 del self.list_cb_data[state_id] 500 del self.list_cb_theory[data_id] 501 print "went here" 502 405 503 def on_remove(self, event): 406 504 """ … … 441 539 self.post_helper(plot=True) 442 540 541 def on_freeze(self, event): 542 """ 543 """ 544 data_to_plot, theory_to_plot = self.set_data_helper() 545 self.parent.freeze(data_id=data_to_plot, theory_id=theory_to_plot) 546 443 547 def set_active_perspective(self, name): 444 548 """ … … 457 561 """ 458 562 data_to_plot, theory_to_plot = self.set_data_helper() 459 460 563 if self.parent is not None: 461 564 self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot, 462 565 append=append) 566 567 463 568 464 569 … … 495 600 """ 496 601 self.panel.layout_perspective(list_of_perspective=list_of_perspective) 602 603 497 604 498 605 … … 512 619 dstate = DataState(data=data) 513 620 dstate.set_path(path=path) 514 dstate.set_theory(theory )515 dstate.set_state(state)621 dstate.set_theory(theory, state) 622 516 623 return dstate 517 624 """' … … 528 635 list_of_perspective = [('perspective2', False), ('perspective1', True)] 529 636 data_list = {} 637 # state 1 530 638 data = Data1D() 531 639 data.name = "data1" 532 640 data.id = 1 533 #data.append_process()534 #process = data.process[len(data.process)-1]535 #process.data = "07/01/2010"641 data.append_empty_process() 642 process = data.process[len(data.process)-1] 643 process.data = "07/01/2010" 536 644 theory = Theory1D() 537 645 theory.id = 34 538 theory. pseudo_name = "theory1"646 theory.name = "theory1" 539 647 path = "path1" 540 648 state = State() 541 649 data_list['1']=set_data_state(data, path,theory, state) 542 650 #state 2 543 651 data = Data1D() 544 652 data.name = "data2" … … 547 655 theory.id = 78 548 656 theory.name = "CoreShell 07/24/25" 549 theory.pseudo_name = "CoreShell"550 657 path = "path2" 658 #state3 551 659 state = State() 552 660 data_list['2']=set_data_state(data, path,theory, state) … … 556 664 theory = Theory1D() 557 665 theory.name = "CoreShell" 558 theory.pseudo_name = "CoreShell"559 666 theory.id = 4 560 #theory.append_process()561 #process = theory.process[len(theory.process)-1]562 #process.description = "this is my description"667 theory.append_empty_process() 668 process = theory.process[len(theory.process)-1] 669 process.description = "this is my description" 563 670 path = "path3" 564 #data.append_process()565 #process = data.process[len(data.process)-1]566 #process.data = "07/22/2010"671 data.append_empty_process() 672 process = data.process[len(data.process)-1] 673 process.data = "07/22/2010" 567 674 data_list['4']=set_data_state(data, path,theory, state) 568 675 #state 4 676 temp_data_list = {} 677 data.name = "data5 erasing data2" 678 temp_data_list['4'] = set_data_state(data, path,theory, state) 679 #state 5 569 680 data = Data2D() 570 681 data.name = "data3" 571 682 data.id = 5 572 #data.append_process()573 #process = data.process[len(data.process)-1]574 #process.data = "07/01/2010"683 data.append_empty_process() 684 process = data.process[len(data.process)-1] 685 process.data = "07/01/2010" 575 686 theory = Theory1D() 576 theory. pseudo_name = "Cylinder"687 theory.name = "Cylinder" 577 688 path = "path2" 578 689 state = State() … … 580 691 theory = Theory1D() 581 692 theory.id = 6 582 theory. pseudo_name = "Sphere"693 theory.name = "CoreShell" 583 694 dstate.set_theory(theory) 584 data_list['3']=dstate 695 theory = Theory1D() 696 theory.id = 6 697 theory.name = "CoreShell replacing coreshell in data3" 698 dstate.set_theory(theory) 699 data_list['3'] = dstate 700 #state 6 701 data_list['6']=set_data_state(None, path,theory, state) 585 702 586 703 window = DataFrame(list=data_list) 587 #window.load_data_list(list=data_list)588 window.layout_perspective(list_of_perspective=list_of_perspective)704 window.load_data_list(list=data_list) 705 #window.layout_perspective(list_of_perspective=list_of_perspective) 589 706 window.Show(True) 707 window.load_data_list(list=temp_data_list) 590 708 except: 591 709 #raise 592 710 print "error",sys.exc_value 711 593 712 app.MainLoop() 594 713
Note: See TracChangeset
for help on using the changeset viewer.