Fixed positioning of the arrow after starting of route following.

This commit is contained in:
Daria Volvenkova 2018-01-16 17:01:36 +03:00 committed by Roman Kuznetsov
parent 1f4ff04f2e
commit 4aba5f3612
6 changed files with 36 additions and 19 deletions

View file

@ -2030,18 +2030,18 @@ void FrontendRenderer::ChangeModelView(m2::RectD const & rect,
void FrontendRenderer::ChangeModelView(m2::PointD const & userPos, double azimuth,
m2::PointD const & pxZero, int preferredZoomLevel,
Animation::TAction const & onFinishAction,
TAnimationCreator const & parallelAnimCreator)
{
AddUserEvent(make_unique_dp<FollowAndRotateEvent>(userPos, pxZero, azimuth, preferredZoomLevel,
true, parallelAnimCreator));
true, onFinishAction, parallelAnimCreator));
}
void FrontendRenderer::ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth,
m2::PointD const & pxZero,
TAnimationCreator const & parallelAnimCreator)
m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator)
{
AddUserEvent(make_unique_dp<FollowAndRotateEvent>(userPos, pxZero, azimuth, autoScale,
parallelAnimCreator));
nullptr, parallelAnimCreator));
}
ScreenBase const & FrontendRenderer::ProcessEvents(bool & modelViewChanged, bool & viewportChanged)

View file

@ -124,11 +124,10 @@ public:
void ChangeModelView(m2::RectD const & rect,
TAnimationCreator const & parallelAnimCreator) override;
void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero,
int preferredZoomLevel,
int preferredZoomLevel, Animation::TAction const & onFinishAction,
TAnimationCreator const & parallelAnimCreator) override;
void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth,
m2::PointD const & pxZero,
TAnimationCreator const & parallelAnimCreator) override;
m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator) override;
drape_ptr<ScenarioManager> const & GetScenarioManager() const;

View file

@ -689,14 +689,16 @@ void MyPositionController::ChangeModelView(m2::RectD const & rect)
}
void MyPositionController::ChangeModelView(m2::PointD const & userPos, double azimuth,
m2::PointD const & pxZero, int zoomLevel)
m2::PointD const & pxZero, int zoomLevel,
Animation::TAction const & onFinishAction)
{
if (m_listener)
m_listener->ChangeModelView(userPos, azimuth, pxZero, zoomLevel, m_animCreator);
m_listener->ChangeModelView(userPos, azimuth, pxZero, zoomLevel, onFinishAction, m_animCreator);
m_animCreator = nullptr;
}
void MyPositionController::ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero)
void MyPositionController::ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth,
m2::PointD const & pxZero)
{
if (m_listener)
m_listener->ChangeModelView(autoScale, userPos, azimuth, pxZero, m_animCreator);
@ -818,7 +820,11 @@ void MyPositionController::ActivateRouting(int zoomLevel, bool enableAutoZoom)
ChangeMode(location::FollowAndRotate);
ChangeModelView(m_position, m_isDirectionAssigned ? m_drawDirection : 0.0,
GetRoutingRotationPixelCenter(), zoomLevel);
GetRoutingRotationPixelCenter(), zoomLevel,
[this](ref_ptr<Animation> anim)
{
UpdateViewport(kDoNotChangeZoom);
});
}
}

View file

@ -1,5 +1,6 @@
#pragma once
#include "drape_frontend/animation/animation.hpp"
#include "drape_frontend/drape_hints.hpp"
#include "drape_frontend/my_position.hpp"
@ -17,7 +18,6 @@
namespace df
{
class Animation;
using TAnimationCreator = function<drape_ptr<Animation>(ref_ptr<Animation>)>;
class MyPositionController
@ -36,7 +36,8 @@ public:
virtual void ChangeModelView(m2::RectD const & rect, TAnimationCreator const & parallelAnimCreator) = 0;
/// Show map where "usePos" (mercator) placed in "pxZero" on screen and map rotated around "userPos"
virtual void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero,
int zoomLevel, TAnimationCreator const & parallelAnimCreator) = 0;
int zoomLevel, Animation::TAction const & onFinishAction,
TAnimationCreator const & parallelAnimCreator) = 0;
virtual void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero,
TAnimationCreator const & parallelAnimCreator) = 0;
};
@ -139,7 +140,8 @@ private:
void ChangeModelView(m2::PointD const & center, int zoomLevel);
void ChangeModelView(double azimuth);
void ChangeModelView(m2::RectD const & rect);
void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, int zoomLevel);
void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, int zoomLevel,
Animation::TAction const & onFinishAction = nullptr);
void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero);
void UpdateViewport(int zoomLevel);

