Skip to content

Commit

Permalink
Added verification to manual ERange adjustment
Browse files Browse the repository at this point in the history
Refs #7860
  • Loading branch information
DanNixon committed Oct 6, 2014
1 parent 5666d5a commit e7d99d3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Expand Up @@ -69,6 +69,7 @@ namespace CustomInterfaces
void plotRawInput(const QString &workspaceName);
void updateMiniPlots();
void replotNewSpectrum(QtProperty *prop, double value);
void verifyERange(QtProperty *prop, double value);
void updateRangeSelectors(QtProperty *prop, double value);
void preview();
void previewAlgDone(bool error);
Expand Down
38 changes: 38 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/IndirectSymmetrise.cpp
Expand Up @@ -132,6 +132,8 @@ namespace CustomInterfaces
// SIGNAL/SLOT CONNECTIONS
// Update range selctors when a property is changed
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRangeSelectors(QtProperty*, double)));
// Verify an energy range when it is updated
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(verifyERange(QtProperty*, double)));
// Plot a new spectrum when the user changes the value of the preview spectrum
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(replotNewSpectrum(QtProperty*, double)));
// Plot miniplot when file has finished loading
Expand Down Expand Up @@ -277,6 +279,42 @@ namespace CustomInterfaces
updateMiniPlots();
}

/**
* Verifies that the E Range is valid.
*
* Resets the last property changed to it's default if not.
*
* @param prop QtProperty changed
* @param value Value it was changed to (unused)
*/
void IndirectSymmetrise::verifyERange(QtProperty *prop, double value)
{
UNUSED_ARG(value);

double eMin = m_dblManager->value(m_properties["EMin"]);
double eMax = m_dblManager->value(m_properties["EMax"]);

// First check that the raw curve has been plotted
if(!m_curves["SymmRawPlot"])
return;

// Get the range of the plotted raw curve
auto axisRange = getCurveRange("SymmRawPlot");

if(prop == m_properties["EMin"])
{
// If range is invalid reset EMin to range/10
if(eMin > eMax)
m_dblManager->setValue(m_properties["EMin"], axisRange.second/10);
}
else if(prop == m_properties["EMax"])
{
// If range is invalid reset EMax to range
if(eMin > eMax)
m_dblManager->setValue(m_properties["EMax"], axisRange.second);
}
}

/**
* Handles a request to preview the symmetrise.
*
Expand Down

0 comments on commit e7d99d3

Please sign in to comment.