From ce4870393dd3902147ddfd29a81dc50af23eff18 Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 19 Jul 2013 14:01:37 +0300 Subject: [PATCH] Fixes according to code review. --- graphics/glyph_layout.cpp | 2 +- indexer/classificator.hpp | 2 +- indexer/scales.hpp | 8 +++++++- map/framework.cpp | 2 +- map/location_state.cpp | 2 +- map/navigator.cpp | 12 ++++++------ map/navigator.hpp | 2 +- map/scales_processor.cpp | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/graphics/glyph_layout.cpp b/graphics/glyph_layout.cpp index 61c3b7defb..5860ca1062 100644 --- a/graphics/glyph_layout.cpp +++ b/graphics/glyph_layout.cpp @@ -291,7 +291,7 @@ namespace graphics entry.m_angle = pivotPt.m_angle; // is path too bended to be shown at all? - if (hasPrevElem && (ang::GetShortestDistance(prevElem.m_angle.val(), entry.m_angle.val()) > 0.5)) + if (hasPrevElem && fabs(ang::GetShortestDistance(prevElem.m_angle.val(), entry.m_angle.val())) > 0.5) break; double const centerOffset = metrics.m_xOffset + metrics.m_width / 2.0; diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index a2be356c7f..dda18d257c 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -114,7 +114,7 @@ public: } } - typedef bitset visible_mask_t; + typedef bitset visible_mask_t; visible_mask_t GetVisibilityMask() const { return m_visibility; } void SetVisibilityMask(visible_mask_t mask) { m_visibility = mask; } void SetVisibilityOnScale(const bool isVisible, const int scale) { m_visibility[scale] = isVisible; } diff --git a/indexer/scales.hpp b/indexer/scales.hpp index aa083c8a9b..88d2182f92 100644 --- a/indexer/scales.hpp +++ b/indexer/scales.hpp @@ -3,13 +3,19 @@ #include "../geometry/rect2d.hpp" #include "../geometry/point2d.hpp" -int const UPPER_STYLE_SCALE = 19; namespace scales { + int const UPPER_STYLE_SCALE = 19; + + /// Upper scale for data generation and indexer buckets. inline int GetUpperScale() { return 17; } + /// Upper scale according to drawing rules. inline int GetUpperStyleScale() { return UPPER_STYLE_SCALE; } + /// Upper scales for World visible styles and indexer buckets. inline int GetUpperWorldScale() { return 9; } + /// Upper scale for user comfort view (e.g. location zoom). + inline int GetUpperComfortScale() { return UPPER_STYLE_SCALE - 2; } double GetM2PFactor(int level); diff --git a/map/framework.cpp b/map/framework.cpp index 895ca92b84..c9429a621c 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -486,7 +486,7 @@ void Framework::ShowBookmark(Bookmark const & bm) double scale = bm.GetScale(); if (scale == -1.0) - scale = scales::GetUpperStyleScale() - 2; + scale = scales::GetUpperComfortScale(); ShowRectExVisibleScale(m_scales.GetRectForDrawScale(scale, bm.GetOrg())); } diff --git a/map/location_state.cpp b/map/location_state.cpp index 8e51963ac7..0d3cc454fd 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -148,7 +148,7 @@ namespace location switch (m_locationProcessMode) { case ELocationCenterAndScale: - m_framework->ShowRectExVisibleScale(rect, scales::GetUpperStyleScale()-2); + m_framework->ShowRectExVisibleScale(rect, scales::GetUpperComfortScale()); SetIsCentered(true); CheckCompassRotation(); diff --git a/map/navigator.cpp b/map/navigator.cpp index 6dd4a3d847..30a4c82fb2 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -419,7 +419,7 @@ void Navigator::ScaleToPoint(m2::PointD const & pt, double factor, double /*time ScaleImpl(pt, endPt, pt, startPt, factor > 1, false); } -bool Navigator::CheckMaxScale(ScreenBase const & screen) const +bool Navigator::CheckMinScale(ScreenBase const & screen) const { m2::RectD const & r = screen.ClipRect(); m2::RectD const & worldR = m_scales.GetWorldRect(); @@ -427,7 +427,7 @@ bool Navigator::CheckMaxScale(ScreenBase const & screen) const return (r.SizeX() <= worldR.SizeX() || r.SizeY() <= worldR.SizeY()); } -bool Navigator::CheckMinScale(ScreenBase const & screen) const +bool Navigator::CheckMaxScale(ScreenBase const & screen) const { return (m_scales.GetDrawTileScale(screen) <= scales::GetUpperStyleScale()); } @@ -442,7 +442,7 @@ bool Navigator::CheckBorders(ScreenBase const & screen) const bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, m2::PointD const & oldPt1, m2::PointD const & oldPt2, - bool skipMaxScaleAndBordersCheck, + bool skipMinScaleAndBordersCheck, bool doRotateScreen) { math::Matrix newM = m_Screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1, oldPt2, newPt1, newPt2); @@ -453,12 +453,12 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, if (!doRotateScreen) tmp.Rotate(-(tmp.GetAngle() - oldAngle)); - if (!skipMaxScaleAndBordersCheck && !CheckMaxScale(tmp)) + if (!skipMinScaleAndBordersCheck && !CheckMinScale(tmp)) return false; m2::RectD const & worldR = m_scales.GetWorldRect(); - if (!skipMaxScaleAndBordersCheck && !CheckBorders(tmp)) + if (!skipMinScaleAndBordersCheck && !CheckBorders(tmp)) { if (CanShrinkInto(tmp, worldR)) tmp = ShrinkInto(tmp, worldR); @@ -466,7 +466,7 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, return false; } - if (!CheckMinScale(tmp)) + if (!CheckMaxScale(tmp)) return false; // re-checking the borders, as we might violate them a bit (don't know why). diff --git a/map/navigator.hpp b/map/navigator.hpp index 0e5910c071..3bcb3820bf 100644 --- a/map/navigator.hpp +++ b/map/navigator.hpp @@ -115,6 +115,6 @@ private: m2::PointD const & newPt2, m2::PointD const & oldPt1, m2::PointD const & oldPt2, - bool skipMaxScaleAndBordersCheck, + bool skipMinScaleAndBordersCheck, bool doRotateScreen); }; diff --git a/map/scales_processor.cpp b/map/scales_processor.cpp index 6ce841577b..5862db6dbe 100644 --- a/map/scales_processor.cpp +++ b/map/scales_processor.cpp @@ -24,7 +24,7 @@ void ScalesProcessor::SetParams(int width, int height, double visualScale) m2::RectD const & ScalesProcessor::GetWorldRect() const { - static m2::RectD worldRect = MercatorBounds::FullRect(); + static m2::RectD const worldRect = MercatorBounds::FullRect(); return worldRect; }