Changeset cb463b4 in sasview for invariantview/perspectives/invariant
- Timestamp:
- Jul 23, 2010 7:05:49 PM (14 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:
- a94c4e1
- Parents:
- 4e9583c
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant.py
r1e3610d rcb463b4 258 258 :param state: State object 259 259 """ 260 261 260 try: 262 261 if datainfo is None: 263 262 raise RuntimeError, "invariant.set_state: datainfo parameter cannot be None in standalone mode" 264 datainfo.meta_data['invstate'].file = datainfo.meta_data['invstate'].file +"_copy"263 datainfo.meta_data['invstate'].file = datainfo.meta_data['invstate'].file 265 264 datainfo.name = datainfo.meta_data['invstate'].file 266 265 datainfo.filename = datainfo.meta_data['invstate'].file … … 274 273 # Make sure the user sees the invariant panel after loading 275 274 self.parent.set_perspective(self.perspective) 276 277 275 # set state 278 self.invariant_panel.set_state(state=temp_state,data=self.__data) 276 self.invariant_panel.set_state(state=temp_state,data=self.__data) 279 277 280 278 except: -
invariantview/perspectives/invariant/invariant_panel.py
r1a3a03b rcb463b4 205 205 self.state = IState() 206 206 else: 207 207 208 if not self.set_current_data(data): 208 209 return … … 211 212 212 213 num = self.state.saved_state['state_num'] 213 self.get_state_by_num(state_num=num) 214 215 if num >0 : 214 215 if num > 0 : 216 216 self._undo_enable() 217 217 if num < len(state.state_list)-1: 218 218 self._redo_enable() 219 219 220 221 220 # get bookmarks 222 221 self.bookmark_num = len(self.state.bookmark_list) 222 223 223 total_bookmark_num = self.bookmark_num+1 224 224 for ind in range(1,total_bookmark_num): … … 229 229 id = wx.NewId() 230 230 self.popUpMenu.Append(id,name,str('')) 231 wx.EVT_MENU(self, id, self._back_to_bookmark) 231 wx.EVT_MENU(self, id, self._back_to_bookmark) 232 233 self.get_state_by_num(state_num=str(num)) 234 232 235 self._get_input_list() 236 233 237 self.new_state = False 234 238 235 239 236 240 def get_background(self): … … 494 498 elif event != None: 495 499 self._set_compute_state(state='compute') 500 self.button_bookmark.Enable(True) 496 501 msg= "\n\nStarting a new invariant computation..." 497 502 wx.PostEvent(self.parent, StatusEvent(status=msg)) 503 498 504 499 505 if self._data is None or self.err_check_on_data(): … … 579 585 self.state.timestamp= self._get_time_stamp() 580 586 msg = self.state.__str__() 587 self.state.set_report_string() 581 588 self.is_power_out = False 582 589 wx.PostEvent(self.parent, StatusEvent(status = msg )) 583 590 584 591 #enable the button_ok for more details 585 592 self.button_details.Enable() 586 587 593 self.button_details.SetFocus() 588 594 if event != None: 595 self.button_report.Enable(True) 589 596 wx.PostEvent(self.parent, StatusEvent(status = '\nFinished invariant computation...')) 590 597 591 598 def undo(self,event=None): 592 599 """ … … 594 601 595 602 : param event: undo button event 596 597 603 """ 598 604 if event != None: event.Skip() … … 612 618 self._info_state_num() 613 619 614 615 620 616 621 def redo(self,event=None): … … 619 624 620 625 : param event: redo button event 621 622 626 """ 623 627 if event != None: event.Skip() … … 636 640 self._info_state_num() 637 641 642 def report(self, event=None): 643 """ 644 Invoke report dialog panel 645 646 : param event: report button event 647 """ 648 from report_dialog import ReportDialog 649 650 report_string = self.state.report_str 651 dialog = ReportDialog(report_string, None, -1, "") 652 dialog.ShowModal() 653 638 654 def get_state_by_num(self,state_num=None): 639 655 """ … … 648 664 649 665 backup_state_list = copy.deepcopy(self.state.state_list) 650 666 651 667 # get the previous state 652 668 try: … … 656 672 except : 657 673 raise ValueError, "No such state exists in history" 658 674 659 675 # get the state at pre_compute_num 660 676 comp_state = copy.deepcopy(self.state.state_list[current_compute_num]) … … 669 685 except: 670 686 pass 671 687 672 688 self.compute_invariant(event=None) 673 689 # set the input params at the state at pre_state_num … … 693 709 self.state.saved_state = current_state 694 710 self.state.state_num = state_num 695 711 712 696 713 697 714 def get_bookmark_by_num(self, num=None): … … 733 750 pass 734 751 self.state.saved_state = copy.deepcopy(current_state) 735 752 736 753 self._enable_high_q_section(event=None) 737 754 self._enable_low_q_section(event=None) … … 766 783 self.button_undo.Disable() 767 784 self.button_redo.Disable() 785 self.button_bookmark.Disable() 786 self.button_report.Disable() 768 787 self.button_calculate.SetFocus() 769 788 #self.SetupScrolling() … … 851 870 self._redo_disable() 852 871 872 853 873 def _reset_state_list(self,data=None): 854 874 """ … … 870 890 871 891 self.state.state_num = self.state.saved_state['state_num'] 892 self.state.timestamp = "('00:00:00', '00/00/0000')" 893 872 894 # Put only the current state in the list 873 895 self.state.state_list[str(self.state.state_num)] = self.state.clone_state()#copy.deepcopy(self.state.saved_state) … … 923 945 self._undo_enable() 924 946 self._redo_disable() 947 self.button_bookmark.Enable(True) 948 self.button_report.Disable() 949 925 950 926 951 def _on_out_text(self, event): … … 1269 1294 """ 1270 1295 if event != None: 1296 self.button_bookmark.Enable(True) 1297 self.button_report.Disable() 1271 1298 print "enable fit==>event!=None" 1272 1299 … … 1285 1312 Disable or enable some button if the user enable low q extrapolation 1286 1313 """ 1287 #if event != None: self._set_compute_state() 1314 if event != None: 1315 self.button_bookmark.Enable(True) 1316 self.button_report.Disable() 1317 1288 1318 if self.enable_low_cbox.GetValue(): 1289 1319 self.npts_low_tcl.Enable() … … 1309 1339 Enable editing power law section at low q range 1310 1340 """ 1311 #if event != None: self._set_compute_state() 1341 if event != None: 1342 self.button_bookmark.Enable(True) 1343 self.button_report.Disable() 1312 1344 if self.guinier.GetValue(): 1313 1345 self.power_law_low.SetValue(False) … … 1399 1431 Enable and disable the power value editing 1400 1432 """ 1401 #if event != None: self._set_compute_state() 1433 if event != None: 1434 self.button_bookmark.Enable(True) 1435 self.button_report.Disable() 1402 1436 if self.fix_enable_high.IsEnabled(): 1403 1437 if self.fix_enable_high.GetValue(): … … 1413 1447 Disable or enable some button if the user enable high q extrapolation 1414 1448 """ 1415 #if event != None: self._set_compute_state() 1449 if event != None: 1450 self.button_bookmark.Enable(True) 1451 self.button_report.Disable() 1416 1452 if self.enable_high_cbox.GetValue(): 1417 1453 self.npts_high_tcl.Enable() … … 1668 1704 self.undo_png = os.path.join(path,"undo.png") 1669 1705 self.redo_png = os.path.join(path,"redo.png") 1706 self.bookmark_png = os.path.join(path,"bookmark.png") 1707 self.report_png = os.path.join(path,"report.png") 1670 1708 self.save_png = os.path.join(path,"save.png") 1671 1709 #undo button … … 1681 1719 self.Bind(wx.EVT_BUTTON, self.redo, id=id) 1682 1720 self.button_redo.Disable() 1721 #bookmark button 1722 id = wx.NewId() 1723 self.button_bookmark = wx.BitmapButton(self, id,wx.Bitmap(self.bookmark_png))#wx.Button(self, id, "Undo",size=(50,20)) 1724 self.button_bookmark.SetToolTipString("Bookmark: right-click on the panel to retrieve") 1725 self.Bind(wx.EVT_BUTTON, self._on_bookmark, id=id) 1726 #self.button_bookmark.Disable() 1727 #report button 1728 id = wx.NewId() 1729 self.button_report = wx.BitmapButton(self, id,wx.Bitmap(self.report_png))#wx.Button(self, id, "Redo",size=(50,20)) 1730 self.button_report.SetToolTipString("Report the result of the computation") 1731 self.Bind(wx.EVT_BUTTON, self.report, id=id) 1732 #self.button_report.Disable() 1683 1733 #save button 1684 1734 id = wx.NewId() … … 1687 1737 self.Bind(wx.EVT_BUTTON, self._on_save_button, id=id) 1688 1738 self.button_save.Disable() 1689 self.save_button_sizer.AddMany([((PANEL_WIDTH/ 1.5,20), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0),1739 self.save_button_sizer.AddMany([((PANEL_WIDTH/2,20), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0), 1690 1740 (self.button_undo, 0 ,wx.LEFT|wx.ADJUST_MINSIZE, 10), 1691 1741 (self.button_redo, 0 ,wx.LEFT|wx.ADJUST_MINSIZE, 10), 1742 (self.button_bookmark, 0 ,wx.LEFT|wx.ADJUST_MINSIZE, 10), 1743 (self.button_report, 0 ,wx.LEFT|wx.ADJUST_MINSIZE, 10), 1692 1744 (self.button_save, 0 ,wx.LEFT|wx.ADJUST_MINSIZE, 10)]) 1693 1745 def _do_layout(self): -
invariantview/perspectives/invariant/invariant_state.py
r4e1c362 rcb463b4 42 42 bookmark_list = {} 43 43 # list of input parameters (will be filled up on panel init) used by __str__ 44 input_list = {} 44 input_list = {'background_tcl':0, 45 'scale_tcl':0, 46 'contrast_tcl':0, 47 'porod_constant_tcl':'', 48 'npts_low_tcl':0, 49 'npts_high_tcl':0, 50 'power_high_tcl':0, 51 'power_low_tcl': 0} 45 52 # list of output parameters (order sensitive) used by __str__ 46 53 output_list = [["qstar_low", "Q* from low Q extrapolation [1/(cm*A)]"], … … 84 91 self.compute_num = 0 85 92 self.state_num = 0 86 self.timestamp = None93 self.timestamp = "('00:00:00', '00/00/0000')" 87 94 self.container = None 88 95 # report_html strings 96 import sans.perspectives.invariant as invariant 97 path = invariant.get_data_path(media='media') 98 path_report_html= os.path.join(path,"report_template.html") 99 html_template=open(path_report_html,"r") 100 self.template_str = html_template.read() 101 self.report_str = self.template_str 102 html_template.close() 103 104 89 105 90 106 def __str__(self): … … 199 215 # Include warning msg 200 216 state += "\n\nNote:\n" + self.container.warning_msg 201 217 202 218 return state 203 219 … … 369 385 except: 370 386 exec "temp_state['%s'] = '%s'"% (item,val) 371 372 387 373 388 comp_entry = get_content('ns:comp_state', entry ) … … 416 431 self.set_saved_state(name=item, value=val) 417 432 418 419 433 def set_report_string(self): 434 """ 435 Get the values (strings) from __str__ for report 436 """ 437 strings = self.__str__() 438 439 # default string values 440 for num in range (1,19): 441 exec "s_%s = 'NA'"% str(num) 442 lines = strings.split('\n') 443 # get all string values from __str__() 444 for line in range(0,len(lines)): 445 if line == 1: 446 s_1 = lines[1] 447 elif line == 2: 448 s_2 = lines[2] 449 else: 450 item = lines[line].split(':') 451 item[0] = item[0].strip() 452 if item[0]== "scale": 453 s_3 = item[1] 454 elif item[0] == "porod constant": 455 s_4 = item[1] 456 elif item[0] == "background": 457 s_5 = item[1] 458 elif item[0] == "contrast": 459 s_6 = item[1] 460 elif item[0] == "Extrapolation": 461 extra = item[1].split(";") 462 bool_0 = extra[0].split("=") 463 bool_1 = extra[1].split("=") 464 s_7 = " "+bool_0[0]+" = "+bool_0[1] 465 s_8 = " "+bool_1[0]+" = "+bool_1[1] 466 elif item[0]=="npts low": 467 s_9 = item[1] 468 elif item[0]=="npts high": 469 s_10 = item[1] 470 elif item[0] == "volume fraction": 471 s_17 = item[1] 472 elif item[0] == "specific surface": 473 s_18 = item[1] 474 elif item[0].split("(")[0].strip()=="power high": 475 s_11 = item[0]+" ="+item[1] 476 elif item[0].split("(")[0].strip()=="power low": 477 s_12 = item[0]+" ="+item[1] 478 elif item[0].split("[")[0].strip()=="Q* from low Q extrapolation": 479 s_13 = item[1] 480 elif item[0].split("[")[0].strip()=="Q* from data": 481 s_14 = item[1] 482 elif item[0].split("[")[0].strip()=="Q* from high Q extrapolation": 483 s_15 = item[1] 484 elif item[0].split("[")[0].strip()=="total Q*": 485 s_16 = item[1] 486 else: 487 continue 488 489 self.report_str = str(self.template_str)% (s_1,s_2,s_3,s_4,s_5,s_6,s_7,s_8,s_9,s_10,s_11,s_12,s_13,s_14,s_15,s_16,s_17,s_18) 490 420 491 def set_saved_state(self, name, value): 421 492 """
Note: See TracChangeset
for help on using the changeset viewer.