diff --git a/Framework/DataHandling/CMakeLists.txt b/Framework/DataHandling/CMakeLists.txt index e44c7a3019924a2903ca3d1a87ab28797734c948..1b217e689d5b25f45fae123c59ca98565a0896b2 100644 --- a/Framework/DataHandling/CMakeLists.txt +++ b/Framework/DataHandling/CMakeLists.txt @@ -58,7 +58,7 @@ set ( SRC_FILES src/LoadLLB.cpp src/LoadLog.cpp src/LoadLogsForSNSPulsedMagnet.cpp - src/LoadMLZ.cpp + src/LoadMLZ.cpp src/LoadMappingTable.cpp src/LoadMask.cpp src/LoadMcStas.cpp @@ -112,6 +112,7 @@ set ( SRC_FILES src/RemoveLogs.cpp src/RenameLog.cpp src/RotateInstrumentComponent.cpp + src/RotateSource.cpp src/SNSDataArchive.cpp src/SaveANSTOAscii.cpp src/SaveAscii.cpp @@ -217,7 +218,7 @@ set ( INC_FILES inc/MantidDataHandling/LoadLLB.h inc/MantidDataHandling/LoadLog.h inc/MantidDataHandling/LoadLogsForSNSPulsedMagnet.h - inc/MantidDataHandling/LoadMLZ.h + inc/MantidDataHandling/LoadMLZ.h inc/MantidDataHandling/LoadMappingTable.h inc/MantidDataHandling/LoadMask.h inc/MantidDataHandling/LoadMcStas.h @@ -266,6 +267,7 @@ set ( INC_FILES inc/MantidDataHandling/RemoveLogs.h inc/MantidDataHandling/RenameLog.h inc/MantidDataHandling/RotateInstrumentComponent.h + inc/MantidDataHandling/RotateSource.h inc/MantidDataHandling/SNSDataArchive.h inc/MantidDataHandling/SaveANSTOAscii.h inc/MantidDataHandling/SaveAscii.h @@ -369,7 +371,7 @@ set ( TEST_FILES LoadIsawDetCalTest.h LoadLLBTest.h LoadLogTest.h - LoadMLZTest.h + LoadMLZTest.h LoadMappingTableTest.h LoadMaskTest.h LoadMcStasNexusTest.h @@ -417,6 +419,7 @@ set ( TEST_FILES RemoveLogsTest.h RenameLogTest.h RotateInstrumentComponentTest.h + RotateSourceTest.h SNSDataArchiveTest.h SaveANSTOAsciiTest.h SaveAscii2Test.h diff --git a/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h b/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h new file mode 100644 index 0000000000000000000000000000000000000000..cb76d56b3c291747cc9ce01c66308611744955ab --- /dev/null +++ b/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h @@ -0,0 +1,54 @@ +#ifndef MANTID_DATAHANDLING_ROTATESOURCE_H_ +#define MANTID_DATAHANDLING_ROTATESOURCE_H_ + +#include "MantidDataHandling/DllConfig.h" +#include "MantidAPI/Algorithm.h" +namespace Mantid { +namespace DataHandling { + +/** RotateSource : TODO: DESCRIPTION + + Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://github.com/mantidproject/mantid> + Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class MANTID_DATAHANDLING_DLL RotateSource : public API::Algorithm { +public: + RotateSource() {}; + virtual ~RotateSource() {}; + + virtual const std::string name() const { return "RotateSource"; }; + virtual int version() const { return 1; }; + virtual const std::string category() const { + return "DataHandling\\Instrument"; + }; + virtual const std::string summary() const { + return "Rotates the source around the specified axis by a given angle"; + }; + +private: + void init(); + void exec(); +}; + +} // namespace DataHandling +} // namespace Mantid + +#endif /* MANTID_DATAHANDLING_ROTATESOURCE_H_ */ \ No newline at end of file diff --git a/Framework/DataHandling/src/RotateSource.cpp b/Framework/DataHandling/src/RotateSource.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5ce2c74e361f6093f2899eee764d9a033952c504 --- /dev/null +++ b/Framework/DataHandling/src/RotateSource.cpp @@ -0,0 +1,38 @@ +#include "MantidDataHandling/RotateSource.h" + +namespace Mantid { +namespace DataHandling { + +using Mantid::Kernel::Direction; +using Mantid::API::WorkspaceProperty; + +// Register the algorithm into the AlgorithmFactory +DECLARE_ALGORITHM(RotateSource) + + +//---------------------------------------------------------------------------------------------- +/** Initialize the algorithm's properties. + */ +void RotateSource::init() { + // When used as a Child Algorithm the workspace name is not used - hence the + // "Anonymous" to satisfy the validator + declareProperty(new WorkspaceProperty<Workspace>("Workspace", "Anonymous", + Direction::InOut), + "The name of the workspace for which the new instrument " + "configuration will have an effect. Any other workspaces " + "stored in the analysis data service will be unaffected."); + declareProperty("X", 0.0, "The x-part of the rotation axis."); + declareProperty("Y", 0.0, "The y-part of the rotation axis."); + declareProperty("Z", 0.0, "The z-part of the rotation axis."); + declareProperty("Angle", 0.0, "The angle of rotation in degrees."); +} + +//---------------------------------------------------------------------------------------------- +/** Execute the algorithm. + */ +void RotateSource::exec() { + // TODO Auto-generated execute stub +} + +} // namespace DataHandling +} // namespace Mantid diff --git a/Framework/DataHandling/test/RotateSourceTest.h b/Framework/DataHandling/test/RotateSourceTest.h new file mode 100644 index 0000000000000000000000000000000000000000..18ea7095b762ad044de2eee666fa08cd56a8f7a6 --- /dev/null +++ b/Framework/DataHandling/test/RotateSourceTest.h @@ -0,0 +1,57 @@ +#ifndef MANTID_DATAHANDLING_ROTATESOURCETEST_H_ +#define MANTID_DATAHANDLING_ROTATESOURCETEST_H_ + +#include <cxxtest/TestSuite.h> + +#include "MantidDataHandling/RotateSource.h" + +using Mantid::DataHandling::RotateSource; + +class RotateSourceTest : public CxxTest::TestSuite { +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static RotateSourceTest *createSuite() { return new RotateSourceTest(); } + static void destroySuite( RotateSourceTest *suite ) { delete suite; } + + + void test_Init() + { + RotateSource alg; + TS_ASSERT_THROWS_NOTHING( alg.initialize() ) + TS_ASSERT( alg.isInitialized() ) + } + + void test_exec() + { + // Create test input if necessary + MatrixWorkspace_sptr inputWS = //-- Fill in appropriate code. Consider using TestHelpers/WorkspaceCreationHelpers.h -- + + RotateSource alg; + // Don't put output in ADS by default + alg.setChild(true); + TS_ASSERT_THROWS_NOTHING( alg.initialize() ) + TS_ASSERT( alg.isInitialized() ) + TS_ASSERT_THROWS_NOTHING( alg.setProperty("InputWorkspace", inputWS) ); + TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", "_unused_for_child") ); + TS_ASSERT_THROWS_NOTHING( alg.execute(); ); + TS_ASSERT( alg.isExecuted() ); + + // Retrieve the workspace from the algorithm. The type here will probably need to change. It should + // be the type using in declareProperty for the "OutputWorkspace" type. + // We can't use auto as it's an implicit conversion. + Workspace_sptr outputWS = alg.getProperty("OutputWorkspace"); + TS_ASSERT(outputWS); + TS_FAIL("TODO: Check the results and remove this line"); + } + + void test_Something() + { + TS_FAIL( "You forgot to write a test!"); + } + + +}; + + +#endif /* MANTID_DATAHANDLING_ROTATESOURCETEST_H_ */ \ No newline at end of file diff --git a/docs/source/algorithms/RotateSource-v1.rst b/docs/source/algorithms/RotateSource-v1.rst new file mode 100644 index 0000000000000000000000000000000000000000..c5db00c2fc2bb4bdc2a3566287b6860c04cbb06c --- /dev/null +++ b/docs/source/algorithms/RotateSource-v1.rst @@ -0,0 +1,46 @@ + +.. algorithm:: + +.. summary:: + +.. alias:: + +.. properties:: + +Description +----------- + +TODO: Enter a full rst-markup description of your algorithm here. + + +Usage +----- +.. Try not to use files in your examples, + but if you cannot avoid it then the (small) files must be added to + autotestdata\UsageData and the following tag unindented + .. include:: ../usagedata-note.txt + +**Example - RotateSource** + +.. testcode:: RotateSourceExample + + # Create a host workspace + ws = CreateWorkspace(DataX=range(0,3), DataY=(0,2)) + or + ws = CreateSampleWorkspace() + + wsOut = RotateSource() + + # Print the result + print "The output workspace has %i spectra" % wsOut.getNumberHistograms() + +Output: + +.. testoutput:: RotateSourceExample + + The output workspace has ?? spectra + +.. categories:: + +.. sourcelink:: +