MCPcopy Create free account
hub / github.com/comaps/comaps / ApplyScale

Function ApplyScale

libs/drape_frontend/screen_operations.cpp:224–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224bool 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

Callers 3

GetScaleAnimationFunction · 0.85
ScaleMethod · 0.85
OnSetCenterMethod · 0.85

Calls 15

CheckMinScaleFunction · 0.85
GetWorldRectFunction · 0.85
CheckBordersFunction · 0.85
CanShrinkIntoFunction · 0.85
ShrinkIntoFunction · 0.85
CheckMaxScaleFunction · 0.85
GetScreenScaleFunction · 0.85
GetUpperStyleScaleFunction · 0.85
ScaleIntoFunction · 0.85
MatchGandP3dMethod · 0.80
PtoGMethod · 0.45
P3dtoPMethod · 0.45

Tested by

no test coverage detected