Commit 9d2e7fb2 authored by Jose Borreguero's avatar Jose Borreguero
Browse files

Refs #30885 remove instrument getter and setter from IPeak



Signed-off-by: default avatarJose Borreguero <borreguero@gmail.com>
parent 3f6cc46c
......@@ -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 &center, 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);
......
......@@ -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);
......
......@@ -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 &center, 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();
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 {
......
......@@ -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;
}
}
//----------------------------------------------------------------------------------------------
......
......@@ -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 &)
}
};
......@@ -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;
......
......@@ -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());
......
......@@ -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
......
......@@ -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();
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment