diff --git a/map/framework.hpp b/map/framework.hpp index 11228a5aa1..7e1b6755f3 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -143,7 +143,9 @@ class FrameWork feature::DataHeader header; header.Load(FilesContainerR(datFile).GetReader(HEADER_FILE_TAG)); - m_model.AddWorldRect(header.GetBounds()); + m2::RectD bounds = header.GetBounds(); + + m_model.AddWorldRect(bounds); { threads::MutexGuard lock(m_modelSyn); m_model.AddMap(datFile); @@ -226,7 +228,8 @@ public: // initializes model with locally downloaded maps storage.Init(bind(&FrameWork::AddMap, this, _1), - bind(&FrameWork::RemoveMap, this, _1)); + bind(&FrameWork::RemoveMap, this, _1), + bind(&FrameWork::RepaintRect, this, _1)); } bool IsEmptyModel() @@ -519,6 +522,16 @@ public: Invalidate(); } + void RepaintRect(m2::RectD const & rect) + { + threads::MutexGuard lock(*m_renderQueue.renderState().m_mutex.get()); + m2::RectD pxRect(0, 0, m_renderQueue.renderState().m_surfaceWidth, m_renderQueue.renderState().m_surfaceHeight); + m2::RectD glbRect; + m_navigator.Screen().PtoG(pxRect, glbRect); + if (glbRect.Intersect(rect)) + Repaint(); + } + void CenterViewport(m2::PointD const & pt) { m_navigator.CenterViewport(pt); diff --git a/storage/storage.cpp b/storage/storage.cpp index 95e9a87666..03864ddb93 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -3,8 +3,11 @@ #include "../base/logging.hpp" #include "../base/string_utils.hpp" +#include "../indexer/data_header.hpp" + #include "../coding/file_writer.hpp" #include "../coding/file_reader.hpp" +#include "../coding/file_container.hpp" #include "../coding/strutil.hpp" #include "../version/version.hpp" @@ -44,12 +47,13 @@ namespace storage } //////////////////////////////////////////////////////////////////////////// - void Storage::Init(TAddMapFunction addFunc, TRemoveMapFunction removeFunc) + void Storage::Init(TAddMapFunction addFunc, TRemoveMapFunction removeFunc, TUpdateRectFunction updateRectFunc) { m_currentVersion = static_cast(Version::BUILD); m_addMap = addFunc; m_removeMap = removeFunc; + m_updateRect = updateRectFunc; // activate all downloaded maps Platform & p = GetPlatform(); @@ -270,10 +274,13 @@ namespace storage } } + m2::RectD bounds = country.Bounds(); + // @TODO: Do not delete pieces which are used by other countries DeactivateAndDeleteCountry(country, m_removeMap); if (m_observerChange) m_observerChange(index); + m_updateRect(bounds); } void Storage::ReInitCountries(bool forceReload) @@ -346,6 +353,10 @@ namespace storage // activate downloaded map piece string const datFile = GetPlatform().ReadPathForFile(FileFromUrl(url)); m_addMap(datFile); + + feature::DataHeader header; + header.Load(FilesContainerR(datFile).GetReader(HEADER_FILE_TAG)); + m_updateRect(header.GetBounds()); } DownloadNextCountryFromQueue(); } diff --git a/storage/storage.hpp b/storage/storage.hpp index b9100555ca..e20387e3f8 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -91,8 +91,10 @@ namespace storage //@{ typedef boost::function TAddMapFunction; typedef boost::function TRemoveMapFunction; + typedef boost::function TUpdateRectFunction; TAddMapFunction m_addMap; TRemoveMapFunction m_removeMap; + TUpdateRectFunction m_updateRect; //@} void DownloadNextCountryFromQueue(); @@ -104,7 +106,7 @@ namespace storage Storage() {} /// Adds all locally downloaded maps to the model - void Init(TAddMapFunction addFunc, TRemoveMapFunction removeFunc); + void Init(TAddMapFunction addFunc, TRemoveMapFunction removeFunc, TUpdateRectFunction updateRectFunc); /// @name Called from DownloadManager //@{