| 312 | } |
| 313 | |
| 314 | void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices, bool fromPackedPolygon, |
| 315 | bool boundingBox) |
| 316 | { |
| 317 | auto const getRegions = [&](std::string const & mwmName) |
| 318 | { |
| 319 | if (fromPackedPolygon) |
| 320 | { |
| 321 | std::vector<storage::CountryDef> countries; |
| 322 | FilesContainerR reader(base::JoinPath(GetPlatform().ResourcesDir(), PACKED_POLYGONS_FILE)); |
| 323 | ReaderSource<ModelReaderPtr> src(reader.GetReader(PACKED_POLYGONS_INFO_TAG)); |
| 324 | rw::Read(src, countries); |
| 325 | |
| 326 | for (size_t id = 0; id < countries.size(); ++id) |
| 327 | { |
| 328 | if (countries[id].m_countryId != mwmName) |
| 329 | continue; |
| 330 | |
| 331 | src = reader.GetReader(std::to_string(id)); |
| 332 | return borders::ReadPolygonsOfOneBorder(src); |
| 333 | } |
| 334 | |
| 335 | UNREACHABLE(); |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | std::string const bordersDir = base::JoinPath(GetPlatform().WritableDir(), BORDERS_DIR); |
| 340 | std::string const path = base::JoinPath(bordersDir, mwmName + BORDERS_EXTENSION); |
| 341 | |
| 342 | std::vector<m2::RegionD> polygons; |
| 343 | borders::LoadBorders(path, polygons); |
| 344 | return polygons; |
| 345 | } |
| 346 | }; |
| 347 | |
| 348 | auto mwmNames = m_framework.GetRegionsCountryIdByRect(rect, false /* rough */); |
| 349 | |
| 350 | for (auto & mwmName : mwmNames) |
| 351 | { |
| 352 | auto regions = getRegions(mwmName); |
| 353 | mwmName += fromPackedPolygon ? ".bin" : ".poly"; |
| 354 | if (boundingBox) |
| 355 | { |
| 356 | std::vector<m2::RegionD> boxes; |
| 357 | for (auto const & region : regions) |
| 358 | { |
| 359 | auto const r = region.GetRect(); |
| 360 | boxes.emplace_back( |
| 361 | std::vector<m2::PointD>({r.LeftBottom(), r.LeftTop(), r.RightTop(), r.RightBottom(), r.LeftBottom()})); |
| 362 | } |
| 363 | |
| 364 | regions = std::move(boxes); |
| 365 | mwmName += ".box"; |
| 366 | } |
| 367 | DrawMwmBorder(m_framework.GetDrapeApi(), mwmName, regions, withVertices); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | void DrawWidget::mouseReleaseEvent(QMouseEvent * e) |
nothing calls this directly
no test coverage detected