bool ApplyScale(m2::PointD const & pixelScaleCenter, double factor, ScreenBase & screen) { m2::PointD const globalScaleCenter = screen.PtoG(screen.P3dtoP(pixelScaleCenter)); ScreenBase tmp = screen; tmp.Scale(factor); tmp.MatchGandP3d(globalScaleCenter, pixelScaleCenter); if (!CheckMinScale(tmp)) return false; m2::RectD const & worldR = df::GetWorldRect(); if (!CheckBorders(tmp)) { if (CanShrinkInto(tmp, worldR)) tmp = ShrinkInto(tmp, worldR); else return false; } if (!CheckMaxScale(tmp)) return false; // re-checking the borders, as we might violate them a bit (don't know why). if (!CheckBorders(tmp)) tmp = ScaleInto(tmp, worldR); screen = tmp; return true; }
void Navigator::DoDrag(m2::PointD const & pt, double /*timeInSec*/) { if (m_LastPt1 == pt) return; ScreenBase const s = ShrinkInto(m_StartScreen, m_scales.GetWorldRect()); double dx = pt.x - m_StartPt1.x; double dy = pt.y - m_StartPt1.y; ScreenBase tmp = s; tmp.Move(dx, 0); if (!CheckBorders(tmp)) dx = 0; tmp = s; tmp.Move(0, dy); if (!CheckBorders(tmp)) dy = 0; tmp = s; tmp.Move(dx, dy); if (CheckBorders(tmp)) { m_StartScreen = tmp; m_StartPt1 = pt; m_LastPt1 = pt; m_Screen = tmp; } }
bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, m2::PointD const & oldPt1, m2::PointD const & oldPt2, bool skipMinScaleAndBordersCheck, bool doRotateScreen) { math::Matrix<double, 3, 3> newM = m_Screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1, oldPt2, newPt1, newPt2); double oldAngle = m_Screen.GetAngle(); ScreenBase tmp = m_Screen; tmp.SetGtoPMatrix(newM); if (!doRotateScreen) tmp.Rotate(-(tmp.GetAngle() - oldAngle)); if (!skipMinScaleAndBordersCheck && !CheckMinScale(tmp)) return false; m2::RectD const & worldR = m_scales.GetWorldRect(); if (!skipMinScaleAndBordersCheck && !CheckBorders(tmp)) { if (CanShrinkInto(tmp, worldR)) tmp = ShrinkInto(tmp, worldR); else return false; } if (!CheckMaxScale(tmp)) return false; // re-checking the borders, as we might violate them a bit (don't know why). if (!CheckBorders(tmp)) tmp = ScaleInto(tmp, worldR); m_Screen = tmp; return true; }