| 164 | } |
| 165 | |
| 166 | bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, m2::PointD const & oldPt1, |
| 167 | m2::PointD const & oldPt2, bool skipMinScaleAndBordersCheck, bool doRotateScreen, |
| 168 | ScreenBase & screen) |
| 169 | { |
| 170 | m2::PointD const center3d = oldPt1; |
| 171 | m2::PointD const center2d = screen.P3dtoP(center3d); |
| 172 | m2::PointD const centerG = screen.PtoG(center2d); |
| 173 | m2::PointD const offset = center2d - center3d; |
| 174 | math::Matrix<double, 3, 3> const newM = |
| 175 | screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1 + offset, oldPt2 + offset, newPt1 + offset, |
| 176 | newPt2 + offset, doRotateScreen, true); |
| 177 | ScreenBase tmp = screen; |
| 178 | tmp.SetGtoPMatrix(newM); |
| 179 | |
| 180 | if (!CheckMaxScale(tmp)) |
| 181 | { |
| 182 | if (doRotateScreen) |
| 183 | { |
| 184 | math::Matrix<double, 3, 3> const tmpM = |
| 185 | screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1 + offset, oldPt2 + offset, newPt1 + offset, |
| 186 | newPt2 + offset, doRotateScreen, false); |
| 187 | tmp.SetGtoPMatrix(tmpM); |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | return false; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if (tmp.isPerspective()) |
| 196 | tmp.MatchGandP3d(centerG, center3d); |
| 197 | |
| 198 | if (!skipMinScaleAndBordersCheck && !CheckMinScale(tmp)) |
| 199 | return false; |
| 200 | |
| 201 | m2::RectD const & worldR = df::GetWorldRect(); |
| 202 | |
| 203 | if (!skipMinScaleAndBordersCheck && !CheckBorders(tmp)) |
| 204 | { |
| 205 | if (CanShrinkInto(tmp, worldR)) |
| 206 | tmp = ShrinkInto(tmp, worldR); |
| 207 | else |
| 208 | return false; |
| 209 | } |
| 210 | |
| 211 | // re-checking the borders, as we might violate them a bit (don't know why). |
| 212 | if (!CheckBorders(tmp)) |
| 213 | tmp = ScaleInto(tmp, worldR); |
| 214 | |
| 215 | screen = tmp; |
| 216 | return true; |
| 217 | } |
| 218 | |
| 219 | void Navigator::DoScale(m2::PointD const & pt1, m2::PointD const & pt2) |
| 220 | { |
nothing calls this directly
no test coverage detected