forked from organicmaps/organicmaps
Better check for minimal rect (upper style scale). Fixed bug in different scales for yopme.
This commit is contained in:
parent
6f61d925d6
commit
cdc5f94490
2 changed files with 28 additions and 33 deletions
|
@ -830,8 +830,6 @@ void Framework::SetViewportCenter(m2::PointD const & pt)
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
static int const theMetersFactor = 6;
|
||||
|
||||
m2::AnyRectD Framework::ToRotated(m2::RectD const & rect) const
|
||||
{
|
||||
double const dx = rect.SizeX();
|
||||
|
@ -842,16 +840,11 @@ m2::AnyRectD Framework::ToRotated(m2::RectD const & rect) const
|
|||
m2::RectD(-dx/2, -dy/2, dx/2, dy/2));
|
||||
}
|
||||
|
||||
void Framework::CheckMinGlobalRect(m2::AnyRectD & rect) const
|
||||
void Framework::CheckMinGlobalRect(m2::RectD & rect) const
|
||||
{
|
||||
m2::RectD const minRect = MercatorBounds::RectByCenterXYAndSizeInMeters(
|
||||
rect.GlobalCenter(), theMetersFactor * m_metresMinWidth);
|
||||
|
||||
m2::AnyRectD const minAnyRect = ToRotated(minRect);
|
||||
|
||||
/// @todo It would be better here to check only AnyRect ortho-sizes with minimal values.
|
||||
if (minAnyRect.IsRectInside(rect))
|
||||
rect = minAnyRect;
|
||||
m2::RectD const minRect = m_scales.GetRectForDrawScale(scales::GetUpperStyleScale(), rect.Center());
|
||||
if (minRect.IsRectInside(rect))
|
||||
rect = minRect;
|
||||
}
|
||||
|
||||
bool Framework::CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/) const
|
||||
|
@ -880,44 +873,41 @@ bool Framework::CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/)
|
|||
|
||||
void Framework::ShowRect(double lat, double lon, double zoom)
|
||||
{
|
||||
m2::RectD rect = m_scales.GetRectForDrawScale(zoom,
|
||||
m2::PointD(MercatorBounds::LonToX(lon),
|
||||
MercatorBounds::LatToY(lat)));
|
||||
ShowRectEx(rect);
|
||||
m2::PointD center(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat));
|
||||
ShowRectEx(m_scales.GetRectForDrawScale(zoom, center));
|
||||
}
|
||||
|
||||
void Framework::ShowRect(m2::RectD const & r)
|
||||
void Framework::ShowRect(m2::RectD rect)
|
||||
{
|
||||
m2::AnyRectD rect(r);
|
||||
CheckMinGlobalRect(rect);
|
||||
|
||||
m_navigator.SetFromRect(rect);
|
||||
m_navigator.SetFromRect(m2::AnyRectD(rect));
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void Framework::ShowRectEx(m2::RectD const & rect)
|
||||
void Framework::ShowRectEx(m2::RectD rect)
|
||||
{
|
||||
ShowRectFixed(ToRotated(rect));
|
||||
CheckMinGlobalRect(rect);
|
||||
|
||||
ShowRectFixed(rect);
|
||||
}
|
||||
|
||||
void Framework::ShowRectExVisibleScale(m2::RectD rect, int maxScale/* = -1*/)
|
||||
{
|
||||
CheckMinMaxVisibleScale(rect, maxScale);
|
||||
ShowRectEx(rect);
|
||||
|
||||
ShowRectFixed(rect);
|
||||
}
|
||||
|
||||
void Framework::ShowRectFixed(m2::AnyRectD const & r)
|
||||
void Framework::ShowRectFixed(m2::RectD const & r)
|
||||
{
|
||||
m2::AnyRectD rect(r);
|
||||
CheckMinGlobalRect(rect);
|
||||
|
||||
double const halfSize = m_scales.GetTileSize() / 2.0;
|
||||
m2::RectD etalonRect(-halfSize, -halfSize, halfSize, halfSize);
|
||||
|
||||
m2::PointD const pxCenter = m_navigator.Screen().PixelRect().Center();
|
||||
etalonRect.Offset(pxCenter);
|
||||
|
||||
m_navigator.SetFromRects(rect, etalonRect);
|
||||
m_navigator.SetFromRects(ToRotated(r), etalonRect);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
|
|
@ -368,19 +368,24 @@ public:
|
|||
virtual void EndPaint(shared_ptr<PaintEvent> const & e);
|
||||
|
||||
private:
|
||||
m2::AnyRectD ToRotated(m2::RectD const & rect) const;
|
||||
void CheckMinGlobalRect(m2::AnyRectD & rect) const;
|
||||
/// Always check rect in public function for minimal draw scale.
|
||||
void CheckMinGlobalRect(m2::RectD & rect) const;
|
||||
/// @return true if rect was fixed to display downloaded zoom level (world map)
|
||||
bool CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale = -1) const;
|
||||
void ShowRectFixed(m2::AnyRectD const & rect);
|
||||
|
||||
m2::AnyRectD ToRotated(m2::RectD const & rect) const;
|
||||
void ShowRectFixed(m2::RectD const & rect);
|
||||
|
||||
public:
|
||||
/// Show rect for point and needed draw scale.
|
||||
void ShowRect(double lat, double lon, double zoom);
|
||||
/// Set navigator viewport by rect as-is.
|
||||
void ShowRect(m2::RectD const & rect);
|
||||
|
||||
/// Set navigator viewport by rect as-is (rect should be in screen viewport).
|
||||
void ShowRect(m2::RectD rect);
|
||||
|
||||
/// - Use navigator rotate angle.
|
||||
/// - Check for fixed scales from navigator.
|
||||
void ShowRectEx(m2::RectD const & rect);
|
||||
/// - Check for fixed scales (rect scale matched on draw tile scale).
|
||||
void ShowRectEx(m2::RectD rect);
|
||||
/// - Check minimal visible scale according to downloaded countries.
|
||||
void ShowRectExVisibleScale(m2::RectD rect, int maxScale = -1);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue