Skip to content

Commit

Permalink
Re #10576. Keep old local parameter values after adding spectra.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Mar 27, 2015
1 parent a25de3d commit e712a2e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Expand Up @@ -294,6 +294,7 @@ class DataController: public QObject
void dataSetUpdated(int i);
void hasSelection(bool);
void spectraRemoved(QList<int>);
void spectraAdded(int n);

public slots:
void setFittingRangeGlobal(bool);
Expand Down
Expand Up @@ -843,6 +843,7 @@ void MultiDatasetFit::initLayout()
connect(m_functionBrowser,SIGNAL(functionStructureChanged()),this,SLOT(reset()));
connect(m_plotController,SIGNAL(currentIndexChanged(int)),m_functionBrowser,SLOT(setCurrentDataset(int)));
connect(m_dataController,SIGNAL(spectraRemoved(QList<int>)),m_functionBrowser,SLOT(removeDatasets(QList<int>)));
connect(m_dataController,SIGNAL(spectraAdded(int)),m_functionBrowser,SLOT(addDatasets(int)));

m_fitOptionsBrowser = new MantidQt::MantidWidgets::FitOptionsBrowser(NULL);
splitter->addWidget( m_fitOptionsBrowser );
Expand Down Expand Up @@ -1330,7 +1331,7 @@ void DataController::addWorkspace()
{
addWorkspaceSpectrum( wsName, *i, *ws );
}
emit dataTableUpdated();
emit spectraAdded(static_cast<int>(indices.size()));
}
else
{
Expand Down
Expand Up @@ -138,11 +138,13 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS FunctionBrowser: public QWidget

public slots:

// Handling of multiple datasets
void setNumberOfDatasets(int n);
void setLocalParameterValue(const QString& parName, int i, double value);
void resetLocalParameters();
void setCurrentDataset(int i);
void removeDatasets(QList<int> indices);
void addDatasets(int n);

protected:
/// Create the Qt property browser
Expand Down Expand Up @@ -218,6 +220,7 @@ public slots:
/// Check if a parameter property has a upper bound
bool hasUpperBound(QtProperty* prop) const;

/// Initialize storage and values for local parameters
void initLocalParameter(const QString& parName)const;

protected slots:
Expand Down
20 changes: 20 additions & 0 deletions Code/Mantid/MantidQt/MantidWidgets/src/FunctionBrowser.cpp
Expand Up @@ -1928,5 +1928,25 @@ void FunctionBrowser::removeDatasets(QList<int> indices)
setNumberOfDatasets( newSize );
}

/// Add local parameters for additional datasets.
/// @param n :: Number of datasets added.
void FunctionBrowser::addDatasets(int n)
{
if ( getNumberOfDatasets() == 0 )
{
setNumberOfDatasets( n );
return;
}
int newSize = m_numberOfDatasets;
for(auto par = m_localParameterValues.begin(); par != m_localParameterValues.end(); ++par)
{
auto &values = par.value();
double value = values.back();
values.insert(values.end(),n,value);
newSize = values.size();
}
setNumberOfDatasets(newSize);
}

} // MantidWidgets
} // MantidQt

0 comments on commit e712a2e

Please sign in to comment.