Skip to content

Commit

Permalink
Refs #6473. Diagnosis table is being populated now.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Dec 10, 2013
1 parent 25c011f commit a8de94d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Expand Up @@ -70,6 +70,10 @@ namespace MantidWidgets
/// Initialize diagnosis table
void initDiagnosisTable();

/// Add a new entry to the diagnosis table
void addDiagnosisEntry(const std::string& runTitle, double fitQuality,
IFunction_sptr fittedFunction);

// -- VARIABLES -----------------------------------------------------------

/// UI form
Expand Down
34 changes: 34 additions & 0 deletions Code/Mantid/MantidQt/MantidWidgets/src/MuonSequentialFitDialog.cpp
Expand Up @@ -118,6 +118,30 @@ namespace MantidWidgets
m_ui.diagnosisTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
}

/**
* Add a new entry to the diagnosis table.
* @param runTitle :: Title of the run fitted
* @param fitQuality :: Number representing a goodness of the fit
* @param fittedFunction :: Function containing fitted parameters
*/
void MuonSequentialFitDialog::addDiagnosisEntry(const std::string& runTitle, double fitQuality,
IFunction_sptr fittedFunction)
{
int newRow = m_ui.diagnosisTable->rowCount();

m_ui.diagnosisTable->insertRow(newRow);

m_ui.diagnosisTable->setItem(newRow, 0, new QTableWidgetItem( QString::fromStdString(runTitle) ) );
m_ui.diagnosisTable->setItem(newRow, 1, new QTableWidgetItem( QString::number(fitQuality) ) );

for(int i = 2; i < m_ui.diagnosisTable->columnCount(); ++i)
{
std::string paramName = m_ui.diagnosisTable->horizontalHeaderItem(i)->text().toStdString();
double value = fittedFunction->getParameter(paramName);
m_ui.diagnosisTable->setItem(newRow, i, new QTableWidgetItem( QString::number(value) ) );
}
}

/**
* Updates visibility/tooltip of label error asterisk.
* @param label :: New label as specified by user
Expand Down Expand Up @@ -225,6 +249,9 @@ namespace MantidWidgets
m_ui.progress->setFormat("%p%");
m_ui.progress->setValue(0);

// Clear diagnosis table for new fit
m_ui.diagnosisTable->setRowCount(0);

setState(Running);
m_stopRequested = false;

Expand Down Expand Up @@ -274,6 +301,8 @@ namespace MantidWidgets
const std::string runTitle = getRunTitle(ws);
const std::string wsBaseName = labelGroupName + "_" + runTitle;

double fitQuality;

try
{
IAlgorithm_sptr fit = AlgorithmManager::Instance().createUnmanaged("Fit");
Expand All @@ -287,6 +316,8 @@ namespace MantidWidgets
fit->setProperty("Minimizer", m_fitPropBrowser->minimizer());
fit->setProperty("CostFunction", m_fitPropBrowser->costFunction());
fit->execute();

fitQuality = fit->getProperty("OutputChi2overDoF");
}
catch(std::exception& e)
{
Expand All @@ -302,6 +333,9 @@ namespace MantidWidgets
ads.addToGroup(labelGroupName, wsBaseName + "_Parameters");
ads.addToGroup(labelGroupName, wsBaseName + "_Workspace");

// Add information about the fit to the diagnosis table
addDiagnosisEntry(runTitle, fitQuality, m_fitPropBrowser->getFittingFunction());

// Update progress
m_ui.progress->setFormat("%p% - " + QString::fromStdString(runTitle) );
m_ui.progress->setValue( m_ui.progress->value() + 1 );
Expand Down

0 comments on commit a8de94d

Please sign in to comment.