diff --git a/geometry/angles.hpp b/geometry/angles.hpp index c7c1abaa78..9249fa9813 100644 --- a/geometry/angles.hpp +++ b/geometry/angles.hpp @@ -50,6 +50,11 @@ namespace ang return *this; } + + friend string DebugPrint(Angle const & ang) + { + return DebugPrint(ang.m_val); + } }; typedef Angle AngleD; diff --git a/geometry/any_rect2d.hpp b/geometry/any_rect2d.hpp index ea9037818e..6068572122 100644 --- a/geometry/any_rect2d.hpp +++ b/geometry/any_rect2d.hpp @@ -4,8 +4,9 @@ #include "rect2d.hpp" #include "rect_intersect.hpp" #include "angles.hpp" + #include "../base/math.hpp" -#include + namespace m2 { @@ -15,10 +16,6 @@ namespace m2 { ang::Angle m_angle; - /// @todo No need to store orthos separately. They are stored in m_angle. - Point m_i; - Point m_j; - Point m_zero; Rect m_rect; @@ -35,11 +32,10 @@ namespace m2 } public: - AnyRect() : m_i(1, 0), m_j(0, 1), m_zero(0, 0), m_rect() {} + AnyRect() : m_zero(0, 0), m_rect() {} /// creating from regular rect explicit AnyRect(Rect const & r) - : m_angle(0), m_i(m_angle.cos(), m_angle.sin()), m_j(-m_angle.sin(), m_angle.cos()) { if (r.IsValid()) { @@ -54,10 +50,9 @@ namespace m2 } AnyRect(Point const & zero, ang::Angle const & angle, Rect const & r) - : m_angle(angle), m_i(m_angle.cos(), m_angle.sin()), m_j(-m_angle.sin(), m_angle.cos()), - m_zero(Convert(zero, Point(1, 0), Point(0, 1), m_i, m_j)), - m_rect(r) + : m_angle(angle), m_rect(r) { + m_zero = Convert(zero, Point(1, 0), Point(0, 1), i(), j()); } Point const & LocalZero() const @@ -67,19 +62,17 @@ namespace m2 Point const GlobalZero() const { - m2::Point i(1, 0); - m2::Point j(0, 1); - return Convert(m_zero, m_i, m_j, i, j); + return Convert(m_zero, i(), j(), m2::Point(1, 0), m2::Point(0, 1)); } - Point const & i() const + Point const i() const { - return m_i; + return Point(m_angle.cos(), m_angle.sin()); } - Point const & j() const + Point const j() const { - return m_j; + return Point(-m_angle.sin(), m_angle.cos()); } void SetAngle(ang::Angle const & a) @@ -87,10 +80,7 @@ namespace m2 m2::Point glbZero = GlobalZero(); m_angle = a; - m_i = m2::Point(m_angle.cos(), m_angle.sin()); - m_j = m2::Point(-m_angle.sin(), m_angle.cos()); - - m_zero = Convert(glbZero, Point(1, 0), Point(0, 1), m_i, m_j); + m_zero = Convert(glbZero, Point(1, 0), Point(0, 1), i(), j()); } ang::Angle const & Angle() const @@ -157,9 +147,9 @@ namespace m2 /// Convert into coordinate system of this AnyRect Point const ConvertTo(Point const & p) const { - m2::Point i(1, 0); - m2::Point j(0, 1); - return Convert(p - Convert(m_zero, m_i, m_j, i, j), i, j, m_i, m_j); + m2::Point i1(1, 0); + m2::Point j1(0, 1); + return Convert(p - Convert(m_zero, i(), j(), i1, j1), i1, j1, i(), j()); } void ConvertTo(Point * pts, size_t count) const @@ -171,9 +161,7 @@ namespace m2 /// Convert into global coordinates from the local coordinates of this AnyRect Point const ConvertFrom(Point const & p) const { - m2::Point i(1, 0); - m2::Point j(0, 1); - return Convert(p + m_zero, m_i, m_j, i, j); + return Convert(p + m_zero, i(), j(), m2::Point(1, 0), m2::Point(0, 1)); } void ConvertFrom(Point * pts, size_t count) const @@ -238,6 +226,13 @@ namespace m2 { m_rect.SetSizesToIncludePoint(ConvertTo(p)); } + + friend string DebugPrint(m2::AnyRect const & r) + { + return "{ Zero = " + DebugPrint(r.m_zero) + + ", Rect = " + DebugPrint(r.m_rect) + + ", Ang = " + DebugPrint(r.m_angle) + " }"; + } }; template @@ -264,10 +259,4 @@ namespace m2 typedef AnyRect AnyRectD; typedef AnyRect AnyRectF; - - template - inline string DebugPrint(m2::AnyRect const & r) - { - return DebugPrint(r.GetGlobalRect()); - } } diff --git a/map/navigator.cpp b/map/navigator.cpp index 705c9ace80..ddff8e76b2 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -81,10 +81,7 @@ double Navigator::ComputeMoveSpeed(m2::PointD const & p0, m2::PointD const & p1) void Navigator::SaveState() { - m2::AnyRectD r = m_Screen.GlobalRect(); - r.SetAngle(0); - - Settings::Set("ScreenClipRect", r); + Settings::Set("ScreenClipRect", m_Screen.GlobalRect()); } bool Navigator::LoadState() diff --git a/platform/settings.cpp b/platform/settings.cpp index 52aafc8de9..1a43b66e3d 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -144,7 +144,6 @@ namespace Settings rect = m2::AnyRectD(m2::PointD(val[0], val[1]), ang::AngleD(val[2]), m2::RectD(val[3], val[4], val[5], val[6])); - return true; } @@ -161,10 +160,7 @@ namespace Settings if (!impl::FromStringArray(str, val)) return false; - rect.setMinX(val[0]); - rect.setMinY(val[1]); - rect.setMaxX(val[2]); - rect.setMaxY(val[3]); + rect = m2::RectD(val[0], val[1], val[2], val[3]); return true; }