Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-05-30 14:51:58 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-07-07 15:31:06 +0300
commitfb39e154fe53384ddbb857681065248abb6792f4 (patch)
tree4fc0bb92a90df958e1008a6561bdd4cf7bf51fed /drape_frontend
parent037a39d938ddac66326fa9aad172cf073b0d904f (diff)
Follow animation operates with pixel positions on viewport.
Diffstat (limited to 'drape_frontend')
-rw-r--r--drape_frontend/animation/follow_animation.cpp10
-rw-r--r--drape_frontend/my_position_controller.cpp14
-rw-r--r--drape_frontend/my_position_controller.hpp2
-rw-r--r--drape_frontend/screen_animations.cpp2
-rw-r--r--drape_frontend/screen_operations.cpp12
-rw-r--r--drape_frontend/screen_operations.hpp2
-rw-r--r--drape_frontend/user_event_stream.cpp6
7 files changed, 33 insertions, 15 deletions
diff --git a/drape_frontend/animation/follow_animation.cpp b/drape_frontend/animation/follow_animation.cpp
index 4c387fcecd..ba708512ea 100644
--- a/drape_frontend/animation/follow_animation.cpp
+++ b/drape_frontend/animation/follow_animation.cpp
@@ -98,7 +98,7 @@ m2::PointD MapFollowAnimation::CalculateCenter(ScreenBase const & screen, m2::Po
m2::PointD const & pixelPos, double azimuth)
{
double const scale = screen.GlobalRect().GetLocalRect().SizeX() / screen.PixelRect().SizeX();
- return CalculateCenter(scale, screen.PixelRect(), userPos, pixelPos, azimuth);
+ return CalculateCenter(scale, screen.PixelRect(), userPos, screen.P3dtoP(pixelPos), azimuth);
}
// static
@@ -126,16 +126,18 @@ bool MapFollowAnimation::GetProperty(TObject object, TProperty property, bool ta
{
if (property == Animation::Position)
{
- m2::RectD const pixelRect = AnimationSystem::Instance().GetLastScreen().PixelRect();
+ ScreenBase const & screen = AnimationSystem::Instance().GetLastScreen();
+ m2::RectD const pixelRect = screen.PixelRect();
if (targetValue)
{
+ // TODO: calculate target pixel position with corresponding scale
value = PropertyValue(CalculateCenter(m_scaleInterpolator.GetTargetScale(), pixelRect, m_globalPosition,
- m_pixelPosInterpolator.GetTargetPosition(), m_angleInterpolator.GetTargetAngle()));
+ screen.P3dtoP(m_pixelPosInterpolator.GetTargetPosition()), m_angleInterpolator.GetTargetAngle()));
}
else
{
value = PropertyValue(CalculateCenter(m_scaleInterpolator.GetScale(), pixelRect, m_globalPosition,
- m_pixelPosInterpolator.GetPosition(), m_angleInterpolator.GetAngle()));
+ screen.P3dtoP(m_pixelPosInterpolator.GetPosition()), m_angleInterpolator.GetAngle()));
}
return true;
}
diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp
index 8c179fab77..5d91c921d4 100644
--- a/drape_frontend/my_position_controller.cpp
+++ b/drape_frontend/my_position_controller.cpp
@@ -112,8 +112,6 @@ void MyPositionController::UpdatePixelPosition(ScreenBase const & screen)
{
m_pixelRect = screen.isPerspective() ? screen.PixelRectIn3d() : screen.PixelRect();
m_positionYOffset = screen.isPerspective() ? kPositionOffsetYIn3D : kPositionOffsetY;
- m_centerPixelPositionRouting = screen.P3dtoP(GetRoutingRotationPixelCenter());
- m_centerPixelPosition = screen.P3dtoP(m_pixelRect.Center());
}
void MyPositionController::SetListener(ref_ptr<MyPositionController::Listener> listener)
@@ -266,7 +264,7 @@ void MyPositionController::NextMode(ScreenBase const & screen)
if (!m_isInRouting)
{
ChangeMode(location::Follow);
- ChangeModelView(m_position, 0.0, m_centerPixelPosition, preferredZoomLevel);
+ ChangeModelView(m_position, 0.0, m_pixelRect.Center(), preferredZoomLevel);
}
}
}
@@ -317,7 +315,7 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool
ChangeModelView(m_position, kDoNotChangeZoom);
else if (m_mode == location::FollowAndRotate)
ChangeModelView(m_position, m_drawDirection,
- m_isInRouting ? m_centerPixelPositionRouting : m_centerPixelPosition, kDoNotChangeZoom);
+ m_isInRouting ? GetRoutingRotationPixelCenter() : m_pixelRect.Center(), kDoNotChangeZoom);
}
}
else if (m_mode == location::PendingPosition || m_mode == location::NotFollowNoPosition)
@@ -525,7 +523,7 @@ void MyPositionController::OnCompassTapped()
if (m_mode == location::FollowAndRotate)
{
ChangeMode(location::Follow);
- ChangeModelView(m_position, 0.0, m_centerPixelPosition, kDoNotChangeZoom);
+ ChangeModelView(m_position, 0.0, m_pixelRect.Center(), kDoNotChangeZoom);
}
else
{
@@ -567,7 +565,7 @@ void MyPositionController::UpdateViewport(int zoomLevel)
ChangeModelView(m_position, zoomLevel);
else if (m_mode == location::FollowAndRotate)
ChangeModelView(m_position, m_drawDirection,
- m_isInRouting ? m_centerPixelPositionRouting : m_centerPixelPosition, zoomLevel);
+ m_isInRouting ? GetRoutingRotationPixelCenter() : m_pixelRect.Center(), zoomLevel);
}
m2::PointD MyPositionController::GetRotationPixelCenter() const
@@ -658,7 +656,7 @@ void MyPositionController::ActivateRouting(int zoomLevel)
if (IsRotationAvailable())
{
ChangeMode(location::FollowAndRotate);
- ChangeModelView(m_position, m_drawDirection, m_centerPixelPositionRouting, zoomLevel);
+ ChangeModelView(m_position, m_drawDirection, GetRoutingRotationPixelCenter(), zoomLevel);
}
else
{
@@ -675,7 +673,7 @@ void MyPositionController::DeactivateRouting()
m_isInRouting = false;
ChangeMode(location::Follow);
- ChangeModelView(m_position, 0.0, m_centerPixelPosition, kDoNotChangeZoom);
+ ChangeModelView(m_position, 0.0, m_pixelRect.Center(), kDoNotChangeZoom);
}
}
diff --git a/drape_frontend/my_position_controller.hpp b/drape_frontend/my_position_controller.hpp
index 997daa6f0e..e93b6e9fff 100644
--- a/drape_frontend/my_position_controller.hpp
+++ b/drape_frontend/my_position_controller.hpp
@@ -153,8 +153,6 @@ private:
double m_lastLocationTimestamp;
m2::RectD m_pixelRect;
- m2::PointD m_centerPixelPositionRouting;
- m2::PointD m_centerPixelPosition;
double m_positionYOffset;
bool m_isVisible;
diff --git a/drape_frontend/screen_animations.cpp b/drape_frontend/screen_animations.cpp
index e4119bbdbd..0364f765d8 100644
--- a/drape_frontend/screen_animations.cpp
+++ b/drape_frontend/screen_animations.cpp
@@ -101,7 +101,7 @@ drape_ptr<MapFollowAnimation> GetFollowAnimation(ScreenBase const & startScreen,
{
auto anim = make_unique_dp<MapFollowAnimation>(userPos, startScreen.GetScale(), targetScale,
startScreen.GetAngle(), targetAngle,
- startScreen.GtoP(userPos), endPixelPos, startScreen.PixelRect());
+ startScreen.PtoP3d(startScreen.GtoP(userPos)), endPixelPos, startScreen.PixelRect());
anim->SetMaxDuration(kMaxAnimationTimeSec);
return anim;
diff --git a/drape_frontend/screen_operations.cpp b/drape_frontend/screen_operations.cpp
index acc083dedc..5060097425 100644
--- a/drape_frontend/screen_operations.cpp
+++ b/drape_frontend/screen_operations.cpp
@@ -272,4 +272,16 @@ bool ApplyScale(m2::PointD const & pixelScaleCenter, double factor, ScreenBase &
return true;
}
+double CalculatePerspectiveAngle(ScreenBase const & screen)
+{
+ double const kStartPerspectiveScale = 0.5;
+ double const kMaxScale = 0.2;
+ double const kMaxPerspectiveAngle = math::pi4;
+
+ double const currentScale = screen.GetScale();
+ if (currentScale > kStartPerspectiveScale)
+ return 0.0;
+ return kMaxPerspectiveAngle * (kStartPerspectiveScale - currentScale) / (kStartPerspectiveScale - kMaxScale);
+}
+
} // namespace df
diff --git a/drape_frontend/screen_operations.hpp b/drape_frontend/screen_operations.hpp
index dd34bdad7e..e9239180e5 100644
--- a/drape_frontend/screen_operations.hpp
+++ b/drape_frontend/screen_operations.hpp
@@ -28,4 +28,6 @@ m2::PointD CalculateCenter(double scale, m2::RectD const & pixelRect,
bool ApplyScale(m2::PointD const & pixelScaleCenter, double factor, ScreenBase & screen);
+double CalculatePerspectiveAngle(ScreenBase const & screen);
+
} // namespace df
diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp
index 0a7cdc687f..622c4b6a10 100644
--- a/drape_frontend/user_event_stream.cpp
+++ b/drape_frontend/user_event_stream.cpp
@@ -576,6 +576,9 @@ void UserEventStream::SetEnable3dMode(double maxRotationAngle, double angleFOV,
{
ResetAnimationsBeforeSwitch3D();
+ //m_navigator.Enable3dMode(0.0, maxRotationAngle, angleFOV);
+ //return;
+
if (immediatelyStart)
InterruptFollowAnimations(true /* force */);
@@ -602,6 +605,9 @@ void UserEventStream::SetDisable3dModeAnimation()
ResetAnimationsBeforeSwitch3D();
InterruptFollowAnimations(true /* force */);
+ //m_navigator.Disable3dMode();
+ //return;
+
if (m_discardedFOV > 0.0 && IsScaleAllowableIn3d(GetDrawTileScale(GetCurrentScreen())))
{
m_discardedFOV = m_discardedAngle = 0.0;