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

Method RecacheDebugLabels

libs/drape_frontend/gui/layer_render.cpp:252–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250
251#ifdef RENDER_DEBUG_INFO_LABELS
252drape_ptr<LayerRenderer> LayerCacher::RecacheDebugLabels(ref_ptr<dp::GraphicsContext> context,
253 ref_ptr<dp::TextureManager> textures)
254{
255 drape_ptr<LayerRenderer> renderer = make_unique_dp<LayerRenderer>();
256
257 auto const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
258 DebugInfoLabels debugLabels = DebugInfoLabels(Position(m2::PointF(10.0f * vs, 50.0f * vs), dp::Center));
259
260 debugLabels.AddLabel(textures,
261 "visible: km2, readed: km2, ratio:", [](ScreenBase const & screen, std::string & content) -> bool
262 {
263 double const sizeX = screen.PixelRectIn3d().SizeX();
264 double const sizeY = screen.PixelRectIn3d().SizeY();
265
266 m2::PointD const p0 = screen.PtoG(screen.P3dtoP(m2::PointD(0.0, 0.0)));
267 m2::PointD const p1 = screen.PtoG(screen.P3dtoP(m2::PointD(0.0, sizeY)));
268 m2::PointD const p2 = screen.PtoG(screen.P3dtoP(m2::PointD(sizeX, sizeY)));
269 m2::PointD const p3 = screen.PtoG(screen.P3dtoP(m2::PointD(sizeX, 0.0)));
270
271 double const areaG = mercator::AreaOnEarth(p0, p1, p2) + mercator::AreaOnEarth(p2, p3, p0);
272
273 double const sizeX_2d = screen.PixelRect().SizeX();
274 double const sizeY_2d = screen.PixelRect().SizeY();
275
276 m2::PointD const p0_2d = screen.PtoG(m2::PointD(0.0, 0.0));
277 m2::PointD const p1_2d = screen.PtoG(m2::PointD(0.0, sizeY_2d));
278 m2::PointD const p2_2d = screen.PtoG(m2::PointD(sizeX_2d, sizeY_2d));
279 m2::PointD const p3_2d = screen.PtoG(m2::PointD(sizeX_2d, 0.0));
280
281 double const areaGTotal = mercator::AreaOnEarth(p0_2d, p1_2d, p2_2d) + mercator::AreaOnEarth(p2_2d, p3_2d, p0_2d);
282
283 std::ostringstream out;
284 out << std::fixed << std::setprecision(2) << "visible: " << areaG / 1000000.0 << " km2"
285 << ", readed: " << areaGTotal / 1000000.0 << " km2"
286 << ", ratio: " << areaGTotal / areaG;
287 content.assign(out.str());
288 return true;
289 });
290
291 debugLabels.AddLabel(textures, "scale2d: m/px, scale2d * vs: m/px",
292 [](ScreenBase const & screen, std::string & content) -> bool
293 {
294 double const distanceG = mercator::DistanceOnEarth(screen.PtoG(screen.PixelRect().LeftBottom()),
295 screen.PtoG(screen.PixelRect().RightBottom()));
296
297 double const vs = df::VisualParams::Instance().GetVisualScale();
298 double const scale = distanceG / screen.PixelRect().SizeX();
299
300 std::ostringstream out;
301 out << std::fixed << std::setprecision(2) << "scale2d: " << scale << " m/px"
302 << ", scale2d * vs: " << scale * vs << " m/px";
303 content.assign(out.str());
304 return true;
305 });
306
307 debugLabels.AddLabel(textures, "distance: m", [](ScreenBase const & screen, std::string & content) -> bool
308 {
309 double const sizeX = screen.PixelRectIn3d().SizeX();

Callers

nothing calls this directly

Calls 15

DebugInfoLabelsClass · 0.85
GetVisualScaleMethod · 0.80
AddLabelMethod · 0.80
SizeXMethod · 0.80
SizeYMethod · 0.80
LeftBottomMethod · 0.80
RightBottomMethod · 0.80
GetRotationAngleMethod · 0.80
AddShapeRendererMethod · 0.80
PositionClass · 0.70
AreaOnEarthFunction · 0.50
DistanceOnEarthFunction · 0.50

Tested by

no test coverage detected