diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-06-06 11:54:32 +0300 |
---|---|---|
committer | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-07-07 15:31:06 +0300 |
commit | c949c0c407bbd1742a03b7189ee42c59f03dcbae (patch) | |
tree | 3fb6de09056f7639ebe7d6eced4ec78f5a52bcbf /geometry | |
parent | 6cb5375879befdfd8cc7cf2f9c93e5c187149bb2 (diff) |
Set perspective angle automatically when the scale is changing.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/screenbase.cpp | 25 | ||||
-rw-r--r-- | geometry/screenbase.hpp | 3 |
2 files changed, 28 insertions, 0 deletions
diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index b46a6da78c..fd5ce38f9b 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -75,6 +75,31 @@ void ScreenBase::UpdateDependentParameters() m_ClipRect = m_GlobalRect.GetGlobalRect(); } +double ScreenBase::CalculatePerspectiveAngle(double scale) +{ + double const kStartPerspectiveScale = 0.13e-4; + double const kMaxScale = 0.13e-5; + double const kMaxPerspectiveAngle = math::pi4; + + if (scale > kStartPerspectiveScale) + return 0.0; + return kMaxPerspectiveAngle * (kStartPerspectiveScale - scale) / (kStartPerspectiveScale - kMaxScale); +} + +void ScreenBase::UpdatePerspectiveParameters() +{ + double const angle = CalculatePerspectiveAngle(m_Scale); + if (angle > 0.0) + { + if (m_isPerspective) + SetRotationAngle(angle); + else + ApplyPerspective(angle, math::pi4, math::pi / 3); + } + else if (m_isPerspective) + ResetPerspective(); +} + void ScreenBase::SetFromRects(m2::AnyRectD const & glbRect, m2::RectD const & pxRect) { double hScale = glbRect.GetLocalRect().SizeX() / pxRect.SizeX(); diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp index 93959d9998..ef5125d9e4 100644 --- a/geometry/screenbase.hpp +++ b/geometry/screenbase.hpp @@ -126,6 +126,7 @@ public: m2::AnyRectD const & GlobalRect() const { return m_GlobalRect; } m2::RectD const & ClipRect() const { return m_ClipRect; } + void UpdatePerspectiveParameters(); void ApplyPerspective(double currentRotationAngle, double maxRotationAngle, double angleFOV); void ResetPerspective(); @@ -156,6 +157,8 @@ public: m2::PointD const & newPt1, m2::PointD const & newPt2, bool allowRotate); + static double CalculatePerspectiveAngle(double scale); + /// Setting GtoP matrix extracts the Angle and m_Org parameters, leaving PixelRect intact void SetGtoPMatrix(MatrixT const & m); |