diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/CMakeLists.txt b/openlr/openlr_match_quality/openlr_assessment_tool/CMakeLists.txt index 7730786e92..3aeb1ec6b6 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/CMakeLists.txt +++ b/openlr/openlr_match_quality/openlr_assessment_tool/CMakeLists.txt @@ -16,6 +16,10 @@ set( mainwindow.hpp map_widget.cpp map_widget.hpp + points_controller_delegate_base.hpp + segment_correspondence.cpp + segment_correspondence.hpp + traffic_drawer_delegate_base.hpp traffic_mode.cpp traffic_mode.hpp traffic_panel.cpp diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp index 99452fb775..979d4053d3 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp @@ -1,8 +1,10 @@ #include "openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/map_widget.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/points_controller_delegate_base.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_drawer_delegate_base.hpp" #include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_panel.hpp" #include "openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.h" -#include "openlr/openlr_match_quality/openlr_assessment_tool/map_widget.hpp" #include "map/framework.hpp" diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/points_controller_delegate_base.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/points_controller_delegate_base.hpp new file mode 100644 index 0000000000..b81506a83d --- /dev/null +++ b/openlr/openlr_match_quality/openlr_assessment_tool/points_controller_delegate_base.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "indexer/feature.hpp" + +#include "geometry/point2d.hpp" + +#include + +using FeaturePoint = std::pair; + +/// This class is responsible for collecting junction points and +/// checking user's clicks. +class PointsControllerDelegateBase +{ +public: + enum class ClickType + { + Miss, + Add, + Remove + }; + + virtual std::vector GetAllJunctionPointsInViewport() const = 0; + /// Returns all junction points at a given location in the form of feature id and + /// point index in the feature. + virtual std::pair, m2::PointD> GetCandidatePoints( + m2::PointD const & p) const = 0; + virtual std::vector GetReachablePoints(m2::PointD const & p) const = 0; + + virtual ClickType CheckClick(m2::PointD const & clickPoint, + m2::PointD const & lastClickedPoint, + std::vector const & reachablePoints) const = 0; +}; diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.cpp new file mode 100644 index 0000000000..9174585cac --- /dev/null +++ b/openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.cpp @@ -0,0 +1,43 @@ +#include "openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.hpp" + +SegmentCorrespondence::SegmentCorrespondence(SegmentCorrespondence const & sc) +{ + m_partnerSegment = sc.m_partnerSegment; + + m_matchedPath = sc.m_matchedPath; + m_fakePath = sc.m_fakePath; + m_goldenPath = sc.m_goldenPath; + + m_partnerXMLDoc.reset(sc.m_partnerXMLDoc); + m_partnerXMLSegment = m_partnerXMLDoc.child("reportSegments"); + + m_status = sc.m_status; +} + +SegmentCorrespondence::SegmentCorrespondence(openlr::LinearSegment const & segment, + openlr::Path const & matchedPath, + openlr::Path const & fakePath, + openlr::Path const & goldenPath, + pugi::xml_node const & partnerSegmentXML) + : m_partnerSegment(segment) + , m_matchedPath(matchedPath) + , m_fakePath(fakePath) +{ + SetGoldenPath(goldenPath); + + m_partnerXMLDoc.append_copy(partnerSegmentXML); + m_partnerXMLSegment = m_partnerXMLDoc.child("reportSegments"); + CHECK(m_partnerXMLSegment, ("Node should contain part")); +} + +void SegmentCorrespondence::SetGoldenPath(openlr::Path const & p) +{ + m_goldenPath = p; + m_status = p.empty() ? Status::Untouched : Status::Assessed; +} + +void SegmentCorrespondence::Ignore() +{ + m_status = Status::Ignored; + m_goldenPath.clear(); +} diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.hpp new file mode 100644 index 0000000000..01791ab309 --- /dev/null +++ b/openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "openlr/decoded_path.hpp" +#include "openlr/openlr_model.hpp" + +#include "3party/pugixml/src/pugixml.hpp" + +class SegmentCorrespondence +{ +public: + enum class Status + { + Untouched, + Assessed, + Ignored + }; + + SegmentCorrespondence(SegmentCorrespondence const & sc); + SegmentCorrespondence(openlr::LinearSegment const & segment, + openlr::Path const & matchedPath, + openlr::Path const & fakePath, + openlr::Path const & goldenPath, + pugi::xml_node const & partnerSegmentXML); + + openlr::Path const & GetMatchedPath() const { return m_matchedPath; } + openlr::Path const & GetFakePath() const { return m_fakePath; } + + openlr::Path const & GetGoldenPath() const { return m_goldenPath; } + void SetGoldenPath(openlr::Path const & p); + + openlr::LinearSegment const & GetPartnerSegment() const { return m_partnerSegment; } + + uint32_t GetPartnerSegmentId() const { return m_partnerSegment.m_segmentId; } + + pugi::xml_document const & GetPartnerXML() const { return m_partnerXMLDoc; } + pugi::xml_node const & GetPartnerXMLSegment() const { return m_partnerXMLSegment; } + + Status GetStatus() const { return m_status; } + + void Ignore(); + +private: + openlr::LinearSegment m_partnerSegment; + + openlr::Path m_matchedPath; + openlr::Path m_fakePath; + openlr::Path m_goldenPath; + + // A dirty hack to save back SegmentCorrespondence. + // TODO(mgsergio): Consider unifying xml serialization with one used in openlr_stat. + pugi::xml_document m_partnerXMLDoc; + // This is used by GetPartnerXMLSegment shortcut to return const ref. pugi::xml_node is + // just a wrapper so returning by value won't guarantee constness. + pugi::xml_node m_partnerXMLSegment; + + Status m_status = Status::Untouched; +}; diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_drawer_delegate_base.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_drawer_delegate_base.hpp new file mode 100644 index 0000000000..f35c465b86 --- /dev/null +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_drawer_delegate_base.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include + +/// This class is used to delegate segments drawing to the DrapeEngine. +class TrafficDrawerDelegateBase +{ +public: + virtual ~TrafficDrawerDelegateBase() = default; + + virtual void SetViewportCenter(m2::PointD const & center) = 0; + + virtual void DrawDecodedSegments(std::vector const & points) = 0; + virtual void DrawEncodedSegment(std::vector const & points) = 0; + virtual void DrawGoldenPath(std::vector const & points) = 0; + + virtual void ClearGoldenPath() = 0; + virtual void ClearAllPaths() = 0; + + virtual void VisualizePoints(std::vector const & points) = 0; + virtual void ClearAllVisualizedPoints() = 0; +}; diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp index eb13692745..f077b4750e 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp @@ -1,6 +1,8 @@ #pragma once -#include "indexer/feature.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/points_controller_delegate_base.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/segment_correspondence.hpp" +#include "openlr/openlr_match_quality/openlr_assessment_tool/traffic_drawer_delegate_base.hpp" #include "openlr/decoded_path.hpp" #include "openlr/openlr_model.hpp" @@ -24,8 +26,6 @@ class Selection; DECLARE_EXCEPTION(TrafficModeError, RootException); -using FeaturePoint = std::pair; - namespace impl { /// This class denotes a "non-deterministic" feature point. @@ -54,131 +54,8 @@ private: }; } // namespace impl -class SegmentCorrespondence -{ -public: - enum class Status - { - Untouched, - Assessed, - Ignored - }; - - SegmentCorrespondence(SegmentCorrespondence const & sc) - { - m_partnerSegment = sc.m_partnerSegment; - - m_matchedPath = sc.m_matchedPath; - m_fakePath = sc.m_fakePath; - m_goldenPath = sc.m_goldenPath; - - m_partnerXMLDoc.reset(sc.m_partnerXMLDoc); - m_partnerXMLSegment = m_partnerXMLDoc.child("reportSegments"); - - m_status = sc.m_status; - } - - SegmentCorrespondence(openlr::LinearSegment const & segment, - openlr::Path const & matchedPath, - openlr::Path const & fakePath, - openlr::Path const & goldenPath, - pugi::xml_node const & partnerSegmentXML) : m_partnerSegment(segment) - , m_matchedPath(matchedPath) - , m_fakePath(fakePath) - { - SetGoldenPath(goldenPath); - - m_partnerXMLDoc.append_copy(partnerSegmentXML); - m_partnerXMLSegment = m_partnerXMLDoc.child("reportSegments"); - CHECK(m_partnerXMLSegment, ("Node should contain part")); - } - - openlr::Path const & GetMatchedPath() const { return m_matchedPath; } - openlr::Path const & GetFakePath() const { return m_fakePath; } - - openlr::Path const & GetGoldenPath() const { return m_goldenPath; } - void SetGoldenPath(openlr::Path const & p) { - m_goldenPath = p; - m_status = p.empty() ? Status::Untouched : Status::Assessed; - } - - openlr::LinearSegment const & GetPartnerSegment() const { return m_partnerSegment; } - - uint32_t GetPartnerSegmentId() const { return m_partnerSegment.m_segmentId; } - - pugi::xml_document const & GetPartnerXML() const { return m_partnerXMLDoc; } - pugi::xml_node const & GetPartnerXMLSegment() const { return m_partnerXMLSegment; } - - Status GetStatus() const { return m_status; } - - void Ignore() - { - m_status = Status::Ignored; - m_goldenPath.clear(); - } - -private: - openlr::LinearSegment m_partnerSegment; - - openlr::Path m_matchedPath; - openlr::Path m_fakePath; - openlr::Path m_goldenPath; - - // A dirty hack to save back SegmentCorrespondence. - // TODO(mgsergio): Consider unifying xml serialization with one used in openlr_stat. - pugi::xml_document m_partnerXMLDoc; - // This is used by GetPartnerXMLSegment shortcut to return const ref. pugi::xml_node is - // just a wrapper so returning by value won't guarantee constness. - pugi::xml_node m_partnerXMLSegment; - - Status m_status = Status::Untouched; -}; - -/// This class is used to delegate segments drawing to the DrapeEngine. -class TrafficDrawerDelegateBase -{ -public: - virtual ~TrafficDrawerDelegateBase() = default; - - virtual void SetViewportCenter(m2::PointD const & center) = 0; - - virtual void DrawDecodedSegments(std::vector const & points) = 0; - virtual void DrawEncodedSegment(std::vector const & points) = 0; - virtual void DrawGoldenPath(std::vector const & points) = 0; - - virtual void ClearGoldenPath() = 0; - virtual void ClearAllPaths() = 0; - - virtual void VisualizePoints(std::vector const & points) = 0; - virtual void ClearAllVisualizedPoints() = 0; -}; - class BookmarkManager; -/// This class is responsible for collecting junction points and -/// checking user's clicks. -class PointsControllerDelegateBase -{ -public: - enum class ClickType - { - Miss, - Add, - Remove - }; - - virtual std::vector GetAllJunctionPointsInViewport() const = 0; - /// Returns all junction points at a given location in the form of feature id and - /// point index in the feature. - virtual std::pair, m2::PointD> GetCandidatePoints( - m2::PointD const & p) const = 0; - virtual std::vector GetReachablePoints(m2::PointD const & p) const = 0; - - virtual ClickType CheckClick(m2::PointD const & clickPoint, - m2::PointD const & lastClickedPoint, - std::vector const & reachablePoints) const = 0; -}; - /// This class is used to map sample ids to real data /// and change sample evaluations. class TrafficMode : public QAbstractTableModel