Changeset c5a2722f in sasview for src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py
- Timestamp:
- Jan 18, 2018 9:44:26 AM (7 years ago)
- Branches:
- 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
- Children:
- ba01ad1
- Parents:
- 2d466e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py
r2d466e4 rc5a2722f 15 15 # Local UI 16 16 from sas.qtgui.Perspectives.Fitting.UI.ComplexConstraintUI import Ui_ComplexConstraintUI 17 from sas.qtgui.Perspectives.Fitting.Constraints import Constraint 17 18 18 19 class ComplexConstraint(QtWidgets.QDialog, Ui_ComplexConstraintUI): … … 52 53 self.cmdHelp.clicked.connect(self.onHelp) 53 54 self.cmdRevert.clicked.connect(self.onRevert) 54 #self.txtConstraint.editingFinished.connect(self.validateFormula)55 self.txtConstraint.editingFinished.connect(self.validateFormula) 55 56 56 57 self.cbParam1.currentIndexChanged.connect(self.onParamIndexChange) … … 95 96 self.txtParam.setText(self.tab_names[0] + ":" + self.cbParam1.currentText()) 96 97 else: 97 self.txtConstraint.setText(self. cbParam2.currentText())98 self.txtConstraint.setText(self.tab_names[1] + "." + self.cbParam2.currentText()) 98 99 pass 99 100 … … 148 149 return False 149 150 150 param_str = str(self.params[1]) 151 # M1.scale --> model_str='M1', constraint_text='scale' 152 param_str = self.cbParam2.currentText() 151 153 constraint_text = constraint_text.strip() 154 model_str = constraint_text[:constraint_text.index('.')] 155 #constraint_text = constraint_text[constraint_text.index('.')+1:] 156 157 # 0. Has to contain the model name 158 if model_str != self.txtName2.text(): 159 return False 160 161 # Remove model name from constraint text 162 constraint_text = constraint_text.replace(model_str+".",'') 152 163 153 164 # 1. just the parameter … … 161 172 parameter_string_end = parameter_string_start + len(param_str) 162 173 163 # 3. parameter name should be a separate word, but can have "()[]*+-/ " around 164 valid_neighbours = "()[]*+-/ " 165 has_only_parameter = False 166 start_loc = parameter_string_start -1 167 end_loc = parameter_string_end 168 if not any([constraint_text[start_loc] == char for char in valid_neighbours]): 169 return False 170 if end_loc < len(constraint_text): 171 if not any([constraint_text[end_loc] == char for char in valid_neighbours]): 172 return False 173 174 # 4. replace parameter name with "1" and try to evaluate the expression 174 # 3. replace parameter name with "1" and try to evaluate the expression 175 175 try: 176 176 expression_to_evaluate = constraint_text.replace(param_str, "1.0") … … 185 185 return True 186 186 187 def constraint(self): 188 """ 189 Return the generated constraint as tuple (model1, param1, operator, constraint) 190 """ 191 return (self.txtName1.text(), self.cbParam1.currentText(), self.cbOperator.currentText(), self.txtConstraint.text()) 192 187 193 def onHelp(self): 188 194 """
Note: See TracChangeset
for help on using the changeset viewer.