From ce321307b8b43b2ee3ab2f44d39f824fc9bca63c Mon Sep 17 00:00:00 2001
From: Janik Zikovsky <zikovskyjl@ornl.gov>
Date: Fri, 9 Sep 2011 19:53:47 +0000
Subject: [PATCH] Refs #3689: Build fix

---
 Code/Mantid/Framework/API/src/Run.cpp                |  8 ++++++++
 Code/Mantid/Framework/API/test/PropertyNexusTest.h   |  4 ++--
 Code/Mantid/Framework/API/test/RunTest.h             | 10 ++++++++--
 Code/Mantid/Framework/API/test/SampleTest.h          |  4 ++--
 Code/Mantid/Framework/CMakeLists.txt                 |  3 +--
 Code/Mantid/Framework/Geometry/CMakeLists.txt        |  4 ++--
 .../Framework/Geometry/src/Instrument/Goniometer.cpp |  4 ++++
 Code/Mantid/Framework/Geometry/test/GoniometerTest.h |  4 ++--
 Code/Mantid/Framework/Geometry/test/MaterialTest.h   |  4 ++--
 .../Framework/Geometry/test/OrientedLatticeTest.h    |  4 ++--
 Code/Mantid/Framework/Kernel/CMakeLists.txt          |  4 +++-
 .../inc/MantidKernel}/NexusTestHelper.h              |  4 ++--
 .../{NexusCPP => Kernel}/src/NexusTestHelper.cpp     |  6 +++---
 Code/Mantid/Framework/Nexus/CMakeLists.txt           |  1 +
 .../{NexusCPP => Nexus}/test/NexusAPITest.h          |  0
 Code/Mantid/Framework/NexusCPP/CMakeLists.txt        | 12 +-----------
 .../NexusCPP/inc/MantidNexusCPP/NeXusFile.hpp        |  2 --
 Code/Mantid/Framework/NexusCPP/src/NeXusFile.cpp     |  2 +-
 18 files changed, 44 insertions(+), 36 deletions(-)
 rename Code/Mantid/Framework/{NexusCPP/inc/MantidNexusCPP => Kernel/inc/MantidKernel}/NexusTestHelper.h (97%)
 rename Code/Mantid/Framework/{NexusCPP => Kernel}/src/NexusTestHelper.cpp (95%)
 rename Code/Mantid/Framework/{NexusCPP => Nexus}/test/NexusAPITest.h (100%)

diff --git a/Code/Mantid/Framework/API/src/Run.cpp b/Code/Mantid/Framework/API/src/Run.cpp
index 95feaf8fb16..dc79fa57319 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 76d72004598..2bd6af3feda 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 fb2383937ce..4636063581d 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 f594cf8d8fa..8d513c8e5b2 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 a912e6c50c2..7082afa70d0 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 38feacbd023..93d34d2a900 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 63a84118a91..bb73778bc1b 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 0fe8598b86d..f299b128a73 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 37a0ea8d4a1..f7d2c404dd2 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 6b535e90331..27cae2fb5fc 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 ca89a29b9f1..54e0438de86 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 8c1a5134287..145c7c02d4f 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 c9d8f0848ef..6fb3a49f2e4 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 586b106dc11..8e727c6f555 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 6bda97fc0b3..bfaaab4a892 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 5fbe88bed67..57e753b22c9 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 2e4e302c6ae..0d50f3b7783 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"
 
-- 
GitLab