drape_ptr<MapLinearAnimation> GetSetRectAnimation(ScreenBase const & screen, m2::AnyRectD const & startRect, m2::AnyRectD const & endRect) { auto anim = make_unique_dp<MapLinearAnimation>(); double const startScale = CalculateScale(screen.PixelRect(), startRect.GetLocalRect()); double const endScale = CalculateScale(screen.PixelRect(), endRect.GetLocalRect()); anim->SetRotate(startRect.Angle().val(), endRect.Angle().val()); anim->SetMove(startRect.GlobalCenter(), endRect.GlobalCenter(), screen); anim->SetScale(startScale, endScale); anim->SetMaxScaleDuration(kMaxAnimationTimeSec); return anim; }
// startRect - mercator visible on screen rect in moment when user release fingers. // direction - mercator space direction of moving. length(direction) - mercator distance on wich map will be offset. KineticScrollAnimation(m2::AnyRectD const & startRect, m2::PointD const & direction, double duration) : BaseModelViewAnimation(duration) , m_targetCenter(startRect.GlobalCenter() + direction) , m_angle(startRect.Angle()) , m_localRect(startRect.GetLocalRect()) , m_direction(direction) { }
string ToString<m2::AnyRectD>(m2::AnyRectD const & rect) { ostringstream out; out.precision(12); m2::PointD glbZero(rect.GlobalZero()); out << glbZero.x << " " << glbZero.y << " "; out << rect.Angle().val() << " "; m2::RectD const & r = rect.GetLocalRect(); out << r.minX() << " " << r.minY() << " " << r.maxX() << " " << r.maxY(); return out.str(); }
void ScreenBase::SetFromRects(m2::AnyRectD const & glbRect, m2::RectD const & pxRect) { double hScale = glbRect.GetLocalRect().SizeX() / pxRect.SizeX(); double vScale = glbRect.GetLocalRect().SizeY() / pxRect.SizeY(); m_Scale = max(hScale, vScale); m_Angle = glbRect.Angle(); m_Org = glbRect.GlobalCenter(); UpdateDependentParameters(); }
double CalculateScale(ScreenBase const & screen, m2::AnyRectD const & rect) { return CalculateScale(screen, rect.GetLocalRect()); }