diff --git a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h index 203cf0912cc762f62f50b3053b3a772db74fbe29..c48859c783abe3738bf9253ad325ffcbf38f019a 100644 --- a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h +++ b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h @@ -285,7 +285,7 @@ private: const Mantid::HistogramData::HistogramX &X, const int specNum, int &Centerchan); - double CalculatePositionSpan(Geometry::IPeak const &peak, const double dQ); + double CalculatePositionSpan(DataObjects::Peak const &peak, const double dQ); void InitializeColumnNamesInTableWorkspace( DataObjects::TableWorkspace_sptr &TabWS); @@ -348,7 +348,7 @@ private: void FindPlane(Kernel::V3D ¢er, Kernel::V3D &xvec, Kernel::V3D &yvec, double &ROW, double &COL, int &NROWS, int &NCOLS, double &pixWidthx, double &pixHeighty, - Geometry::IPeak const &peak) const; + DataObjects::Peak const &peak) const; int findTimeChannel(const Mantid::HistogramData::HistogramX &X, const double time); diff --git a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h index f317f8187c7deeec6983295548207485b7bc0b9a..b9d701e97d3c35367b6d49ea72ed1b2477052236 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h @@ -68,7 +68,7 @@ public: *parameters) and time adjusted. */ static DataObjects::Peak - createNewPeak(const Geometry::IPeak &peak_old, + createNewPeak(const DataObjects::Peak &peak_old, const Geometry::Instrument_sptr &instrNew, double T0, double L0); diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp index 2c7ff91c84cd479a2f29aa62b0e1c4614f068642..dc52ec6ebc271704615fa49df3438b64d6486f23 100644 --- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp +++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp @@ -224,7 +224,7 @@ void IntegratePeakTimeSlices::exec() { int indx = getProperty("PeakIndex"); - IPeak &peak = peaksW->getPeak(indx); + Peak &peak = peaksW->getPeak(indx); //------------------------------- Get Panel //-------------------------------------- @@ -767,7 +767,7 @@ bool IntegratePeakTimeSlices::updateNeighbors( * Also s=r*theta was used to transfer d ScatAng to distance on a bank. */ double -IntegratePeakTimeSlices::CalculatePositionSpan(Geometry::IPeak const &peak, +IntegratePeakTimeSlices::CalculatePositionSpan(Peak const &peak, const double dQ) { try { @@ -853,7 +853,7 @@ void IntegratePeakTimeSlices::FindPlane(V3D ¢er, V3D &xvec, V3D &yvec, double &ROW, double &COL, int &NROWS, int &NCOLS, double &pixWidthx, double &pixHeighty, - Geometry::IPeak const &peak) const { + DataObjects::Peak const &peak) const { NROWS = NCOLS = -1; IDetector_const_sptr det = peak.getDetector(); diff --git a/Framework/Crystal/src/PeakHKLErrors.cpp b/Framework/Crystal/src/PeakHKLErrors.cpp index ba417d568ce373e5ae24dd9826640aa77bcc326f..374410e132f7f59b303002d722c577bbb88bbe2a 100644 --- a/Framework/Crystal/src/PeakHKLErrors.cpp +++ b/Framework/Crystal/src/PeakHKLErrors.cpp @@ -385,7 +385,7 @@ void PeakHKLErrors::function1D(double *out, const double *xValues, double ChiSqTot = 0.0; for (size_t i = 0; i < nData; i += 3) { int peakNum = boost::math::iround(xValues[i]); - IPeak &peak_old = Peaks->getPeak(peakNum); + Peak &peak_old = Peaks->getPeak(peakNum); int runNum = peak_old.getRunNumber(); std::string runNumStr = std::to_string(runNum); @@ -484,7 +484,7 @@ void PeakHKLErrors::functionDeriv1D(Jacobian *out, const double *xValues, for (size_t i = 0; i < nData; i += 3) { int peakNum = boost::math::iround(xValues[i]); - IPeak &peak_old = Peaks->getPeak(peakNum); + Peak &peak_old = Peaks->getPeak(peakNum); Peak peak = createNewPeak(peak_old, instNew, 0, peak_old.getL1()); int runNum = peak_old.getRunNumber(); @@ -642,7 +642,7 @@ void PeakHKLErrors::functionDeriv1D(Jacobian *out, const double *xValues, } } -Peak PeakHKLErrors::createNewPeak(const Geometry::IPeak &peak_old, +Peak PeakHKLErrors::createNewPeak(const DataObjects::Peak &peak_old, const Geometry::Instrument_sptr &instrNew, double T0, double L0) { Geometry::Instrument_const_sptr inst = peak_old.getInstrument(); diff --git a/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h b/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h index 09057be8c28393879646f8666122e2eb4ada2c70..978bea3c41cc6db835a013698b34e4e630ad3a53 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h @@ -60,9 +60,7 @@ public: void setDetectorID(int) override; int getDetectorID() const override; - void setInstrument(const Geometry::Instrument_const_sptr &) override; Geometry::IDetector_const_sptr getDetector() const override; - Geometry::Instrument_const_sptr getInstrument() const override; std::shared_ptr<const Geometry::ReferenceFrame> getReferenceFrame() const override; diff --git a/Framework/DataObjects/inc/MantidDataObjects/Peak.h b/Framework/DataObjects/inc/MantidDataObjects/Peak.h index e2cb112f5050cb4b3b4bd0ea2045417ab7c42363..1df10f3c3d9fb695e67043112e71685f3f079bf8 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Peak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Peak.h @@ -29,7 +29,7 @@ namespace DataObjects { /** Structure describing a single-crystal peak. The peak is described * by the physical detector position (determined either from detector - * infomation or calculated from Q-lab) and inital/final energy + * information or calculated from Q-lab) and initial/final energy * (calculated from Q-lab or provided wavelength) * */ @@ -85,9 +85,9 @@ public: void removeContributingDetector(const int id); const std::set<int> &getContributingDetIDs() const; - void setInstrument(const Geometry::Instrument_const_sptr &inst) override; + void setInstrument(const Geometry::Instrument_const_sptr &inst); Geometry::IDetector_const_sptr getDetector() const override; - Geometry::Instrument_const_sptr getInstrument() const override; + Geometry::Instrument_const_sptr getInstrument() const; std::shared_ptr<const Geometry::ReferenceFrame> getReferenceFrame() const override; diff --git a/Framework/DataObjects/src/LeanElasticPeak.cpp b/Framework/DataObjects/src/LeanElasticPeak.cpp index fc5029e8da5b90da0e2d01b736186594d0067530..62e3d7c855b7f8426424133279ac9e343ed5437f 100644 --- a/Framework/DataObjects/src/LeanElasticPeak.cpp +++ b/Framework/DataObjects/src/LeanElasticPeak.cpp @@ -117,17 +117,6 @@ int LeanElasticPeak::getDetectorID() const { "LeanElasticPeak::getDetectorID(): no detector ID on LeanElasticPeak"); } -//---------------------------------------------------------------------------------------------- -/** Set the instrument (and save the source/sample pos). - * Call setDetectorID AFTER this call. - * - */ -void LeanElasticPeak::setInstrument(const Geometry::Instrument_const_sptr &) { - throw Exception::NotImplementedError( - "LeanElasticPeak::setInstrument(): Can't set instrument on " - "LeanElasticPeak"); -} - //---------------------------------------------------------------------------------------------- /** Return a shared ptr to the detector at center of peak. */ Geometry::IDetector_const_sptr LeanElasticPeak::getDetector() const { @@ -135,12 +124,6 @@ Geometry::IDetector_const_sptr LeanElasticPeak::getDetector() const { "LeanElasticPeak::getDetector(): Has no detector ID"); } -/** Return a shared ptr to the instrument for this peak. */ -Geometry::Instrument_const_sptr LeanElasticPeak::getInstrument() const { - throw Exception::NotImplementedError( - "LeanElasticPeak::setInstrument(): Has no instrument"); -} - /** Return a shared ptr to the reference frame for this peak. */ std::shared_ptr<const Geometry::ReferenceFrame> LeanElasticPeak::getReferenceFrame() const { diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index 9d3431efc6591726843f3e9f40e83fae89cc8355..21295ba8896c6bd1c9e162516df553f3f9a9c5b4 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -168,14 +168,14 @@ Peak::Peak(const Geometry::IPeak &ipeak) : BasePeak(ipeak), m_detectorID(ipeak.getDetectorID()), m_initialEnergy(ipeak.getInitialEnergy()), m_finalEnergy(ipeak.getFinalEnergy()) { - setInstrument(ipeak.getInstrument()); + const auto *peak = dynamic_cast<const Peak *>(&ipeak); + if (peak) + setInstrument(peak->getInstrument()); detid_t id = ipeak.getDetectorID(); - if (id >= 0) { + if (id >= 0) setDetectorID(id); - } - if (const auto *peak = dynamic_cast<const Peak *>(&ipeak)) { + if (peak) this->m_detIDs = peak->m_detIDs; - } } //---------------------------------------------------------------------------------------------- diff --git a/Framework/DataObjects/test/LeanElasticPeakTest.h b/Framework/DataObjects/test/LeanElasticPeakTest.h index 10c3338939954ba6d47a362fb5a62340f171541f..3a9f38bd3e127f31ede2745ab5ea2d78927dfaad 100644 --- a/Framework/DataObjects/test/LeanElasticPeakTest.h +++ b/Framework/DataObjects/test/LeanElasticPeakTest.h @@ -40,7 +40,6 @@ public: TS_ASSERT_THROWS(p.getDetectorID(), const Exception::NotImplementedError &) TS_ASSERT_THROWS(p.getDetector(), const Exception::NotImplementedError &) - TS_ASSERT_THROWS(p.getInstrument(), const Exception::NotImplementedError &) TS_ASSERT_THROWS(p.getDetectorPosition(), const Exception::NotImplementedError &) TS_ASSERT_THROWS(p.getDetectorPositionNoCheck(), @@ -335,7 +334,5 @@ public: TS_ASSERT_THROWS(leanpeak.getDetector(), const Exception::NotImplementedError &) - TS_ASSERT_THROWS(leanpeak.getInstrument(), - const Exception::NotImplementedError &) } }; diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h b/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h index af4c4dababc2b3a5b510163c0de8ed3913f3845f..45ecc0131a44a2fbfdf130a0b661862714d8d766 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h @@ -26,13 +26,9 @@ class InstrumentRayTracer; class MANTID_GEOMETRY_DLL IPeak { public: virtual ~IPeak() = default; - - virtual void setInstrument(const Geometry::Instrument_const_sptr &inst) = 0; - virtual int getDetectorID() const = 0; virtual void setDetectorID(int m_DetectorID) = 0; virtual Geometry::IDetector_const_sptr getDetector() const = 0; - virtual Geometry::Instrument_const_sptr getInstrument() const = 0; virtual std::shared_ptr<const Geometry::ReferenceFrame> getReferenceFrame() const = 0; diff --git a/Framework/Geometry/test/MockObjects.h b/Framework/Geometry/test/MockObjects.h index 7f4c94a3cdc5994ee92c1e06614999df56ea21a3..b6e2e9f22c110142c0cf9e6d656df678e44ba7b5 100644 --- a/Framework/Geometry/test/MockObjects.h +++ b/Framework/Geometry/test/MockObjects.h @@ -64,12 +64,9 @@ Mock IPeak ------------------------------------------------------------*/ class MockIPeak : public Mantid::Geometry::IPeak { public: - MOCK_METHOD1(setInstrument, - void(const Geometry::Instrument_const_sptr &inst)); MOCK_CONST_METHOD0(getDetectorID, int()); MOCK_METHOD1(setDetectorID, void(int m_DetectorID)); MOCK_CONST_METHOD0(getDetector, Geometry::IDetector_const_sptr()); - MOCK_CONST_METHOD0(getInstrument, Geometry::Instrument_const_sptr()); MOCK_CONST_METHOD0(getReferenceFrame, std::shared_ptr<const Geometry::ReferenceFrame>()); MOCK_CONST_METHOD0(getRunNumber, int()); diff --git a/qt/widgets/instrumentview/CMakeLists.txt b/qt/widgets/instrumentview/CMakeLists.txt index 29a6cbb62f642ec752eeb89d26c00259ca4f902d..bcd4490e4f4f373be81d792a7c1a3ce140754e56 100644 --- a/qt/widgets/instrumentview/CMakeLists.txt +++ b/qt/widgets/instrumentview/CMakeLists.txt @@ -164,6 +164,7 @@ mtd_add_qt_library(TARGET_NAME MantidQtWidgetsInstrumentView IN_MANTIDQT_INSTRUMENTVIEW INCLUDE_DIRS inc + ../../../Framework/DataObjects/inc SYSTEM_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} LINK_LIBS @@ -206,6 +207,7 @@ mtd_add_qt_library(TARGET_NAME MantidQtWidgetsInstrumentView IN_MANTIDQT_INSTRUMENTVIEW INCLUDE_DIRS inc + ../../../Framework/DataObjects/inc LINK_LIBS ${CORE_MANTIDLIBS} PythonInterfaceCore diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h index b9f2fdb0434f7722a61e35a63c211ed4082127b4..92a6a77556ea77e09714e2acb2c361b044347d0a 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h @@ -12,6 +12,7 @@ #include "MantidAPI/MatrixWorkspace_fwd.h" #include "MantidGeometry/Crystal/IPeak.h" +#include "MantidDataObjects/Peak.h" #include "MantidGeometry/ICompAssembly.h" #include "MantidGeometry/IDTypes.h" @@ -116,10 +117,10 @@ private slots: void singleComponentTouched(size_t pickID); void singleComponentPicked(size_t pickID); void alignPeaks(const std::vector<Mantid::Kernel::V3D> &planePeaks, - const Mantid::Geometry::IPeak *peak); + const Mantid::DataObjects::Peak *peak); void - comparePeaks(const std::pair<std::vector<Mantid::Geometry::IPeak *>, - std::vector<Mantid::Geometry::IPeak *>> &peaks); + comparePeaks(const std::pair<std::vector<Mantid::DataObjects::Peak *>, + std::vector<Mantid::DataObjects::Peak *>> &peaks); void updateSelectionInfoDisplay(); void shapeCreated(); void updatePlotMultipleDetectors(); @@ -208,16 +209,16 @@ public: public slots: void displayInfo(size_t pickID); void displayComparePeaksInfo( - const std::pair<std::vector<Mantid::Geometry::IPeak *>, - std::vector<Mantid::Geometry::IPeak *>> &peaks); + const std::pair<std::vector<Mantid::DataObjects::Peak *>, + std::vector<Mantid::DataObjects::Peak *>> &peaks); void displayAlignPeaksInfo(const std::vector<Mantid::Kernel::V3D> &planePeaks, - const Mantid::Geometry::IPeak *peak); + const Mantid::DataObjects::Peak *peak); void clear(); private: QString displayDetectorInfo(size_t index); QString displayNonDetectorInfo(Mantid::Geometry::ComponentID compID); - QString displayPeakInfo(Mantid::Geometry::IPeak *peak); + QString displayPeakInfo(Mantid::DataObjects::Peak *peak); QString displayPeakAngles(const std::pair<Mantid::Geometry::IPeak *, Mantid::Geometry::IPeak *> &peaks); QString getPeakOverlayInfo(); diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp index 4920fc3177dbbfea0db86b3bddf9b330649dd2d3..cbf035e48410456a89871df841c4dc0ad77657e3 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp @@ -757,14 +757,14 @@ void InstrumentWidgetPickTab::singleComponentPicked(size_t pickID) { } void InstrumentWidgetPickTab::comparePeaks( - const std::pair<std::vector<Mantid::Geometry::IPeak *>, - std::vector<Mantid::Geometry::IPeak *>> &peaks) { + const std::pair<std::vector<Mantid::DataObjects::Peak *>, + std::vector<Mantid::DataObjects::Peak *>> &peaks) { m_infoController->displayComparePeaksInfo(peaks); } void InstrumentWidgetPickTab::alignPeaks( const std::vector<Mantid::Kernel::V3D> &planePeaks, - const Mantid::Geometry::IPeak *peak) { + const Mantid::DataObjects::Peak *peak) { m_infoController->displayAlignPeaksInfo(planePeaks, peak); } @@ -1004,7 +1004,7 @@ QString ComponentInfoController::displayNonDetectorInfo( } QString -ComponentInfoController::displayPeakInfo(Mantid::Geometry::IPeak *peak) { +ComponentInfoController::displayPeakInfo(Mantid::DataObjects::Peak *peak) { std::stringstream text; auto instrument = peak->getInstrument(); auto sample = instrument->getSample()->getPos(); @@ -1041,8 +1041,8 @@ QString ComponentInfoController::displayPeakAngles( } void ComponentInfoController::displayComparePeaksInfo( - const std::pair<std::vector<Mantid::Geometry::IPeak *>, - std::vector<Mantid::Geometry::IPeak *>> &peaks) { + const std::pair<std::vector<Mantid::DataObjects::Peak *>, + std::vector<Mantid::DataObjects::Peak *>> &peaks) { std::stringstream text; text << "Comparison Information\n"; @@ -1067,7 +1067,7 @@ void ComponentInfoController::displayComparePeaksInfo( void ComponentInfoController::displayAlignPeaksInfo( const std::vector<Mantid::Kernel::V3D> &planePeaks, - const Mantid::Geometry::IPeak *peak) { + const Mantid::DataObjects::Peak *peak) { using Mantid::Kernel::V3D;