forked from organicmaps/organicmaps
[OpenLR-tool] Mark matched path as golden.
This commit is contained in:
parent
d79fdcb53d
commit
485b4c6f3e
4 changed files with 50 additions and 20 deletions
|
@ -273,6 +273,8 @@ MainWindow::MainWindow(Framework & framework, std::string const & url, std::stri
|
|||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
m_goldifyMatchedPathAction = fileMenu->addAction(
|
||||
"Goldify", [this] { m_trafficMode->GoldifyMatchedPath(); }, QKeySequence("Ctrl+G"));
|
||||
m_startEditingAction = fileMenu->addAction("Edit",
|
||||
[this] {
|
||||
m_trafficMode->StartBuildingPath();
|
||||
|
@ -300,6 +302,7 @@ MainWindow::MainWindow(Framework & framework, std::string const & url, std::stri
|
|||
},
|
||||
QKeySequence("Ctrl+I"));
|
||||
|
||||
m_goldifyMatchedPathAction->setEnabled(false /* enabled */);
|
||||
m_closeTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_saveTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_startEditingAction->setEnabled(false /* enabled */);
|
||||
|
@ -361,6 +364,7 @@ void MainWindow::OnOpenTrafficSample()
|
|||
return;
|
||||
}
|
||||
|
||||
m_goldifyMatchedPathAction->setEnabled(true /* enabled */);
|
||||
m_closeTrafficSampleAction->setEnabled(true /* enabled */);
|
||||
m_saveTrafficSampleAction->setEnabled(true /* enabled */);
|
||||
m_startEditingAction->setEnabled(true /* enabled */);
|
||||
|
@ -373,6 +377,7 @@ void MainWindow::OnCloseTrafficSample()
|
|||
// If not saved, ask a user if he/she wants to save.
|
||||
// OnSaveTrafficSample()
|
||||
|
||||
m_goldifyMatchedPathAction->setEnabled(false /* enabled */);
|
||||
m_saveTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_closeTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_startEditingAction->setEnabled(false /* enabled */);
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
openlr::TrafficMode * m_trafficMode = nullptr;
|
||||
QDockWidget * m_docWidget = nullptr;
|
||||
|
||||
QAction * m_goldifyMatchedPathAction = nullptr;
|
||||
QAction * m_saveTrafficSampleAction = nullptr;
|
||||
QAction * m_closeTrafficSampleAction = nullptr;
|
||||
QAction * m_startEditingAction = nullptr;
|
||||
|
|
|
@ -268,29 +268,33 @@ Qt::ItemFlags TrafficMode::flags(QModelIndex const & index) const
|
|||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
void TrafficMode::GoldifyMatchedPath()
|
||||
{
|
||||
if (!m_currentSegment->HasMatchedPath())
|
||||
{
|
||||
QMessageBox::information(nullptr /* parent */, "Error",
|
||||
"The selected segment does not have a matched path");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!StartBuildingPathChecks())
|
||||
return;
|
||||
|
||||
m_currentSegment->SetGoldenPath(m_currentSegment->GetMatchedPath());
|
||||
m_goldenPath.clear();
|
||||
m_drawerDelegate->DrawGoldenPath(GetPoints(m_currentSegment->GetGoldenPath()));
|
||||
}
|
||||
|
||||
void TrafficMode::StartBuildingPath()
|
||||
{
|
||||
CHECK(m_currentSegment, ("A segment should be selected before path building is started."));
|
||||
|
||||
if (m_buildingPath)
|
||||
MYTHROW(TrafficModeError, ("Path building already in progress."));
|
||||
|
||||
if (m_currentSegment->HasGoldenPath())
|
||||
{
|
||||
auto const btn = QMessageBox::question(
|
||||
nullptr,
|
||||
"Override warning",
|
||||
"The selected segment already has a golden path. Do you want to override?");
|
||||
if (btn == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
if (!StartBuildingPathChecks())
|
||||
return;
|
||||
|
||||
m_currentSegment->SetGoldenPath({});
|
||||
|
||||
m_buildingPath = true;
|
||||
m_drawerDelegate->ClearGoldenPath();
|
||||
m_drawerDelegate->VisualizePoints(
|
||||
m_pointsDelegate->GetAllJunctionPointsInViewport());
|
||||
m_drawerDelegate->VisualizePoints(m_pointsDelegate->GetAllJunctionPointsInViewport());
|
||||
}
|
||||
|
||||
void TrafficMode::PushPoint(m2::PointD const & coord, std::vector<FeaturePoint> const & points)
|
||||
|
@ -382,10 +386,9 @@ void TrafficMode::IgnorePath()
|
|||
|
||||
if (m_currentSegment->HasGoldenPath())
|
||||
{
|
||||
auto const btn = QMessageBox::question(
|
||||
nullptr,
|
||||
"Override warning",
|
||||
"The selected segment has a golden path. Do you want to discard it?");
|
||||
auto const btn =
|
||||
QMessageBox::question(nullptr /* parent */, "Override warning",
|
||||
"The selected segment has a golden path. Do you want to discard it?");
|
||||
if (btn == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
|
@ -502,4 +505,23 @@ void TrafficMode::HandlePoint(m2::PointD clickPoint, Qt::MouseButton const butto
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool TrafficMode::StartBuildingPathChecks() const
|
||||
{
|
||||
CHECK(m_currentSegment, ("A segment should be selected before path building is started."));
|
||||
|
||||
if (m_buildingPath)
|
||||
MYTHROW(TrafficModeError, ("Path building already in progress."));
|
||||
|
||||
if (m_currentSegment->HasGoldenPath())
|
||||
{
|
||||
auto const btn = QMessageBox::question(
|
||||
nullptr /* parent */, "Override warning",
|
||||
"The selected segment already has a golden path. Do you want to override?");
|
||||
if (btn == QMessageBox::No)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace openlr
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
Qt::ItemFlags flags(QModelIndex const & index) const Q_DECL_OVERRIDE;
|
||||
|
||||
bool IsBuildingPath() const { return m_buildingPath; }
|
||||
void GoldifyMatchedPath();
|
||||
void StartBuildingPath();
|
||||
void PushPoint(m2::PointD const & coord,
|
||||
std::vector<FeaturePoint> const & points);
|
||||
|
@ -110,6 +111,7 @@ signals:
|
|||
|
||||
private:
|
||||
void HandlePoint(m2::PointD clickPoint, Qt::MouseButton const button);
|
||||
bool StartBuildingPathChecks() const;
|
||||
|
||||
Index const & m_index;
|
||||
std::vector<SegmentCorrespondence> m_segments;
|
||||
|
|
Loading…
Add table
Reference in a new issue