From ba7b5963e026d94becb96305d6329a7db430bf30 Mon Sep 17 00:00:00 2001 From: rachytski Date: Mon, 3 Oct 2011 13:42:04 +0300 Subject: [PATCH] added saving and loading of AARect into Settings. --- platform/settings.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/platform/settings.cpp b/platform/settings.cpp index 0b8fec1c0d..2bdc682075 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -3,6 +3,7 @@ #include "../defines.hpp" #include "../geometry/rect2d.hpp" +#include "../geometry/aa_rect2d.hpp" #include "../platform/platform.hpp" @@ -78,6 +79,36 @@ namespace Settings return true; } + template <> string ToString(m2::AARectD const & rect) + { + ostringstream out; + out.precision(12); + m2::PointD glbZero(rect.GlobalZero()); + out << glbZero.x << " " << glbZero.y << " "; + out << rect.angle().val() << " "; + m2::RectD r = rect.GetLocalRect(); + out << r.minX() << " " << r.minY() << " " << r.maxX() << " " << r.maxY(); + return out.str(); + } + + template <> bool FromString(string const & str, m2::AARectD & rect) + { + istringstream in(str); + double val[7]; + size_t count = 0; + while (in.good() && count < 7) + in >> val[count++]; + + if (count != 7) + return false; + + rect = m2::AARectD(m2::PointD(val[0], val[1]), + ang::AngleD(val[2]), + m2::RectD(val[3], val[4], val[5], val[6])); + + return true; + } + template <> string ToString(m2::RectD const & rect) { ostringstream stream;