MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / drawImpl

Method drawImpl

src/tools/draw_text_tool.cpp:431–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429}
430
431void DrawTextTool::drawImpl(QPainter* painter, MapWidget* widget)
432{
433 painter->save();
434
435 if (!preview_text->hasSingleAnchor())
436 {
437 painter->setPen(active_color);
438 painter->setBrush(Qt::NoBrush);
439
440 // Default is what is fast (and stable!) while dragging.
441 auto map_rect = QRectF { click_pos_map, constrained_pos_map };
442 if (!isDragging())
443 {
444 // This is the actual frame, but it would be shaky while dragging,
445 // because of discretization in non-antialiased drawing.
446 const auto center = preview_text->getAnchorCoordF();
447 const auto width = preview_text->getBoxWidth();
448 const auto height = preview_text->getBoxHeight();
449 map_rect = QRectF { center.x()-width/2, center.y()-height/2, width, height };
450 }
451 auto rect = widget->mapToViewport(map_rect);
452
453 painter->drawRect(rect);
454 rect.adjust(1, 1, -1, -1);
455 painter->setPen(qRgb(255, 255, 255));
456 painter->drawRect(rect);
457 }
458
459 widget->applyMapTransform(painter);
460
461 float opacity = text_editor ? 1.0f : 0.5f;
462 RenderConfig config = { *map(), widget->getMapView()->calculateViewedRect(widget->viewportToView(widget->rect())), widget->getMapView()->calculateFinalZoomFactor(), RenderConfig::Tool, opacity };
463 renderables.draw(painter, config);
464
465 if (text_editor)
466 text_editor->draw(painter, widget);
467
468 painter->restore();
469}
470
471void DrawTextTool::updateStatusText()
472{

Callers

nothing calls this directly

Calls 15

hasSingleAnchorMethod · 0.80
getAnchorCoordFMethod · 0.80
getBoxWidthMethod · 0.80
getBoxHeightMethod · 0.80
xMethod · 0.80
yMethod · 0.80
mapToViewportMethod · 0.80
applyMapTransformMethod · 0.80
calculateViewedRectMethod · 0.80
getMapViewMethod · 0.80
viewportToViewMethod · 0.80

Tested by

no test coverage detected