Mantid
Loading...
Searching...
No Matches
MultifitSetupDialog.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//---------------------------------------
8// Includes
9//---------------------------------------
10
13
17
18//---------------------------------------
19// Public member functions
20//---------------------------------------
21
23
27 : QDialog(fitBrowser), m_fitBrowser(fitBrowser) {
28 ui.setupUi(this);
29 auto f = m_fitBrowser->compositeFunction()->getFunction(0);
30 if (!f) {
31 throw std::runtime_error("IFitFunction expected but func function of another type");
32 }
33 QAbstractItemModel *model = ui.paramTable->model();
34 for (size_t i = 0; i < f->nParams(); ++i) {
35 int j = static_cast<int>(i);
36 ui.paramTable->insertRow(ui.paramTable->rowCount());
37 model->setData(model->index(j, 0), QString::fromStdString(f->parameterName(i)));
38 ui.paramTable->item(j, 0)->setFlags(Qt::ItemFlags());
39 model->setData(model->index(j, 1), "");
40 ui.paramTable->item(j, 1)->setCheckState(Qt::Unchecked);
41 }
42 ui.paramTable->resizeColumnToContents(0);
43 connect(ui.paramTable, SIGNAL(cellChanged(int, int)), this, SLOT(cellChanged(int, int)));
44}
45
48 m_ties.clear();
49 for (int i = 0; i < ui.paramTable->rowCount(); ++i) {
50 if (ui.paramTable->item(i, 1)->checkState() == Qt::Checked) {
51 m_ties << ui.paramTable->item(i, 1)->text();
52 } else {
53 m_ties << "";
54 }
55 }
56 close();
57}
58
59void MultifitSetupDialog::cellChanged(int row, int col) {
60 if (col == 1) {
61 bool isChecked = ui.paramTable->item(row, col)->checkState() == Qt::Checked;
62 QString text = ui.paramTable->item(row, col)->text();
63 // toggle global/local
64 if (isChecked && text.isEmpty()) {
65 ui.paramTable->item(row, col)->setText(
66 QString::fromStdString(m_fitBrowser->compositeFunction()->parameterName(row)));
67 } else if (!isChecked) {
68 ui.paramTable->item(row, col)->setText("");
69 }
70 }
71}
72} // namespace MantidQt::MantidWidgets
Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function paramet...
std::shared_ptr< Mantid::API::CompositeFunction > compositeFunction() const
Get Composite Function.
MultifitSetupDialog(FitPropertyBrowser *fitBrowser)
Default constructor.
void accept() override
Setup the function and close dialog.
QStringList m_ties
A list with parameter ties.
FitPropertyBrowser * m_fitBrowser
Pointer to the calling fit browser.
Ui::MultifitSetupDialog ui
The form generated with Qt Designer.