diff --git a/Code/Mantid/Framework/API/src/Run.cpp b/Code/Mantid/Framework/API/src/Run.cpp index 95feaf8fb162364163157b68f9d4f9e18b3eed02..dc79fa5731934740b248a6664b3dd56df76ea7e7 100644 --- a/Code/Mantid/Framework/API/src/Run.cpp +++ b/Code/Mantid/Framework/API/src/Run.cpp @@ -350,6 +350,9 @@ Kernel::Logger& Run::g_log = Kernel::Logger::get("Run"); file->makeGroup(group, "NXgroup", 1); file->putAttr("version", 1); + // Now the goniometer + m_goniometer.saveNexus(file, "goniometer"); + // Save all the properties as NXlog std::vector<Property *> props = m_manager.getProperties(); for (size_t i=0; i<props.size(); i++) @@ -386,6 +389,11 @@ Kernel::Logger& Run::g_log = Kernel::Logger::get("Run"); m_manager.declareProperty(prop); } } + else if (name_class.second == "NXpositioner") + { + // Goniometer class + m_goniometer.loadNexus(file, name_class.first); + } // Go to next one name_class = file->getNextEntry(); } diff --git a/Code/Mantid/Framework/API/test/PropertyNexusTest.h b/Code/Mantid/Framework/API/test/PropertyNexusTest.h index 76d72004598818ce4c05c66f9c1c81e614f81e7a..2bd6af3feda8c3fa5ebb65bdd719a7292369c88d 100644 --- a/Code/Mantid/Framework/API/test/PropertyNexusTest.h +++ b/Code/Mantid/Framework/API/test/PropertyNexusTest.h @@ -7,7 +7,7 @@ #include <cxxtest/TestSuite.h> #include <iomanip> #include <iostream> -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/DateAndTime.h" @@ -15,7 +15,7 @@ using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; -using Mantid::NexusCPP::NexusTestHelper; +using Mantid::Kernel::NexusTestHelper; class PropertyNexusTest : public CxxTest::TestSuite { diff --git a/Code/Mantid/Framework/API/test/RunTest.h b/Code/Mantid/Framework/API/test/RunTest.h index fb2383937cef185dd93eb9d35deda4d09682cda5..4636063581d9c566194e54a8c93d57e5adb11038 100644 --- a/Code/Mantid/Framework/API/test/RunTest.h +++ b/Code/Mantid/Framework/API/test/RunTest.h @@ -8,13 +8,13 @@ #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/V3D.h" #include <cxxtest/TestSuite.h> -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid; -using Mantid::NexusCPP::NexusTestHelper; +using Mantid::Kernel::NexusTestHelper; // Helper class namespace @@ -171,10 +171,14 @@ public: th.createFile("RunTest.nxs"); Run run1; + run1.getGoniometer().makeUniversalGoniometer(); AddTSPEntry(run1, "double_series", 45.0); run1.addProperty( new PropertyWithValue<int>("int_val", 1234) ); run1.addProperty( new PropertyWithValue<std::string>("string_val", "help_im_stuck_in_a_log_file") ); run1.addProperty( new PropertyWithValue<double>("double_val", 5678.9) ); + AddTSPEntry(run1, "phi", 12.3); + AddTSPEntry(run1, "chi", 45.6); + AddTSPEntry(run1, "omega", 78.9); run1.saveNexus(th.file, "logs"); th.file->openGroup("logs", "NXgroup"); @@ -189,6 +193,8 @@ public: TS_ASSERT( run2.hasProperty("int_val") ); TS_ASSERT( run2.hasProperty("string_val") ); TS_ASSERT( run2.hasProperty("double_val") ); + // This test both uses the goniometer axes AND looks up some values. + TS_ASSERT_EQUALS( run2.getGoniometerMatrix(), run1.getGoniometerMatrix() ); // Reload without opening the group (for backwards-compatible reading of old files) Run run3; diff --git a/Code/Mantid/Framework/API/test/SampleTest.h b/Code/Mantid/Framework/API/test/SampleTest.h index f594cf8d8faadc42103fb746d6ea56a8817bb8d7..8d513c8e5b2f126dbb2a5e0ca61b54db79252174 100644 --- a/Code/Mantid/Framework/API/test/SampleTest.h +++ b/Code/Mantid/Framework/API/test/SampleTest.h @@ -9,14 +9,14 @@ #include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidKernel/Exception.h" #include <cxxtest/TestSuite.h> -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::Geometry; using Mantid::API::Sample; using Mantid::API::SampleEnvironment; -using Mantid::NexusCPP::NexusTestHelper; +using Mantid::Kernel::NexusTestHelper; class SampleTest : public CxxTest::TestSuite { diff --git a/Code/Mantid/Framework/CMakeLists.txt b/Code/Mantid/Framework/CMakeLists.txt index a912e6c50c280ec1c3c6fa3944a387276bd3073c..7082afa70d06b3c18d8e9f33bfe3dfd6e3850408 100644 --- a/Code/Mantid/Framework/CMakeLists.txt +++ b/Code/Mantid/Framework/CMakeLists.txt @@ -91,13 +91,12 @@ add_custom_target ( FrameworkTests ) # target for all framework tests add_dependencies ( check FrameworkTests ) include_directories (NexusCPP/inc) +add_subdirectory (NexusCPP) include_directories (Kernel/inc) add_subdirectory (Kernel) set ( MANTIDLIBS ${MANTIDLIBS} Kernel ) -add_subdirectory (NexusCPP) - include_directories (Geometry/inc) # muParser needed by Geometry and subsequent packages include_directories ( ${MUPARSER_INCLUDE_DIR} ) diff --git a/Code/Mantid/Framework/Geometry/CMakeLists.txt b/Code/Mantid/Framework/Geometry/CMakeLists.txt index 38feacbd02344a92789d71d17a82797a85c2f8e9..93d34d2a900b93448e64019d31f23c7be2626303 100644 --- a/Code/Mantid/Framework/Geometry/CMakeLists.txt +++ b/Code/Mantid/Framework/Geometry/CMakeLists.txt @@ -307,10 +307,10 @@ if ( CXXTEST_FOUND ) if ( GMOCK_FOUND AND GTEST_FOUND ) cxxtest_add_test ( GeometryTest ${TEST_FILES} ${GMOCK_TEST_FILES}) - target_link_libraries( GeometryTest Geometry ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} ) + target_link_libraries( GeometryTest Geometry ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} NexusCPP Kernel) else () cxxtest_add_test ( GeometryTest ${TEST_FILES} ) - target_link_libraries( GeometryTest Geometry ) + target_link_libraries( GeometryTest Geometry NexusCPP Kernel) endif() add_dependencies ( FrameworkTests GeometryTest ) diff --git a/Code/Mantid/Framework/Geometry/src/Instrument/Goniometer.cpp b/Code/Mantid/Framework/Geometry/src/Instrument/Goniometer.cpp index 63a84118a9110c446007d3cf81cc0607fadcda9e..bb73778bc1b898e4e8e5e0a41397daf061b4ac7a 100644 --- a/Code/Mantid/Framework/Geometry/src/Instrument/Goniometer.cpp +++ b/Code/Mantid/Framework/Geometry/src/Instrument/Goniometer.cpp @@ -149,6 +149,8 @@ void Goniometer::setRotationAngle( std::string name, double value) */ void Goniometer::setRotationAngle( size_t axisnumber, double value) { + if (axisnumber >= motors.size()) + throw std::out_of_range("Goniometer::setRotationAngle(): axis number specified is too large."); (motors.at(axisnumber)).angle=value;//it will throw out of range exception if axisnumber is not in range recalculateR(); } @@ -157,6 +159,8 @@ void Goniometer::setRotationAngle( size_t axisnumber, double value) /// @param axisnumber :: axis number (from 0) GoniometerAxis Goniometer::getAxis( size_t axisnumber) { + if (axisnumber >= motors.size()) + throw std::out_of_range("Goniometer::getAxis(): axis number specified is too large."); return motors.at(axisnumber);//it will throw out of range exception if axisnumber is not in range } /// Get GoniometerAxis obfject using motor number diff --git a/Code/Mantid/Framework/Geometry/test/GoniometerTest.h b/Code/Mantid/Framework/Geometry/test/GoniometerTest.h index 0fe8598b86de99dec57e6da002bb0fc24949e9a2..f299b128a73db2a27865b179e49a15c948769ed2 100644 --- a/Code/Mantid/Framework/Geometry/test/GoniometerTest.h +++ b/Code/Mantid/Framework/Geometry/test/GoniometerTest.h @@ -7,12 +7,12 @@ #include <stdexcept> #include <string> #include "MantidKernel/Quat.h" -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" using namespace Mantid::Geometry; using Mantid::Kernel::V3D; using Mantid::Kernel::Quat; using Mantid::Kernel::DblMatrix; -using Mantid::NexusCPP::NexusTestHelper; +using Mantid::Kernel::NexusTestHelper; class GoniometerTest : public CxxTest::TestSuite { diff --git a/Code/Mantid/Framework/Geometry/test/MaterialTest.h b/Code/Mantid/Framework/Geometry/test/MaterialTest.h index 37a0ea8d4a17ac8ccd0b41882be020c5f45ba0c2..f7d2c404dd214086a0aecaae6933cf4737185c1f 100644 --- a/Code/Mantid/Framework/Geometry/test/MaterialTest.h +++ b/Code/Mantid/Framework/Geometry/test/MaterialTest.h @@ -6,10 +6,10 @@ #include "MantidGeometry/Objects/Material.h" #include "MantidKernel/NeutronAtom.h" -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" using Mantid::Geometry::Material; -using Mantid::NexusCPP::NexusTestHelper; +using Mantid::Kernel::NexusTestHelper; class MaterialTest: public CxxTest::TestSuite { diff --git a/Code/Mantid/Framework/Geometry/test/OrientedLatticeTest.h b/Code/Mantid/Framework/Geometry/test/OrientedLatticeTest.h index 6b535e90331f9539b0d5ff5e446fa8f274c6e3a0..27cae2fb5fc5b182fd52d77357fa31c0f8d1afce 100644 --- a/Code/Mantid/Framework/Geometry/test/OrientedLatticeTest.h +++ b/Code/Mantid/Framework/Geometry/test/OrientedLatticeTest.h @@ -6,13 +6,13 @@ #include <iomanip> #include <MantidKernel/Matrix.h> #include <MantidGeometry/Crystal/OrientedLattice.h> -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" using namespace Mantid::Geometry; using Mantid::Kernel::V3D; using Mantid::Kernel::DblMatrix; using Mantid::Kernel::Matrix; -using Mantid::NexusCPP::NexusTestHelper; +using Mantid::Kernel::NexusTestHelper; class OrientedLatticeTest : public CxxTest::TestSuite { diff --git a/Code/Mantid/Framework/Kernel/CMakeLists.txt b/Code/Mantid/Framework/Kernel/CMakeLists.txt index ca89a29b9f189da5712c4f575677d48378ffa9ec..54e0438de86bcb5fc9fa774fbd1d378d3fda9a93 100644 --- a/Code/Mantid/Framework/Kernel/CMakeLists.txt +++ b/Code/Mantid/Framework/Kernel/CMakeLists.txt @@ -40,6 +40,7 @@ set ( SRC_FILES src/MatrixProperty.cpp src/Memory.cpp src/MersenneTwister.cpp + src/NexusTestHelper.cpp src/NeutronAtom.cpp src/ProgressBase.cpp src/ProgressText.cpp @@ -142,6 +143,7 @@ set ( INC_FILES inc/MantidKernel/MersenneTwister.h inc/MantidKernel/MultiThreaded.h inc/MantidKernel/NeutronAtom.h + inc/MantidKernel/NexusTestHelper.h inc/MantidKernel/NullValidator.h inc/MantidKernel/PhysicalConstants.h inc/MantidKernel/ProgressBase.h @@ -277,7 +279,7 @@ target_link_libraries ( Kernel ${MANTIDLIBS} ) if ( CXXTEST_FOUND ) cxxtest_add_test ( KernelTest ${TEST_FILES} ) include_directories ( inc test ) - target_link_libraries( KernelTest Kernel) + target_link_libraries( KernelTest Kernel NexusCPP ) add_dependencies ( FrameworkTests KernelTest ) # Add to the 'FrameworkTests' group in VS set_property ( TARGET KernelTest PROPERTY FOLDER "UnitTests" ) diff --git a/Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NexusTestHelper.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/NexusTestHelper.h similarity index 97% rename from Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NexusTestHelper.h rename to Code/Mantid/Framework/Kernel/inc/MantidKernel/NexusTestHelper.h index 8c1a5134287c181b102dea91c3f03042c2e5f47a..145c7c02d4ffc2656e5f49608a6bb5cb733558c6 100644 --- a/Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NexusTestHelper.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/NexusTestHelper.h @@ -7,7 +7,7 @@ namespace Mantid { -namespace NexusCPP +namespace Kernel { /** A Helper class for easily writing nexus saving/loading tests. @@ -55,7 +55,7 @@ namespace NexusCPP }; -} // namespace NexusCPP +} // namespace Kernel } // namespace Mantid #endif /* MANTID_NEXUSCPP_NEXUSTESTHELPER_H_ */ diff --git a/Code/Mantid/Framework/NexusCPP/src/NexusTestHelper.cpp b/Code/Mantid/Framework/Kernel/src/NexusTestHelper.cpp similarity index 95% rename from Code/Mantid/Framework/NexusCPP/src/NexusTestHelper.cpp rename to Code/Mantid/Framework/Kernel/src/NexusTestHelper.cpp index c9d8f0848ef5686b789a716c8c29b69f07cc3291..6fb3a49f2e4baf00a8ccb067beeb96cbe68cc9a5 100644 --- a/Code/Mantid/Framework/NexusCPP/src/NexusTestHelper.cpp +++ b/Code/Mantid/Framework/Kernel/src/NexusTestHelper.cpp @@ -1,11 +1,11 @@ #include "MantidKernel/ConfigService.h" #include "MantidKernel/System.h" -#include "MantidNexusCPP/NexusTestHelper.h" +#include "MantidKernel/NexusTestHelper.h" #include <Poco/File.h> namespace Mantid { -namespace NexusCPP +namespace Kernel { @@ -64,5 +64,5 @@ namespace NexusCPP } // namespace Mantid -} // namespace NexusCPP +} // namespace Kernel diff --git a/Code/Mantid/Framework/Nexus/CMakeLists.txt b/Code/Mantid/Framework/Nexus/CMakeLists.txt index 586b106dc110da63a1734d9d345ded7b9dfdeada..8e727c6f55540af80a8ec85d6b8fa76766b427b8 100644 --- a/Code/Mantid/Framework/Nexus/CMakeLists.txt +++ b/Code/Mantid/Framework/Nexus/CMakeLists.txt @@ -12,6 +12,7 @@ set ( INC_FILES ) set ( TEST_FILES + test/NexusAPITest.h ) # Add the dependency on the nexus library diff --git a/Code/Mantid/Framework/NexusCPP/test/NexusAPITest.h b/Code/Mantid/Framework/Nexus/test/NexusAPITest.h similarity index 100% rename from Code/Mantid/Framework/NexusCPP/test/NexusAPITest.h rename to Code/Mantid/Framework/Nexus/test/NexusAPITest.h diff --git a/Code/Mantid/Framework/NexusCPP/CMakeLists.txt b/Code/Mantid/Framework/NexusCPP/CMakeLists.txt index 6bda97fc0b39f78caea5d0d73861b005ef4736eb..bfaaab4a892dfc452e662549f62bb13d0c82d7b3 100644 --- a/Code/Mantid/Framework/NexusCPP/CMakeLists.txt +++ b/Code/Mantid/Framework/NexusCPP/CMakeLists.txt @@ -2,18 +2,15 @@ set ( SRC_FILES src/NeXusException.cpp src/NeXusFile.cpp src/NeXusStream.cpp - src/NexusTestHelper.cpp ) set ( INC_FILES inc/MantidNexusCPP/NeXusException.hpp inc/MantidNexusCPP/NeXusFile.hpp inc/MantidNexusCPP/NeXusStream.hpp - inc/MantidNexusCPP/NexusTestHelper.h ) set ( TEST_FILES - test/NexusAPITest.h ) # Add the dependency on the nexus library @@ -32,15 +29,8 @@ set_property ( TARGET NexusCPP PROPERTY FOLDER "MantidFramework" ) include_directories ( inc ) -target_link_libraries ( NexusCPP ${NEXUS_LIBRARIES} ${POCO_LIBRARIES} Kernel ) +target_link_libraries ( NexusCPP ${NEXUS_LIBRARIES} ${POCO_LIBRARIES} ) -if ( CXXTEST_FOUND ) - cxxtest_add_test ( NexusCPPTest ${TEST_FILES} ) - target_link_libraries( NexusCPPTest NexusCPP ) - add_dependencies ( FrameworkTests NexusCPPTest ) - # Add to the 'FrameworkTests' group in VS - set_property ( TARGET NexusCPPTest PROPERTY FOLDER "UnitTests" ) -endif () ########################################################################### # Installation settings diff --git a/Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NeXusFile.hpp b/Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NeXusFile.hpp index 5fbe88bed674d45ae42df9674f9dbcb29a1cb3ea..57e753b22c9224f7e5ffbe051e7a2eba1c99baae 100644 --- a/Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NeXusFile.hpp +++ b/Code/Mantid/Framework/NexusCPP/inc/MantidNexusCPP/NeXusFile.hpp @@ -7,8 +7,6 @@ #include <vector> #include <napi.h> -#include "MantidKernel/System.h" - #ifdef _WIN32 #ifndef _MSC_VER diff --git a/Code/Mantid/Framework/NexusCPP/src/NeXusFile.cpp b/Code/Mantid/Framework/NexusCPP/src/NeXusFile.cpp index 2e4e302c6aef49ca6bdf9a795899d7fe65522652..0d50f3b778381cb66a12b879437200da05126682 100644 --- a/Code/Mantid/Framework/NexusCPP/src/NeXusFile.cpp +++ b/Code/Mantid/Framework/NexusCPP/src/NeXusFile.cpp @@ -3,7 +3,7 @@ #include <iostream> #include <sstream> //#include "napiconfig.h" -#include "MantidKernel/System.h" +#include "../../Kernel/inc/MantidKernel/System.h" #include "MantidNexusCPP/NeXusFile.hpp" #include "MantidNexusCPP/NeXusException.hpp"