| 222 | } |
| 223 | |
| 224 | bool ApplyScale(m2::PointD const & pixelScaleCenter, double factor, ScreenBase & screen) |
| 225 | { |
| 226 | m2::PointD const globalScaleCenter = screen.PtoG(screen.P3dtoP(pixelScaleCenter)); |
| 227 | |
| 228 | ScreenBase tmp = screen; |
| 229 | tmp.Scale(factor); |
| 230 | tmp.MatchGandP3d(globalScaleCenter, pixelScaleCenter); |
| 231 | |
| 232 | if (!CheckMinScale(tmp)) |
| 233 | return false; |
| 234 | |
| 235 | m2::RectD const & worldR = df::GetWorldRect(); |
| 236 | |
| 237 | if (!CheckBorders(tmp)) |
| 238 | { |
| 239 | if (CanShrinkInto(tmp, worldR)) |
| 240 | tmp = ShrinkInto(tmp, worldR); |
| 241 | else |
| 242 | return false; |
| 243 | } |
| 244 | |
| 245 | if (!CheckMaxScale(tmp)) |
| 246 | { |
| 247 | auto const maxScale = GetScreenScale(scales::GetUpperStyleScale() + 0.42); |
| 248 | if (maxScale > screen.GetScale() && CheckMaxScale(screen)) |
| 249 | return false; |
| 250 | tmp.SetScale(maxScale); |
| 251 | } |
| 252 | |
| 253 | // re-checking the borders, as we might violate them a bit (don't know why). |
| 254 | if (!CheckBorders(tmp)) |
| 255 | tmp = ScaleInto(tmp, worldR); |
| 256 | |
| 257 | screen = tmp; |
| 258 | return true; |
| 259 | } |
| 260 | |
| 261 | } // namespace df |
no test coverage detected