/** * @RDE_HEADER@ * CoordinateTranslation * $Id$ * $HeadURL$ * $Author$ */ #pragma once // Own #include // #define WITH_LOGGING #ifdef WITH_LOGGING # include #endif // WITH_LOGGING // ESRI // Qt #include //---------------------------------------------------------------------------- namespace SituationMap { //forward: class CoordTranslationFunctor; class AbstractMapObjectImpl; class SITUATIONMAP_EXPORT TranslatedBase { public: explicit TranslatedBase() = default; virtual ~TranslatedBase() = default; // use ONE of the following methods to set functor: void setCoordTransFunctor(CoordTranslationFunctor *functor); // set functor direct void setMapObjectImpl(AbstractMapObjectImpl *mapObjectImpl); // MapObject->Map->functor bool isTranslated() const { return m_translated; } virtual bool isEmpty() const = 0; protected: mutable CoordTranslationFunctor *m_coordTransFunctor = nullptr; AbstractMapObjectImpl *m_mapObjectImpl = nullptr; ///< parent / host mutable bool m_translated = false; }; class SITUATIONMAP_EXPORT OriginTranslated final : public TranslatedBase { public: OriginTranslated(); Point3D origin() const; bool setOrigin(const Point3D &origin); const Point3D &originTranslated() const; void clear() { m_origin = Point3D(); } bool isEmpty() const { return m_origin.isNull(); } /** * @brief operator== Compare two objects * @param other to be compared with * @return True if identical, otherwise false. */ bool operator==(const OriginTranslated &other) const { // m_positionsTranslated must be skipped! return ((this->m_origin == other.m_origin)); } /** * @brief operator!= Compare two objects * @param other to be compared with * @return True if NOT identical, otherwise false. */ bool operator!=(const OriginTranslated &other) const { return !(*this == other); } private: #ifdef WITH_LOGGING LOGGER_T m_logger; ///< Interface of the Logging-Facility #endif Point3D m_origin; mutable Point3D m_originTranslated; }; /** * @brief The PositionsTranslated class to translate positions of simulation world to map coordinate. * A the translation is done using the CoordTranslationFunctor. * (A copy of this object is not allowed since inner mutex can“t be copied.) */ class SITUATIONMAP_EXPORT PositionsTranslated : public TranslatedBase { public: PositionsTranslated(); // disable copy PositionsTranslated(const PositionsTranslated &) = delete; PositionsTranslated &operator=(const PositionsTranslated &) = delete; PositionCont positions() const; bool setPositions(const PositionCont &posCont); void addSinglePosition(const Point3D &singlePositions); bool setPositionsTranslated(const PositionCont &posCont); int size() const; bool isEmpty() const; void clear(); Point3D first(); Point3D last(); bool isTranslated() const { return m_translated && m_singlePositions.isEmpty(); } const PositionCont &positionsTranslated() const; const Point3D &startPointTranslated() const; const Point3D &endPointTranslated() const; double angleOfStartSegment() const; double angleOfEndSegment() const; double angleOfClosingSegment() const; ///< Angle between end and start /** * @brief operator== Compare two objects * @param other to be compared with * @return True if identical, otherwise false. */ bool operator==(const PositionsTranslated &other) const { // m_positionsTranslated must be skipped! return ((this->m_positions == other.m_positions)); } /** * @brief operator!= Compare two objects * @param other to be compared with * @return True if NOT identical, otherwise false. */ bool operator!=(const PositionsTranslated &other) const { return !(*this == other); } protected: void consolidate() const; // method is const private: #ifdef WITH_LOGGING LOGGER_T m_logger; ///< Interface of the Logging-Facility #endif PositionCont geographicToMap(const PositionCont &positions) const; mutable PositionCont m_positions; // mutable to enable consolidate mutable PositionCont m_singlePositions; // mutable to enable consolidate mutable PositionCont m_positionsTranslated; // mutable to enable positionsTranslated mutable QMutex m_mutex; }; } // namespace SituationMap