From 1392ed923e8c2f02ecc178b498d971148b7f5f6d Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Tue, 31 May 2011 03:18:32 +0200 Subject: [PATCH] Fixes to framework::ShowRect() @TODO: Remove magic --- map/framework.cpp | 31 +++++-------------------------- map/framework.hpp | 4 ++-- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index cebe23bcf4..4ab3c8d1c4 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -809,34 +809,13 @@ void FrameWork::AddRedrawCommandSure() void FrameWork::ShowRect(m2::RectD const & rect) { m2::RectD r(rect); - - m2::PointD center = rect.Center(); - - double minWidthX = MercatorBounds::ConvertMetresToX(center.x, m_metresMinWidth); - double minWidthY = MercatorBounds::ConvertMetresToY(center.y, m_metresMinWidth); - - double k = m_navigator.Screen().PixelRect().SizeX() * 1.0 / m_minRulerWidth; - - if ((r.SizeX() == 0) || (r.SizeY() == 0)) + if (my::AlmostEqual(rect.minX(), rect.maxX()) + || my::AlmostEqual(rect.minY(), rect.maxY())) { - r = m2::RectD(center.x - MercatorBounds::ConvertMetresToX(center.x, m_metresMinWidth / 2), - center.y - MercatorBounds::ConvertMetresToY(center.y, m_metresMinWidth / 2), - center.x + MercatorBounds::ConvertMetresToX(center.x, m_metresMinWidth / 2), - center.y + MercatorBounds::ConvertMetresToY(center.y, m_metresMinWidth / 2)); - - r.Scale(k); + double const minWidthX = MercatorBounds::ConvertMetresToX(rect.minX(), 6 * m_metresMinWidth); + double const minWidthY = MercatorBounds::ConvertMetresToY(rect.minY(), 6 * m_metresMinWidth); + r.Inflate(minWidthX, minWidthY); } - else - { - if (k * r.SizeX() < minWidthX) - k *= minWidthX / (k * r.SizeX()); - - if (k * r.SizeY() < minWidthY) - k *= minWidthY / (k * r.SizeY()); - - r.Scale(k); - } - m_navigator.SetFromRect(r); UpdateNow(); } diff --git a/map/framework.hpp b/map/framework.hpp index 0ccbac9da6..e627dfe2eb 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -121,8 +121,8 @@ class FrameWork /// is AddRedrawCommand enabled? bool m_isRedrawEnabled; - double m_metresMinWidth; - int m_minRulerWidth; + double const m_metresMinWidth; + int const m_minRulerWidth; enum TGpsCenteringMode