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

Method ScaleImpl

libs/drape_frontend/navigator.cpp:166–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166bool 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
219void Navigator::DoScale(m2::PointD const & pt1, m2::PointD const & pt2)
220{

Callers

nothing calls this directly

Calls 12

CheckMaxScaleFunction · 0.85
CheckMinScaleFunction · 0.85
GetWorldRectFunction · 0.85
CheckBordersFunction · 0.85
CanShrinkIntoFunction · 0.85
ShrinkIntoFunction · 0.85
ScaleIntoFunction · 0.85
SetGtoPMatrixMethod · 0.80
isPerspectiveMethod · 0.80
MatchGandP3dMethod · 0.80
P3dtoPMethod · 0.45
PtoGMethod · 0.45

Tested by

no test coverage detected