Skip to content

Commit

Permalink
Add proper plotting in ConvFit UI for fit
Browse files Browse the repository at this point in the history
Refs #11167
  • Loading branch information
DanNixon committed Feb 24, 2015
1 parent 3e1e8e7 commit ddcf419
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Expand Up @@ -29,7 +29,7 @@ namespace IDA
void typeSelection(int index);
void bgTypeSelection(int index);
void newDataLoaded(const QString wsName);
void plotInput();
void updatePlot();
void plotGuess();
void singleFit();
void specMinChanged(int value);
Expand Down
25 changes: 20 additions & 5 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp
Expand Up @@ -121,7 +121,7 @@ namespace IDA
bgTypeSelection(m_uiForm.cbBackground->currentIndex());

// Replot input automatically when file / spec no changes
connect(m_uiForm.spPlotSpectrum, SIGNAL(valueChanged(int)), this, SLOT(plotInput()));
connect(m_uiForm.spPlotSpectrum, SIGNAL(valueChanged(int)), this, SLOT(updatePlot()));
connect(m_uiForm.dsSampleInput, SIGNAL(dataReady(const QString&)), this, SLOT(newDataLoaded(const QString&)));

connect(m_uiForm.spSpectraMin, SIGNAL(valueChanged(int)), this, SLOT(specMinChanged(int)));
Expand Down Expand Up @@ -203,6 +203,8 @@ namespace IDA
QString inputWsName = QString::fromStdString(m_cfInputWS->getName());
QString resultWsName = inputWsName.left(inputWsName.lastIndexOf("_")) + "_conv_" + fitType + bgType + specMin + "_to_" + specMax + "_Workspaces";
m_pythonExportWsName = resultWsName.toStdString();

updatePlot();
}

/**
Expand Down Expand Up @@ -260,7 +262,7 @@ namespace IDA
m_uiForm.spSpectraMax->setMinimum(0);
m_uiForm.spSpectraMax->setValue(maxSpecIndex);

plotInput();
updatePlot();
}

namespace
Expand Down Expand Up @@ -670,7 +672,7 @@ namespace IDA
}
}

void ConvFit::plotInput()
void ConvFit::updatePlot()
{
using Mantid::Kernel::Exception::NotFoundError;

Expand Down Expand Up @@ -707,6 +709,17 @@ namespace IDA
m_dblManager->setValue(m_properties["Lorentzian 1.FWHM"], resolution);
m_dblManager->setValue(m_properties["Lorentzian 2.FWHM"], resolution);
}

// If there is a result plot then plot it
if(AnalysisDataService::Instance().doesExist(m_pythonExportWsName))
{
WorkspaceGroup_sptr outputGroup = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(m_pythonExportWsName);
if(specNo >= static_cast<int>(outputGroup->size()))
return;
MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>(outputGroup->getItem(specNo));
if(ws)
m_uiForm.ppPlot->addSpectrum("Fit", ws, 1, Qt::red);
}
}

void ConvFit::plotGuess()
Expand All @@ -723,7 +736,7 @@ namespace IDA

if ( m_cfInputWS == NULL )
{
plotInput();
updatePlot();
}

const size_t binIndexLow = m_cfInputWS->binIndexOf(m_dblManager->value(m_properties["StartX"]));
Expand Down Expand Up @@ -777,7 +790,7 @@ namespace IDA
if(!validate())
return;

plotInput();
updatePlot();

m_uiForm.ckPlotGuess->setChecked(false);

Expand Down Expand Up @@ -897,6 +910,8 @@ namespace IDA
m_dblManager->setValue(m_properties["Lorentzian 2.PeakCentre"], parameters[pref+"PeakCentre"]);
m_dblManager->setValue(m_properties["Lorentzian 2.FWHM"], parameters[pref+"FWHM"]);
}

m_pythonExportWsName = "";
}

/**
Expand Down

0 comments on commit ddcf419

Please sign in to comment.