Skip to content

Commit

Permalink
Swap range selectors in Fury(Fit)
Browse files Browse the repository at this point in the history
Refs #11365
  • Loading branch information
DanNixon committed Mar 17, 2015
1 parent b0acce8 commit d532944
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
18 changes: 11 additions & 7 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Fury.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ namespace IDA

m_furTree->setFactoryForManager(m_dblManager, m_dblEdFac);

m_rangeSelectors["FuryRange"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot);
auto xRangeSelector = m_uiForm.ppPlot->addRangeSelector("FuryRange");

// signals / slots & validators
connect(m_rangeSelectors["FuryRange"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rsRangeChangedLazy(double, double)));
connect(xRangeSelector, SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rsRangeChangedLazy(double, double)));
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRS(QtProperty*, double)));
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePropertyValues(QtProperty*, double)));
connect(m_uiForm.dsInput, SIGNAL(dataReady(const QString&)), this, SLOT(plotInput(const QString&)));
Expand Down Expand Up @@ -252,6 +252,8 @@ namespace IDA
m_uiForm.ppPlot->clear();
m_uiForm.ppPlot->addSpectrum("Sample", workspace, 0);

auto xRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryRange");

try
{
QPair<double, double> range = m_uiForm.ppPlot->getCurveRange("Sample");
Expand All @@ -260,7 +262,7 @@ namespace IDA
const std::string instrName(workspace->getInstrument()->getName());
if(instrName == "BASIS")
{
m_rangeSelectors["FuryRange"]->setRange(range.first, range.second);
xRangeSelector->setRange(range.first, range.second);
m_dblManager->setValue(m_properties["ELow"], rounded_min);
m_dblManager->setValue(m_properties["EHigh"], rounded_max);
m_dblManager->setValue(m_properties["EWidth"], 0.0004);
Expand All @@ -285,13 +287,13 @@ namespace IDA
//check incase we have a really small range
if (fabs(rounded_min) > 0 && fabs(rounded_max) > 0)
{
m_rangeSelectors["FuryRange"]->setRange(rounded_min, rounded_max);
xRangeSelector->setRange(rounded_min, rounded_max);
m_dblManager->setValue(m_properties["ELow"], rounded_min);
m_dblManager->setValue(m_properties["EHigh"], rounded_max);
}
else
{
m_rangeSelectors["FuryRange"]->setRange(range.first, range.second);
xRangeSelector->setRange(range.first, range.second);
m_dblManager->setValue(m_properties["ELow"], range.first);
m_dblManager->setValue(m_properties["EHigh"], range.second);
}
Expand Down Expand Up @@ -327,10 +329,12 @@ namespace IDA

void Fury::updateRS(QtProperty* prop, double val)
{
auto xRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryRange");

if(prop == m_properties["ELow"])
m_rangeSelectors["FuryRange"]->setMinimum(val);
xRangeSelector->setMinimum(val);
else if(prop == m_properties["EHigh"])
m_rangeSelectors["FuryRange"]->setMaximum(val);
xRangeSelector->setMaximum(val);
}

} // namespace IDA
Expand Down
29 changes: 16 additions & 13 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/FuryFit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ namespace IDA
m_ffTree = new QtTreePropertyBrowser(m_parentWidget);
m_uiForm.properties->addWidget(m_ffTree);

m_rangeSelectors["FuryFitRange"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot);
connect(m_rangeSelectors["FuryFitRange"], SIGNAL(minValueChanged(double)), this, SLOT(xMinSelected(double)));
connect(m_rangeSelectors["FuryFitRange"], SIGNAL(maxValueChanged(double)), this, SLOT(xMaxSelected(double)));
auto fitRangeSelector = m_uiForm.ppPlot->addRangeSelector("FuryFitRange");
connect(fitRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(xMinSelected(double)));
connect(fitRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(xMaxSelected(double)));

m_rangeSelectors["FuryFitBackground"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot,
MantidQt::MantidWidgets::RangeSelector::YSINGLE);
m_rangeSelectors["FuryFitBackground"]->setRange(0.0,1.0);
m_rangeSelectors["FuryFitBackground"]->setColour(Qt::darkGreen);
connect(m_rangeSelectors["FuryFitBackground"], SIGNAL(minValueChanged(double)), this, SLOT(backgroundSelected(double)));
auto backgroundRangeSelector = m_uiForm.ppPlot->addRangeSelector("FuryFitBackground",
MantidWidgets::RangeSelector::YSINGLE);
backgroundRangeSelector->setRange(0.0,1.0);
backgroundRangeSelector->setColour(Qt::darkGreen);
connect(backgroundRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(backgroundSelected(double)));

// setupTreePropertyBrowser
m_ffRangeManager = new QtDoublePropertyManager(m_parentWidget);
Expand Down Expand Up @@ -399,7 +399,7 @@ namespace IDA
{
const QPair<double, double> curveRange = m_uiForm.ppPlot->getCurveRange("Sample");
const std::pair<double, double> range(curveRange.first, curveRange.second);
m_rangeSelectors["FuryFitRange"]->setRange(range.first, range.second);
m_uiForm.ppPlot->getRangeSelector("FuryFitRange")->setRange(range.first, range.second);
m_ffRangeManager->setRange(m_properties["StartX"], range.first, range.second);
m_ffRangeManager->setRange(m_properties["EndX"], range.first, range.second);

Expand Down Expand Up @@ -489,17 +489,20 @@ namespace IDA

void FuryFit::propertyChanged(QtProperty* prop, double val)
{
auto fitRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryFitRange");
auto backgroundRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryFitBackground");

if ( prop == m_properties["StartX"] )
{
m_rangeSelectors["FuryFitRange"]->setMinimum(val);
fitRangeSelector->setMinimum(val);
}
else if ( prop == m_properties["EndX"] )
{
m_rangeSelectors["FuryFitRange"]->setMaximum(val);
fitRangeSelector->setMaximum(val);
}
else if ( prop == m_properties["BackgroundA0"])
{
m_rangeSelectors["FuryFitBackground"]->setMinimum(val);
backgroundRangeSelector->setMinimum(val);
m_dblManager->setValue(m_properties["Exponential1.Intensity"], 1.0-val);
m_dblManager->setValue(m_properties["Exponential2.Intensity"], 1.0-val);
m_dblManager->setValue(m_properties["StretchedExp.Intensity"], 1.0-val);
Expand All @@ -508,7 +511,7 @@ namespace IDA
|| prop == m_properties["Exponential2.Intensity"]
|| prop == m_properties["StretchedExp.Intensity"])
{
m_rangeSelectors["FuryFitBackground"]->setMinimum(1.0-val);
backgroundRangeSelector->setMinimum(1.0-val);
m_dblManager->setValue(m_properties["Exponential1.Intensity"], val);
m_dblManager->setValue(m_properties["Exponential2.Intensity"], val);
m_dblManager->setValue(m_properties["StretchedExp.Intensity"], val);
Expand Down

0 comments on commit d532944

Please sign in to comment.