Changeset c99a6c5 in sasview for sansview/perspectives
- Timestamp:
- Nov 5, 2009 6:17:31 PM (15 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:
- c660493
- Parents:
- cf76ca74
- Location:
- sansview/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r77f6a8b rc99a6c5 19 19 #Control panel width 20 20 if sys.platform.count("win32")>0: 21 PANEL_WIDTH = 4 2021 PANEL_WIDTH = 430 22 22 else: 23 PANEL_WIDTH = 49023 PANEL_WIDTH = 500 24 24 25 25 class BasicPage(wx.ScrolledWindow): … … 113 113 #wx.EVT_MENU(self, id, self.onRedo) 114 114 #self.popUpMenu.AppendSeparator() 115 116 id = wx.NewId()117 self._keep = wx.MenuItem(self.popUpMenu,id,"BookMark"," Keep the panel status to recall it later")118 self.popUpMenu.AppendItem(self._keep)119 self._keep.Enable(True)120 wx.EVT_MENU(self, id, self.onSave)121 self.popUpMenu.AppendSeparator()115 if sys.platform.count("win32")>0: 116 id = wx.NewId() 117 self._keep = wx.MenuItem(self.popUpMenu,id,"BookMark"," Keep the panel status to recall it later") 118 self.popUpMenu.AppendItem(self._keep) 119 self._keep.Enable(True) 120 wx.EVT_MENU(self, id, self.onSave) 121 self.popUpMenu.AppendSeparator() 122 122 123 123 ## Default locations … … 491 491 #self.model._persistency_dict = {} 492 492 #self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict) 493 493 494 #Remember fit engine_type for fit panel 495 if self.engine_type == None and self.manager !=None: 496 self.engine_type = self.manager._return_engine_type() 497 498 self.state.engine_type = self.engine_type 499 494 500 new_state = self.state.clone() 495 501 new_state.model.name = self.state.model.name … … 516 522 wx.EVT_MENU(self, id, self.onResetModel) 517 523 518 519 524 def onSetFocus(self, evt): 520 525 """ 521 526 highlight the current textcrtl and hide the error text control shown 522 527 after fitting 523 """ 524 if hasattr(self,"text2_3"): 525 self.text2_3.Hide() 526 if len(self.parameters)>0: 527 for item in self.parameters: 528 ## hide statictext +/- 529 if item[3]!=None: 530 item[3].Hide() 531 ## hide textcrtl for error after fit 532 if item[4]!=None: 533 item[4].Clear() 534 item[4].Hide() 535 if len(self.fittable_param)>0: 536 for item in self.fittable_param: 537 ## hide statictext +/- 538 if item[3]!=None: 539 item[3].Hide() 540 ## hide textcrtl for error after fit 541 if item[4]!=None: 542 item[4].Clear() 543 item[4].Hide() 544 ##Is this layout necessary? Had a problem w/MAC. 545 #self.Layout() 528 :Not implemented. 529 """ 546 530 return 547 548 531 549 532 def read_file(self, path): … … 594 577 self.state.disp_list= copy.deepcopy(self.disp_list) 595 578 self.state.model = self.model.clone() 596 579 597 580 self.state.enable2D = copy.deepcopy(self.enable2D) 598 581 self.state.values= copy.deepcopy(self.values) … … 665 648 def save_current_state_fit(self): 666 649 """ 667 Store current state 650 Store current state for fit_page 668 651 """ 669 652 ## save model option … … 672 655 self.state.disp_list= copy.deepcopy(self.disp_list) 673 656 self.state.model = self.model.clone() 674 657 #if hasattr(self,self.engine_type)> 0: 658 #self.state.engine_type = self.engine_type.clone() 675 659 self.state.enable2D = copy.deepcopy(self.enable2D) 676 660 self.state.values= copy.deepcopy(self.values) … … 758 742 self.smearer= smear_selection( self.data ) 759 743 self.enable2D= state.enable2D 760 744 self.engine_type = state.engine_type 761 745 #??? 762 746 self.disp_cb_dict = state.disp_cb_dict … … 866 850 self._draw_model() 867 851 868 852 def _clear_Err_on_Fit(self): 853 """ 854 hide the error text control shown 855 after fitting 856 """ 857 858 if hasattr(self,"text2_3"): 859 self.text2_3.Hide() 860 861 if len(self.parameters)>0: 862 for item in self.parameters: 863 ## hide statictext +/- 864 if item[3]!=None and item[3].IsShown(): 865 item[3].Hide() 866 ## hide textcrtl for error after fit 867 if item[4]!=None and item[4].IsShown(): 868 item[4].Clear() 869 item[4].Hide() 870 if len(self.fittable_param)>0: 871 for item in self.fittable_param: 872 ## hide statictext +/- 873 if item[3]!=None and item[3].IsShown(): 874 item[3].Hide() 875 ## hide textcrtl for error after fit 876 if item[4]!=None and item[4].IsShown(): 877 item[4].Clear() 878 item[4].Hide() 879 ##Is this layout necessary? Had a problem w/MAC. 880 #self.Layout() 881 882 return 869 883 def _selectDlg(self): 870 884 """ … … 913 927 self.state.structurebox= self.structurebox.GetCurrentSelection() 914 928 self.state.formfactorbox = self.formfactorbox.GetCurrentSelection() 915 929 916 930 #self._undo.Enable(True) 917 931 ## post state to fit panel … … 945 959 is_modified =self._check_value_enter( self.fixed_param ,is_modified) 946 960 is_modified =self._check_value_enter( self.parameters ,is_modified) 947 961 948 962 if is_modified: 949 963 self.sizer3.Layout() 950 964 self.Layout() 951 965 self.Refresh() 966 952 967 # Here we should check whether the boundaries have been modified. 953 968 # If qmin and qmax have been modified, update qmin and qmax and … … 972 987 msg= "Cannot Plot :Must enter a number!!! " 973 988 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 974 989 975 990 976 991 ## if any value is modify draw model with new value … … 978 993 self.state_change= True 979 994 self._draw_model() 980 self.save_current_state() 981 982 self.is_modified = is_modified 995 self.save_current_state() 983 996 984 def _is_modified(self ):997 def _is_modified(self, is_modified): 985 998 """ 986 999 return to self._is_modified 987 1000 """ 988 return self.is_modified1001 return is_modified 989 1002 990 1003 def _reset_parameters_state(self, listtorestore,statelist): … … 996 1009 if len(statelist)!= len(listtorestore) : 997 1010 return 1011 998 1012 for j in range(len(listtorestore)): 999 1013 item_page = listtorestore[j] … … 1245 1259 self.Bind( wx.EVT_RADIOBUTTON, self._show_combox, 1246 1260 id= self.plugin_rbutton.GetId() ) 1247 1261 #MAC needs SetValue 1248 1262 self.shape_rbutton.SetValue(True) 1249 1263 … … 1438 1452 when enter value on panel redraw model according to changed 1439 1453 """ 1454 1440 1455 tcrtl= event.GetEventObject() 1456 1441 1457 ## save current state 1442 1458 self.save_current_state() … … 1445 1461 event = PageInfoEvent(page = self) 1446 1462 wx.PostEvent(self.parent, event) 1447 1463 1448 1464 if check_float(tcrtl): 1449 1465 1450 1466 self._onparamEnter_helper() 1467 1451 1468 else: 1452 1469 msg= "Cannot Plot :Must enter a number!!! " … … 1461 1478 item=[cb state, name, value, "+/-", error of fit, min, max , units] 1462 1479 """ 1463 self.is_modified = modified1480 is_modified = modified 1464 1481 if len(list)==0: 1465 return self.is_modified1482 return is_modified 1466 1483 for item in list: 1467 1484 try: 1468 1485 name = str(item[1]) 1469 if hasattr(self,"text2_3"): 1470 self.text2_3.Hide() 1486 if hasattr(self,"text2_3") and self.text2_3.IsShown(): 1487 if hasattr(self,"item[4]")and self.item[4] == None: 1488 self.text2_3.Hide() 1471 1489 ## check model parameters range 1472 1490 ## check minimun value … … 1476 1494 if item[5].GetValue().lstrip().rstrip()!="": 1477 1495 param_min = float(item[5].GetValue()) 1478 1479 1496 ## check maximum value 1480 1497 if item[6]!= None: … … 1489 1506 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1490 1507 if name in self.model.details.keys(): 1491 self.model.details[name][1: ]= param_min,param_max1492 1508 self.model.details[name][1:3]= param_min,param_max 1509 1493 1510 ## hide statictext +/- 1494 if item[3]!=None:1495 item[3].Hide()1511 #if item[3]!=None and item[3].IsShown(): 1512 # item[3].Hide() 1496 1513 ## hide textcrtl for error after fit 1497 if item[4]!=None:1498 item[4].Clear()1499 item[4].Hide()1500 1514 #if item[4]!=None and item[4].IsShown(): 1515 # item[4].Clear() 1516 # item[4].Hide() 1517 1501 1518 value= float(item[2].GetValue()) 1502 1503 1519 # If the value of the parameter has changed, 1504 1520 # +update the model and set the is_modified flag 1505 1521 if value != self.model.getParam(name): 1506 1522 self.model.setParam(name,value) 1507 self.is_modified = True1508 1523 is_modified = True 1524 1509 1525 except: 1510 1526 msg= "Model Drawing Error:wrong value entered : %s"% sys.exc_value 1511 1527 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1512 1528 return 1513 1514 return self.is_modified 1529 return is_modified 1515 1530 1516 1531 … … 1533 1548 return 1534 1549 #remove previous added details for dispersion parameters. 1535 for item in self.model.details.keys():1536 if item in self.model.fixed:1537 del self.model.details [item]1550 #for item in self.model.dispersion.keys():#for item in self.model.details.keys(): 1551 # if item in self.model.fixed and item in self.model.details.keys(): 1552 # del self.model.details [item] 1538 1553 1539 1554 if self.enable_disp.GetValue(): … … 1822 1837 self.sizer5.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 1823 1838 self.sizer5.Layout() 1824 self.Layout()1825 self.SetScrollbars(20,20,25,65)1839 #self.Layout() 1840 #self.SetScrollbars(20,20,25,65) 1826 1841 1827 1842 -
sansview/perspectives/fitting/fitpage.py
r77f6a8b rc99a6c5 44 44 ## default fitengine type 45 45 self.engine_type = None 46 #self.smearer = None47 46 ## draw sizer 48 47 self._fill_datainfo_sizer() … … 138 137 item[6].Show(True) 139 138 140 141 139 self.SetScrollbars(20,20,25,65) 142 140 … … 343 341 name2=item+".npts" 344 342 name3=item+".nsigmas" 343 if not self.model.details.has_key(name1): 344 self.model.details [name1] = ["",None, None, None] 345 345 346 iy += 1 346 347 for p in self.model.dispersion[item].keys(): … … 365 366 text2.Hide() 366 367 ## txtcrtl to add error from fit 368 fit_errs = self.model.details[item][3] 369 367 370 ix = 3 368 371 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 372 ctl2.SetValue(str(format_number(fit_errs))) 369 373 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 370 ctl2.Hide() 371 374 if fit_errs==None or not numpy.isfinite(fit_errs): 375 ctl2.Hide() 376 else: 377 if not text2.IsShown(): 378 text2.Show(True) 379 ctl2.Show(True) 372 380 #Prepare add min and max in model.details.(Maybe Not correct way) 373 if not self.model.details.has_key(name1): 374 self.model.details [name1] = ["",None, None] 375 param_min, param_max= self.model.details[name1][1:] 381 param_min, param_max= self.model.details[name1][1:3] 376 382 ix = 4 377 383 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 378 384 kill_focus_callback = self._on_paramRangeEnter, 379 385 set_focus_callback = self._on_paramRangeEnter) 380 if param_min ==None :386 if param_min ==None or not numpy.isfinite(param_min): 381 387 ctl3.SetValue("") 382 388 else: … … 390 396 set_focus_callback = self._on_paramRangeEnter) 391 397 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 392 if param_max==None :398 if param_max==None or not numpy.isfinite(param_max): 393 399 ctl4.SetValue("") 394 400 else: … … 401 407 402 408 self.fittable_param.append([cb,name1,ctl1,text2, 403 ctl2, ctl3, ctl4,None]) 404 #self.parameters.append([cb,name1, ctl1,text2,ctl2, ctl3, ctl4,None]) 405 #self.orientation_params.append([cb,name1, ctl1,text2,ctl2, ctl3, ctl4,None]) 406 409 ctl2, ctl3, ctl4,None]) 407 410 408 411 elif p=="npts": … … 441 444 name2=item+".npts" 442 445 name3=item+".nsigmas" 446 if not self.model.details.has_key(name1): 447 self.model.details [name1] = ["",None, None, None] 443 448 iy += 1 444 449 for p in self.model.dispersion[item].keys(): … … 452 457 if self.data.__class__.__name__ =="Data2D": 453 458 cb.Show(True) 454 el se:459 elif cb.IsShown(): 455 460 cb.Hide() 456 461 ix = 1 … … 461 466 if self.data.__class__.__name__ =="Data2D": 462 467 ctl1.Show(True) 463 el se:468 elif ctl1.IsShown(): 464 469 ctl1.Hide() 465 470 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) … … 470 475 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 471 476 text2.Hide() 472 ## txtcrtl to add error from fit 477 ## txtcrtl to add error from fit 478 fit_errs = self.model.details[item][3] 473 479 ix = 3 474 480 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 481 ctl2.SetValue(str(format_number(fit_errs))) 475 482 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 476 ctl2.Hide() 477 if self.data.__class__.__name__ =="Data2D": 478 ctl2.Enable() 483 if fit_errs==None or not numpy.isfinite(fit_errs) or self.data.__class__.__name__ !="Data2D": 484 ctl2.Hide() 479 485 else: 480 ctl2.Disable() 486 if not text2.IsShown(): 487 text2.Show(True) 488 ctl2.Show(True) 489 #if self.data.__class__.__name__ =="Data2D": 490 #ctl2.Show(True) 491 #elif ctl2.IsShown(): 492 #ctl2.Hide() 481 493 482 483 if not self.model.details.has_key(name1): 484 self.model.details [name1] = ["",None, None] 485 486 param_min, param_max= self.model.details[name1][1:] 494 param_min, param_max= self.model.details[name1][1:3] 487 495 ix = 4 488 496 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 489 497 kill_focus_callback = self._onparamRangeEnter, 490 498 set_focus_callback = self._onparamRangeEnter) 491 if param_min ==None :499 if param_min ==None or not numpy.isfinite(param_min): 492 500 ctl3.SetValue("") 493 501 else: 494 502 ctl3.SetValue(str(param_min)) 495 503 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 504 496 505 ctl3.Hide() 497 if self.data.__class__.__name__ =="Data2D":498 ctl3.Enable()499 else:500 ctl3.Disable()501 506 502 507 ix = 5 … … 505 510 set_focus_callback = self._onparamRangeEnter) 506 511 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 507 if param_max==None :512 if param_max==None or not numpy.isfinite(param_max): 508 513 ctl4.SetValue("") 509 514 else: 510 515 ctl4.SetValue(str(param_max)) 511 516 ctl4.Hide() 512 if self.data.__class__.__name__ =="Data2D":513 ctl4.Enable()514 else:515 ctl4.Disable()517 #if self.data.__class__.__name__ =="Data2D": 518 #ctl4.Enable(True) 519 #elif ctl4.Shown(): 520 #ctl4.Hide() 516 521 517 522 if self.engine_type=="park" and self.data.__class__.__name__ =="Data2D": 518 523 ctl3.Show(True) 519 ctl4.Show(True) 524 ctl3.Enable(True) 525 ctl4.Show(True) 526 ctl4.Enable(True) 520 527 521 528 … … 524 531 self.fittable_param.append([cb,name1,ctl1,text2, 525 532 ctl2, ctl3, ctl4,None]) 526 #self.parameters.append([cb,name1, ctl1,text2,ctl2, ctl3, ctl4,None])527 #self.orientation_params.append([cb,name1,ctl1,text2, ctl2, ctl3, ctl4,None])528 533 self.orientation_params_disp.append([cb,name1,ctl1,text2, 529 534 ctl2, ctl3, ctl4,None]) … … 565 570 self.orientation_params_disp.append([None,name3, Tctl 566 571 ,None,None, None, None,None]) 572 #Display units text on panel 573 for item in self.model.dispersion.keys(): 574 if self.model.details[item][3]!= None and numpy.isfinite(self.model.details[item][3]): 575 if not self.text2_3.IsShown(): 576 self.text2_3.Show() 577 break 578 else: 579 self.text2_3.Hide() 567 580 568 581 self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) … … 581 594 ix =0 582 595 iy +=1 583 #self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)584 596 self.sizer4_4.Layout() 585 597 self.sizer4.Layout() … … 594 606 """ 595 607 from sans.guiframe.utils import check_value 608 self.select_param(event =None) 596 609 flag = check_value( self.qmin, self.qmax) 597 610 … … 606 619 return 607 620 608 621 #Clear errors if exist from previous fitting 622 self._clear_Err_on_Fit() 609 623 610 624 # Remove or do not allow fitting on the Q=0 point, especially when y(q=0)=None at x[0]. … … 640 654 641 655 642 self.btFit.SetFocus()643 self.sizer5.Layout()656 #self.btFit.SetFocus() 657 #self.sizer5.Layout() 644 658 #self.SetScrollbars(20,20,55,40) 645 659 … … 670 684 qmax= float(self.qmax_x)) 671 685 evt = ModelEventbox(model=self.model) 672 wx.PostEvent(self.event_owner, evt) 686 wx.PostEvent(self.event_owner, evt) 673 687 674 688 self.btFit.SetFocus() … … 728 742 """ 729 743 tcrtl= event.GetEventObject() 730 744 731 745 if check_float(tcrtl): 732 746 self._onparamEnter_helper() … … 735 749 if self.enable_smearer.GetValue(): 736 750 temp_smearer= self.smearer 737 738 751 self.compute_chisqr(smearer= temp_smearer) 752 739 753 ## new state posted 740 754 if self.state_change: … … 794 808 reset the state 795 809 """ 796 #if first: 797 # self._undo.Enable(False) 798 810 import sans.guiframe.gui_manager 811 799 812 self.reset_page_helper(state) 800 813 evt = ModelEventbox(model=state.model) 801 wx.PostEvent(self.event_owner, evt) 802 814 wx.PostEvent(self.event_owner, evt) 815 self.manager._on_change_engine(engine=self.engine_type) 816 #Not improving anything yet. 817 #self.set_model_param_sizer(model=state.model) 803 818 804 819 def get_range(self): … … 832 847 is_modified = False 833 848 has_error = False 834 self.text2_3.Hide()835 849 try: 836 850 n = self.disp_box.GetCurrentSelection() … … 844 858 pass 845 859 #set the panel when fit result are float not list 846 if out.__class__== numpy.float64:860 if out.__class__== numpy.float64: 847 861 self.param_toFit[0][2].SetValue(format_number(out)) 848 862 self.param_toFit[0][2].Refresh() … … 860 874 except: 861 875 pass 876 862 877 if cov[0]==None or not numpy.isfinite(cov[0]): 863 878 self.param_toFit[0][3].Hide() 864 879 self.param_toFit[0][4].Clear() 865 self.param_toFit[0][4].Hide()880 #self.param_toFit[0][4].Hide() 866 881 self.param_toFit[0][4].Refresh() 867 882 else: … … 874 889 i=0 875 890 j=0 891 k=0 892 893 if self.text2_3.IsShown(): 894 self.text2_3.Hide() 895 876 896 #Set the panel when fit result are list 877 for item in self.param_toFit: 897 for item in self.param_toFit: 878 898 ## reset error value to initial state 879 item[4].Clear() 880 item[4].Hide() 881 item[4].Refresh() 899 if item[3].IsShown(): 900 item[3].Hide() 901 if item[4].IsShown(): 902 item[4].Hide() 903 882 904 if( out != None ) and len(out)<=len(self.param_toFit)and i < len(out): 883 905 item[2].SetValue(format_number(self.model.getParam(item[1]))) 884 906 item[2].Refresh() 885 if(cov !=None)and len(cov)<=len(self.param_toFit)and i < len(cov): 886 self.text2_3.Show(True)907 908 if(cov !=None) and len(cov)<=len(self.param_toFit)and i < len(cov): 887 909 try: 888 910 name= dispersity.__name__ … … 892 914 self.text_disp_1.Show(True) 893 915 except: 894 pass 895 item[3].Show(True) 896 item[4].Clear() 916 pass 897 917 for j in range(len(out)): 898 918 if out[j]==self.model.getParam(item[1]): 919 899 920 break 900 ## unable to compare cov[j]==numpy.nan so switch to None 901 if cov[j]==None or not numpy.isfinite(cov[j]): 902 item[3].Hide() 921 ## unable to compare cov[j]==numpy.nan so switch to None 922 #Save errors to model.details[item][3] 923 self.model.details[item[1]][3] = cov[i] 924 925 926 if cov[i]==None or not numpy.isfinite(cov[i]): 927 928 if item[3].IsShown: 929 item[3].Hide() 930 if item[4].IsShown: 931 item[4].Hide() 932 #k += 1 933 934 935 else: 936 k += 1 937 item[3].Show(True) 938 item[3].Refresh() 939 item[4].Show(True) 940 item[4].SetValue(format_number(cov[i])) 903 941 item[4].Refresh() 904 item[4].Clear() 905 item[4].Hide() 906 else: 907 item[4].SetValue(format_number(cov[j])) 908 item[4].Refresh() 909 item[4].Show(True) 910 i+=1 911 912 self.sizer3.Layout() 913 self.sizer4.Layout() 942 943 944 i+=1 945 #Show error title when any errors displayed 946 if k != 0: # len(self.param_toFit): 947 if not self.text2_3.IsShown(): 948 self.text2_3.Show(True) 949 950 self.text2_3.Refresh() 914 951 self.Layout() 915 self.Refresh()916 self.SetScrollbars(20,20,25,65)917 952 918 953 … … 960 995 961 996 self.sizer5.Layout() 962 self.Layout()963 self.Refresh964 ## post state to fit panel965 997 self.state.tcChi =output 966 998 … … 1093 1125 item[0].SetValue(False) 1094 1126 self.param_toFit=[] 1095 1096 #self._copy_parameters_state(self.orientation_params,1097 # self.state.orientation_params)1098 #self._copy_parameters_state(self.orientation_params_disp,1099 # self.state.orientation_params_disp)1100 #self._copy_parameters_state(self.parameters, self.state.parameters)1101 #self._copy_parameters_state(self.fittable_param, self.state.fittable_param)1102 #self._copy_parameters_state(self.fixed_param, self.state.fixed_param)1103 1127 1104 1128 self.save_current_state_fit() … … 1140 1164 else: 1141 1165 self.cb1.SetValue(False) 1142 ## save current state of the page1143 #self.state.cb1 = self.cb1.GetValue()1144 #self._copy_parameters_state(self.orientation_params,1145 # self.state.orientation_params)1146 #self._copy_parameters_state(self.orientation_params_disp,1147 # self.state.orientation_params_disp)1148 #self._copy_parameters_state(self.parameters, self.state.parameters)1149 #self._copy_parameters_state(self.fittable_param, self.state.fittable_param)1150 #self._copy_parameters_state(self.fixed_param, self.state.fixed_param)1151 1152 1166 self.save_current_state_fit() 1153 1167 if event !=None: … … 1179 1193 if self.engine_type==None and self.manager !=None: 1180 1194 self.engine_type= self.manager._return_engine_type() 1195 1181 1196 1182 1197 box_description= wx.StaticBox(self, -1,str("Model Parameters")) … … 1230 1245 for item in keys: 1231 1246 if not item in self.disp_list and not item in self.model.orientation_params: 1232 1247 ##prepare a spot for error 1248 if len(self.model.details[item])<4: 1249 self.model.details[item].append(numpy.nan) 1233 1250 iy += 1 1234 1251 ix = 0 … … 1255 1272 text2.Hide() 1256 1273 ## txtcrtl to add error from fit 1274 fit_errs = self.model.details[item][3] 1275 1257 1276 ix += 1 1258 1277 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 1278 1279 1280 ctl2.SetValue(str(format_number(fit_errs))) 1259 1281 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1260 ctl2.Hide() 1282 if fit_errs==None or not numpy.isfinite(fit_errs): 1283 ctl2.Hide() 1284 else: 1285 if not self.text2_3.IsShown(): 1286 self.text2_3.Show(True) 1287 if not text2.IsShown(): 1288 text2.Show(True) 1289 ctl2.Show(True) 1261 1290 1262 param_min, param_max= self.model.details[item][1: ]1291 param_min, param_max= self.model.details[item][1:3] 1263 1292 ix += 1 1264 1293 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1265 1294 kill_focus_callback = self._on_paramRangeEnter, 1266 1295 set_focus_callback = self._on_paramRangeEnter) 1267 if param_min ==None :1296 if param_min ==None or not numpy.isfinite(param_min): 1268 1297 ctl3.SetValue("") 1269 1298 else: … … 1277 1306 set_focus_callback = self._on_paramRangeEnter) 1278 1307 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1279 if param_max==None :1308 if param_max==None or not numpy.isfinite(param_max): 1280 1309 ctl4.SetValue("") 1281 1310 else: … … 1324 1353 for item in self.model.orientation_params: 1325 1354 if not item in self.disp_list: 1355 if len(self.model.details[item])<4: 1356 self.model.details[item].append(numpy.nan) 1326 1357 iy += 1 1327 1358 ix = 0 … … 1332 1363 if self.data.__class__.__name__ =="Data2D": 1333 1364 cb.Show(True) 1334 #cb.Enable()1335 1365 else: 1336 1366 cb.Hide() 1337 #cb.Disable()1338 1367 sizer.Add( cb,( iy, ix),(1,1), 1339 1368 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) … … 1348 1377 if self.data.__class__.__name__ =="Data2D": 1349 1378 ctl1.Show(True) 1350 #ctl1.Enable()1351 1379 else: 1352 1380 ctl1.Hide() 1353 #ctl1.Disable()1354 1381 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 1355 1382 ## text to show error sign … … 1360 1387 text2.Hide() 1361 1388 ## txtcrtl to add error from fit 1389 fit_errs = self.model.details[item][3] 1362 1390 ix += 1 1363 1391 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 1392 ctl2.SetValue(str(format_number(fit_errs))) 1364 1393 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1365 1394 ctl2.Hide() 1366 if self.data.__class__.__name__ =="Data2D": 1367 ctl1.Show(True) 1368 #ctl1.Enable() 1395 if self.data.__class__.__name__ !="Data2D": 1396 ctl2.Hide() 1369 1397 else: 1370 ctl1.Hide() 1371 #ctl1.Disable() 1372 param_min, param_max= self.model.details[item][1:] 1398 if fit_errs!=None and numpy.isfinite(fit_errs): 1399 if not text2.IsShown(): 1400 text2.Show(True) 1401 ctl2.Show(True) 1402 1403 param_min, param_max= self.model.details[item][1:3] 1373 1404 ix += 1 1374 1405 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1375 1406 kill_focus_callback = self._onparamRangeEnter, 1376 1407 set_focus_callback = self._onparamRangeEnter) 1377 if param_min ==None :1408 if param_min ==None or not numpy.isfinite(param_min): 1378 1409 ctl3.SetValue("") 1379 1410 else: … … 1383 1414 if self.data.__class__.__name__ =="Data2D": 1384 1415 ctl3.Show(True) 1385 #ctl3.Enable()1416 1386 1417 else: 1387 1418 ctl3.Hide() 1388 #ctl3.Disable()1419 1389 1420 ix += 1 1390 1421 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, … … 1392 1423 set_focus_callback = self._onparamRangeEnter) 1393 1424 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1394 if param_max ==None :1425 if param_max ==None or not numpy.isfinite(param_max): 1395 1426 ctl4.SetValue("") 1396 1427 else: … … 1399 1430 if self.data.__class__.__name__ =="Data2D": 1400 1431 ctl4.Show(True) 1401 #ctl4.Enable()1432 1402 1433 else: 1403 1434 ctl4.Hide() 1404 #ctl4.Disable()1435 1405 1436 if self.engine_type !="park" or self.data.__class__.__name__ !="Data2D": 1406 1437 ctl3.Hide() … … 1418 1449 if self.data.__class__.__name__ =="Data2D": 1419 1450 units.Show(True) 1420 #units.Enable()1451 1421 1452 else: 1422 1453 units.Hide() 1423 #units.Disable()1454 1424 1455 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1425 1456 -
sansview/perspectives/fitting/modelpage.py
racd0bda3 rc99a6c5 31 31 """ 32 32 self._fill_model_sizer( self.sizer1) 33 self._fill_range_sizer() 33 self._fill_range_sizer() 34 self.engine_type = None 34 35 35 36 description="" -
sansview/perspectives/fitting/pagestate.py
r3b9e023 rc99a6c5 19 19 #Data used for fitting 20 20 self.data = data 21 #engine type 22 self.engine_type = None 21 23 # flag to allow data2D plot 22 24 self.enable2D = False … … 101 103 obj.data = copy.deepcopy(self.data) 102 104 obj.model_list_box = copy.deepcopy(self.model_list_box) 105 obj.engine_type = copy.deepcopy(self.engine_type) 103 106 104 107 obj.formfactorcombobox= self.formfactorcombobox -
sansview/perspectives/fitting/simfitpage.py
r17c5868 rc99a6c5 2 2 import sys,re,string, wx 3 3 import wx.lib.newevent 4 from sans.guicomm.events import StatusEvent 4 from sans.guicomm.events import StatusEvent 5 6 #Control panel width 7 if sys.platform.count("win32")>0: 8 PANEL_WID = 420 9 else: 10 PANEL_WID = 490 5 11 6 12 … … 67 73 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 68 74 self.sizer3 = wx.BoxSizer(wx.VERTICAL) 69 self.sizer1.SetMinSize((375,-1)) 70 self.sizer2.SetMinSize((375,-1)) 71 self.sizer3.SetMinSize((375,-1)) 75 76 self.sizer1.SetMinSize((PANEL_WID,-1)) 77 self.sizer2.SetMinSize((PANEL_WID,-1)) 78 self.sizer3.SetMinSize((PANEL_WID,-1)) 72 79 self.vbox.Add(self.sizer1) 73 80 self.vbox.Add(self.sizer2) … … 75 82 76 83 def set_scroll(self): 77 self.SetScrollbars(20,20,2 00,100)84 self.SetScrollbars(20,20,25,65) 78 85 self.Layout() 79 86 … … 107 114 108 115 self.sizer2.Layout() 109 self.SetScrollbars(20,20,2 00,100)116 self.SetScrollbars(20,20,25,65) 110 117 self.constraints_list.remove(item) 111 118 self.nb_constraint -= 1 … … 226 233 #------------------------------------------------------ 227 234 if len(self.page_finder)==0: 228 sizer_title.Add(wx.StaticText(self,-1," No fit combination available!"))235 sizer_title.Add(wx.StaticText(self,-1," No fit combinations are found!")) 229 236 else: 230 237 ## store model … … 253 260 self.sizer1.Add(boxsizer1,1, wx.EXPAND | wx.ALL, 10) 254 261 self.sizer1.Layout() 255 self.SetScrollbars(20,20,2 00,100)262 self.SetScrollbars(20,20,25,65) 256 263 self.AdjustScrollbars() 257 264 … … 302 309 self.sizer_constraints.Layout() 303 310 self.sizer2.Layout() 304 self.SetScrollbars(20,20,2 00,100)311 self.SetScrollbars(20,20,25,65) 305 312 return 306 313 … … 310 317 self.sizer_constraints.Layout() 311 318 self.sizer2.Layout() 312 self.SetScrollbars(20,20,2 00,100)319 self.SetScrollbars(20,20,25,65) 313 320 return 314 321 … … 357 364 self.sizer_constraints.Layout() 358 365 self.sizer2.Layout() 359 self.SetScrollbars(20,20,2 00,100)366 self.SetScrollbars(20,20,25,65) 360 367 361 368 def _hide_constraint(self): … … 376 383 self.sizer_constraints.Layout() 377 384 self.sizer2.Layout() 378 self.SetScrollbars(20,20,2 00,100)385 self.SetScrollbars(20,20,25,65) 379 386 self.AdjustScrollbars() 380 387 … … 404 411 405 412 self.sizer2.Layout() 406 self.SetScrollbars(20,20,2 00,100)413 self.SetScrollbars(20,20,25,65) 407 414 408 415 … … 427 434 428 435 self.sizer2.Layout() 429 self.SetScrollbars(20,20,2 00,100)436 self.SetScrollbars(20,20,25,65) 430 437 431 438 … … 486 493 self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 487 494 self.sizer3.Layout() 488 self.SetScrollbars(20,20,2 00,100)495 self.SetScrollbars(20,20,25,65) 489 496 490 497 def _fill_sizer_constraint(self): … … 539 546 self.sizer2.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 540 547 self.sizer2.Layout() 541 self.SetScrollbars(20,20,2 00,100)548 self.SetScrollbars(20,20,25,65) 542 549 543 550 -
sansview/perspectives/fitting/sldPanel.py
r6c5239c rc99a6c5 14 14 _STATICBOX_WIDTH = 350 15 15 _SCALE = 1e-6 16 17 #SLD panel size 18 if sys.platform.count("win32")>0: 19 _STATICBOX_WIDTH = 350 20 PANEL_SIZE = 400 21 else: 22 _STATICBOX_WIDTH = 380 23 PANEL_SIZE = 430 16 24 17 25 class SldPanel(wx.Panel): … … 35 43 Draw window content 36 44 """ 45 unit_a = '[A]' 46 unit_density = '[g/cm^(3)]' 47 unit_sld= '[1/A^(2)]' 48 unit_cm1='[1/cm]' 49 unit_cm='[cm]' 37 50 sizer_input = wx.GridBagSizer(5,5) 38 51 sizer_output = wx.GridBagSizer(5,5) … … 46 59 boxsizer1.SetMinSize((_STATICBOX_WIDTH,-1)) 47 60 48 compound_txt = wx.StaticText(self, -1, 'Compound ')61 compound_txt = wx.StaticText(self, -1, 'Compound ') 49 62 self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 50 density_txt = wx.StaticText(self, -1, 'Density (g/cm^3)')63 density_txt = wx.StaticText(self, -1, 'Density ') 51 64 self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 52 wavelength_txt = wx.StaticText(self, -1, 'Wavelength (A)') 65 unit_density_txt = wx.StaticText(self, -1, unit_density) 66 wavelength_txt = wx.StaticText(self, -1, 'Wavelength ') 53 67 self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 54 68 self.wavelength_ctl.SetValue(str(self.wavelength)) 69 unit_a_txt = wx.StaticText(self, -1, unit_a) 55 70 iy = 0 56 71 ix = 0 … … 67 82 sizer_input.Add(self.density_ctl,(iy, ix),(1,1),\ 68 83 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 84 ix +=1 85 sizer_input.Add(unit_density_txt,(iy, ix),(1,1),\ 86 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 69 87 iy += 1 70 88 ix = 0 … … 73 91 ix +=1 74 92 sizer_input.Add(self.wavelength_ctl,(iy, ix),(1,1),\ 93 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 94 ix +=1 95 sizer_input.Add(unit_a_txt,(iy, ix),(1,1),\ 75 96 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 76 97 boxsizer1.Add( sizer_input ) … … 81 102 boxsizer2.SetMinSize((_STATICBOX_WIDTH,-1)) 82 103 83 unit_a= '[A^(-2)]'84 unit_cm1='[cm^(-1)]'85 unit_cm='[cm]'86 104 i_complex= '+ i' 87 105 neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD') … … 92 110 self.neutron_sld_im_ctl.SetEditable(False) 93 111 self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary.") 94 neutron_sld_units_txt = wx.StaticText(self, -1, unit_ a)112 neutron_sld_units_txt = wx.StaticText(self, -1, unit_sld) 95 113 96 114 cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD') … … 101 119 self.cu_ka_sld_im_ctl.SetEditable(False) 102 120 self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.") 103 cu_ka_sld_units_txt = wx.StaticText(self, -1, unit_ a)121 cu_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) 104 122 105 123 mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') … … 110 128 self.mo_ka_sld_im_ctl.SetEditable(False) 111 129 self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD reel.") 112 mo_ka_sld_units_txt = wx.StaticText(self, -1, unit_ a)130 mo_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) 113 131 114 132 neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs') … … 339 357 class SldWindow(wx.Frame): 340 358 def __init__(self, parent=None, id=1, title="SLD Calculator",base=None): 341 wx.Frame.__init__(self, parent, id, title, size=( 400, 400))359 wx.Frame.__init__(self, parent, id, title, size=( PANEL_SIZE, PANEL_SIZE)) 342 360 343 361 self.panel = SldPanel(self, base=base)
Note: See TracChangeset
for help on using the changeset viewer.