diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp index c4791d5ead09784a182a2df54d98d52f4d4ea83d..390a518b096e6525c3e19bbb98638f528f183f16 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp @@ -691,6 +691,16 @@ bool ReflectometryReductionOneAuto2::processGroups() { groupAlg->setProperty("OutputWorkspace", outputIvsQBinned); groupAlg->execute(); + // Set other properties so they can be updated in the Reflectometry interface + setPropertyValue("ThetaIn", alg->getPropertyValue("ThetaIn")); + setPropertyValue("MomentumTransferMin", + alg->getPropertyValue("MomentumTransferMin")); + setPropertyValue("MomentumTransferMax", + alg->getPropertyValue("MomentumTransferMax")); + setPropertyValue("MomentumTransferStep", + alg->getPropertyValue("MomentumTransferStep")); + setPropertyValue("ScaleFactor", alg->getPropertyValue("ScaleFactor")); + if (!polarizationAnalysisOn) { // No polarization analysis. Reduction stops here setPropertyValue("OutputWorkspace", outputIvsQ); @@ -743,6 +753,7 @@ bool ReflectometryReductionOneAuto2::processGroups() { setPropertyValue("OutputWorkspace", outputIvsQ); setPropertyValue("OutputWorkspaceBinned", outputIvsQBinned); setPropertyValue("OutputWorkspaceWavelength", outputIvsLam); + return true; } diff --git a/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h b/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h index f4d24729d31c59fbc442a746abc6a63d18654af2..59cc5e8488f9fc8695df4b9f88cfe7bfb94d7940 100644 --- a/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h +++ b/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h @@ -7,6 +7,7 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceGroup.h" #include "MantidGeometry/Instrument.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h" #include "MantidQtMantidWidgets/DataProcessorUI/GenericDataProcessorPresenter.h" @@ -118,6 +119,21 @@ private: AnalysisDataService::Instance().addOrReplace(wsName, tinyWS); } + void createMultiPeriodTOFWorkspace(const std::string &wsName, + const std::string &runNumber = "") { + + createTOFWorkspace(wsName + "_1", runNumber); + createTOFWorkspace(wsName + "_2", runNumber); + + WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>(); + group->addWorkspace( + AnalysisDataService::Instance().retrieve(wsName + "_1")); + group->addWorkspace( + AnalysisDataService::Instance().retrieve(wsName + "_2")); + + AnalysisDataService::Instance().addOrReplace(wsName, group); + } + ITableWorkspace_sptr createPrefilledWorkspace(const std::string &wsName, const DataProcessorWhiteList &whitelist) { @@ -1156,6 +1172,92 @@ public: TS_ASSERT(Mock::VerifyAndClearExpectations(&mockMainPresenter)); } + void testTreeUpdatedAfterProcessMultiPeriod() { + NiceMock<MockDataProcessorView> mockDataProcessorView; + NiceMock<MockProgressableView> mockProgress; + NiceMock<MockMainPresenter> mockMainPresenter; + GenericDataProcessorPresenter presenter( + createReflectometryWhiteList(), createReflectometryPreprocessMap(), + createReflectometryProcessor(), createReflectometryPostprocessor()); + presenter.acceptViews(&mockDataProcessorView, &mockProgress); + presenter.accept(&mockMainPresenter); + + auto ws = + createPrefilledWorkspace("TestWorkspace", presenter.getWhiteList()); + ws->String(0, ThetaCol) = ""; + ws->String(0, ScaleCol) = ""; + ws->String(1, ThetaCol) = ""; + ws->String(1, ScaleCol) = ""; + EXPECT_CALL(mockDataProcessorView, getWorkspaceToOpen()) + .Times(1) + .WillRepeatedly(Return("TestWorkspace")); + presenter.notify(DataProcessorPresenter::OpenTableFlag); + + std::set<int> grouplist; + grouplist.insert(0); + + createMultiPeriodTOFWorkspace("TOF_12345", "12345"); + createMultiPeriodTOFWorkspace("TOF_12346", "12346"); + + // We should not receive any errors + EXPECT_CALL(mockMainPresenter, giveUserCritical(_, _)).Times(0); + + // The user hits the "process" button with the first group selected + EXPECT_CALL(mockDataProcessorView, getSelectedChildren()) + .Times(1) + .WillRepeatedly(Return(std::map<int, std::set<int>>())); + EXPECT_CALL(mockDataProcessorView, getSelectedParents()) + .Times(1) + .WillRepeatedly(Return(grouplist)); + EXPECT_CALL(mockMainPresenter, getPreprocessingOptions()) + .Times(2) + .WillRepeatedly(Return(std::map<std::string, std::string>())); + EXPECT_CALL(mockMainPresenter, getProcessingOptions()) + .Times(2) + .WillRepeatedly(Return("")); + EXPECT_CALL(mockMainPresenter, getPostprocessingOptions()) + .Times(1) + .WillOnce(Return("Params = \"0.1\"")); + EXPECT_CALL(mockDataProcessorView, getEnableNotebook()) + .Times(1) + .WillRepeatedly(Return(false)); + EXPECT_CALL(mockDataProcessorView, requestNotebookPath()).Times(0); + + presenter.notify(DataProcessorPresenter::ProcessFlag); + presenter.notify(DataProcessorPresenter::SaveFlag); + + ws = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>( + "TestWorkspace"); + TS_ASSERT_EQUALS(ws->rowCount(), 4); + TS_ASSERT_EQUALS(ws->String(0, RunCol), "12345"); + TS_ASSERT_EQUALS(ws->String(0, ThetaCol), "22.5"); + TS_ASSERT_EQUALS(ws->String(0, ScaleCol), "1"); + TS_ASSERT_EQUALS(ws->String(1, RunCol), "12346"); + TS_ASSERT_EQUALS(ws->String(1, ThetaCol), "22.5"); + TS_ASSERT_EQUALS(ws->String(1, ScaleCol), "1"); + + // Check output workspaces were created as expected + // Check output workspaces were created as expected + TS_ASSERT( + AnalysisDataService::Instance().doesExist("IvsQ_binned_TOF_12345")); + TS_ASSERT(AnalysisDataService::Instance().doesExist("IvsQ_TOF_12345")); + TS_ASSERT(AnalysisDataService::Instance().doesExist("IvsLam_TOF_12345")); + TS_ASSERT(AnalysisDataService::Instance().doesExist("TOF_12345")); + TS_ASSERT( + AnalysisDataService::Instance().doesExist("IvsQ_binned_TOF_12346")); + TS_ASSERT(AnalysisDataService::Instance().doesExist("IvsQ_TOF_12346")); + TS_ASSERT(AnalysisDataService::Instance().doesExist("IvsLam_TOF_12346")); + TS_ASSERT(AnalysisDataService::Instance().doesExist("TOF_12346")); + TS_ASSERT( + AnalysisDataService::Instance().doesExist("IvsQ_TOF_12345_TOF_12346")); + + // Tidy up + AnalysisDataService::Instance().clear(); + + TS_ASSERT(Mock::VerifyAndClearExpectations(&mockDataProcessorView)); + TS_ASSERT(Mock::VerifyAndClearExpectations(&mockMainPresenter)); + } + void testProcessOnlyRowsSelected() { NiceMock<MockDataProcessorView> mockDataProcessorView; NiceMock<MockProgressableView> mockProgress;