From f2877833418597541d4acfff756b51cefaddeb36 Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Thu, 16 Aug 2012 10:24:55 +0100
Subject: [PATCH] Modifying original ParameterMap instead of copy. Refs #5384

A detector retrieved before the Move/Rotate can then see the updated
parameters without retrieval.
---
 .../Framework/DataHandling/src/MoveInstrumentComponent.cpp   | 5 +++--
 .../Framework/DataHandling/src/RotateInstrumentComponent.cpp | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Code/Mantid/Framework/DataHandling/src/MoveInstrumentComponent.cpp b/Code/Mantid/Framework/DataHandling/src/MoveInstrumentComponent.cpp
index 4f2b69dc378..a558ece135d 100644
--- a/Code/Mantid/Framework/DataHandling/src/MoveInstrumentComponent.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/MoveInstrumentComponent.cpp
@@ -71,6 +71,9 @@ void MoveInstrumentComponent::exec()
   const double Z = getProperty("Z");
   const bool RelativePosition = getProperty("RelativePosition");
 
+  // Get the ParameterMap reference before the instrument so that
+  // we avoid a copy
+  Geometry::ParameterMap& pmap = WS->instrumentParameters();
   Instrument_const_sptr inst = WS->getInstrument();
   IComponent_const_sptr comp;
 
@@ -130,8 +133,6 @@ void MoveInstrumentComponent::exec()
       rot.inverse();
       rot.rotate(Pos);
   }
-
-  Geometry::ParameterMap& pmap = WS->instrumentParameters();
   // Add a parameter for the new position
   pmap.addV3D(comp.get(), "pos", Pos);
 
diff --git a/Code/Mantid/Framework/DataHandling/src/RotateInstrumentComponent.cpp b/Code/Mantid/Framework/DataHandling/src/RotateInstrumentComponent.cpp
index d1929b07db3..c358bca4ea8 100644
--- a/Code/Mantid/Framework/DataHandling/src/RotateInstrumentComponent.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/RotateInstrumentComponent.cpp
@@ -68,6 +68,9 @@ void RotateInstrumentComponent::exec()
 
   if (X + Y + Z == 0.0) throw std::invalid_argument("The rotation axis must not be a zero vector");
 
+  // Get the ParameterMap reference before the instrument so that
+  // we avoid a copy
+  Geometry::ParameterMap& pmap = WS->instrumentParameters();
   Instrument_const_sptr inst = WS->getInstrument();
   IComponent_const_sptr comp;
 
@@ -120,8 +123,6 @@ void RotateInstrumentComponent::exec()
       }
   }
 
-  //Need to get the address to the base instrument component
-  Geometry::ParameterMap& pmap = WS->instrumentParameters();
   // Add a parameter for the new rotation
   pmap.addQuat(comp.get(), "rot", Rot);
 
-- 
GitLab