Changeset e89aed5 in sasview for src/sas/sasgui/perspectives/fitting/simfitpage.py
- Timestamp:
- Oct 6, 2016 3:47:28 PM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 1dbdb83
- Parents:
- ef3e09b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/simfitpage.py
ra95ae9a re89aed5 768 768 """ 769 769 Show constraint fields 770 :param dict: dictionary mapping constraint values 770 771 """ 771 772 self.btAdd.Show(True) … … 871 872 def _on_select_model(self, event): 872 873 """ 873 fill combo xbox with list of parameters874 fill combo box with list of parameters 874 875 """ 875 876 if not self.constraints_list: … … 1041 1042 # List of constraints 1042 1043 self.constraints_list = [] 1044 1045 def load_from_save_state(self, fit): 1046 """ 1047 Load in a simultaneous/constrained fit from a save state 1048 :param fit: Fitpanel object 1049 :return: None 1050 """ 1051 1052 model_map = {} 1053 fit.fit_panel.add_sim_page() 1054 1055 # Process each model and associate old M# with new M# 1056 i = 0 1057 for model in fit.fit_panel.sim_page.model_list: 1058 model_id = self._format_id(model[1].keys()[0]) 1059 for saved_model in self.model_list: 1060 save_id = saved_model.pop('name') 1061 saved_model['name'] = save_id 1062 save_id = self._format_id(save_id) 1063 if save_id == model_id: 1064 model_map[saved_model.pop('fit_page_source')] = \ 1065 model[3].name 1066 check = bool(saved_model.pop('checked')) 1067 fit.fit_panel.sim_page.model_list[i][0].SetValue(check) 1068 continue 1069 i += 1 1070 fit.fit_panel.sim_page.check_model_name(None) 1071 1072 if len(self.constraints_list) > 0: 1073 fit.fit_panel.sim_page.hide_constraint.SetValue(False) 1074 fit.fit_panel.sim_page.show_constraint.SetValue(True) 1075 fit.fit_panel.sim_page._display_constraint(None) 1076 1077 for constraint in self.constraints_list: 1078 model_cbox = constraint.pop('model_cbox') 1079 constraint_value = constraint.pop('constraint') 1080 for key, value in model_map.iteritems(): 1081 model_cbox.replace(key, value) 1082 constraint_value.replace(key, value) 1083 1084 bt_remove = wx.Button(fit.fit_panel.sim_page, 1085 fit.fit_panel.sim_page._ids.next(), 'Remove') 1086 bt_remove.Bind(wx.EVT_BUTTON, fit.fit_panel.sim_page.on_remove, 1087 id=bt_remove.GetId()) 1088 bt_remove.SetToolTipString("Remove constraint.") 1089 param_cbox = wx.ComboBox(fit.fit_panel.sim_page, wx.ID_ANY, 1090 style=wx.CB_READONLY, size=(100, -1)) 1091 egal_txt = wx.StaticText(fit.fit_panel.sim_page, wx.ID_ANY, " = ") 1092 # Model list 1093 model_cbox_sizer = wx.ComboBox(fit.fit_panel.sim_page, 1094 wx.ID_ANY, style=wx.CB_READONLY) 1095 model_cbox_sizer.Clear() 1096 wx.EVT_COMBOBOX(model_cbox_sizer, wx.ID_ANY, 1097 fit.fit_panel.sim_page._on_select_model) 1098 constraint_sizer = wx.TextCtrl(fit.fit_panel.sim_page, wx.ID_ANY) 1099 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 1100 sizer_constraint.Add((5, -1)) 1101 sizer_constraint.Add(model_cbox_sizer, flag=wx.RIGHT | wx.EXPAND, 1102 border=10) 1103 sizer_constraint.Add(param_cbox, flag=wx.RIGHT | wx.EXPAND, 1104 border=5) 1105 sizer_constraint.Add(egal_txt, flag=wx.RIGHT | wx.EXPAND, border=5) 1106 sizer_constraint.Add(constraint_sizer, flag=wx.RIGHT | wx.EXPAND, 1107 border=10) 1108 sizer_constraint.Add(bt_remove, flag=wx.RIGHT | wx.EXPAND, 1109 border=10) 1110 new_const = ConstraintLine(model_cbox=model_cbox_sizer, 1111 param_cbox=constraint.pop('param_cbox'), 1112 egal_txt=constraint.pop('egal_txt'), 1113 constraint=constraint_value, 1114 btRemove=bt_remove, 1115 sizer=sizer_constraint 1116 ) 1117 # ConstraintLine = namedtuple('ConstraintLine', 1118 # 'model_cbox param_cbox egal_txt constraint btRemove sizer') 1119 fit.fit_panel.sim_page.sizer_constraints.Insert( 1120 before=fit.fit_panel.sim_page.nb_constraint, 1121 item=sizer_constraint, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, 1122 border=5) 1123 fit.fit_panel.sim_page.constraints_list.append(new_const) 1124 1125 def _format_id(self, original_id): 1126 original_id = original_id.rstrip('1234567890.') 1127 new_id_list = original_id.split() 1128 new_id = ' '.join(new_id_list) 1129 return new_id
Note: See TracChangeset
for help on using the changeset viewer.