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

Function drawPos

shape_plugins/shape/shhandler.cpp:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29constexpr double Size = StickingDistance / 2;
30
31void drawPos(QPainter* painter, const QPointF& pt1)
32{
33 QFont font;
34 font.setPixelSize(16);
35 const QString text = QString(App::settings().inch() ? " X = %1 in\n"
36 " Y = %2 in\n"
37 : " X = %1 mm\n"
38 " Y = %2 mm\n")
39 .arg(pt1.x() / (App::settings().inch() ? 25.4 : 1.0), 4, 'f', 3, '0')
40 .arg(pt1.y() / (App::settings().inch() ? 25.4 : 1.0), 4, 'f', 3, '0');
41
42 const QRectF textRect = QFontMetricsF(font).boundingRect(QRectF(), Qt::AlignLeft, text);
43 const double k = App::graphicsView()->scaleFactor();
44 painter->save();
45 painter->scale(k, -k);
46 int i = 0;
47 for (QString txt : text.split('\n')) {
48 QPainterPath path;
49 path.addText(textRect.topLeft() + QPointF(textRect.left(), textRect.height() * 0.25 * ++i), font, txt);
50 painter->setPen(QPen(Qt::black, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
51 painter->setBrush(Qt::NoBrush);
52 painter->drawPath(path);
53 painter->setPen(Qt::NoPen);
54 painter->setBrush(Qt::white);
55 painter->drawPath(path);
56 }
57 painter->restore();
58}
59
60Handler::Handler(Shape* shape, HType type)
61 : shape(shape)

Callers 1

paintMethod · 0.85

Calls 10

inchMethod · 0.80
xMethod · 0.80
yMethod · 0.80
scaleMethod · 0.80
boundingRectMethod · 0.45
scaleFactorMethod · 0.45
saveMethod · 0.45
heightMethod · 0.45
setPenMethod · 0.45
restoreMethod · 0.45

Tested by

no test coverage detected