diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-04-19 13:45:42 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-04-22 14:52:11 +0300 |
commit | fe27fac70eeade00550bc383cd32eab500079bee (patch) | |
tree | 145dbc2ecc09686e3836c0b3dfab4bbf8eaa23e0 | |
parent | 0947ace7f8497cfcdaf65a2ce9de38ce61e6443a (diff) |
Turned off 3d buildings and displacement for add-new-place mode
-rw-r--r-- | drape/overlay_tree.cpp | 24 | ||||
-rw-r--r-- | drape/overlay_tree.hpp | 4 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.cpp | 34 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.hpp | 3 | ||||
-rw-r--r-- | drape_frontend/gui/layer_render.cpp | 5 | ||||
-rw-r--r-- | drape_frontend/gui/layer_render.hpp | 2 | ||||
-rw-r--r-- | drape_frontend/my_position_controller.hpp | 5 | ||||
-rw-r--r-- | indexer/scales.hpp | 10 |
8 files changed, 74 insertions, 13 deletions
diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp index b50317e67e..394ce7e0a6 100644 --- a/drape/overlay_tree.cpp +++ b/drape/overlay_tree.cpp @@ -8,6 +8,7 @@ namespace dp int const kFrameUpdatePeriod = 10; int const kAverageHandlesCount[dp::OverlayRanksCount] = { 300, 200, 50 }; +int const kInvalidFrame = -1; namespace { @@ -59,8 +60,9 @@ private: } // namespace OverlayTree::OverlayTree() - : m_frameCounter(-1) + : m_frameCounter(kInvalidFrame) , m_followingMode(false) + , m_isDisplacementEnabled(true) { for (size_t i = 0; i < m_handles.size(); i++) m_handles[i].reserve(kAverageHandlesCount[i]); @@ -73,14 +75,14 @@ bool OverlayTree::Frame() m_frameCounter++; if (m_frameCounter >= kFrameUpdatePeriod) - m_frameCounter = -1; + m_frameCounter = kInvalidFrame; return IsNeedUpdate(); } bool OverlayTree::IsNeedUpdate() const { - return m_frameCounter == -1; + return m_frameCounter == kInvalidFrame; } void OverlayTree::StartOverlayPlacing(ScreenBase const & screen) @@ -97,11 +99,11 @@ void OverlayTree::StartOverlayPlacing(ScreenBase const & screen) void OverlayTree::Remove(ref_ptr<OverlayHandle> handle) { - if (m_frameCounter == -1) + if (m_frameCounter == kInvalidFrame) return; if (m_handlesCache.find(handle) != m_handlesCache.end()) - m_frameCounter = -1; + m_frameCounter = kInvalidFrame; } void OverlayTree::Add(ref_ptr<OverlayHandle> handle) @@ -161,6 +163,12 @@ void OverlayTree::InsertHandle(ref_ptr<OverlayHandle> handle, ScreenBase const & modelView = GetModelView(); m2::RectD const pixelRect = handle->GetExtendedPixelRect(modelView); + if (!m_isDisplacementEnabled) + { + m_handlesCache.insert(handle); + TBase::Add(handle, pixelRect); + return; + } TOverlayContainer rivals; HandleComparator comparator(true /* enableMask */, m_followingMode); @@ -383,6 +391,12 @@ void OverlayTree::SetFollowingMode(bool mode) m_followingMode = mode; } +void OverlayTree::SetDisplacementEnabled(bool enabled) +{ + m_isDisplacementEnabled = enabled; + m_frameCounter = kInvalidFrame; +} + #ifdef COLLECT_DISPLACEMENT_INFO OverlayTree::TDisplacementInfo const & OverlayTree::GetDisplacementInfo() const diff --git a/drape/overlay_tree.hpp b/drape/overlay_tree.hpp index 817680ff45..3b11413352 100644 --- a/drape/overlay_tree.hpp +++ b/drape/overlay_tree.hpp @@ -63,6 +63,8 @@ public: void SetFollowingMode(bool mode); + void SetDisplacementEnabled(bool enabled); + #ifdef COLLECT_DISPLACEMENT_INFO struct DisplacementData { @@ -90,6 +92,8 @@ private: unordered_set<ref_ptr<OverlayHandle>, detail::OverlayHasher> m_handlesCache; bool m_followingMode; + bool m_isDisplacementEnabled; + #ifdef COLLECT_DISPLACEMENT_INFO TDisplacementInfo m_displacementInfo; #endif diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 5e2cacad1c..8e77bfc85e 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -119,6 +119,7 @@ FrontendRenderer::FrontendRenderer(Params const & params) , m_enable3dBuildings(params.m_allow3dBuildings) , m_isIsometry(false) , m_blockTapEvents(params.m_blockTapEvents) + , m_choosePositionMode(false) , m_viewport(params.m_viewport) , m_modelViewChangedFn(params.m_modelViewChangedFn) , m_tapEventInfoFn(params.m_tapEventFn) @@ -347,6 +348,26 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message) m_guiRenderer = move(renderer); else m_guiRenderer->Merge(make_ref(renderer)); + + bool oldMode = m_choosePositionMode; + m_choosePositionMode = m_guiRenderer->HasWidget(gui::WIDGET_CHOOSE_POSITION_MARK); + if (oldMode != m_choosePositionMode) + { + ScreenBase const & screen = m_userEventStream.GetCurrentScreen(); + CheckIsometryMinScale(screen); + UpdateDisplacementEnabled(); + if (!m_choosePositionMode || m_currentZoomLevel >= scales::GetAddNewPlaceScale()) + { + InvalidateRect(screen.ClipRect()); + } + else + { + m2::PointD pt = screen.GlobalRect().Center(); + if (!m_myPositionController->IsWaitingForLocation()) + pt = m_myPositionController->GetDrawablePosition(); + AddUserEvent(SetCenterEvent(pt, scales::GetAddNewPlaceScale(), true)); + } + } break; } @@ -1189,10 +1210,10 @@ void FrontendRenderer::DisablePerspective() AddUserEvent(DisablePerspectiveEvent()); } -void FrontendRenderer::CheckIsometryMinScale(const ScreenBase &screen) +void FrontendRenderer::CheckIsometryMinScale(ScreenBase const & screen) { bool const isScaleAllowableIn3d = UserEventStream::IsScaleAllowableIn3d(m_currentZoomLevel); - bool const isIsometry = m_enable3dBuildings && isScaleAllowableIn3d; + bool const isIsometry = m_enable3dBuildings && !m_choosePositionMode && isScaleAllowableIn3d; if (m_isIsometry != isIsometry) { m_isIsometry = isIsometry; @@ -1224,6 +1245,15 @@ void FrontendRenderer::ResolveZoomLevel(ScreenBase const & screen) CheckIsometryMinScale(screen); CheckPerspectiveMinScale(); + UpdateDisplacementEnabled(); +} + +void FrontendRenderer::UpdateDisplacementEnabled() +{ + if (m_choosePositionMode) + m_overlayTree->SetDisplacementEnabled(m_currentZoomLevel < scales::GetAddNewPlaceScale()); + else + m_overlayTree->SetDisplacementEnabled(true); } void FrontendRenderer::OnTap(m2::PointD const & pt, bool isLongTap) diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 461dc51aba..c2732e2e34 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -168,6 +168,7 @@ private: TTilesCollection ResolveTileKeys(ScreenBase const & screen); void ResolveZoomLevel(ScreenBase const & screen); + void UpdateDisplacementEnabled(); void CheckPerspectiveMinScale(); void CheckIsometryMinScale(ScreenBase const & screen); @@ -272,6 +273,8 @@ private: bool m_blockTapEvents; + bool m_choosePositionMode; + Viewport m_viewport; UserEventStream m_userEventStream; TModelViewChanged m_modelViewChangedFn; diff --git a/drape_frontend/gui/layer_render.cpp b/drape_frontend/gui/layer_render.cpp index 8ec711ab78..3282fc89ca 100644 --- a/drape_frontend/gui/layer_render.cpp +++ b/drape_frontend/gui/layer_render.cpp @@ -129,6 +129,11 @@ void LayerRenderer::OnTouchCancel(m2::RectD const & touchArea) } } +bool LayerRenderer::HasWidget(EWidget widget) const +{ + return m_renderers.find(widget) != m_renderers.end(); +} + namespace { diff --git a/drape_frontend/gui/layer_render.hpp b/drape_frontend/gui/layer_render.hpp index dd8f63e444..f48cf76c0c 100644 --- a/drape_frontend/gui/layer_render.hpp +++ b/drape_frontend/gui/layer_render.hpp @@ -35,6 +35,8 @@ public: void OnTouchUp(m2::RectD const & touchArea); void OnTouchCancel(m2::RectD const & touchArea); + bool HasWidget(EWidget widget) const; + private: void DestroyRenderers(); diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp index 65200a910c..30ba569d01 100644 --- a/drape_frontend/my_position_controller.hpp +++ b/drape_frontend/my_position_controller.hpp @@ -95,12 +95,14 @@ public: bool IsRouteFollowingActive() const; bool IsWaitingForTimers() const; + bool IsWaitingForLocation() const; + m2::PointD GetDrawablePosition() const; + private: bool IsModeChangeViewport() const; void ChangeMode(location::EMyPositionMode newMode); void SetDirection(double bearing); - bool IsWaitingForLocation() const; bool IsVisible() const { return m_isVisible; } void SetIsVisible(bool isVisible) { m_isVisible = isVisible; } @@ -114,7 +116,6 @@ private: m2::PointD GetRotationPixelCenter() const; m2::PointD GetRoutingRotationPixelCenter() const; - m2::PointD GetDrawablePosition() const; double GetDrawableAzimut() const; void CheckAnimFinished() const; void CreateAnim(m2::PointD const & oldPos, double oldAzimut, ScreenBase const & screen); diff --git a/indexer/scales.hpp b/indexer/scales.hpp index 2e0b21048a..10d9cc1c4a 100644 --- a/indexer/scales.hpp +++ b/indexer/scales.hpp @@ -18,14 +18,16 @@ namespace scales constexpr int GetUpperCountryScale() { return GetUpperWorldScale() + 1; } /// Upper scale for user comfort view (e.g. location zoom). constexpr int GetUpperComfortScale() { return UPPER_STYLE_SCALE - 2; } - /// Default navigation mode scale + /// Default navigation mode scale. constexpr int GetNavigationScale() { return UPPER_STYLE_SCALE - 3; } - /// Default pedestrian navigation mode scale + /// Default pedestrian navigation mode scale. constexpr int GetPedestrianNavigationScale() { return UPPER_STYLE_SCALE - 2; } - /// Default navigation 3d mode scale + /// Default navigation 3d mode scale. constexpr int GetNavigation3dScale() { return UPPER_STYLE_SCALE - 2; } - /// Default pedestrian navigation 3d mode scale + /// Default pedestrian navigation 3d mode scale. constexpr int GetPedestrianNavigation3dScale() { return UPPER_STYLE_SCALE - 2; } + /// Default scale in adding-new-place mode. + constexpr int GetAddNewPlaceScale() { return 18; } int GetMinAllowableIn3dScale(); |