full check of loaded ScreenClipRect

This commit is contained in:
ExMix 2015-05-15 13:41:20 +03:00 committed by Alex Zolotarev
parent 98081c9720
commit 244b5b6807
4 changed files with 19 additions and 28 deletions

View file

@ -35,12 +35,10 @@ DrapeSurface::DrapeSurface()
for_each(maps.begin(), maps.end(), bind(&model::FeaturesFetcher::RegisterMap, &m_model, _1));
///}
///
m_navigator.LoadState();
}
DrapeSurface::~DrapeSurface()
{
m_navigator.SaveState();
m_drapeEngine.Destroy();
m_contextFactory.Destroy();
}

View file

@ -652,17 +652,33 @@ void Framework::InvalidateRect(m2::RectD const & rect, bool doForceUpdate)
void Framework::SaveState()
{
m_navigator.SaveState();
Settings::Set("ScreenClipRect", m_navigator.Screen().GlobalRect());
}
bool Framework::LoadState()
{
bool r = m_navigator.LoadState();
m2::AnyRectD rect;
if (!Settings::Get("ScreenClipRect", rect))
return false;
// additional check for valid rect
if (!m_scales.GetWorldRect().IsRectInside(rect.GetGlobalRect()))
return false;
m2::RectD r = rect.GetGlobalRect();
CheckMinMaxVisibleScale(r);
double const dx = r.SizeX();
double const dy = r.SizeY();
m2::AnyRectD safeRect(r.Center(), rect.Angle(), m2::RectD(-dx/2, -dy/2, dx/2, dy/2));
m_navigator.SetFromRect(safeRect);
#ifdef USE_DRAPE
if (!m_drapeEngine.IsNull())
m_drapeEngine->UpdateCoverage(m_navigator.Screen());
#endif
return r;
return true;
}
//@}

View file

@ -79,25 +79,6 @@ double Navigator::ComputeMoveSpeed(m2::PointD const & /*p0*/, m2::PointD const &
return 0.2;//max(0.5, min(0.5, 0.5 * GtoP(p0).Length(GtoP(p1)) / 50.0));
}
void Navigator::SaveState()
{
Settings::Set("ScreenClipRect", m_Screen.GlobalRect());
}
bool Navigator::LoadState()
{
m2::AnyRectD rect;
if (!Settings::Get("ScreenClipRect", rect))
return false;
// additional check for valid rect
if (!m_scales.GetWorldRect().IsRectInside(rect.GetGlobalRect()))
return false;
SetFromRect(rect);
return true;
}
void Navigator::OnSize(int x0, int y0, int w, int h)
{
m2::RectD const & worldR = m_scales.GetWorldRect();

View file

@ -22,10 +22,6 @@ public:
double ComputeMoveSpeed(m2::PointD const & p0, m2::PointD const & p1) const;
void SaveState();
/// @return false if can't load previously saved values
bool LoadState();
void OnSize(int x0, int y0, int w, int h);
ScreenBase const & Screen() const { return m_Screen; }