From aa5ee14e4473ab37a156399b2fa68ff94c354cfa Mon Sep 17 00:00:00 2001
From: Lamar Moore <lamar.moore@stfc.ac.uk>
Date: Wed, 3 Oct 2018 11:56:34 +0100
Subject: [PATCH] Remove dynamic cast for detectors in MoveInstrumentComponent
 #23073

---
 .../DataHandling/src/MoveInstrumentComponent.cpp   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Framework/DataHandling/src/MoveInstrumentComponent.cpp b/Framework/DataHandling/src/MoveInstrumentComponent.cpp
index 8f9ccf029d4..efde8f13b69 100644
--- a/Framework/DataHandling/src/MoveInstrumentComponent.cpp
+++ b/Framework/DataHandling/src/MoveInstrumentComponent.cpp
@@ -106,10 +106,20 @@ void MoveInstrumentComponent::exec() {
     throw std::invalid_argument("DetectorID or ComponentName must be given.");
   }
 
-  if (dynamic_cast<const Geometry::GridDetectorPixel *>(comp.get())) {
+  const auto &componentInfo = inputW->componentInfo();
+  auto compIndex = componentInfo.indexOf(comp->getComponentID());
+  auto parent = componentInfo.parent(compIndex);
+  auto grandParent = componentInfo.parent(parent);
+  if (componentInfo.isDetector(compIndex) &&
+      (componentInfo.componentType(grandParent) ==
+           Mantid::Beamline::ComponentType::Grid ||
+       componentInfo.componentType(grandParent) ==
+           Mantid::Beamline::ComponentType::Rectangular ||
+       componentInfo.componentType(grandParent) ==
+           Mantid::Beamline::ComponentType::Structured)) {
     // DetectorInfo makes changing positions possible but we keep the old
     // behavior of ignoring position changes for GridDetectorPixel.
-    g_log.warning("Component is a GridDetectorPixel, moving is not "
+    g_log.warning("Component is fixed within a structured bank, moving is not "
                   "possible, doing nothing.");
     return;
   }
-- 
GitLab