From aec9b72d24b490c72399dc18eb9331075870f1fb Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Fri, 3 Oct 2014 14:08:23 +0100 Subject: [PATCH] Refs #10235 Replicate calculation quirks of refl_gui.py in new UI --- .../CustomInterfaces/src/ReflMainViewPresenter.cpp | 12 +++++++++--- .../test/ReflLoadedMainViewPresenterTest.h | 12 ++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp index ee50317fabc8..d87a24ed5efc 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp @@ -4,6 +4,7 @@ #include "MantidGeometry/Instrument/ParameterMap.h" #include "MantidKernel/Strings.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/Utils.h" #include "MantidQtCustomInterfaces/ReflMainView.h" #include @@ -171,7 +172,7 @@ namespace MantidQt throw std::runtime_error("Value for two theta could not be found in log."); //Update the model - m_model->String(rowNo, COL_ANGLE) = Strings::toString(thetaVal); + m_model->String(rowNo, COL_ANGLE) = Strings::toString(Utils::roundToDP(thetaVal, 3)); } //If we need to calculate the resolution, do. @@ -346,8 +347,8 @@ namespace MantidQt try { const Instrument_const_sptr instrument = ws->getInstrument(); - lmin = instrument->getNumberParameter("LambdaMin")[0]; - lmax = instrument->getNumberParameter("LambdaMax")[0]; + lmin = instrument->getNumberParameter("LambdaMin")[0] + 1; + lmax = instrument->getNumberParameter("LambdaMax")[0] - 2; } catch(std::exception&) { @@ -356,6 +357,11 @@ namespace MantidQt double qmin = 4 * M_PI / lmax * sin(theta * M_PI / 180.0); double qmax = 4 * M_PI / lmin * sin(theta * M_PI / 180.0); + qmin = Utils::roundToDP(qmin, 3); + qmax = Utils::roundToDP(qmax, 3); + + //The old refl_gui performs this additional calculation on the last workspace of a stitch group + //qmax = 4 * M_PI / ((4 * M_PI / qmax * sin(theta * M_PI / 180)) - 0.5) * sin(theta * M_PI / 180); std::vector ret; ret.push_back(qmin); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/test/ReflLoadedMainViewPresenterTest.h b/Code/Mantid/MantidQt/CustomInterfaces/test/ReflLoadedMainViewPresenterTest.h index 1ca2004186bf..f0a7786dc5c6 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/test/ReflLoadedMainViewPresenterTest.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/test/ReflLoadedMainViewPresenterTest.h @@ -577,15 +577,15 @@ class ReflLoadedMainViewPresenterTest : public CxxTest::TestSuite //Check the table was updated as expected ws = AnalysisDataService::Instance().retrieveWS("TestWorkspace"); - TS_ASSERT_EQUALS(ws->String(0, ThetaCol), "0.70002"); - TS_ASSERT_EQUALS(ws->String(0, DQQCol), "0.0340292"); - TS_ASSERT_EQUALS(ws->String(0, QMinCol), "0.00903104"); - TS_ASSERT_EQUALS(ws->String(0, QMaxCol), "0.153528"); + TS_ASSERT_EQUALS(ws->String(0, ThetaCol), "0.7"); + TS_ASSERT_EQUALS(ws->String(0, DQQCol), "0.0340301"); + TS_ASSERT_EQUALS(ws->String(0, QMinCol), "0.01"); + TS_ASSERT_EQUALS(ws->String(0, QMaxCol), "0.077"); TS_ASSERT_EQUALS(ws->String(1, ThetaCol), "2.3"); TS_ASSERT_EQUALS(ws->String(1, DQQCol), "0.0340505"); - TS_ASSERT_EQUALS(ws->String(1, QMinCol), "0.0296654"); - TS_ASSERT_EQUALS(ws->String(1, QMaxCol), "0.504311"); + TS_ASSERT_EQUALS(ws->String(1, QMinCol), "0.034"); + TS_ASSERT_EQUALS(ws->String(1, QMaxCol), "0.252"); //Tidy up AnalysisDataService::Instance().remove("TestWorkspace");