From df1bdbd1aa5909360488ac6fa8de9ccfa222efa0 Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Wed, 23 Dec 2015 13:42:00 +0300 Subject: [PATCH] Immediately changing mode in routing. --- drape_frontend/drape_engine.cpp | 4 ++-- drape_frontend/drape_engine.hpp | 2 +- drape_frontend/frontend_renderer.cpp | 17 +++++++++++++++-- drape_frontend/message_subclasses.hpp | 8 +++++++- drape_frontend/my_position_controller.hpp | 2 +- map/framework.cpp | 2 +- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index e3a6f6fefa..d17bcfb23c 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -429,14 +429,14 @@ gui::TWidgetsSizeInfo const & DrapeEngine::GetWidgetSizes() return m_widgetSizes; } -void DrapeEngine::Allow3dMode(bool allow3d, bool allow3dBuildings) +void DrapeEngine::Allow3dMode(bool allow3d, bool allow3dBuildings, double rotationAngle, double angleFOV) { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp(allow3d && allow3dBuildings), MessagePriority::Normal); m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, - make_unique_dp(allow3d), + make_unique_dp(allow3d, rotationAngle, angleFOV), MessagePriority::Normal); } diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index a1dfa983ad..4d138a7885 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -114,7 +114,7 @@ public: void SetWidgetLayout(gui::TWidgetsLayoutInfo && info); gui::TWidgetsSizeInfo const & GetWidgetSizes(); - void Allow3dMode(bool allow3d, bool allow3dBuildings); + void Allow3dMode(bool allow3d, bool allow3dBuildings, double rotationAngle, double angleFOV); void EnablePerspective(double rotationAngle, double angleFOV); private: diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 4398affd36..b391766017 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -513,20 +513,33 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) case Message::Allow3dMode: { ref_ptr const msg = message; -#ifdef OMIM_OS_DESKTOP bool const isPerspective = m_userEventStream.GetCurrentScreen().isPerspective(); +#ifdef OMIM_OS_DESKTOP if (m_enable3dInNavigation == msg->Allow() && m_enable3dInNavigation != isPerspective) { if (m_enable3dInNavigation) - AddUserEvent(EnablePerspectiveEvent(M_PI / 4.0, M_PI / 3.0, + AddUserEvent(EnablePerspectiveEvent(msg->GetRotationAngle(), msg->GetAngleFOV(), false /* animated */, true /* immediately start */)); else AddUserEvent(DisablePerspectiveEvent()); } #endif m_enable3dInNavigation = msg->Allow(); + + if (m_myPositionController->IsInRouting()) + { + if (m_enable3dInNavigation && !isPerspective && !m_perspectiveDiscarded) + { + AddUserEvent(EnablePerspectiveEvent(msg->GetRotationAngle(), msg->GetAngleFOV(), + true /* animated */, true /* immediately start */)); + } + else if (!m_enable3dInNavigation && (isPerspective || m_perspectiveDiscarded)) + { + DisablePerspective(); + } + } break; } diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 02fb3a396e..67d465290d 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -656,15 +656,21 @@ public: class Allow3dModeMessage : public Message { public: - Allow3dModeMessage(bool allow) + Allow3dModeMessage(bool allow, double rotationAngle, double angleFOV) : m_allow(allow) + , m_rotationAngle(rotationAngle) + , m_angleFOV(angleFOV) {} Type GetType() const override { return Message::Allow3dMode; } bool Allow() const { return m_allow; } + double GetRotationAngle() const { return m_rotationAngle; } + double GetAngleFOV() const { return m_angleFOV; } private: bool const m_allow; + double const m_rotationAngle; + double const m_angleFOV; }; class Allow3dBuildingsMessage : public Message diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp index 3b883334c7..7acfdd1800 100644 --- a/drape_frontend/my_position_controller.hpp +++ b/drape_frontend/my_position_controller.hpp @@ -85,6 +85,7 @@ public: dp::UniformValuesStorage const & commonUniforms); bool IsFollowingActive() const; + bool IsInRouting() const; private: void AnimateStateTransition(location::EMyPositionMode oldMode, location::EMyPositionMode newMode); @@ -97,7 +98,6 @@ private: location::EMyPositionMode GetMode() const; void CallModeListener(uint32_t mode); - bool IsInRouting() const; bool IsRotationActive() const; bool IsVisible() const { return m_isVisible; } diff --git a/map/framework.cpp b/map/framework.cpp index 511012fa44..a143ee6540 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2078,7 +2078,7 @@ void Framework::SetRouteFinishPoint(m2::PointD const & pt, bool isValid) void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings) { - CallDrapeFunction(bind(&df::DrapeEngine::Allow3dMode, _1, allow3d, allow3dBuildings)); + CallDrapeFunction(bind(&df::DrapeEngine::Allow3dMode, _1, allow3d, allow3dBuildings, kRotationAngle, kAngleFOV)); } void Framework::Save3dMode(bool allow3d, bool allow3dBuildings)