MCPcopy Create free account
hub / github.com/XRay3D/GERBER_X3 / drawText

Function drawText

file_plugins/gerber/compitem.cpp:50–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void drawText(QPainter* painter, const QString& str, const QColor& color, QPointF pt, double scale)
51{
52 painter->save();
53 static QFont f("Consolas");
54 f.setPixelSize(20);
55 f.setBold(true);
56 const QRectF textRect = QFontMetricsF(f).boundingRect(QRectF(), Qt::AlignLeft, str);
57 pt.rx() -= textRect.width() * scale * 0.5;
58 pt.ry() += textRect.height() * scale * 0.5;
59 painter->translate(pt);
60 painter->scale(scale, -scale);
61 painter->setPen(color);
62 painter->setFont(f);
63 painter->drawText(textRect.topLeft() + QPointF(textRect.left(), textRect.height() * 2), str);
64 painter->restore();
65}
66
67void ComponentItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
68{

Callers 1

paintMethod · 0.85

Calls 8

widthMethod · 0.80
translateMethod · 0.80
scaleMethod · 0.80
saveMethod · 0.45
boundingRectMethod · 0.45
heightMethod · 0.45
setPenMethod · 0.45
restoreMethod · 0.45

Tested by

no test coverage detected