diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-06-14 18:44:59 +0300 |
---|---|---|
committer | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-07-07 15:31:08 +0300 |
commit | eb300949c0f0a17b14976fac3ed047a3ae3e43df (patch) | |
tree | a3b26ae15ed2e281440882f6cadaff5bea05d663 /drape_frontend | |
parent | c8285a867a6cc43c06843fb696a6a64db59399da (diff) |
Global rect checks corrected in perspective mode.
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/navigator.cpp | 25 | ||||
-rw-r--r-- | drape_frontend/navigator.hpp | 10 | ||||
-rw-r--r-- | drape_frontend/user_event_stream.cpp | 20 |
3 files changed, 33 insertions, 22 deletions
diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index a2e2034ec1..273e8c1194 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -19,6 +19,8 @@ namespace df { +double const kDefault3dScale = 1.0; + Navigator::Navigator() : m_InAction(false) { @@ -56,8 +58,9 @@ void Navigator::SetFromRect(m2::AnyRectD const & r, uint32_t tileSize, double vi { int const scale = scales::GetUpperStyleScale() - 1; m2::RectD newRect = df::GetRectForDrawScale(scale, r.Center()); - CheckMinMaxVisibleScale(newRect, scale); - tmp = m_Screen; + newRect.Scale(m_Screen.GetScale3d()); + CheckMinMaxVisibleScale(newRect, scale, m_Screen.GetScale3d()); + tmp = m_Screen; tmp.SetFromRect(m2::AnyRectD(newRect)); ASSERT(CheckMaxScale(tmp, tileSize, visualScale), ()); } @@ -324,36 +327,38 @@ m2::AnyRectD ToRotated(Navigator const & navigator, m2::RectD const & rect) m2::RectD(-dx/2, -dy/2, dx/2, dy/2)); } -void CheckMinGlobalRect(m2::RectD & rect, uint32_t tileSize, double visualScale) +void CheckMinGlobalRect(m2::RectD & rect, uint32_t tileSize, double visualScale, double scale3d) { - m2::RectD const minRect = df::GetRectForDrawScale(scales::GetUpperStyleScale(), rect.Center(), tileSize, visualScale); + m2::RectD minRect = df::GetRectForDrawScale(scales::GetUpperStyleScale(), rect.Center(), tileSize, visualScale); + minRect.Scale(scale3d); if (minRect.IsRectInside(rect)) rect = minRect; } -void CheckMinGlobalRect(m2::RectD & rect) +void CheckMinGlobalRect(m2::RectD & rect, double scale3d) { VisualParams const & p = VisualParams::Instance(); - CheckMinGlobalRect(rect, p.GetTileSize(), p.GetVisualScale()); + CheckMinGlobalRect(rect, p.GetTileSize(), p.GetVisualScale(), scale3d); } void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale, - uint32_t tileSize, double visualScale) + uint32_t tileSize, double visualScale, double scale3d) { - CheckMinGlobalRect(rect, tileSize, visualScale); + CheckMinGlobalRect(rect, tileSize, visualScale, scale3d); int scale = df::GetDrawTileScale(rect, tileSize, visualScale); if (maxScale != -1 && scale > maxScale) { // limit on passed maximal scale m2::PointD const c = rect.Center(); rect = df::GetRectForDrawScale(maxScale, c, tileSize, visualScale); + rect.Scale(scale3d); } } -void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale) +void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale, double scale3d) { VisualParams const & p = VisualParams::Instance(); - CheckMinMaxVisibleScale(rect, maxScale, p.GetTileSize(), p.GetVisualScale()); + CheckMinMaxVisibleScale(rect, maxScale, p.GetTileSize(), p.GetVisualScale(), scale3d); } } // namespace df diff --git a/drape_frontend/navigator.hpp b/drape_frontend/navigator.hpp index 6e05419e81..01c3272d95 100644 --- a/drape_frontend/navigator.hpp +++ b/drape_frontend/navigator.hpp @@ -10,6 +10,8 @@ namespace df { +extern double const kDefault3dScale; + /// Calculates screen parameters in navigation (dragging, scaling, etc.). class Navigator { @@ -76,10 +78,10 @@ private: }; m2::AnyRectD ToRotated(Navigator const & navigator, m2::RectD const & rect); -void CheckMinGlobalRect(m2::RectD & rect, uint32_t tileSize, double visualScale); -void CheckMinGlobalRect(m2::RectD & rect); +void CheckMinGlobalRect(m2::RectD & rect, uint32_t tileSize, double visualScale, double scale3d = kDefault3dScale); +void CheckMinGlobalRect(m2::RectD & rect, double scale3d = kDefault3dScale); -void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/, uint32_t tileSize, double visualScale); -void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/); +void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/, uint32_t tileSize, double visualScale, double scale3d = kDefault3dScale); +void CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/, double scale3d = kDefault3dScale); } diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index eab529320f..d5d7e10092 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -385,7 +385,7 @@ bool UserEventStream::SetCenter(m2::PointD const & center, int zoom, bool isAnim screen.ResetPerspective(); } - double const scale3d = screen.PixelRect().SizeX() / screen.PixelRectIn3d().SizeX(); + double const scale3d = screen.GetScale3d(); if (zoom == kDoNotChangeZoom) { @@ -398,11 +398,12 @@ bool UserEventStream::SetCenter(m2::PointD const & center, int zoom, bool isAnim angle = screen.GlobalRect().Angle(); localRect = df::GetRectForDrawScale(zoom, center); - CheckMinGlobalRect(localRect); - CheckMinMaxVisibleScale(localRect, zoom); + localRect.Scale(scale3d); + + CheckMinGlobalRect(localRect, scale3d); + CheckMinMaxVisibleScale(localRect, zoom, scale3d); localRect.Offset(-center); - localRect.Scale(scale3d); double const aspectRatio = screen.PixelRect().SizeY() / screen.PixelRect().SizeX(); if (aspectRatio > 1.0) @@ -433,8 +434,9 @@ bool UserEventStream::SetCenter(m2::PointD const & center, int zoom, bool isAnim bool UserEventStream::SetRect(m2::RectD rect, int zoom, bool applyRotation, bool isAnim) { - CheckMinGlobalRect(rect); - CheckMinMaxVisibleScale(rect, zoom); + ScreenBase const & screen = GetCurrentScreen(); + CheckMinGlobalRect(rect, screen.GetScale3d()); + CheckMinMaxVisibleScale(rect, zoom, screen.GetScale3d()); m2::AnyRectD targetRect = applyRotation ? ToRotated(m_navigator, rect) : m2::AnyRectD(rect); return SetRect(targetRect, isAnim); } @@ -506,9 +508,11 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD if (preferredZoomLevel != kDoNotChangeZoom) { ScreenBase newScreen = GetCurrentScreen(); + double const scale3d = newScreen.GetScale3d(); m2::RectD r = df::GetRectForDrawScale(preferredZoomLevel, m2::PointD::Zero()); - CheckMinGlobalRect(r); - CheckMinMaxVisibleScale(r, preferredZoomLevel); + r.Scale(scale3d); + CheckMinGlobalRect(r, scale3d); + CheckMinMaxVisibleScale(r, preferredZoomLevel, scale3d); newScreen.SetFromRect(m2::AnyRectD(r)); targetLocalRect = newScreen.GlobalRect().GetLocalRect(); } |