Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--map/framework.cpp22
-rw-r--r--map/framework.hpp4
-rw-r--r--qt/draw_widget.cpp142
-rw-r--r--qt/draw_widget.hpp10
-rw-r--r--qt/mainwindow.cpp73
-rw-r--r--qt/mwms_borders_selection.cpp24
-rw-r--r--qt/mwms_borders_selection.hpp12
7 files changed, 171 insertions, 116 deletions
diff --git a/map/framework.cpp b/map/framework.cpp
index c6f36039dd..48769cc3a4 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -3500,27 +3500,21 @@ void VisualizeFeatureInRect(m2::RectD const & rect, FeatureType & ft, df::DrapeA
} // namespace
void Framework::DrawMwmBorder(std::string const & mwmName,
- std::vector<m2::RegionD> const & polygons, bool withPoints)
+ std::vector<m2::RegionD> const & regions, bool withVertices)
{
- for (auto const & region : polygons)
+ for (auto const & region : regions)
{
auto const points = region.Data();
if (points.empty())
return;
static uint32_t kColorCounter = 0;
- if (withPoints)
- {
- m_drapeApi.AddLine(mwmName, df::DrapeApiLineData(points, colorList[kColorCounter])
- .Width(4.0f)
- .ShowId()
- .ShowPoints(true));
- }
- else
- {
- m_drapeApi.AddLine(
- mwmName, df::DrapeApiLineData(points, colorList[kColorCounter]).Width(4.0f).ShowId());
- }
+
+ auto lineData = df::DrapeApiLineData(points, colorList[kColorCounter]).Width(4.0f).ShowId();
+ if (withVertices)
+ lineData.ShowPoints(true /* markPoints */);
+
+ m_drapeApi.AddLine(mwmName, lineData);
kColorCounter = (kColorCounter + 1) % colorList.size();
}
diff --git a/map/framework.hpp b/map/framework.hpp
index 95c1c4c8c2..7a5e2488c2 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -407,8 +407,8 @@ public:
/// Used to "refresh" UI in some cases (e.g. feature editing).
void UpdatePlacePageInfoForCurrentSelection();
- void DrawMwmBorder(std::string const & mwmName, std::vector<m2::RegionD> const & points,
- bool withPoints);
+ void DrawMwmBorder(std::string const & mwmName, std::vector<m2::RegionD> const & regions,
+ bool withVertices);
/// Called to notify UI that object on a map was selected (UI should show Place Page, for example).
using TActivateMapSelectionFn = function<void (place_page::Info const &)>;
diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp
index 163fce5a20..3e78264403 100644
--- a/qt/draw_widget.cpp
+++ b/qt/draw_widget.cpp
@@ -250,10 +250,10 @@ void DrawWidget::mouseMoveEvent(QMouseEvent * e)
}
}
-void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withPoints,
- bool fromPackedPolygon)
+void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices,
+ bool fromPackedPolygon, bool boundingBox)
{
- auto const getPolygons = [&](std::string const & mwmName)
+ auto const getRegions = [&](std::string const & mwmName)
{
if (fromPackedPolygon)
{
@@ -286,12 +286,26 @@ void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withPoi
}
};
- auto const mwmNames = m_framework.GetRegionsCountryIdByRect(rect, false /* rough */);
+ auto mwmNames = m_framework.GetRegionsCountryIdByRect(rect, false /* rough */);
- for (auto const & mwmName : mwmNames)
+ for (auto & mwmName : mwmNames)
{
- auto const polygons = getPolygons(mwmName);
- m_framework.DrawMwmBorder(mwmName, polygons, withPoints);
+ auto regions = getRegions(mwmName);
+ mwmName += fromPackedPolygon ? ".bin" : ".poly";
+ if (boundingBox)
+ {
+ std::vector<m2::RegionD> boxes;
+ for (auto const & region : regions)
+ {
+ auto const r = region.GetRect();
+ boxes.emplace_back(std::vector<m2::PointD>({r.LeftBottom(), r.LeftTop(), r.RightTop(),
+ r.RightBottom(), r.LeftBottom()}));
+ }
+
+ regions = std::move(boxes);
+ mwmName += ".box";
+ }
+ m_framework.DrawMwmBorder(mwmName, regions, withVertices);
}
}
@@ -308,54 +322,76 @@ void DrawWidget::mouseReleaseEvent(QMouseEvent * e)
else if (m_currentSelectionMode && IsRightButton(e) &&
m_rubberBand != nullptr && m_rubberBand->isVisible())
{
- QPoint const lt = m_rubberBand->geometry().topLeft();
- QPoint const rb = m_rubberBand->geometry().bottomRight();
- m2::RectD rect;
- rect.Add(m_framework.PtoG(m2::PointD(L2D(lt.x()), L2D(lt.y()))));
- rect.Add(m_framework.PtoG(m2::PointD(L2D(rb.x()), L2D(rb.y()))));
- switch (*m_currentSelectionMode)
- {
- case SelectionMode::Features:
- {
- m_framework.VisualizeRoadsInRect(rect);
- break;
- }
- case SelectionMode::CityBoundaries:
- {
- m_framework.VisualizeCityBoundariesInRect(rect);
- break;
- }
- case SelectionMode::CityRoads:
- {
- m_framework.VisualizeCityRoadsInRect(rect);
- break;
- }
- case SelectionMode::MwmsBordersByPolyFiles:
- {
- VisualizeMwmsBordersInRect(rect, false /* withPoints */, false /* fromPackedPolygon */);
- break;
- }
- case SelectionMode::MwmsBordersWithPointsByPolyFiles:
- {
- VisualizeMwmsBordersInRect(rect, true /* withPoints */, false /* fromPackedPolygon */);
- break;
- }
- case SelectionMode::MwmsBordersByPackedPolygon:
- {
- VisualizeMwmsBordersInRect(rect, false /* withPoints */, true /* fromPackedPolygon */);
- break;
- }
- case SelectionMode::MwmsBordersWithPointsByPackedPolygon:
- {
- VisualizeMwmsBordersInRect(rect, true /* withPoints */, true /* fromPackedPolygon */);
- break;
- }
- default:
- UNREACHABLE();
- }
+ ProcessSelectionMode();
+ }
+}
+
+void DrawWidget::ProcessSelectionMode()
+{
+ QPoint const lt = m_rubberBand->geometry().topLeft();
+ QPoint const rb = m_rubberBand->geometry().bottomRight();
+ m2::RectD rect;
+ rect.Add(m_framework.PtoG(m2::PointD(L2D(lt.x()), L2D(lt.y()))));
+ rect.Add(m_framework.PtoG(m2::PointD(L2D(rb.x()), L2D(rb.y()))));
- m_rubberBand->hide();
+ switch (*m_currentSelectionMode)
+ {
+ case SelectionMode::Features:
+ {
+ m_framework.VisualizeRoadsInRect(rect);
+ break;
+ }
+ case SelectionMode::CityBoundaries:
+ {
+ m_framework.VisualizeCityBoundariesInRect(rect);
+ break;
+ }
+ case SelectionMode::CityRoads:
+ {
+ m_framework.VisualizeCityRoadsInRect(rect);
+ break;
}
+ case SelectionMode::MwmsBordersByPolyFiles:
+ {
+ VisualizeMwmsBordersInRect(rect, false /* withVertices */, false /* fromPackedPolygon */,
+ false /* boundingBox */);
+ break;
+ }
+ case SelectionMode::MwmsBordersWithVerticesByPolyFiles:
+ {
+ VisualizeMwmsBordersInRect(rect, true /* withVertices */, false /* fromPackedPolygon */,
+ false /* boundingBox */);
+ break;
+ }
+ case SelectionMode::MwmsBordersByPackedPolygon:
+ {
+ VisualizeMwmsBordersInRect(rect, false /* withVertices */, true /* fromPackedPolygon */,
+ false /* boundingBox */);
+ break;
+ }
+ case SelectionMode::MwmsBordersWithVerticesByPackedPolygon:
+ {
+ VisualizeMwmsBordersInRect(rect, true /* withVertices */, true /* fromPackedPolygon */,
+ false /* boundingBox */);
+ break;
+ }
+ case SelectionMode::BoundingBoxByPolyFiles:
+ {
+ VisualizeMwmsBordersInRect(rect, true /* withVertices */, false /* fromPackedPolygon */,
+ true /* boundingBox */);
+ break;
+ }
+ case SelectionMode::BoundingBoxByPackedPolygon:
+ {
+ VisualizeMwmsBordersInRect(rect, true /* withVertices */, true /* fromPackedPolygon */,
+ true /* boundingBox */);
+ break;
+ }
+ default:
+ UNREACHABLE();
+ }
+
+ m_rubberBand->hide();
}
void DrawWidget::keyPressEvent(QKeyEvent * e)
diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp
index dbc5bee990..7c9fc68e4c 100644
--- a/qt/draw_widget.hpp
+++ b/qt/draw_widget.hpp
@@ -109,7 +109,8 @@ private:
void UpdateCountryStatus(storage::CountryId const & countryId);
- void VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withPoints, bool fromPackedPolygon);
+ void VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices,
+ bool fromPackedPolygon, bool boundingBox);
m2::PointD GetCoordsFromSettingsIfExists(bool start, m2::PointD const & pt);
@@ -128,9 +129,11 @@ public:
CityBoundaries,
CityRoads,
MwmsBordersByPolyFiles,
- MwmsBordersWithPointsByPolyFiles,
+ MwmsBordersWithVerticesByPolyFiles,
MwmsBordersByPackedPolygon,
- MwmsBordersWithPointsByPackedPolygon
+ MwmsBordersWithVerticesByPackedPolygon,
+ BoundingBoxByPolyFiles,
+ BoundingBoxByPackedPolygon,
};
void SetSelectionMode(SelectionMode mode) { m_currentSelectionMode = {mode}; }
@@ -139,6 +142,7 @@ public:
SelectionMode GetSelectionMode() const { return *m_currentSelectionMode; }
private:
+ void ProcessSelectionMode();
boost::optional<SelectionMode> m_currentSelectionMode;
RouteMarkType m_routePointAddMode = RouteMarkType::Finish;
diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp
index 0b65131be2..d352c33887 100644
--- a/qt/mainwindow.cpp
+++ b/qt/mainwindow.cpp
@@ -60,6 +60,44 @@
#endif // NO_DOWNLOADER
+namespace
+{
+using namespace qt;
+
+DrawWidget::SelectionMode ConvertFromMwmsBordersSelection(qt::MwmsBordersSelection::Response mode)
+{
+ switch (mode)
+ {
+ case MwmsBordersSelection::Response::MwmsBordersByPolyFiles:
+ {
+ return DrawWidget::SelectionMode::MwmsBordersByPolyFiles;
+ }
+ case MwmsBordersSelection::Response::MwmsBordersWithVerticesByPolyFiles:
+ {
+ return DrawWidget::SelectionMode::MwmsBordersWithVerticesByPolyFiles;
+ }
+ case MwmsBordersSelection::Response::MwmsBordersByPackedPolygon:
+ {
+ return DrawWidget::SelectionMode::MwmsBordersByPackedPolygon;
+ }
+ case MwmsBordersSelection::Response::MwmsBordersWithVerticesByPackedPolygon:
+ {
+ return DrawWidget::SelectionMode::MwmsBordersWithVerticesByPackedPolygon;
+ }
+ case MwmsBordersSelection::Response::BoundingBoxByPolyFiles:
+ {
+ return DrawWidget::SelectionMode::BoundingBoxByPolyFiles;
+ }
+ case MwmsBordersSelection::Response::BoundingBoxByPackedPolygon:
+ {
+ return DrawWidget::SelectionMode::BoundingBoxByPackedPolygon;
+ }
+ default:
+ UNREACHABLE();
+ }
+}
+} // namespace
+
namespace qt
{
// Defined in osm_auth_dialog.cpp.
@@ -275,9 +313,9 @@ void FormatMapSize(uint64_t sizeInBytes, string & units, size_t & sizeToDownload
bool IsMwmsBordersSelectionMode(DrawWidget::SelectionMode mode)
{
return mode == DrawWidget::SelectionMode::MwmsBordersByPolyFiles ||
- mode == DrawWidget::SelectionMode::MwmsBordersWithPointsByPolyFiles ||
+ mode == DrawWidget::SelectionMode::MwmsBordersWithVerticesByPolyFiles ||
mode == DrawWidget::SelectionMode::MwmsBordersByPackedPolygon ||
- mode == DrawWidget::SelectionMode::MwmsBordersWithPointsByPackedPolygon;
+ mode == DrawWidget::SelectionMode::MwmsBordersWithVerticesByPackedPolygon;
}
} // namespace
@@ -659,42 +697,13 @@ void MainWindow::OnSwitchMwmsBordersSelectionMode()
return;
}
- CHECK(response == MwmsBordersSelection::Response::JustBordersByPolyFiles ||
- response == MwmsBordersSelection::Response::WithPointsAndBordersByPolyFiles ||
- response == MwmsBordersSelection::Response::JustBordersByPackedPolygon ||
- response == MwmsBordersSelection::Response::WithPointsAndBordersByPackedPolygon, ());
-
m_selectionMode->setChecked(false);
m_selectionCityBoundariesMode->setChecked(false);
m_selectionCityRoadsMode->setChecked(false);
m_selectionMwmsBordersMode->setChecked(true);
- switch (response)
- {
- case MwmsBordersSelection::Response::JustBordersByPolyFiles:
- {
- m_pDrawWidget->SetSelectionMode(DrawWidget::SelectionMode::MwmsBordersByPolyFiles);
- break;
- }
- case MwmsBordersSelection::Response::WithPointsAndBordersByPolyFiles:
- {
- m_pDrawWidget->SetSelectionMode(DrawWidget::SelectionMode::MwmsBordersWithPointsByPolyFiles);
- break;
- }
- case MwmsBordersSelection::Response::JustBordersByPackedPolygon:
- {
- m_pDrawWidget->SetSelectionMode(DrawWidget::SelectionMode::MwmsBordersByPackedPolygon);
- break;
- }
- case MwmsBordersSelection::Response::WithPointsAndBordersByPackedPolygon:
- {
- m_pDrawWidget->SetSelectionMode(DrawWidget::SelectionMode::MwmsBordersWithPointsByPackedPolygon);
- break;
- }
- default:
- UNREACHABLE();
- }
+ m_pDrawWidget->SetSelectionMode(ConvertFromMwmsBordersSelection(response));
}
void MainWindow::OnClearSelection()
diff --git a/qt/mwms_borders_selection.cpp b/qt/mwms_borders_selection.cpp
index 280e924cf6..e7ea331f75 100644
--- a/qt/mwms_borders_selection.cpp
+++ b/qt/mwms_borders_selection.cpp
@@ -49,10 +49,13 @@ MwmsBordersSelection::Response MwmsBordersSelection::ShowModal()
if (m_radioBordersFromData->isChecked())
{
if (m_radioJustBorders->isChecked())
- return Response::JustBordersByPolyFiles;
+ return Response::MwmsBordersByPolyFiles;
if (m_radioWithPoints->isChecked())
- return Response::WithPointsAndBordersByPolyFiles;
+ return Response::MwmsBordersWithVerticesByPolyFiles;
+
+ if (m_radioBoundingBox->isChecked())
+ return Response::BoundingBoxByPolyFiles;
UNREACHABLE();
}
@@ -60,10 +63,13 @@ MwmsBordersSelection::Response MwmsBordersSelection::ShowModal()
if (m_radioBordersFromPackedPolygon->isChecked())
{
if (m_radioJustBorders->isChecked())
- return Response::JustBordersByPackedPolygon;
+ return Response::MwmsBordersByPackedPolygon;
if (m_radioWithPoints->isChecked())
- return Response::WithPointsAndBordersByPackedPolygon;
+ return Response::MwmsBordersWithVerticesByPackedPolygon;
+
+ if (m_radioBoundingBox->isChecked())
+ return Response::BoundingBoxByPackedPolygon;
UNREACHABLE();
}
@@ -75,8 +81,8 @@ QGroupBox * MwmsBordersSelection::CreateSourceChoosingGroup()
{
auto * groupBox = new QGroupBox();
- m_radioBordersFromPackedPolygon = new QRadioButton(tr("Show borders from packed_polygon.bin."));
- m_radioBordersFromData = new QRadioButton(tr("Show borders from *.poly files."));
+ m_radioBordersFromPackedPolygon = new QRadioButton(tr("Get borders from packed_polygon.bin"));
+ m_radioBordersFromData = new QRadioButton(tr("Get borders from *.poly files"));
m_radioBordersFromPackedPolygon->setChecked(true);
@@ -93,8 +99,9 @@ QGroupBox * MwmsBordersSelection::CreateViewTypeGroup()
{
auto * groupBox = new QGroupBox();
- m_radioWithPoints = new QRadioButton(tr("Show borders with points."));
- m_radioJustBorders = new QRadioButton(tr("Show just borders."));
+ m_radioWithPoints = new QRadioButton(tr("Show borders with vertices"));
+ m_radioJustBorders = new QRadioButton(tr("Show just borders"));
+ m_radioBoundingBox = new QRadioButton(tr("Show bounding box"));
m_radioWithPoints->setChecked(true);
@@ -102,6 +109,7 @@ QGroupBox * MwmsBordersSelection::CreateViewTypeGroup()
vbox->addWidget(m_radioWithPoints);
vbox->addWidget(m_radioJustBorders);
+ vbox->addWidget(m_radioBoundingBox);
groupBox->setLayout(vbox);
return groupBox;
diff --git a/qt/mwms_borders_selection.hpp b/qt/mwms_borders_selection.hpp
index 7766985882..f9d725c2ae 100644
--- a/qt/mwms_borders_selection.hpp
+++ b/qt/mwms_borders_selection.hpp
@@ -19,11 +19,14 @@ public:
enum class Response
{
- JustBordersByPolyFiles,
- WithPointsAndBordersByPolyFiles,
+ MwmsBordersByPolyFiles,
+ MwmsBordersWithVerticesByPolyFiles,
- JustBordersByPackedPolygon,
- WithPointsAndBordersByPackedPolygon,
+ MwmsBordersByPackedPolygon,
+ MwmsBordersWithVerticesByPackedPolygon,
+
+ BoundingBoxByPolyFiles,
+ BoundingBoxByPackedPolygon,
Cancelled
};
@@ -40,5 +43,6 @@ private:
QRadioButton * m_radioWithPoints;
QRadioButton * m_radioJustBorders;
+ QRadioButton * m_radioBoundingBox;
};
} // namespace qt