Skip to content

Commit

Permalink
Plot ComboBox now updates when functions change
Browse files Browse the repository at this point in the history
Refs #12669
  • Loading branch information
Elliot Oram authored and Elliot Oram committed Jul 31, 2015
1 parent 2264306 commit 4c4c331
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private slots:
void singleFitComplete(bool error);
void fitFunctionSelected(const QString &);


private:
boost::shared_ptr<Mantid::API::CompositeFunction>
createFunction(bool tieCentres = false);
Expand All @@ -59,6 +60,7 @@ private slots:
QString backgroundString() const;
QString minimizerString(QString outputName) const;
QStringList getFunctionParameters(QString);
void updatePlotOptions();

Ui::ConvFit m_uiForm;
QtStringPropertyManager *m_stringManager;
Expand Down
45 changes: 42 additions & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ void ConvFit::setup() {
connect(m_uiForm.cbFitType, SIGNAL(currentIndexChanged(QString)),
SLOT(showTieCheckbox(QString)));
showTieCheckbox(m_uiForm.cbFitType->currentText());

updatePlotOptions();
}

/**
Expand Down Expand Up @@ -846,6 +848,8 @@ void ConvFit::typeSelection(int index) {
// DiffRotDiscreteCircle
m_uiForm.ckPlotGuess->setEnabled(index < 3);
m_properties["UseDeltaFunc"]->setEnabled(index < 3);

updatePlotOptions();
}

/**
Expand Down Expand Up @@ -1230,7 +1234,9 @@ void ConvFit::hwhmUpdateRS(double val) {
void ConvFit::checkBoxUpdate(QtProperty *prop, bool checked) {
UNUSED_ARG(checked);

if (prop == m_properties["UseFABADA"]) {
if (prop == m_properties["UseDeltaFunc"])
updatePlotOptions();
else if (prop == m_properties["UseFABADA"]) {
if (checked) {
// FABADA needs a much higher iteration limit
m_dblManager->setValue(m_properties["MaxIterations"], 20000);
Expand Down Expand Up @@ -1372,14 +1378,14 @@ void ConvFit::fitFunctionSelected(const QString &functionName) {
// remove previous parameters from tree
m_cfTree->removeProperty(m_properties["FitFunction1"]);
m_cfTree->removeProperty(m_properties["FitFunction2"]);

m_uiForm.ckPlotGuess->setChecked(false);
m_uiForm.ckTieCentres->setChecked(false);


// Add new parameter elements
int fitFunctionIndex = m_uiForm.cbFitType->currentIndex();
QStringList parameters = getFunctionParameters(functionName);
updatePlotOptions();

// Two Loremtzians Fit
if (fitFunctionIndex == 2) {
Expand Down Expand Up @@ -1451,6 +1457,39 @@ void ConvFit::fitFunctionSelected(const QString &functionName) {
}
}

/**
* Populates the plot combobox
* @param params The values to append to the list of plot Types
*/
void ConvFit::updatePlotOptions() {
m_uiForm.cbPlotType->clear();

const bool deltaFunction = m_blnManager->value(m_properties["UseDeltaFunc"]);
const int fitFunctionType = m_uiForm.cbFitType->currentIndex();
QStringList plotOptions;
plotOptions << "None";

if (deltaFunction && fitFunctionType < 3){
plotOptions << "Height";
}

QStringList params = QStringList();

if (fitFunctionType != 2) {
params = getFunctionParameters(m_uiForm.cbFitType->currentText());
} else {
params = getFunctionParameters(QString("One Lorentzian"));
}
if (fitFunctionType != 0) {
plotOptions.append(params);
}

if(fitFunctionType != 0 || deltaFunction){
plotOptions << "All";
}
m_uiForm.cbPlotType->addItems(plotOptions);
}

} // namespace IDA
} // namespace CustomInterfaces
} // namespace MantidQt

0 comments on commit 4c4c331

Please sign in to comment.