mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[traff_assessment_tool] On click, zoom to message and show reference points
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -4,8 +4,12 @@
|
|||||||
#include "openlr/openlr_model_xml.hpp"
|
#include "openlr/openlr_model_xml.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "drape_frontend/drape_api.hpp"
|
||||||
|
|
||||||
#include "indexer/data_source.hpp"
|
#include "indexer/data_source.hpp"
|
||||||
|
|
||||||
|
#include "map/framework.hpp"
|
||||||
|
|
||||||
#include "base/assert.hpp"
|
#include "base/assert.hpp"
|
||||||
#include "base/scope_guard.hpp"
|
#include "base/scope_guard.hpp"
|
||||||
|
|
||||||
@@ -291,6 +295,7 @@ TrafficModel::TrafficModel(Framework & framework, DataSource const & dataSource,
|
|||||||
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate, // TODO do we need that?
|
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate, // TODO do we need that?
|
||||||
QObject * parent)
|
QObject * parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
|
, m_framework(framework)
|
||||||
, m_dataSource(dataSource)
|
, m_dataSource(dataSource)
|
||||||
, m_drawerDelegate(std::move(drawerDelegate))
|
, m_drawerDelegate(std::move(drawerDelegate))
|
||||||
, m_pointsDelegate(std::move(pointsDelegate))
|
, m_pointsDelegate(std::move(pointsDelegate))
|
||||||
@@ -427,30 +432,44 @@ QVariant TrafficModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
|
|
||||||
void TrafficModel::OnItemSelected(QItemSelection const & selected, QItemSelection const &)
|
void TrafficModel::OnItemSelected(QItemSelection const & selected, QItemSelection const &)
|
||||||
{
|
{
|
||||||
#ifdef openlr_obsolete
|
|
||||||
ASSERT(!selected.empty(), ());
|
ASSERT(!selected.empty(), ());
|
||||||
ASSERT(!m_segments.empty(), ());
|
ASSERT(!m_messages.empty(), ());
|
||||||
|
|
||||||
auto const row = selected.front().top();
|
auto const row = selected.front().top();
|
||||||
|
|
||||||
CHECK_LESS(static_cast<size_t>(row), m_segments.size(), ());
|
CHECK_LESS(static_cast<size_t>(row), m_messages.size(), ());
|
||||||
m_currentSegment = &m_segments[row];
|
auto message = &m_messages[row];
|
||||||
|
if (!message->m_location)
|
||||||
|
return;
|
||||||
|
|
||||||
auto const & partnerSegment = m_currentSegment->GetPartnerSegment();
|
m2::RectD rect;
|
||||||
auto const & partnerSegmentPoints = partnerSegment.GetMercatorPoints();
|
std::vector<m2::PointD> points;
|
||||||
auto const & viewportCenter = partnerSegmentPoints.front();
|
|
||||||
|
|
||||||
m_drawerDelegate->ClearAllPaths();
|
for (auto & coords : {
|
||||||
// TODO(mgsergio): Use a better way to set viewport and scale.
|
message->m_location.value().m_from,
|
||||||
m_drawerDelegate->SetViewportCenter(viewportCenter);
|
message->m_location.value().m_at,
|
||||||
m_drawerDelegate->DrawEncodedSegment(partnerSegmentPoints);
|
message->m_location.value().m_via,
|
||||||
if (m_currentSegment->HasMatchedPath())
|
message->m_location.value().m_notVia,
|
||||||
m_drawerDelegate->DrawDecodedSegments(GetPoints(m_currentSegment->GetMatchedPath()));
|
message->m_location.value().m_to
|
||||||
if (m_currentSegment->HasGoldenPath())
|
})
|
||||||
m_drawerDelegate->DrawGoldenPath(GetPoints(m_currentSegment->GetGoldenPath()));
|
if (coords)
|
||||||
|
{
|
||||||
|
auto point = mercator::FromLatLon(coords.value().m_coordinates);
|
||||||
|
rect.Add(point);
|
||||||
|
points.push_back(point);
|
||||||
|
}
|
||||||
|
|
||||||
emit SegmentSelected(static_cast<int>(partnerSegment.m_segmentId));
|
if (rect.IsValid())
|
||||||
#endif
|
{
|
||||||
|
rect.Scale(1.5);
|
||||||
|
m_framework.ShowRect(rect, 15 /* maxScale */, true /* animation */, true /* useVisibleViewport */);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto editSession = m_framework.GetBookmarkManager().GetEditSession();
|
||||||
|
editSession.ClearGroup(UserMark::Type::DEBUG_MARK);
|
||||||
|
editSession.SetIsVisible(UserMark::Type::DEBUG_MARK, true);
|
||||||
|
for (auto const & p : points)
|
||||||
|
editSession.CreateUserMark<DebugMarkPoint>(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags TrafficModel::flags(QModelIndex const & index) const
|
Qt::ItemFlags TrafficModel::flags(QModelIndex const & index) const
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ private:
|
|||||||
bool StartBuildingPathChecks() const;
|
bool StartBuildingPathChecks() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Framework & m_framework;
|
||||||
DataSource const & m_dataSource;
|
DataSource const & m_dataSource;
|
||||||
#ifdef openlr_obsolete
|
#ifdef openlr_obsolete
|
||||||
std::vector<SegmentCorrespondence> m_segments;
|
std::vector<SegmentCorrespondence> m_segments;
|
||||||
|
|||||||
Reference in New Issue
Block a user