From 28f4ec01e6ed16d212366883f034ecaf422fb12e Mon Sep 17 00:00:00 2001 From: Joachim Wuttke <j.wuttke@fz-juelich.de> Date: Sun, 2 Apr 2023 09:57:05 +0200 Subject: [PATCH] ICoordSystem: member m_axes now here (#71) --- Device/Coord/CoordSystem1D.cpp | 6 +++--- Device/Coord/CoordSystem1D.h | 4 +--- Device/Coord/CoordSystem2D.cpp | 4 ++-- Device/Coord/CoordSystem2D.h | 2 -- Device/Coord/ICoordSystem.h | 6 ++++++ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Device/Coord/CoordSystem1D.cpp b/Device/Coord/CoordSystem1D.cpp index 2ff35bc9e4f..31507318ec2 100644 --- a/Device/Coord/CoordSystem1D.cpp +++ b/Device/Coord/CoordSystem1D.cpp @@ -66,7 +66,7 @@ PointwiseAxis* createAxisFrom(const IAxis& axis, Coords coords, const std::strin // ************************************************************************************************ CoordSystem1D::CoordSystem1D(const IAxis* axis) - : m_axis(axis) + : ICoordSystem({axis}) { } @@ -116,12 +116,12 @@ AngularReflectometryCoords::AngularReflectometryCoords(double wavelength, const : CoordSystem1D(createAxisFrom(axis, axis_units, nameOfAxis0(axis_units), wavelength)) , m_wavelength(wavelength) { - if (m_axis->min() < 0 || m_axis->max() > M_PI_2) + if (m_axes[0]->min() < 0 || m_axes[0]->max() > M_PI_2) throw std::runtime_error("Error in CoordSystem1D: input axis range is out of bounds"); } AngularReflectometryCoords::AngularReflectometryCoords(const AngularReflectometryCoords& other) - : CoordSystem1D(other.m_axis->clone()) + : CoordSystem1D(other.m_axes[0]->clone()) , m_wavelength(other.m_wavelength) { } diff --git a/Device/Coord/CoordSystem1D.h b/Device/Coord/CoordSystem1D.h index 92f4a71c1f1..33937d6ac23 100644 --- a/Device/Coord/CoordSystem1D.h +++ b/Device/Coord/CoordSystem1D.h @@ -47,9 +47,7 @@ protected: //! Returns translating functional (rads --> output units) virtual std::function<double(double)> getTraslatorTo(Coords units) const = 0; - const IAxis* coordinateAxis() const { return m_axis.get(); } - - std::unique_ptr<const IAxis> m_axis; //!< semantics depends on subclass + const IAxis* coordinateAxis() const { return m_axes[0]; } }; diff --git a/Device/Coord/CoordSystem2D.cpp b/Device/Coord/CoordSystem2D.cpp index a4cea536ee6..a499d0a9d0d 100644 --- a/Device/Coord/CoordSystem2D.cpp +++ b/Device/Coord/CoordSystem2D.cpp @@ -42,12 +42,12 @@ double axisAngle(size_t i_axis, R3 kf) // ************************************************************************************************ CoordSystem2D::CoordSystem2D(const std::vector<const IAxis*>& axes) - : m_axes(axes) + : ICoordSystem(axes) { } CoordSystem2D::CoordSystem2D(const CoordSystem2D& other) - : m_axes(other.m_axes) + : CoordSystem2D(other.m_axes) { } diff --git a/Device/Coord/CoordSystem2D.h b/Device/Coord/CoordSystem2D.h index 344a79ba8d5..91d1d212f8c 100644 --- a/Device/Coord/CoordSystem2D.h +++ b/Device/Coord/CoordSystem2D.h @@ -45,8 +45,6 @@ public: protected: CoordSystem2D(const CoordSystem2D& other); - std::vector<const IAxis*> m_axes; - private: virtual double calculateValue(size_t i_axis, Coords units, double value) const = 0; }; diff --git a/Device/Coord/ICoordSystem.h b/Device/Coord/ICoordSystem.h index 7e7176dbd91..04355beef99 100644 --- a/Device/Coord/ICoordSystem.h +++ b/Device/Coord/ICoordSystem.h @@ -35,6 +35,10 @@ class IAxis; class ICoordSystem : public ICloneable { public: + ICoordSystem(std::vector<const IAxis*> axes) + : m_axes(axes) + { + } ~ICoordSystem() override; ICoordSystem* clone() const override = 0; @@ -56,6 +60,8 @@ public: protected: Coords substituteDefaultUnits(Coords units) const; + + std::vector<const IAxis*> m_axes; }; #endif // BORNAGAIN_DEVICE_COORD_ICOORDSYSTEM_H -- GitLab