Changeset baeac95 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Nov 14, 2018 5:43:28 AM (5 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- ecc5d043
- Parents:
- e5ae812
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
re5ae812 rbaeac95 622 622 to_string = "to its current value" if num_rows == 1 else "to their current values" 623 623 has_constraints = any([self.rowHasConstraint(i) for i in rows]) 624 has_real_constraints = any([self.rowHasActiveConstraint(i) for i in rows]) 624 625 625 626 self.actionSelect = QtWidgets.QAction(self) … … 639 640 self.actionRemoveConstraint.setText(QtCore.QCoreApplication.translate("self", "Remove constraint")) 640 641 642 self.actionEditConstraint = QtWidgets.QAction(self) 643 self.actionEditConstraint.setObjectName("actionEditConstrain") 644 self.actionEditConstraint.setText(QtCore.QCoreApplication.translate("self", "Edit constraint")) 645 641 646 self.actionMultiConstrain = QtWidgets.QAction(self) 642 647 self.actionMultiConstrain.setObjectName("actionMultiConstrain") … … 653 658 if has_constraints: 654 659 menu.addAction(self.actionRemoveConstraint) 660 if num_rows == 1 and has_real_constraints: 661 menu.addAction(self.actionEditConstraint) 655 662 #if num_rows == 1: 656 663 # menu.addAction(self.actionEditConstraint) … … 663 670 self.actionConstrain.triggered.connect(self.addSimpleConstraint) 664 671 self.actionRemoveConstraint.triggered.connect(self.deleteConstraint) 672 self.actionEditConstraint.triggered.connect(self.editConstraint) 665 673 self.actionMutualMultiConstrain.triggered.connect(self.showMultiConstraint) 666 674 self.actionSelect.triggered.connect(self.selectParameters) … … 700 708 new_func = c_text.replace(param_used, updated_param_used) 701 709 constraint.func = new_func 710 constraint.value_ex = updated_param_used 702 711 # Which row is the constrained parameter in? 703 712 row = self.getRowFromName(constraint.param) 713 714 # what is the parameter to constraint to? 715 constraint.value = param_used 704 716 705 717 # Create a new item and add the Constraint object as a child … … 797 809 self.modifyViewOnRow(row, font=font, brush=brush) 798 810 self.communicate.statusBarUpdateSignal.emit('Constraint added') 811 812 def editConstraint(self): 813 """ 814 Delete constraints from selected parameters. 815 """ 816 params_list = [s.data() for s in self.lstParams.selectionModel().selectedRows() 817 if self.isCheckable(s.row())] 818 assert len(params_list) == 1 819 row = self.lstParams.selectionModel().selectedRows()[0].row() 820 constraint = self.getConstraintForRow(row) 821 # Create and display the widget for param1 and param2 822 mc_widget = MultiConstraint(self, params=params_list, constraint=constraint) 823 # Check if any of the parameters are polydisperse 824 if not np.any([FittingUtilities.isParamPolydisperse(p, self.model_parameters, is2D=self.is2D) for p in params_list]): 825 # no parameters are pd - reset the text to not show the warning 826 mc_widget.lblWarning.setText("") 827 if mc_widget.exec_() != QtWidgets.QDialog.Accepted: 828 return 829 830 constraint = Constraint() 831 c_text = mc_widget.txtConstraint.text() 832 833 # widget.params[0] is the parameter we're constraining 834 constraint.param = mc_widget.params[0] 835 # parameter should have the model name preamble 836 model_name = self.kernel_module.name 837 # param_used is the parameter we're using in constraining function 838 param_used = mc_widget.params[1] 839 # Replace param_used with model_name.param_used 840 updated_param_used = model_name + "." + param_used 841 # Update constraint with new values 842 constraint.func = c_text 843 constraint.value_ex = updated_param_used 844 constraint.value = param_used 845 846 # Which row is the constrained parameter in? 847 row = self.getRowFromName(constraint.param) 848 849 # Create a new item and add the Constraint object as a child 850 self.addConstraintToRow(constraint=constraint, row=row) 799 851 800 852 def deleteConstraint(self): … … 3603 3655 value = constraint.value 3604 3656 func = constraint.func 3605 cons = (value, func) 3657 value_ex = constraint.value_ex 3658 param = constraint.param 3659 3660 cons = (value, param, value_ex, func) 3606 3661 3607 3662 param_list.append([param_name, param_checked, param_value, param_error, param_min, param_max, cons]) … … 3853 3908 # constraints 3854 3909 cons = param_dict[param_name][4+ioffset] 3855 if cons is not None and cons:3910 if cons is not None and len(cons)==4: 3856 3911 value = cons[0] 3857 function = cons[1] 3912 param = cons[1] 3913 value_ex = cons[2] 3914 function = cons[3] 3858 3915 constraint = Constraint() 3859 3916 constraint.value = value 3860 3917 constraint.func = function 3918 constraint.param = param 3919 constraint.value_ex = value_ex 3861 3920 self.addConstraintToRow(constraint=constraint, row=row) 3862 3921
Note: See TracChangeset
for help on using the changeset viewer.