Changeset 700b03b in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- Sep 4, 2018 5:51:03 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- c7809a9
- Parents:
- 00b7ddf0
- git-author:
- Torin Cooper-Bennun <torin.cooper-bennun@…> (08/17/18 11:51:05)
- git-committer:
- Torin Cooper-Bennun <torin.cooper-bennun@…> (09/04/18 05:51:03)
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
r00b7ddf0 r700b03b 124 124 return item 125 125 126 def addSimpleParametersToModel(parameters, is2D ):126 def addSimpleParametersToModel(parameters, is2D, parameters_original=None): 127 127 """ 128 128 Update local ModelModel with sasmodel parameters 129 parameters_original: list of parameters before any tagging on their IDs, e.g. for product model 130 (so that those are the display names; see below) 129 131 """ 130 132 if is2D: … … 132 134 else: 133 135 params = parameters.iq_parameters 136 137 if parameters_original: 138 # 'parameters_original' contains the parameters as they are to be DISPLAYED, while 'parameters' 139 # contains the parameters as they were renamed; this is for handling name collisions in product model. 140 # The 'real name' of the parameter will be stored in the item's user data. 141 if is2D: 142 params_orig = [p for p in parameters_original.kernel_parameters if p.type != 'magnetic'] 143 else: 144 params_orig = parameters_original.iq_parameters 145 else: 146 # no difference in names anyway 147 params_orig = params 148 134 149 item = [] 135 for param in params:150 for param, param_orig in zip(params, params_orig): 136 151 # Create the top level, checkable item 137 item_name = param .name152 item_name = param_orig.name 138 153 item1 = QtGui.QStandardItem(item_name) 154 item1.setData(param.name, QtCore.Qt.UserRole) 139 155 item1.setCheckable(True) 140 156 item1.setEditable(False) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r00b7ddf0 r700b03b 2060 2060 """ 2061 2061 structure_module = generate.load_kernel_module(structure_factor) 2062 structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 2063 2064 structure_kernel = self.models[structure_factor]() 2065 form_kernel = self.kernel_module 2066 2067 self.kernel_module = MultiplicationModel(form_kernel, structure_kernel) 2062 2063 s_kernel = self.models[structure_factor]() 2064 p_kernel = self.kernel_module 2065 2066 p_pars_len = len(p_kernel._model_info.parameters.kernel_parameters) 2067 s_pars_len = len(s_kernel._model_info.parameters.kernel_parameters) - 1 # no radius_effective 2068 2069 self.kernel_module = MultiplicationModel(p_kernel, s_kernel) 2070 2071 # S(Q) params from the product model are not necessarily the same as those from the S(Q) model; any conflicting 2072 # names with P(Q) params will cause a rename; we also lose radius_effective (for now...) 2073 s_params = modelinfo.ParameterTable( 2074 self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len:p_pars_len+s_pars_len]) 2075 2076 # These are the parameters before rename; ignore the first one, as it is radius_effective, which is removed 2077 # from the product model to be handled internally (for now...) 2078 s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 2068 2079 2069 2080 # Get new rows for QModel 2070 new_rows = FittingUtilities.addSimpleParametersToModel(structure_parameters, self.is2D) 2081 # Any renamed parameters are stored as data in the relevant item, for later handling 2082 new_rows = FittingUtilities.addSimpleParametersToModel(s_params, self.is2D, s_params_orig) 2083 2084 # TODO: deal with new parameter(s) added to product model, in kernel_parameters[p_pars_len+s_pars_len:] 2071 2085 2072 2086 # Add heading row … … 2108 2122 model_row = item.row() 2109 2123 name_index = self._model_model.index(model_row, 0) 2124 name_item = self._model_model.itemFromIndex(name_index) 2110 2125 2111 2126 # Extract changed value. … … 2116 2131 return 2117 2132 2118 parameter_name = str(self._model_model.data(name_index)) # sld, background etc. 2133 # if the item has user data, this is the actual parameter name (e.g. to handle duplicate names) 2134 if name_item.data(QtCore.Qt.UserRole): 2135 parameter_name = str(name_item.data(QtCore.Qt.UserRole)) 2136 else: 2137 parameter_name = str(self._model_model.data(name_index)) 2119 2138 2120 2139 # Update the parameter value - note: this supports +/-inf as well
Note: See TracChangeset
for help on using the changeset viewer.