Changeset edd166b in sasview for sansview/perspectives/fitting/basepage.py
- Timestamp:
- Nov 20, 2009 12:48:21 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:
- b4ad125
- Parents:
- d23528ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r35c9d31 redd166b 6 6 import copy 7 7 import math 8 import string 8 9 from sans.guiframe.utils import format_number,check_float 9 10 from sans.guicomm.events import StatusEvent … … 496 497 if hasattr(self, "disp_box"): 497 498 self.state.disp_box = copy.deepcopy(self.disp_box.GetSelection()) 498 499 self.state.model = self.model.clone() 499 500 500 self.state.model.name= self.model.name 501 501 #if not hasattr(self.model, "_persistency_dict"): … … 504 504 505 505 #Remember fit engine_type for fit panel 506 if self.engine_type == None and self.manager !=None: 507 self.engine_type = self.manager._return_engine_type() 508 509 self.state.engine_type = self.engine_type 506 if self.engine_type == None: 507 self.engine_type = "scipy" 508 if self.manager !=None: 509 self.manager._on_change_engine(engine=self.engine_type) 510 #self.engine_type = self.manager._return_engine_type() 511 512 self.state.engine_type = self.engine_type 510 513 511 514 new_state = self.state.clone() … … 720 723 self._save_plotting_range() 721 724 722 #self.state.orientation_params =[]723 #self.state.orientation_params_disp =[]724 #self.state.parameters =[]725 #self.state.fittable_param =[]726 #self.state.fixed_param =[]727 728 729 725 ## save checkbutton state and txtcrtl values 730 726 self._copy_parameters_state(self.orientation_params, … … 755 751 self.enable2D= state.enable2D 756 752 self.engine_type = state.engine_type 757 758 #??? 753 759 754 self.disp_cb_dict = state.disp_cb_dict 760 755 self.disp_list = state.disp_list … … 768 763 self._set_model_sizer_selection( self.model ) 769 764 self.set_model_param_sizer(self.model) 770 765 771 766 ## reset value of combox box 772 767 self.structurebox.SetSelection(state.structurecombobox ) … … 783 778 if hasattr(self, "cb1"): 784 779 self.cb1.SetValue(state.cb1) 785 780 786 781 ## reset state of checkbox,textcrtl and regular parameters value 787 782 … … 794 789 self.enable_disp.SetValue(state.enable_disp) 795 790 self.disable_disp.SetValue(state.disable_disp) 796 791 797 792 if hasattr(self, "disp_box"): 798 793 … … 836 831 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 837 832 self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 838 833 839 834 ##plotting range restore 840 835 self._reset_plotting_range(state) 836 841 837 ## smearing info restore 842 838 if hasattr(self,"enable_smearer"): … … 844 840 self.enable_smearer.SetValue(state.enable_smearer) 845 841 self.disable_smearer.SetValue(state.disable_smearer) 846 self.onSmear(event=None) 847 self.tcChi.SetLabel(str( state.tcChi)) 842 self.onSmear(event=None) 848 843 849 844 ## reset state of checkbox,textcrtl and dispersity parameters value 850 845 self._reset_parameters_state(self.fittable_param,state.fittable_param) 851 846 self._reset_parameters_state(self.fixed_param,state.fixed_param) 852 847 853 848 ## draw the model with previous parameters value 854 849 self._onparamEnter_helper() 855 850 856 851 ## reset context menu items 857 852 self._reset_context_menu() … … 860 855 self.state = state.clone() 861 856 self._draw_model() 862 863 def _clear_Err_on_Fit(self): 864 """ 865 hide the error text control shown 866 after fitting 867 """ 868 """ 869 if hasattr(self,"text2_3"): 870 self.text2_3.Hide() 871 872 if len(self.parameters)>0: 873 for item in self.parameters: 874 ## hide statictext +/- 875 if item[3]!=None and item[3].IsShown(): 876 item[3].Hide() 877 ## hide textcrtl for error after fit 878 if item[4]!=None and item[4].IsShown(): 879 item[4].Clear() 880 item[4].Hide() 881 if len(self.fittable_param)>0: 882 for item in self.fittable_param: 883 ## hide statictext +/- 884 if item[3]!=None and item[3].IsShown(): 885 item[3].Hide() 886 ## hide textcrtl for error after fit 887 if item[4]!=None and item[4].IsShown(): 888 item[4].Clear() 889 item[4].Hide() 890 ##Is this layout necessary? Had a problem w/MAC:Not anymore. 891 self.Layout() 892 """ 893 return 857 894 858 def _selectDlg(self): 895 859 """ … … 963 927 #self._undo.Enable(True) 964 928 if self.model !=None: 965 966 967 # Flag to register when a parameter has changed. 929 # Flag to register when a parameter has changed. 968 930 is_modified = False 969 is_modified =self._check_value_enter( self.fittable_param ,is_modified) 970 is_modified =self._check_value_enter( self.fixed_param ,is_modified) 971 is_modified =self._check_value_enter( self.parameters ,is_modified) 972 973 if is_modified: 974 #self.sizer3.Layout() 975 self.Layout() 976 self.Refresh() 977 else: 978 self.Layout() 931 try: 932 is_modified =self._check_value_enter( self.fittable_param ,is_modified) 933 is_modified =self._check_value_enter( self.fixed_param ,is_modified) 934 is_modified =self._check_value_enter( self.parameters ,is_modified) 935 except: 936 pass 937 #if is_modified: 979 938 980 939 # Here we should check whether the boundaries have been modified. … … 1006 965 self.state_change= True 1007 966 self._draw_model() 1008 967 self.Layout() 968 self.Refresh() 969 1009 970 def _update_paramv_on_fit(self): 1010 971 """ … … 1021 982 self._check_value_enter( self.fittable_param ,is_modified) 1022 983 self._check_value_enter( self.fixed_param ,is_modified) 1023 self._check_value_enter( self.parameters ,is_modified) 984 self._check_value_enter( self.parameters ,is_modified) 1024 985 1025 986 # If qmin and qmax have been modified, update qmin and qmax and … … 1036 997 if float(self.npts.GetValue()) != self.num_points: 1037 998 self.num_points = float(self.npts.GetValue()) 1038 1039 999 else: 1040 1000 msg= "Cannot Fit :Must select a model!!! " … … 1501 1461 tcrtl= event.GetEventObject() 1502 1462 1463 #Clear msg if previously shown. 1464 msg= "" 1465 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1466 1503 1467 ## save current state 1504 1468 self.save_current_state() … … 1511 1475 1512 1476 self._onparamEnter_helper() 1513 1477 1514 1478 else: 1515 1479 msg= "Cannot Plot :Must enter a number!!! " … … 1527 1491 if len(list)==0: 1528 1492 return is_modified 1493 1529 1494 for item in list: 1530 try: 1531 name = str(item[1]) 1532 if hasattr(self,"text2_3") and self.text2_3.IsShown(): 1533 if hasattr(self,"item[4]")and self.item[4] == None: 1534 self.text2_3.Hide() 1535 1495 #skip angle parameters for 1D 1496 if self.data.__class__.__name__ !="Data2D": 1497 if item in self.orientation_params: 1498 continue 1499 #try: 1500 name = str(item[1]) 1501 1502 if string.find(name,".npts") ==-1 and string.find(name,".nsigmas")==-1: 1536 1503 ## check model parameters range 1537 1504 param_min= None 1538 1505 param_max= None 1506 1539 1507 ## check minimun value 1540 if item[5]!= None :1508 if item[5]!= None and item[5]!= "": 1541 1509 if item[5].GetValue().lstrip().rstrip()!="": 1542 param_min = float(item[5].GetValue()) 1510 try: 1511 param_min = float(item[5].GetValue()) 1512 except: 1513 msg = "Wrong Fit parameter range entered " 1514 wx.PostEvent(self.parent.parent, StatusEvent(status = msg)) 1515 raise ValueError, msg 1543 1516 is_modified = True 1544 1517 ## check maximum value 1545 if item[6]!= None :1518 if item[6]!= None and item[5]!= "": 1546 1519 if item[6].GetValue().lstrip().rstrip()!="": 1547 param_max = float(item[6].GetValue()) 1520 try: 1521 param_max = float(item[6].GetValue()) 1522 except: 1523 msg = "Wrong Fit parameter range entered " 1524 wx.PostEvent(self.parent.parent, StatusEvent(status = msg)) 1525 raise ValueError, msg 1548 1526 is_modified = True 1549 1527 from sans.guiframe.utils import check_value 1528 1550 1529 if param_min != None and param_max !=None: 1551 1530 if not check_value(item[5], item[6]): 1552 1531 msg= "Wrong Fit range entered for parameter " 1553 1532 msg+= "name %s of model %s "%(name, self.model.name) 1554 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1533 wx.PostEvent(self.parent.parent, StatusEvent(status = msg)) 1534 1555 1535 if name in self.model.details.keys(): 1556 self.model.details[name][1:]= param_min,param_max 1557 1558 value= float(item[2].GetValue()) 1559 1560 # If the value of the parameter has changed, 1561 # +update the model and set the is_modified flag 1562 if value != self.model.getParam(name): 1563 self.model.setParam(name,value) 1564 is_modified = True 1565 1566 except: 1567 msg= "Model Drawing Error:wrong value entered : %s"% sys.exc_value 1568 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1569 return 1536 if param_min != self.model.details[name][1] or param_max != self.model.details[name][2]: 1537 self.model.details[name][1:3]= param_min,param_max 1538 is_modified = True 1539 1540 else: 1541 self.model.details [name] = ["",param_min,param_max] 1542 is_modified = True 1543 1544 value= float(item[2].GetValue()) 1545 1546 # If the value of the parameter has changed, 1547 # +update the model and set the is_modified flag 1548 if value != self.model.getParam(name): 1549 self.model.setParam(name,value) 1550 is_modified = True 1551 1570 1552 return is_modified 1571 1553 … … 1617 1599 self.sizer5.Layout() 1618 1600 self.Layout() 1619 #self.Refresh()1601 self.Refresh() 1620 1602 1621 1603 … … 1648 1630 if item in self.param_toFit: 1649 1631 self.param_toFit.remove(item) 1632 1650 1633 for item in self.orientation_params_disp: 1651 1634 if item in self.param_toFit:
Note: See TracChangeset
for help on using the changeset viewer.