Skip to content

Commit

Permalink
Handle max and min spectra indexes, correct merge errors
Browse files Browse the repository at this point in the history
Refs #9338
  • Loading branch information
DanNixon committed Sep 15, 2014
1 parent 1c94c78 commit ebf6a5a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Expand Up @@ -845,7 +845,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_15">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -857,13 +857,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="furyfit_pbSingle">
<property name="text">
<string>Fit Single Spectrum</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down Expand Up @@ -2841,8 +2834,6 @@
<tabstop>confit_cbFitType</tabstop>
<tabstop>confit_cbBackground</tabstop>
<tabstop>confit_ckPlotGuess</tabstop>
<tabstop>confit_leSpecNo</tabstop>
<tabstop>confit_leSpecMax</tabstop>
<tabstop>abscor_cbPlotOutput</tabstop>
<tabstop>pbHelp</tabstop>
<tabstop>pbRun</tabstop>
Expand Down
14 changes: 10 additions & 4 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp
Expand Up @@ -623,15 +623,21 @@ namespace IDA

int specNo = uiForm().confit_lePlotSpectrum->text().toInt();
// Set spectra max value
size_t specMax = m_cfInputWS->getNumberHistograms();
if( specMax > 0 ) specMax -= 1;
if ( specNo < 0 || static_cast<size_t>(specNo) > specMax ) //cast is okay as the first check is for less-than-zero
int specMin = 0;
int specMax = static_cast<int>(m_cfInputWS->getNumberHistograms()) - 1;

m_intVal->setRange(specMin, specMax);
uiForm().confit_leSpectraMin->setText(QString::number(specMin));
uiForm().confit_leSpectraMax->setText(QString::number(specMax));

if ( specNo < 0 || specNo > specMax )
{
uiForm().confit_lePlotSpectrum->setText("0");
specNo = 0;
}

int smCurrent = uiForm().confit_leSpectraMax->text().toInt();
if ( smCurrent < 0 || static_cast<size_t>(smCurrent) > specMax )
if ( smCurrent < 0 || smCurrent > specMax )
{
uiForm().confit_leSpectraMax->setText(QString::number(specMax));
}
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/FuryFit.cpp
Expand Up @@ -430,6 +430,12 @@ namespace IDA

int specNo = uiForm().furyfit_lePlotSpectrum->text().toInt();
int nHist = static_cast<int>(m_ffInputWS->getNumberHistograms());
int specMin = 0;
int specMax = nHist - 1;

m_intVal->setRange(specMin, specMax);
uiForm().furyfit_leSpectraMin->setText(QString::number(specMin));
uiForm().furyfit_leSpectraMax->setText(QString::number(specMax));

if( specNo < 0 || specNo >= nHist )
{
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MSDFit.cpp
Expand Up @@ -168,13 +168,13 @@ namespace IDA
auto ws = Mantid::API::AnalysisDataService::Instance().retrieveWS<const MatrixWorkspace>(wsname.toStdString());
int nHist = static_cast<int>(ws->getNumberHistograms());

QString plotSpec =uiForm().msd_lePlotSpectrum->text();
QString plotSpec = uiForm().msd_lePlotSpectrum->text();
QString specMin = uiForm().msd_leSpectraMin->text();
QString specMax = uiForm().msd_leSpectraMax->text();

int wsIndex = 0;
int minIndex = 0;
int maxIndex = nHist-1;
int maxIndex = nHist - 1;

if (currentWsName == wsname)
{
Expand Down Expand Up @@ -213,7 +213,7 @@ namespace IDA
uiForm().msd_leSpectraMax->setText(QString::number(maxIndex));
uiForm().msd_lePlotSpectrum->setText(QString::number(wsIndex));

m_intVal->setRange(0, nHist-1);
m_intVal->setRange(0, maxIndex);

//delete reference to fitting.
if (m_msdFitCurve != NULL)
Expand Down

0 comments on commit ebf6a5a

Please sign in to comment.