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-06-28 12:54:31 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-07-07 15:31:10 +0300
commit5bd3d26105c12dc662d0b6e118e9b436abb093bd (patch)
tree01e9a654421f66e2dd8041b28ec94f55cac4b821 /drape_frontend
parent599063085a467816be63fc93ba505150e7d67281 (diff)
Set center fixed.
Diffstat (limited to 'drape_frontend')
-rw-r--r--drape_frontend/my_position_controller.cpp4
-rw-r--r--drape_frontend/screen_animations.cpp18
-rw-r--r--drape_frontend/screen_animations.hpp2
-rw-r--r--drape_frontend/user_event_stream.cpp74
-rw-r--r--drape_frontend/user_event_stream.hpp2
-rw-r--r--drape_frontend/visual_params.cpp12
-rw-r--r--drape_frontend/visual_params.hpp3
7 files changed, 90 insertions, 25 deletions
diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp
index 29bbf6e6c4..0feaf86a64 100644
--- a/drape_frontend/my_position_controller.cpp
+++ b/drape_frontend/my_position_controller.cpp
@@ -52,7 +52,7 @@ string LocationModeStatisticsName(location::EMyPositionMode mode)
int GetZoomLevel(ScreenBase const & screen)
{
- return my::clamp(fabs(log(screen.GetScale()) / log(2.0)), 1, scales::GetUpperStyleScale());
+ return df::GetZoomLevel(screen.GetScale());
}
int GetZoomLevel(ScreenBase const & screen, m2::PointD const & position, double errorRadius)
@@ -63,6 +63,8 @@ int GetZoomLevel(ScreenBase const & screen, m2::PointD const & position, double
return GetZoomLevel(s);
}
+
+
} // namespace
MyPositionController::MyPositionController(location::EMyPositionMode initMode, double timeInBackground,
diff --git a/drape_frontend/screen_animations.cpp b/drape_frontend/screen_animations.cpp
index e2076746ef..8a68748a8c 100644
--- a/drape_frontend/screen_animations.cpp
+++ b/drape_frontend/screen_animations.cpp
@@ -13,6 +13,12 @@ namespace df
string const kPrettyMoveAnim = "PrettyMove";
string const kPrettyFollowAnim = "PrettyFollow";
+drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & startScreen, ScreenBase const & endScreen)
+{
+ return GetPrettyMoveAnimation(startScreen, startScreen.GetScale(), endScreen.GetScale(),
+ startScreen.GetOrg(), endScreen.GetOrg());
+}
+
drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & screen,
m2::AnyRectD const & startRect, m2::AnyRectD const & endRect)
{
@@ -80,6 +86,18 @@ drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & screen,
return sequenceAnim;
}
+drape_ptr<MapLinearAnimation> GetRectAnimation(ScreenBase const & startScreen, ScreenBase const & endScreen)
+{
+ auto anim = make_unique_dp<MapLinearAnimation>();
+
+ anim->SetRotate(startScreen.GetAngle(), endScreen.GetAngle());
+ anim->SetMove(startScreen.GetOrg(), endScreen.GetOrg(), startScreen);
+ anim->SetScale(startScreen.GetScale(), endScreen.GetScale());
+ anim->SetMaxScaleDuration(kMaxAnimationTimeSec);
+
+ return anim;
+}
+
drape_ptr<MapLinearAnimation> GetSetRectAnimation(ScreenBase const & screen,
m2::AnyRectD const & startRect, m2::AnyRectD const & endRect)
{
diff --git a/drape_frontend/screen_animations.hpp b/drape_frontend/screen_animations.hpp
index b8a6d83622..15dfa758da 100644
--- a/drape_frontend/screen_animations.hpp
+++ b/drape_frontend/screen_animations.hpp
@@ -15,6 +15,7 @@ class MapLinearAnimation;
class MapFollowAnimation;
class MapScaleAnimation;
+drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & startScreen, ScreenBase const & endScreen);
drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & screen,
m2::AnyRectD const & startRect, m2::AnyRectD const & endRect);
drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & screen, double startScale, double endScale,
@@ -24,6 +25,7 @@ drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & screen,
m2::PointD const & startPt, m2::PointD const & userPos,
double targetAngle, m2::PointD const & endPixelPos);
+drape_ptr<MapLinearAnimation> GetRectAnimation(ScreenBase const & startScreen, ScreenBase const & endScreen);
drape_ptr<MapLinearAnimation> GetSetRectAnimation(ScreenBase const & screen,
m2::AnyRectD const & startRect, m2::AnyRectD const & endRect);
diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp
index d611b20e3d..c7049d8f45 100644
--- a/drape_frontend/user_event_stream.cpp
+++ b/drape_frontend/user_event_stream.cpp
@@ -366,40 +366,26 @@ bool UserEventStream::SetScale(m2::PointD const & pxScaleCenter, double factor,
bool UserEventStream::SetCenter(m2::PointD const & center, int zoom, bool isAnim)
{
- m2::PointD targetCenter = center;
- ang::AngleD angle;
- m2::RectD localRect;
-
ScreenBase const & currentScreen = GetCurrentScreen();
ScreenBase screen = currentScreen;
if (zoom == kDoNotChangeZoom)
{
- m2::AnyRectD const r = GetTargetRect();
- angle = r.Angle();
- localRect = r.GetLocalRect();
+ GetTargetScreen(screen);
+ screen.MatchGandP3d(center, screen.PixelRectIn3d().Center());
}
else
{
- angle = screen.GlobalRect().Angle();
-
- double scale3d = kDefault3dScale;//screen.CalculateScale3d(screen.CalculatePerspectiveAngle());
- localRect = df::GetRectForDrawScale(zoom, center);
- localRect.Scale(scale3d);
-
- CheckMinGlobalRect(localRect, scale3d);
- CheckMinMaxVisibleScale(localRect, zoom, scale3d);
+ screen.SetFromParams(center, screen.GetAngle(), GetScale(zoom));
+ screen.MatchGandP3d(center, screen.PixelRectIn3d().Center());
+ }
- localRect.Offset(-center);
+ ASSERT_GREATER_OR_EQUAL(zoom, scales::GetUpperWorldScale(), ());
+ ASSERT_LESS_OR_EQUAL(zoom, scales::GetUpperStyleScale(), ());
- double const aspectRatio = screen.PixelRect().SizeY() / screen.PixelRect().SizeX();
- if (aspectRatio > 1.0)
- localRect.Inflate(0.0, localRect.SizeY() * 0.5 * aspectRatio);
- else
- localRect.Inflate(localRect.SizeX() * 0.5 / aspectRatio, 0.0);
- }
+ ShrinkAndScaleInto(screen, df::GetWorldRect());
- return SetRect(m2::AnyRectD(targetCenter, angle, localRect), isAnim);
+ return SetScreen(screen, isAnim);
}
bool UserEventStream::SetRect(m2::RectD rect, int zoom, bool applyRotation, bool isAnim)
@@ -410,9 +396,44 @@ bool UserEventStream::SetRect(m2::RectD rect, int zoom, bool applyRotation, bool
return SetRect(targetRect, isAnim);
}
+bool UserEventStream::SetScreen(ScreenBase const & endScreen, bool isAnim)
+{
+ if (isAnim)
+ {
+ auto onStartHandler = [this](ref_ptr<Animation> animation)
+ {
+ if (m_listener)
+ m_listener->OnAnimationStarted(animation);
+ };
+
+ ScreenBase const & screen = GetCurrentScreen();
+
+ drape_ptr<Animation> anim = GetRectAnimation(screen, endScreen);
+ if (!df::IsAnimationAllowed(anim->GetDuration(), screen))
+ {
+ anim.reset();
+ double const moveDuration = PositionInterpolator::GetMoveDuration(screen.GetOrg(),
+ endScreen.GetOrg(), screen);
+ if (moveDuration > kMaxAnimationTimeSec)
+ anim = GetPrettyMoveAnimation(screen, endScreen);
+ }
+
+ if (anim != nullptr)
+ {
+ anim->SetOnStartAction(onStartHandler);
+ m_animationSystem.CombineAnimation(move(anim));
+ return false;
+ }
+ }
+
+ ResetMapPlaneAnimations();
+ m_navigator.SetScreen(endScreen);
+ return true;
+}
+
bool UserEventStream::SetRect(m2::AnyRectD const & rect, bool isAnim)
{
- isAnim = false;
+ //isAnim = false;
if (isAnim)
{
auto onStartHandler = [this](ref_ptr<Animation> animation)
@@ -642,6 +663,11 @@ m2::AnyRectD UserEventStream::GetCurrentRect() const
return m_navigator.Screen().GlobalRect();
}
+void UserEventStream::GetTargetScreen(ScreenBase & screen) const
+{
+ m_animationSystem.GetTargetScreen(m_navigator.Screen(), screen);
+}
+
m2::AnyRectD UserEventStream::GetTargetRect() const
{
ScreenBase targetScreen;
diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp
index 28d926f428..b8d8133536 100644
--- a/drape_frontend/user_event_stream.hpp
+++ b/drape_frontend/user_event_stream.hpp
@@ -269,6 +269,7 @@ public:
ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged);
ScreenBase const & GetCurrentScreen() const;
+ void GetTargetScreen(ScreenBase & screen) const;
m2::AnyRectD GetTargetRect() const;
bool IsInUserAction() const;
bool IsInPerspectiveAnimation() const;
@@ -306,6 +307,7 @@ private:
bool SetCenter(m2::PointD const & center, int zoom, bool isAnim);
bool SetRect(m2::RectD rect, int zoom, bool applyRotation, bool isAnim);
bool SetRect(m2::AnyRectD const & rect, bool isAnim);
+ bool SetScreen(ScreenBase const & screen, bool isAnim);
bool SetFollowAndRotate(m2::PointD const & userPos, m2::PointD const & pixelPos,
double azimuth, int preferredZoomLevel, bool isAnim);
diff --git a/drape_frontend/visual_params.cpp b/drape_frontend/visual_params.cpp
index cf0de06c78..9f134ba03c 100644
--- a/drape_frontend/visual_params.cpp
+++ b/drape_frontend/visual_params.cpp
@@ -6,6 +6,8 @@
#include "geometry/mercator.hpp"
+#include "indexer/scales.hpp"
+
#include "std/limits.hpp"
#include "std/algorithm.hpp"
@@ -270,4 +272,14 @@ int GetDrawTileScale(m2::RectD const & r)
return GetDrawTileScale(r, p.GetTileSize(), p.GetVisualScale());
}
+double GetZoomLevel(double scale)
+{
+ return my::clamp(fabs(log(scale) / log(2.0)), 1, scales::GetUpperStyleScale());
+}
+
+double GetScale(double zoomLevel)
+{
+ return pow(2.0, -zoomLevel);
+}
+
} // namespace df
diff --git a/drape_frontend/visual_params.hpp b/drape_frontend/visual_params.hpp
index 5e912843d4..b61c723040 100644
--- a/drape_frontend/visual_params.hpp
+++ b/drape_frontend/visual_params.hpp
@@ -75,4 +75,7 @@ m2::RectD GetRectForDrawScale(double drawScale, m2::PointD const & center);
int CalculateTileSize(int screenWidth, int screenHeight);
+double GetZoomLevel(double scale);
+double GetScale(double zoomLevel);
+
} // namespace df