diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index dfed0e3848..1dd323dc44 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -448,7 +448,7 @@ void Framework::SetMyPositionModeListener(location::TMyPositionModeChanged const m_myPositionModeSignal = fn; } -location::EMyPositionMode Framework::GetMyPositionMode() +location::EMyPositionMode Framework::GetMyPositionMode() const { return m_currentMode; } diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 5d2941f167..9fe7959ad3 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -143,7 +143,7 @@ namespace android void RemoveActiveMapsListener(int slotID); void SetMyPositionModeListener(location::TMyPositionModeChanged const & fn); - location::EMyPositionMode GetMyPositionMode(); + location::EMyPositionMode GetMyPositionMode() const; // Fills mapobject's metadata from UserMark void InjectMetadata(JNIEnv * env, jclass clazz, jobject const mapObject, UserMark const * userMark); diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index f6e1b46d08..a64574303a 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -1,5 +1,4 @@ #include "drape_frontend/drape_engine.hpp" - #include "drape_frontend/message_subclasses.hpp" #include "drape_frontend/visual_params.hpp" @@ -8,9 +7,8 @@ #include "drape/texture_manager.hpp" -#include "platform/settings.hpp" - #include "platform/platform.hpp" +#include "platform/settings.hpp" #include "std/bind.hpp" diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 00bf43f8cb..e380a550e2 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -1,7 +1,7 @@ #pragma once -#include "drape_frontend/frontend_renderer.hpp" #include "drape_frontend/backend_renderer.hpp" +#include "drape_frontend/frontend_renderer.hpp" #include "drape_frontend/threads_commutator.hpp" #include "drape/pointers.hpp" diff --git a/drape_frontend/drape_frontend.pro b/drape_frontend/drape_frontend.pro index da83108c1f..e15d1b97c6 100755 --- a/drape_frontend/drape_frontend.pro +++ b/drape_frontend/drape_frontend.pro @@ -27,6 +27,8 @@ SOURCES += \ memory_feature_index.cpp \ message_acceptor.cpp \ message_queue.cpp \ + my_position.cpp \ + my_position_controller.cpp \ navigator.cpp \ path_symbol_shape.cpp \ path_text_shape.cpp \ @@ -44,13 +46,11 @@ SOURCES += \ tile_tree.cpp \ tile_tree_builder.cpp \ tile_utils.cpp \ + user_event_stream.cpp \ user_mark_shapes.cpp \ user_marks_provider.cpp \ viewport.cpp \ visual_params.cpp \ - my_position.cpp \ - user_event_stream.cpp \ - my_position_controller.cpp HEADERS += \ animation/base_interpolator.hpp \ @@ -75,6 +75,8 @@ HEADERS += \ message_acceptor.hpp \ message_queue.hpp \ message_subclasses.hpp \ + my_position.hpp \ + my_position_controller.hpp \ navigator.hpp \ path_symbol_shape.hpp \ path_text_shape.hpp \ @@ -93,10 +95,8 @@ HEADERS += \ tile_tree.hpp \ tile_tree_builder.hpp \ tile_utils.hpp \ + user_event_stream.hpp \ user_mark_shapes.hpp \ user_marks_provider.hpp \ viewport.hpp \ visual_params.hpp \ - my_position.hpp \ - user_event_stream.hpp \ - my_position_controller.hpp diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 4d1dc604e3..c058fce057 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -202,10 +202,10 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) m_myPositionController->Invalidate(); break; case ChangeMyPositionModeMessage::TYPE_CANCEL: - m_myPositionController->TurnOf(); + m_myPositionController->TurnOff(); break; default: - ASSERT(false, ()); + ASSERT(false, ("Unknown change type:", static_cast(msg->GetChangeType()))); break; } break; diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index d760aa00dc..3b99f912ea 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -302,7 +302,7 @@ public: TYPE_INVALIDATE }; - ChangeMyPositionModeMessage(EChangeType changeType) + explicit ChangeMyPositionModeMessage(EChangeType changeType) : m_changeType(changeType) { } @@ -311,7 +311,7 @@ public: Type GetType() const override { return Message::ChangeMyPostitionMode; } private: - EChangeType m_changeType; + EChangeType const m_changeType; }; class CompassInfoMessage : public Message @@ -325,7 +325,7 @@ public: location::CompassInfo const & GetInfo() const { return m_info; } private: - location::CompassInfo m_info; + location::CompassInfo const m_info; }; class GpsInfoMessage : public Message @@ -343,9 +343,9 @@ public: location::RouteMatchingInfo const & GetRouteInfo() const { return m_routeInfo; } private: - location::GpsInfo m_info; - bool m_isNavigable; - location::RouteMatchingInfo m_routeInfo; + location::GpsInfo const m_info; + bool const m_isNavigable; + location::RouteMatchingInfo const m_routeInfo; }; } // namespace df diff --git a/drape_frontend/my_position.cpp b/drape_frontend/my_position.cpp index 8b5bdbd9de..f4508e5b3a 100644 --- a/drape_frontend/my_position.cpp +++ b/drape_frontend/my_position.cpp @@ -51,9 +51,9 @@ dp::BindingInfo GetBindingInfo() MyPosition::MyPosition(ref_ptr mng) : m_position(m2::PointF::Zero()) - , m_azimut(0.0f) + , m_azimuth(0.0f) , m_accuracy(0.0f) - , m_showAzimut(false) + , m_showAzimuth(false) { m_parts.resize(3); CacheAccuracySector(mng); @@ -65,14 +65,14 @@ void MyPosition::SetPosition(m2::PointF const & pt) m_position = pt; } -void MyPosition::SetAzimut(float azimut) +void MyPosition::SetAzimuth(float azimut) { - m_azimut = azimut; + m_azimuth = azimut; } -void MyPosition::SetIsValidAzimut(bool isValid) +void MyPosition::SetIsValidAzimuth(bool isValid) { - m_showAzimut = isValid; + m_showAzimuth = isValid; } void MyPosition::SetAccuracy(float accuracy) @@ -98,8 +98,8 @@ void MyPosition::Render(ScreenBase const & screen, { dp::UniformValuesStorage arrowUniforms = uniforms; arrowUniforms.SetFloatValue("u_position", m_position.x, m_position.y, dp::depth::MY_POSITION_MARK); - arrowUniforms.SetFloatValue("u_azimut", -(m_azimut + screen.GetAngle())); - RenderPart(mng, arrowUniforms, (m_showAzimut == true) ? MY_POSITION_ARROW : MY_POSITION_POINT); + arrowUniforms.SetFloatValue("u_azimut", -(m_azimuth + screen.GetAngle())); + RenderPart(mng, arrowUniforms, (m_showAzimuth == true) ? MY_POSITION_ARROW : MY_POSITION_POINT); } } diff --git a/drape_frontend/my_position.hpp b/drape_frontend/my_position.hpp index b6584dbf42..f1ff4c177f 100644 --- a/drape_frontend/my_position.hpp +++ b/drape_frontend/my_position.hpp @@ -18,8 +18,8 @@ public: ///@param pt = mercator point void SetPosition(m2::PointF const & pt); - void SetAzimut(float azimut); - void SetIsValidAzimut(bool isValid); + void SetAzimuth(float azimut); + void SetIsValidAzimuth(bool isValid); void SetAccuracy(float accuracy); void Render(ScreenBase const & screen, @@ -59,9 +59,9 @@ private: private: m2::PointF m_position; - float m_azimut; + float m_azimuth; float m_accuracy; - bool m_showAzimut; + bool m_showAzimuth; using TPart = pair; diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index c52ccc35ab..30d5b0f054 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -10,19 +10,20 @@ namespace df namespace { -static const double GPS_BEARING_LIFETIME_S = 5.0; +double const GPS_BEARING_LIFETIME_S = 5.0; +double const MIN_SPEED_THRESHOLD_MPS = 1.0; -uint16_t IncludeModeBit(uint16_t mode, uint16_t bit) +uint16_t SetModeBit(uint16_t mode, uint16_t bit) { return mode | bit; } -//uint16_t ExcludeModeBit(uint16_t mode, uint16_t bit) +//uint16_t ResetModeBit(uint16_t mode, uint16_t bit) //{ // return mode & (~bit); //} -location::EMyPositionMode ExcludeAllBits(uint16_t mode) +location::EMyPositionMode ResetAllModeBits(uint16_t mode) { return (location::EMyPositionMode)(mode & 0xF); } @@ -81,7 +82,7 @@ void MyPositionController::SetRenderShape(drape_ptr && shape) void MyPositionController::SetFixedZoom() { - SetModeInfo(IncludeModeBit(m_modeInfo, FixedZoomBit)); + SetModeInfo(SetModeBit(m_modeInfo, FixedZoomBit)); } void MyPositionController::NextMode() @@ -125,12 +126,14 @@ void MyPositionController::NextMode() } } else + { newMode = IsRotationActive() ? location::MODE_ROTATE_AND_FOLLOW : location::MODE_FOLLOW; + } SetModeInfo(ChangeMode(m_modeInfo, newMode)); } -void MyPositionController::TurnOf() +void MyPositionController::TurnOff() { StopLocationFollow(); SetModeInfo(location::MODE_UNKNOWN_POSITION); @@ -166,7 +169,9 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool m_afterPendingMode = location::MODE_FOLLOW; } else + { AnimateFollow(); + } } void MyPositionController::OnCompassUpdate(location::CompassInfo const & info) @@ -187,8 +192,8 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr location::MODE_PENDING_POSITION) { m_shape->SetPosition(m_position); - m_shape->SetAzimut(m_drawDirection); - m_shape->SetIsValidAzimut(IsRotationActive()); + m_shape->SetAzimuth(m_drawDirection); + m_shape->SetIsValidAzimuth(IsRotationActive()); m_shape->SetAccuracy(m_errorRadius); m_shape->Render(screen, mng, commonUniforms); } @@ -196,12 +201,12 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr 1.0)) + if ((isNavigable && hasBearing) || + (!isNavigable && hasBearing && info.HasSpeed() && info.m_speed > MIN_SPEED_THRESHOLD_MPS)) { SetDirection(my::DegToRad(info.m_bearing)); m_lastGPSBearing.Reset(); @@ -225,7 +230,9 @@ bool MyPositionController::Assign(location::CompassInfo const & info) { if ((IsInRouting() && GetMode() >= location::MODE_FOLLOW) || (m_lastGPSBearing.ElapsedSeconds() < GPS_BEARING_LIFETIME_S)) + { return false; + } SetDirection(info.m_bearing); return true; @@ -234,12 +241,12 @@ bool MyPositionController::Assign(location::CompassInfo const & info) void MyPositionController::SetDirection(double bearing) { m_drawDirection = bearing; - SetModeInfo(IncludeModeBit(m_modeInfo, KnownDirectionBit)); + SetModeInfo(SetModeBit(m_modeInfo, KnownDirectionBit)); } void MyPositionController::SetModeInfo(uint16_t modeInfo, bool force) { - location::EMyPositionMode const newMode = ExcludeAllBits(modeInfo); + location::EMyPositionMode const newMode = ResetAllModeBits(modeInfo); location::EMyPositionMode const oldMode = GetMode(); m_modeInfo = modeInfo; if (newMode != oldMode || force) @@ -251,13 +258,13 @@ void MyPositionController::SetModeInfo(uint16_t modeInfo, bool force) location::EMyPositionMode MyPositionController::GetMode() const { - return ExcludeAllBits(m_modeInfo); + return ResetAllModeBits(m_modeInfo); } void MyPositionController::CallModeListener(uint16_t mode) { if (m_modeChangeCallback != nullptr) - m_modeChangeCallback(ExcludeAllBits(mode)); + m_modeChangeCallback(ResetAllModeBits(mode)); } bool MyPositionController::IsInRouting() const diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp index d15259d1cd..08d3d7dc60 100644 --- a/drape_frontend/my_position_controller.hpp +++ b/drape_frontend/my_position_controller.hpp @@ -30,7 +30,7 @@ public: void SetFixedZoom(); void NextMode(); - void TurnOf(); + void TurnOff(); void Invalidate(); void OnLocationUpdate(location::GpsInfo const & info, bool isNavigable); @@ -80,7 +80,7 @@ private: double m_errorRadius; //< error radius in mercator m2::PointD m_position; //< position in mercator double m_drawDirection; - my::Timer m_lastGPSBearing; + my::HighResTimer m_lastGPSBearing; bool m_isVisible; };