| 48 | } |
| 49 | |
| 50 | void 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 | |
| 67 | void ComponentItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) |
| 68 | { |