Skip to content

Commit

Permalink
Refs #4858 Add validation to interface options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Feb 10, 2014
1 parent 108e45a commit daae0dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -30,6 +30,7 @@ namespace IDA
void updateRS(QtProperty* prop, double val);

private:
QIntValidator * m_intVal;
QwtPlot* m_msdPlot;
MantidWidgets::RangeSelector* m_msdRange;
QwtPlotCurve* m_msdDataCurve;
Expand Down
16 changes: 15 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/MSDFit.cpp
Expand Up @@ -22,7 +22,7 @@ namespace IDA
// Tree Browser
m_msdTree = new QtTreePropertyBrowser();
uiForm().msd_properties->addWidget(m_msdTree);

m_intVal = new QIntValidator(this);
m_msdDblMng = new QtDoublePropertyManager();

m_msdTree->setFactoryForManager(m_msdDblMng, doubleEditorFactory());
Expand Down Expand Up @@ -51,6 +51,9 @@ namespace IDA

connect(uiForm().msd_pbPlotInput, SIGNAL(clicked()), this, SLOT(plotInput()));
connect(uiForm().msd_inputFile, SIGNAL(filesFound()), this, SLOT(plotInput()));

uiForm().msd_leSpectraMin->setValidator(m_intVal);
uiForm().msd_leSpectraMax->setValidator(m_intVal);
}

void MSDFit::run()
Expand Down Expand Up @@ -85,6 +88,11 @@ namespace IDA
auto range = std::make_pair(m_msdDblMng->value(m_msdProp["Start"]), m_msdDblMng->value(m_msdProp["End"]));
uiv.checkValidRange("a range", range);

QString specMin = uiForm().msd_leSpectraMin->text();
QString specMax = uiForm().msd_leSpectraMax->text();
auto specRange = std::make_pair(specMin.toDouble(), specMax.toDouble());
uiv.checkValidRange("spectrum range", specRange);

return uiv.generateErrorMessage();
}

Expand All @@ -111,6 +119,12 @@ namespace IDA
{
const std::pair<double, double> range = getCurveRange(m_msdDataCurve);
m_msdRange->setRange(range.first, range.second);

int nHist = static_cast<int>(ws->getNumberHistograms());
uiForm().msd_leSpectraMin->setText("0");
uiForm().msd_leSpectraMax->setText(QString::number(nHist-1));
m_intVal->setRange(0, nHist-1);

// Replot
m_msdPlot->replot();
}
Expand Down

0 comments on commit daae0dd

Please sign in to comment.