diff --git a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp index da9d62a34a01..50cec8a5b3fd 100644 --- a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp +++ b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp @@ -750,7 +750,7 @@ namespace Mantid { Instrument_const_sptr instrument = getInstrument(); - Geometry::IObjComponent_const_sptr source = instrument->getSource(); + Geometry::IComponent_const_sptr source = instrument->getSource(); Geometry::IComponent_const_sptr sample = instrument->getSample(); if ( source == NULL || sample == NULL ) { @@ -776,7 +776,7 @@ namespace Mantid */ double MatrixWorkspace::detectorTwoTheta(Geometry::IDetector_const_sptr det) const { - Geometry::IObjComponent_const_sptr source = getInstrument()->getSource(); + Geometry::IComponent_const_sptr source = getInstrument()->getSource(); Geometry::IComponent_const_sptr sample = getInstrument()->getSample(); if ( source == NULL || sample == NULL ) { diff --git a/Code/Mantid/Framework/Algorithms/src/AddPeak.cpp b/Code/Mantid/Framework/Algorithms/src/AddPeak.cpp index f59db7a09d55..aadfc02c9e12 100644 --- a/Code/Mantid/Framework/Algorithms/src/AddPeak.cpp +++ b/Code/Mantid/Framework/Algorithms/src/AddPeak.cpp @@ -75,7 +75,7 @@ namespace Algorithms const double count = getProperty("BinCount"); Mantid::Geometry::Instrument_const_sptr instr = runWS->getInstrument(); - Mantid::Geometry::IObjComponent_const_sptr source = instr->getSource(); + Mantid::Geometry::IComponent_const_sptr source = instr->getSource(); Mantid::Geometry::IComponent_const_sptr sample = instr->getSample(); Mantid::Geometry::IDetector_const_sptr det = instr->getDetector(detID); diff --git a/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis.cpp b/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis.cpp index 8d6c71ab6cc5..e820e02a7798 100644 --- a/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis.cpp +++ b/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis.cpp @@ -86,7 +86,7 @@ namespace Algorithms { Kernel::Unit_sptr fromUnit = inputWS->getAxis(0)->unit(); Kernel::Unit_sptr toUnit = UnitFactory::Instance().create(unitTarget); - IObjComponent_const_sptr source = inputWS->getInstrument()->getSource(); + IComponent_const_sptr source = inputWS->getInstrument()->getSource(); IComponent_const_sptr sample = inputWS->getInstrument()->getSample(); std::vector emptyVector; const double l1 = source->getDistance(*sample); diff --git a/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp b/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp index dfea65610ce5..69cda48dda8b 100644 --- a/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp +++ b/Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp @@ -134,7 +134,7 @@ namespace Algorithms void ConvertSpectrumAxis2::createElasticQMap(const std::string & targetUnit) { - IObjComponent_const_sptr source = m_inputWS->getInstrument()->getSource(); + IComponent_const_sptr source = m_inputWS->getInstrument()->getSource(); IComponent_const_sptr sample = m_inputWS->getInstrument()->getSample(); const std::string emodeStr = getProperty("EMode"); diff --git a/Code/Mantid/Framework/Algorithms/src/ConvertUnits.cpp b/Code/Mantid/Framework/Algorithms/src/ConvertUnits.cpp index 8681b1817ff6..c391547b186a 100644 --- a/Code/Mantid/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Code/Mantid/Framework/Algorithms/src/ConvertUnits.cpp @@ -394,7 +394,7 @@ void ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit, API::MatrixWo Kernel::Unit_const_sptr outputUnit = outputWS->getAxis(0)->unit(); // Get the distance between the source and the sample (assume in metres) - IObjComponent_const_sptr source = instrument->getSource(); + IComponent_const_sptr source = instrument->getSource(); IComponent_const_sptr sample = instrument->getSample(); if ( source == NULL || sample == NULL ) { diff --git a/Code/Mantid/Framework/Algorithms/src/CreateLogTimeCorrection.cpp b/Code/Mantid/Framework/Algorithms/src/CreateLogTimeCorrection.cpp index ba518391ba78..8fa2379ee1c0 100644 --- a/Code/Mantid/Framework/Algorithms/src/CreateLogTimeCorrection.cpp +++ b/Code/Mantid/Framework/Algorithms/src/CreateLogTimeCorrection.cpp @@ -124,7 +124,7 @@ namespace Algorithms } V3D samplepos = sample->getPos(); - IObjComponent_const_sptr source = m_instrument->getSource(); + IComponent_const_sptr source = m_instrument->getSource(); if (!source) { throw runtime_error("No source has been set."); diff --git a/Code/Mantid/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp b/Code/Mantid/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp index 46e1baad915b..b1bc5076ace8 100644 --- a/Code/Mantid/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp +++ b/Code/Mantid/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp @@ -409,7 +409,7 @@ namespace Algorithms outfile << "# "<< DateAndTime::getCurrentTime().toFormattedString("%c") <<"\n"; outfile << "#\n"; outfile << "6 L1 T0_SHIFT\n"; - IObjComponent_const_sptr source = inst->getSource(); + IComponent_const_sptr source = inst->getSource(); IComponent_const_sptr sample = inst->getSample(); outfile << "7 "<getDistance(*sample)*100<<" 0\n"; outfile << "4 DETNUM NROWS NCOLS WIDTH HEIGHT DEPTH DETD CenterX CenterY CenterZ BaseX BaseY BaseZ UpX UpY UpZ\n"; diff --git a/Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp b/Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp index dcc382cd8c11..ce069fb394f1 100644 --- a/Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp +++ b/Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp @@ -207,7 +207,7 @@ namespace Algorithms g_log.error(errmsg); throw std::runtime_error(errmsg); } - Geometry::IObjComponent_const_sptr source = originstrument->getSource(); + Geometry::IComponent_const_sptr source = originstrument->getSource(); Geometry::IComponent_const_sptr sample = originstrument->getSample(); l1 = source->getDistance(*sample); g_log.information() << "Retrieve L1 from input data workspace. \n"; diff --git a/Code/Mantid/Framework/Algorithms/src/GetEi.cpp b/Code/Mantid/Framework/Algorithms/src/GetEi.cpp index fa5442047183..1705b4de99a4 100644 --- a/Code/Mantid/Framework/Algorithms/src/GetEi.cpp +++ b/Code/Mantid/Framework/Algorithms/src/GetEi.cpp @@ -151,7 +151,7 @@ void GetEi::exec() */ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specid_t mon0Spec, specid_t mon1Spec, double &monitor0Dist, double &monitor1Dist) const { - const IObjComponent_const_sptr source = WS->getInstrument()->getSource(); + const IComponent_const_sptr source = WS->getInstrument()->getSource(); // retrieve a pointer to the first detector and get its distance size_t monWI = 0; diff --git a/Code/Mantid/Framework/Algorithms/src/GetEi2.cpp b/Code/Mantid/Framework/Algorithms/src/GetEi2.cpp index ec8c6f79656a..29d1f0f7e1f6 100644 --- a/Code/Mantid/Framework/Algorithms/src/GetEi2.cpp +++ b/Code/Mantid/Framework/Algorithms/src/GetEi2.cpp @@ -295,7 +295,7 @@ double GetEi2::getDistanceFromSource(size_t ws_index) const { g_log.debug() << "Computing distance between spectrum at index '" << ws_index << "' and the source\n"; - const IObjComponent_const_sptr source = m_input_ws->getInstrument()->getSource(); + const IComponent_const_sptr source = m_input_ws->getInstrument()->getSource(); // Retrieve a pointer detector IDetector_const_sptr det = m_input_ws->getDetector(ws_index); if( !det ) diff --git a/Code/Mantid/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp b/Code/Mantid/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp index 69ab7fbd495a..3ca2311db099 100644 --- a/Code/Mantid/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp +++ b/Code/Mantid/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp @@ -144,7 +144,7 @@ void MultipleScatteringCylinderAbsorption::exec() Instrument_const_sptr instrument = in_WS->getInstrument(); if (instrument == NULL) throw std::runtime_error("Failed to find instrument attached to InputWorkspace"); - IObjComponent_const_sptr source = instrument->getSource(); + IComponent_const_sptr source = instrument->getSource(); IComponent_const_sptr sample = instrument->getSample(); if (source == NULL) throw std::runtime_error("Failed to find source in the instrument for InputWorkspace"); diff --git a/Code/Mantid/Framework/Algorithms/src/SofQW.cpp b/Code/Mantid/Framework/Algorithms/src/SofQW.cpp index 2fb590111ded..2bc8b2bc8259 100644 --- a/Code/Mantid/Framework/Algorithms/src/SofQW.cpp +++ b/Code/Mantid/Framework/Algorithms/src/SofQW.cpp @@ -114,7 +114,7 @@ void SofQW::exec() Instrument_const_sptr instrument = inputWorkspace->getInstrument(); // Get the distance between the source and the sample (assume in metres) - IObjComponent_const_sptr source = instrument->getSource(); + IComponent_const_sptr source = instrument->getSource(); IComponent_const_sptr sample = instrument->getSample(); V3D beamDir = sample->getPos() - source->getPos(); beamDir.normalize(); diff --git a/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h b/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h index b19226ffe85a..ffa1a3c2b753 100644 --- a/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h +++ b/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h @@ -197,7 +197,7 @@ namespace Crystal * */ static void updateSourceParams( - boost::shared_ptr bank_const, + boost::shared_ptr bank_const, boost::shared_ptr pmap, boost::shared_ptr pmapSv); diff --git a/Code/Mantid/Framework/Crystal/src/SCDCalibratePanels.cpp b/Code/Mantid/Framework/Crystal/src/SCDCalibratePanels.cpp index 5fbb0f64bcff..5d9914215cd8 100644 --- a/Code/Mantid/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Code/Mantid/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -1145,7 +1145,7 @@ namespace Mantid double mL1; stringstream(line) >> count >> mL1 >> T0; double scaleL0= .01*mL1/beamlineLen; - const IObjComponent_const_sptr source=instrument->getSource(); + const IComponent_const_sptr source=instrument->getSource(); V3D NewSourcePos= samplePos-beamline*scaleL0*2.0;//beamLine is 2*length. L0=beamline.norm()*scaleL0*2.0; V3D RelSourcePos = source->getRelativePos()+NewSourcePos-source->getPos(); @@ -1617,7 +1617,7 @@ namespace Mantid } - void SCDCalibratePanels::updateSourceParams(boost::shared_ptr bank_const, + void SCDCalibratePanels::updateSourceParams(boost::shared_ptr bank_const, boost::shared_ptr pmap, boost::shared_ptr pmapSv) { vector< V3D > posv = pmapSv->getV3D(bank_const->getName(), "pos"); @@ -1642,7 +1642,7 @@ namespace Mantid boost::shared_ptr const pmapOld) { boost::shared_ptr pmap = NewInstrument->getParameterMap(); - IObjComponent_const_sptr source = NewInstrument->getSource(); + IComponent_const_sptr source = NewInstrument->getSource(); updateSourceParams(source, pmap, pmapOld); IComponent_const_sptr sample = NewInstrument->getSample(); @@ -1801,7 +1801,7 @@ namespace Mantid } // for each group // write out the source - IObjComponent_const_sptr source = instrument->getSource(); + IComponent_const_sptr source = instrument->getSource(); oss3 << "getName() << "\">" << endl; IComponent_const_sptr sample = instrument->getSample(); diff --git a/Code/Mantid/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp b/Code/Mantid/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp index efe56ee9ef48..0bbfdf883024 100644 --- a/Code/Mantid/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp @@ -194,7 +194,7 @@ namespace DataHandling // Get the sample (needed to calculate distances) Geometry::IComponent_const_sptr sample = instrument->getSample(); // Get the source (moderator) - Geometry::IObjComponent_const_sptr source = instrument->getSource(); + Geometry::IComponent_const_sptr source = instrument->getSource(); // Open the NeXus file ::NeXus::File nxfile(m_filename, NXACC_RDWR); diff --git a/Code/Mantid/Framework/DataHandling/src/SaveFocusedXYE.cpp b/Code/Mantid/Framework/DataHandling/src/SaveFocusedXYE.cpp index c870aee2f4e9..2fceb14a3115 100644 --- a/Code/Mantid/Framework/DataHandling/src/SaveFocusedXYE.cpp +++ b/Code/Mantid/Framework/DataHandling/src/SaveFocusedXYE.cpp @@ -333,7 +333,7 @@ void SaveFocusedXYE::getFocusedPos(Mantid::API::MatrixWorkspace_const_sptr wksp, tth = 0.; return; } - Geometry::IObjComponent_const_sptr source = instrument->getSource(); + Geometry::IComponent_const_sptr source = instrument->getSource(); Geometry::IComponent_const_sptr sample = instrument->getSample(); if (source == NULL || sample == NULL) { diff --git a/Code/Mantid/Framework/DataHandling/src/SaveGSS.cpp b/Code/Mantid/Framework/DataHandling/src/SaveGSS.cpp index b5e017354b5c..40da87bb76fd 100644 --- a/Code/Mantid/Framework/DataHandling/src/SaveGSS.cpp +++ b/Code/Mantid/Framework/DataHandling/src/SaveGSS.cpp @@ -93,7 +93,7 @@ namespace Mantid tth = 0.; return; } - Geometry::IObjComponent_const_sptr source = instrument->getSource(); + Geometry::IComponent_const_sptr source = instrument->getSource(); Geometry::IComponent_const_sptr sample = instrument->getSample(); if (source == NULL || sample == NULL) { @@ -143,7 +143,7 @@ namespace Mantid Progress p(this, 0.0, 1.0, nHist); double l1, l2, tth; Geometry::Instrument_const_sptr instrument = inputWS->getInstrument(); - Geometry::IObjComponent_const_sptr source; + Geometry::IComponent_const_sptr source; Geometry::IComponent_const_sptr sample; if (instrument != NULL) { diff --git a/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h b/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h index 1c98404662d6..b9b6561bdd5d 100644 --- a/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h @@ -178,7 +178,7 @@ class LoadInstrumentTest : public CxxTest::TestSuite void evaluate_GEM(MatrixWorkspace_sptr output) { boost::shared_ptr i = output->getInstrument(); - boost::shared_ptr source = i->getSource(); + boost::shared_ptr source = i->getSource(); TS_ASSERT_EQUALS( source->getName(), "undulator"); TS_ASSERT_DELTA( source->getPos().Z(), -17.0,0.01); @@ -292,7 +292,7 @@ class LoadInstrumentTest : public CxxTest::TestSuite TS_ASSERT_THROWS_NOTHING(output = AnalysisDataService::Instance().retrieveWS(wsName)); boost::shared_ptr i = output->getInstrument(); - boost::shared_ptr source = i->getSource(); + boost::shared_ptr source = i->getSource(); TS_ASSERT_EQUALS( source->getName(), "undulator"); TS_ASSERT_DELTA( source->getPos().Z(), -11.016,0.01); diff --git a/Code/Mantid/Framework/DataObjects/src/Peak.cpp b/Code/Mantid/Framework/DataObjects/src/Peak.cpp index 79174ec59e9a..8d79736cc78f 100644 --- a/Code/Mantid/Framework/DataObjects/src/Peak.cpp +++ b/Code/Mantid/Framework/DataObjects/src/Peak.cpp @@ -319,7 +319,7 @@ namespace DataObjects if (!inst) throw std::runtime_error("Peak::setInstrument(): No instrument is set!"); // Cache some positions - const Geometry::IObjComponent_const_sptr sourceObj = m_inst->getSource(); + const Geometry::IComponent_const_sptr sourceObj = m_inst->getSource(); if (sourceObj == NULL) throw Exception::InstrumentDefinitionError("Peak::setInstrument(): Failed to get source component from instrument"); const Geometry::IComponent_const_sptr sampleObj = m_inst->getSample(); diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Instrument.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Instrument.h index c7416b326b48..4e9a33db69b4 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Instrument.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Instrument.h @@ -75,7 +75,7 @@ namespace Mantid Instrument* clone() const; - IObjComponent_const_sptr getSource() const; + IComponent_const_sptr getSource() const; IObjComponent_const_sptr getChopperPoint(const size_t index = 0) const; size_t getNumberOfChopperPoints() const; IComponent_const_sptr getSample() const; @@ -107,7 +107,7 @@ namespace Mantid /// mark a Component which has already been added to the Instrument (as a child comp.) /// to be 'the' source Component. For now it is assumed that we have /// at most one of these. - void markAsSource(const ObjComponent*); + void markAsSource(const IComponent*); /// mark a Component which has already been added to the Instrument (as a child comp.) /// to be a Detector component by adding it to _detectorCache @@ -245,7 +245,7 @@ namespace Mantid std::map m_detectorCache; /// Purpose to hold copy of source component. For now assumed to be just one component - const ObjComponent* m_sourceCache; + const IComponent* m_sourceCache; /// Hold a list of places where a chopper can be situated /// A pointer so that parameterized intruments are still fast to create. diff --git a/Code/Mantid/Framework/Geometry/src/Instrument.cpp b/Code/Mantid/Framework/Geometry/src/Instrument.cpp index 93f23711d86c..56f601692e63 100644 --- a/Code/Mantid/Framework/Geometry/src/Instrument.cpp +++ b/Code/Mantid/Framework/Geometry/src/Instrument.cpp @@ -327,20 +327,32 @@ namespace Mantid /** Gets a pointer to the source * @returns a pointer to the source */ - IObjComponent_const_sptr Instrument::getSource() const + IComponent_const_sptr Instrument::getSource() const { if ( !m_sourceCache ) { g_log.warning("In Instrument::getSource(). No source has been set."); - return IObjComponent_const_sptr(m_sourceCache,NoDeleting()); + return IComponent_const_sptr(m_sourceCache,NoDeleting()); } else if (m_isParametrized) { - return IObjComponent_const_sptr(new ObjComponent(static_cast(m_base)->m_sourceCache,m_map)); + auto sourceCache = static_cast(m_base)->m_sourceCache; + if ( dynamic_cast(sourceCache) ) + return IComponent_const_sptr(new ObjComponent(sourceCache,m_map)); + else if ( dynamic_cast(sourceCache) ) + return IComponent_const_sptr(new CompAssembly(sourceCache,m_map)); + else if ( dynamic_cast(sourceCache) ) + return IComponent_const_sptr(new Component(sourceCache,m_map)); + else + { + g_log.error("In Instrument::getSource(). Source is not a recognised component type."); + g_log.error("Try to assume it is a Component."); + return IComponent_const_sptr(new ObjComponent(sourceCache,m_map)); + } } else { - return IObjComponent_const_sptr(m_sourceCache,NoDeleting()); + return IComponent_const_sptr(m_sourceCache,NoDeleting()); } } @@ -651,7 +663,7 @@ namespace Mantid { throw std::invalid_argument("Instrument::markAsChopper - Chopper component must have a name"); } - IObjComponent_const_sptr source = getSource(); + IComponent_const_sptr source = getSource(); if(!source) { throw Exception::InstrumentDefinitionError("Instrument::markAsChopper - No source is set, cannot defined chopper positions."); @@ -702,7 +714,7 @@ namespace Mantid * * @param comp :: Component to be marked (stored for later retrieval) as a "source" Component */ - void Instrument::markAsSource(const ObjComponent* comp) + void Instrument::markAsSource(const IComponent* comp) { if (m_isParametrized) throw std::runtime_error("Instrument::markAsSource() called on a parametrized Instrument object."); @@ -1022,7 +1034,7 @@ namespace Mantid double & beamline_norm, Kernel::V3D & samplePos) const { // Get some positions - const IObjComponent_const_sptr sourceObj = this->getSource(); + const IComponent_const_sptr sourceObj = this->getSource(); if (sourceObj == NULL) { throw Exception::InstrumentDefinitionError("Failed to get source component from instrument"); diff --git a/Code/Mantid/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Code/Mantid/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index c101f61fe4fd..a5c0b8e264fa 100644 --- a/Code/Mantid/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Code/Mantid/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -1015,6 +1015,10 @@ namespace Geometry { m_instrument->markAsSamplePos(ass); } + if ( category.compare("Source") == 0 || category.compare("source") == 0 ) + { + m_instrument->markAsSource(ass); + } // If enabled, check for a 'neutronic position' tag and add to cache if found if ( m_indirectPositions ) diff --git a/Code/Mantid/Framework/Geometry/test/InstrumentDefinitionParserTest.h b/Code/Mantid/Framework/Geometry/test/InstrumentDefinitionParserTest.h index 6d4f2b11f495..61d987d71bd9 100644 --- a/Code/Mantid/Framework/Geometry/test/InstrumentDefinitionParserTest.h +++ b/Code/Mantid/Framework/Geometry/test/InstrumentDefinitionParserTest.h @@ -159,7 +159,7 @@ class InstrumentDefinitionParserTest : public CxxTest::TestSuite TS_FAIL("Cannot find expected .vtp file next to " + filename); } - boost::shared_ptr source = i->getSource(); + boost::shared_ptr source = boost::dynamic_pointer_cast(i->getSource()); TS_ASSERT_EQUALS( source->getName(), "undulator"); TS_ASSERT_DELTA( source->getPos().Z(), -17.0,0.01); @@ -445,6 +445,11 @@ class InstrumentDefinitionParserTest : public CxxTest::TestSuite TS_ASSERT_EQUALS( sample->getName(), "nickel-holder"); TS_ASSERT_DELTA( sample->getPos().X(), 2.0,0.01); + // test source + boost::shared_ptr source = i->getSource(); + TS_ASSERT_EQUALS( source->getName(), "undulator"); + TS_ASSERT_DELTA( source->getPos().Z(), -95.0,0.01); + // Test of monitor shape boost::shared_ptr ptrMonShape = i->getDetector(1001); TS_ASSERT( ptrMonShape->isValid(V3D(0.002,0.0,0.0)+ptrMonShape->getPos()) ); diff --git a/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp index ff8651b2d129..473eff403fe0 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp @@ -253,7 +253,7 @@ namespace Mantid Geometry::Instrument_const_sptr instrument = inputWS->getInstrument(); //this->pBaseInstr = instrument->baseInstrument(); // - Geometry::IObjComponent_const_sptr source = instrument->getSource(); + Geometry::IComponent_const_sptr source = instrument->getSource(); Geometry::IComponent_const_sptr sample = instrument->getSample(); if ((!source) || (!sample)) { diff --git a/Code/Mantid/Framework/MDAlgorithms/src/Quantification/CachedExperimentInfo.cpp b/Code/Mantid/Framework/MDAlgorithms/src/Quantification/CachedExperimentInfo.cpp index 68d2ec25c182..d08bace22235 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/Quantification/CachedExperimentInfo.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/Quantification/CachedExperimentInfo.cpp @@ -154,7 +154,7 @@ namespace Mantid m_up = refFrame->pointingUp(); m_horiz = refFrame->pointingHorizontal(); - IObjComponent_const_sptr source = instrument->getSource(); + IComponent_const_sptr source = instrument->getSource(); IComponent_const_sptr sample = instrument->getSample(); IComponent_const_sptr aperture = instrument->getComponentByName("aperture", 1); if(!aperture) diff --git a/Code/Mantid/Framework/MDAlgorithms/src/Quantification/Resolution/ModeratorChopperResolution.cpp b/Code/Mantid/Framework/MDAlgorithms/src/Quantification/Resolution/ModeratorChopperResolution.cpp index a4d20946ea19..0eb450474fb7 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/Quantification/Resolution/ModeratorChopperResolution.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/Quantification/Resolution/ModeratorChopperResolution.cpp @@ -12,6 +12,7 @@ namespace Mantid { using Geometry::Instrument_const_sptr; using Geometry::IObjComponent_const_sptr; + using Geometry::IComponent_const_sptr; using Geometry::IDetector_const_sptr; /** @@ -78,7 +79,7 @@ namespace Mantid void ModeratorChopperResolution::initCaches() { Instrument_const_sptr instr = m_observation.experimentInfo().getInstrument(); - IObjComponent_const_sptr source = instr->getSource(); + IComponent_const_sptr source = instr->getSource(); m_modChopDist = m_observation.moderatorToFirstChopperDistance(); m_chopSampleDist = m_observation.firstChopperToSampleDistance(); diff --git a/Code/Mantid/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Code/Mantid/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index 3c40cf4f1dbe..8ed081e01ec4 100644 --- a/Code/Mantid/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Code/Mantid/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -1162,7 +1162,7 @@ namespace WorkspaceCreationHelper { Geometry::Instrument_const_sptr instrument = inputWS->getInstrument(); // - Geometry::IObjComponent_const_sptr source = instrument->getSource(); + Geometry::IComponent_const_sptr source = instrument->getSource(); Geometry::IComponent_const_sptr sample = instrument->getSample(); if ((!source) || (!sample)) { diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp index 138046b63c32..a02865b37b93 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp @@ -37,7 +37,7 @@ DECLARE_ALGORITHM(SANSSolidAngleCorrection) static double getYTubeAngle(IDetector_const_sptr det, MatrixWorkspace_const_sptr workspace) { - Geometry::IObjComponent_const_sptr source = workspace->getInstrument()->getSource(); + Geometry::IComponent_const_sptr source = workspace->getInstrument()->getSource(); Geometry::IComponent_const_sptr sample = workspace->getInstrument()->getSample(); if ( source == NULL || sample == NULL ) { diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp index 7c8e0ac50a62..fa9bb342b3b0 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp @@ -1152,7 +1152,7 @@ void SANSRunWindow::componentLOQDistances(boost::shared_ptrgetInstrument(); if( !instr ) return; - Mantid::Geometry::IObjComponent_const_sptr source = instr->getSource(); + Mantid::Geometry::IComponent_const_sptr source = instr->getSource(); if( source == boost::shared_ptr() ) return; Mantid::Geometry::IComponent_const_sptr sample = instr->getSample(); if( sample == boost::shared_ptr() ) return; diff --git a/Code/Mantid/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp b/Code/Mantid/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp index 6728772f73f3..6d9b91a2bd11 100644 --- a/Code/Mantid/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp +++ b/Code/Mantid/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp @@ -292,7 +292,7 @@ void MatrixWSDataSource::GetInfoList( double x, return; } - IObjComponent_const_sptr source = instrument->getSource(); + IComponent_const_sptr source = instrument->getSource(); if ( source == 0 ) { ErrorHandler::Error("No SOURCE on instrument in MatrixWorkspace"); diff --git a/Code/Mantid/instrument/IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING2.xml b/Code/Mantid/instrument/IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING2.xml index d57882a268ab..840a36165da5 100644 --- a/Code/Mantid/instrument/IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING2.xml +++ b/Code/Mantid/instrument/IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING2.xml @@ -100,15 +100,22 @@ + + + + + + + - + - +