View file

@ -234,7 +234,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool
breakAnim = SetFollowAndRotate(followEvent->GetUserPos(), followEvent->GetPixelZero(),
followEvent->GetAzimuth(), followEvent->GetPreferredZoomLelel(),
followEvent->GetAutoScale(), followEvent->IsAnim(), followEvent->IsAutoScale(),
followEvent->GetParallelAnimCreator());
followEvent->GetOnFinishAction(), followEvent->GetParallelAnimCreator());
}
break;
case UserEvent::EventType::AutoPerspective:
@ -437,6 +437,7 @@ bool UserEventStream::SetAngle(double azimuth, TAnimationCreator const & paralle
return SetFollowAndRotate(gPt, pt,
azimuth, kDoNotChangeZoom, kDoNotAutoZoom,
true /* isAnim */, false /* isAutoScale */,
nullptr /* onFinishAction */,
parallelAnimCreator);
}
@ -530,7 +531,8 @@ bool UserEventStream::InterruptFollowAnimations(bool force)
bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD const & pixelPos,
double azimuth, int preferredZoomLevel, double autoScale,
bool isAnim, bool isAutoScale, TAnimationCreator const & parallelAnimCreator)
bool isAnim, bool isAutoScale, Animation::TAction const & onFinishAction,
TAnimationCreator const & parallelAnimCreator)
{
// Reset current follow-and-rotate animation if possible.
if (isAnim && !InterruptFollowAnimations(false /* force */))
@ -575,6 +577,8 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD
anim->SetCouldBeBlended(false);
}
anim->SetOnFinishAction(onFinishAction);
if (parallelAnimCreator != nullptr)
{
drape_ptr<ParallelAnimation> parallelAnim = make_unique_dp<ParallelAnimation>();

View file

@ -216,7 +216,8 @@ class FollowAndRotateEvent : public UserEvent
{
public:
FollowAndRotateEvent(m2::PointD const & userPos, m2::PointD const & pixelZero,
double azimuth, double autoScale, TAnimationCreator const & parallelAnimCreator = nullptr)
double azimuth, double autoScale,
TAnimationCreator const & parallelAnimCreator = nullptr)
: m_userPos(userPos)
, m_pixelZero(pixelZero)
, m_azimuth(azimuth)
@ -224,13 +225,15 @@ public:
, m_autoScale(autoScale)
, m_isAutoScale(true)
, m_isAnim(true)
, m_onFinishAction(nullptr)
, m_parallelAnimCreator(parallelAnimCreator)
{
}
FollowAndRotateEvent(m2::PointD const & userPos, m2::PointD const & pixelZero,
double azimuth, int preferredZoomLevel,
bool isAnim, TAnimationCreator const & parallelAnimCreator = nullptr)
bool isAnim, Animation::TAction const & onFinishAction = nullptr,
TAnimationCreator const & parallelAnimCreator = nullptr)
: m_userPos(userPos)
, m_pixelZero(pixelZero)
, m_azimuth(azimuth)
@ -238,6 +241,7 @@ public:
, m_autoScale(kDoNotAutoZoom)
, m_isAutoScale(false)
, m_isAnim(isAnim)
, m_onFinishAction(onFinishAction)
, m_parallelAnimCreator(parallelAnimCreator)
{}
@ -251,6 +255,7 @@ public:
bool IsAutoScale() const { return m_isAutoScale; }
bool IsAnim() const { return m_isAnim; }
TAnimationCreator const & GetParallelAnimCreator() const { return m_parallelAnimCreator; }
Animation::TAction const & GetOnFinishAction() const { return m_onFinishAction; }
private:
m2::PointD m_userPos;
@ -260,6 +265,7 @@ private:
double m_autoScale;
bool m_isAutoScale;
bool m_isAnim;
Animation::TAction m_onFinishAction;
TAnimationCreator m_parallelAnimCreator;
};
@ -412,7 +418,7 @@ private:
TAnimationCreator const & parallelAnimCreator = nullptr);
bool SetFollowAndRotate(m2::PointD const & userPos, m2::PointD const & pixelPos,
double azimuth, int preferredZoomLevel, double autoScale,
bool isAnim, bool isAutoScale,
bool isAnim, bool isAutoScale, Animation::TAction const & onFinishAction = nullptr,
TAnimationCreator const & parallelAnimCreator = nullptr);
void SetAutoPerspective(bool isAutoPerspective);
void CheckAutoRotate();