diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-08-04 17:14:34 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-08-18 17:06:24 +0300 |
commit | 0ce929a238636dc5b012111a196579fc374cbd88 (patch) | |
tree | 88a99f219e20235bb60de0c6955552637afd7f5a /drape_frontend | |
parent | becf0013f6fd67ae9a8b56f9a474ea938a8cd957 (diff) |
Less detailed autozoom levels in 2d navigation.
Diffstat (limited to 'drape_frontend')
-rwxr-xr-x | drape_frontend/frontend_renderer.cpp | 1 | ||||
-rw-r--r-- | drape_frontend/my_position_controller.cpp | 34 | ||||
-rw-r--r-- | drape_frontend/my_position_controller.hpp | 5 |
3 files changed, 32 insertions, 8 deletions
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index d2afb09d40..7facf8a204 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -645,6 +645,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message) if (m_enablePerspectiveInNavigation != msg->AllowPerspective()) { m_enablePerspectiveInNavigation = msg->AllowPerspective(); + m_myPositionController->EnablePerspectiveInRouting(m_enablePerspectiveInNavigation); if (m_myPositionController->IsInRouting()) { AddUserEvent(SetAutoPerspectiveEvent(m_enablePerspectiveInNavigation)); diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index aa6954933c..4498b5cb6f 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -66,10 +66,10 @@ int GetZoomLevel(ScreenBase const & screen, m2::PointD const & position, double } // Calculate zoom value in meters per pixel -double CalculateZoomBySpeed(double speed) +double CalculateZoomBySpeed(double speed, bool isPerspectiveAllowed) { using TSpeedScale = pair<double, double>; - static vector<TSpeedScale> scales = { + static vector<TSpeedScale> scales3d = { make_pair(20.0, 0.25), make_pair(40.0, 0.5), make_pair(60.0, 1.0), @@ -78,6 +78,17 @@ double CalculateZoomBySpeed(double speed) make_pair(90.0, 7.0), }; + static vector<TSpeedScale> scales2d = { + make_pair(20.0, 0.7), + make_pair(40.0, 1.0), + make_pair(60.0, 1.5), + make_pair(75.0, 1.75), + make_pair(85.0, 3.5), + make_pair(90.0, 7.0), + }; + + vector<TSpeedScale> const & scales = isPerspectiveAllowed ? scales3d : scales2d; + double const kDefaultSpeed = 80.0; if (speed < 0.0) speed = kDefaultSpeed; @@ -122,8 +133,10 @@ MyPositionController::MyPositionController(location::EMyPositionMode initMode, d , m_drawDirection(0.0) , m_oldPosition(m2::PointD::Zero()) , m_oldDrawDirection(0.0) + , m_enablePerspectiveInRouting(false) , m_enableAutoZoomInRouting(false) - , m_autoScale(GetScale(kDefaultAutoZoom)) + , m_autoScale2d(GetScale(kDefaultAutoZoom)) + , m_autoScale3d(m_autoScale2d) , m_lastGPSBearing(false) , m_lastLocationTimestamp(0.0) , m_positionYOffset(kPositionOffsetY) @@ -342,8 +355,9 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool m_position = MercatorBounds::FromLatLon(info.m_latitude, info.m_longitude); m_errorRadius = rect.SizeX() * 0.5; - double const zoom = CalculateZoomBySpeed(info.m_speed); - m_autoScale = zoom * (m_errorRadius / info.m_horizontalAccuracy); + double const mercatorPerMeter = m_errorRadius / info.m_horizontalAccuracy; + m_autoScale2d = mercatorPerMeter * CalculateZoomBySpeed(info.m_speed, false /* isPerspectiveAllowed */); + m_autoScale3d = mercatorPerMeter * CalculateZoomBySpeed(info.m_speed, true /* isPerspectiveAllowed */); bool const hasBearing = info.HasBearing(); if ((isNavigable && hasBearing) || @@ -472,7 +486,8 @@ bool MyPositionController::UpdateViewportWithAutoZoom() if (m_mode == location::FollowAndRotate && m_isInRouting && m_enableAutoZoomInRouting && !m_needBlockAutoZoom) { - ChangeModelView(m_autoScale, m_position, m_drawDirection, GetRoutingRotationPixelCenter()); + ChangeModelView(m_enablePerspectiveInRouting ? m_autoScale3d : m_autoScale2d, + m_position, m_drawDirection, GetRoutingRotationPixelCenter()); return true; } return false; @@ -507,7 +522,7 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr<dp::GpuProg m_updateLocationTimer.ElapsedSeconds() >= kMaxUpdateLocationInvervalSec) { m_positionIsObsolete = true; - m_autoScale = GetScale(kDefaultAutoZoom); + m_autoScale2d = m_autoScale3d = GetScale(kDefaultAutoZoom); m_isDirtyAutoZoom = true; } @@ -741,6 +756,11 @@ void MyPositionController::CreateAnim(m2::PointD const & oldPos, double oldAzimu } } +void MyPositionController::EnablePerspectiveInRouting(bool enablePerspective) +{ + m_enablePerspectiveInRouting = enablePerspective; +} + void MyPositionController::EnableAutoZoomInRouting(bool enableAutoZoom) { if (m_isInRouting) diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp index 12b5c91f28..15d9c5e60e 100644 --- a/drape_frontend/my_position_controller.hpp +++ b/drape_frontend/my_position_controller.hpp @@ -73,6 +73,7 @@ public: void ActivateRouting(int zoomLevel, bool enableAutoZoom); void DeactivateRouting(); + void EnablePerspectiveInRouting(bool enablePerspective); void EnableAutoZoomInRouting(bool enableAutoZoom); void StopLocationFollow(); @@ -146,8 +147,10 @@ private: m2::PointD m_oldPosition; // position in mercator double m_oldDrawDirection; + bool m_enablePerspectiveInRouting; bool m_enableAutoZoomInRouting; - double m_autoScale; + double m_autoScale2d; + double m_autoScale3d; my::Timer m_lastGPSBearing; my::Timer m_pendingTimer; |