| 29 | constexpr double Size = StickingDistance / 2; |
| 30 | |
| 31 | void 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 | |
| 60 | Handler::Handler(Shape* shape, HType type) |
| 61 | : shape(shape) |