From 2235f312a16520a39a3ad3684c962abfff074eb9 Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Fri, 15 Jul 2016 19:40:50 +0300 Subject: [PATCH] Review fixes. --- drape_frontend/animation/interpolators.cpp | 2 +- drape_frontend/frontend_renderer.cpp | 4 +-- drape_frontend/my_position_controller.cpp | 37 +++++++++++----------- drape_frontend/my_position_controller.hpp | 4 +-- drape_frontend/user_event_stream.cpp | 3 +- drape_frontend/user_event_stream.hpp | 5 +-- map/framework.cpp | 4 ++- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/drape_frontend/animation/interpolators.cpp b/drape_frontend/animation/interpolators.cpp index f51a010c54..b7b6234b4e 100644 --- a/drape_frontend/animation/interpolators.cpp +++ b/drape_frontend/animation/interpolators.cpp @@ -196,7 +196,7 @@ ScaleInterpolator::ScaleInterpolator(double delay, double startScale, double end // static double ScaleInterpolator::GetScaleDuration(double startScale, double endScale, bool isAutoZoom) { - // Resize 2.0 times should be done for 0.2 seconds. + // Resize 2.0 times should be done for 1.5 seconds in autozoom or for 0.2 seconds in usual case. double const kPixelSpeed = isAutoZoom ? (2.0 / 1.5) : (2.0 / 0.2); if (startScale > endScale) diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index affcbab563..c8b6c4dc03 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -728,7 +728,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) case Message::Invalidate: { m_myPositionController->ResetRoutingNotFollowTimer(); - m_myPositionController->ResetRoutingNotAutoZoomTimer(); + m_myPositionController->ResetBlockAutoZoomTimer(); break; } @@ -1397,7 +1397,7 @@ void FrontendRenderer::OnScaleEnded() void FrontendRenderer::OnAnimatedScaleEnded() { - m_myPositionController->ResetRoutingNotAutoZoomTimer(); + m_myPositionController->ResetBlockAutoZoomTimer(); PullToBoundArea(false /* randomPlace */, false /* applyZoom */); } diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index fb5cfa8dee..52cb3cbfc8 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -28,7 +28,7 @@ double const kMaxPendingLocationTimeSec = 60.0; double const kMaxTimeInBackgroundSec = 60.0 * 60; double const kMaxNotFollowRoutingTimeSec = 10.0; double const kMaxUpdateLocationInvervalSec = 30.0; -double const kMaxNotAutoZoomRoutingTimeSec = 10.0; +double const kMaxBlockAutoZoomTimeSec = 10.0; int const kZoomThreshold = 10; int const kMaxScaleZoomLevel = 16; @@ -70,12 +70,12 @@ double CalculateZoomBySpeed(double speed) { using TSpeedScale = pair; static vector scales = { - make_pair(20.0, 0.1), - make_pair(40.0, 0.25), - make_pair(60.0, 0.5), - make_pair(80.0, 0.85), - make_pair(100.0, 1.75), - make_pair(120.0, 3.5), + make_pair(20.0, 0.25), + make_pair(40.0, 0.5), + make_pair(60.0, 1.0), + make_pair(80.0, 1.75), + make_pair(100.0, 3.5), + make_pair(120.0, 7.0), }; double const kDefaultSpeed = 80.0; @@ -89,10 +89,12 @@ double CalculateZoomBySpeed(double speed) if (scales[i].first >= speed) break; + double const vs = df::VisualParams::Instance().GetVisualScale(); + if (i == 0) - return scales.front().second; + return scales.front().second / vs; if (i == scales.size()) - return scales.back().second; + return scales.back().second / vs; double const minSpeed = scales[i - 1].first; double const maxSpeed = scales[i].first; @@ -101,7 +103,6 @@ double CalculateZoomBySpeed(double speed) double const minScale = scales[i - 1].second; double const maxScale = scales[i].second; double const zoom = minScale + k * (maxScale - minScale); - double const vs = df::VisualParams::Instance().GetVisualScale(); return zoom / vs; } @@ -205,13 +206,13 @@ void MyPositionController::DragEnded(m2::PointD const & distance) void MyPositionController::ScaleStarted() { m_needBlockAnimation = true; - ResetRoutingNotAutoZoomTimer(); + ResetBlockAutoZoomTimer(); } void MyPositionController::ScaleEnded() { m_needBlockAnimation = false; - ResetRoutingNotAutoZoomTimer(); + ResetBlockAutoZoomTimer(); if (m_wasRotationInScaling) { m_wasRotationInScaling = false; @@ -233,12 +234,12 @@ void MyPositionController::ResetRoutingNotFollowTimer() m_routingNotFollowTimer.Reset(); } -void MyPositionController::ResetRoutingNotAutoZoomTimer() +void MyPositionController::ResetBlockAutoZoomTimer() { if (m_isInRouting && m_enableAutoZoomInRouting) { m_needBlockAutoZoom = true; - m_routingNotAutoZoomTimer.Reset(); + m_blockAutoZoomTimer.Reset(); } } @@ -342,7 +343,7 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool m_errorRadius = rect.SizeX() * 0.5; double const zoom = CalculateZoomBySpeed(info.m_speed); - m_autoScale = zoom * (rect.SizeX() / info.m_horizontalAccuracy); + m_autoScale = zoom * (m_errorRadius / info.m_horizontalAccuracy); bool const hasBearing = info.HasBearing(); if ((isNavigable && hasBearing) || @@ -496,7 +497,7 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr= kMaxNotAutoZoomRoutingTimeSec) + m_blockAutoZoomTimer.ElapsedSeconds() >= kMaxBlockAutoZoomTimeSec) { m_needBlockAutoZoom = false; m_isDirtyAutoZoom = true; @@ -559,7 +560,7 @@ void MyPositionController::SetDirection(double bearing) void MyPositionController::ChangeMode(location::EMyPositionMode newMode) { if (m_isInRouting && (m_mode != newMode) && (newMode == location::FollowAndRotate)) - ResetRoutingNotAutoZoomTimer(); + ResetBlockAutoZoomTimer(); m_mode = newMode; if (m_modeChangeCallback != nullptr) @@ -745,7 +746,7 @@ void MyPositionController::EnableAutoZoomInRouting(bool enableAutoZoom) if (m_isInRouting) { m_enableAutoZoomInRouting = enableAutoZoom; - ResetRoutingNotAutoZoomTimer(); + ResetBlockAutoZoomTimer(); } } diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp index 9e17642737..12b5c91f28 100644 --- a/drape_frontend/my_position_controller.hpp +++ b/drape_frontend/my_position_controller.hpp @@ -62,7 +62,7 @@ public: void Rotated(); void ResetRoutingNotFollowTimer(); - void ResetRoutingNotAutoZoomTimer(); + void ResetBlockAutoZoomTimer(); void CorrectScalePoint(m2::PointD & pt) const; void CorrectScalePoint(m2::PointD & pt1, m2::PointD & pt2) const; @@ -152,7 +152,7 @@ private: my::Timer m_lastGPSBearing; my::Timer m_pendingTimer; my::Timer m_routingNotFollowTimer; - my::Timer m_routingNotAutoZoomTimer; + my::Timer m_blockAutoZoomTimer; my::Timer m_updateLocationTimer; double m_lastLocationTimestamp; diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 7b05856043..11cda5b227 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -188,7 +188,8 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool { m2::PointD pt = screen.PixelRectIn3d().Center(); breakAnim = SetFollowAndRotate(screen.PtoG(screen.P3dtoP(pt)), pt, - e.m_rotate.m_targetAzimut, kDoNotChangeZoom, -1.0, true, false); + e.m_rotate.m_targetAzimut, kDoNotChangeZoom, kDoNotAutoZoom, + true /* isAnim */, false /* isAutoScale */); } else { diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp index edcacce40b..0929bd0c06 100644 --- a/drape_frontend/user_event_stream.hpp +++ b/drape_frontend/user_event_stream.hpp @@ -21,6 +21,7 @@ namespace df { int const kDoNotChangeZoom = -1; +double const kDoNotAutoZoom = -1.0; struct Touch { @@ -134,7 +135,7 @@ struct FollowAndRotateEvent : m_userPos(userPos) , m_pixelZero(pixelZero) , m_azimuth(azimuth) - , m_preferredZoomLevel(-1) + , m_preferredZoomLevel(kDoNotChangeZoom) , m_autoScale(autoScale) , m_isAutoScale(true) , m_isAnim(true) @@ -147,7 +148,7 @@ struct FollowAndRotateEvent , m_pixelZero(pixelZero) , m_azimuth(azimuth) , m_preferredZoomLevel(preferredZoomLevel) - , m_autoScale(-1.0) + , m_autoScale(kDoNotAutoZoom) , m_isAutoScale(false) , m_isAnim(isAnim) {} diff --git a/map/framework.cpp b/map/framework.cpp index 30644554cd..a18a91252d 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2565,7 +2565,9 @@ bool Framework::LoadAutoZoom() void Framework::AllowAutoZoom(bool allowAutoZoom) { - CallDrapeFunction(bind(&df::DrapeEngine::AllowAutoZoom, _1, allowAutoZoom)); + bool const isPedestrianRoute = m_currentRouterType == RouterType::Pedestrian; + + CallDrapeFunction(bind(&df::DrapeEngine::AllowAutoZoom, _1, allowAutoZoom && !isPedestrianRoute)); } void Framework::SaveAutoZoom(bool allowAutoZoom)