| 525 | } |
| 526 | |
| 527 | void UBGraphicsCompass::paintRadiusDisplay(QPainter *painter) |
| 528 | { |
| 529 | double pixelsPerCentimeter = UBApplication::boardController->activeScene()->backgroundGridSize(); |
| 530 | |
| 531 | qreal radiusInCentimeters = rect().width() / pixelsPerCentimeter; |
| 532 | QString format = rect().width() >= sDisplayRadiusUnitMinLength ? "%1 cm" : "%1"; |
| 533 | QString radiusText = QString(format).arg(radiusInCentimeters, 0, 'f', 1); |
| 534 | |
| 535 | bool onPencilArm = rect().width() > sDisplayRadiusOnPencilArmMinLength; |
| 536 | |
| 537 | painter->save(); |
| 538 | painter->setFont(font()); |
| 539 | QFontMetricsF fm(painter->font()); |
| 540 | QPointF textCenter; |
| 541 | |
| 542 | if (onPencilArm) |
| 543 | textCenter = QPointF(rect().right() - sPencilBaseLength - sPencilLength - fm.horizontalAdvance(radiusText) / 2 - 24 - 8, rect().center().y()); |
| 544 | else |
| 545 | textCenter = QPointF((rect().left() + sNeedleLength + sNeedleBaseLength + hingeRect().left()) / 2, rect().center().y()); |
| 546 | |
| 547 | painter->translate(textCenter); |
| 548 | qreal angle = angleInDegrees(); |
| 549 | if (angle > 180) |
| 550 | angle -= 360; |
| 551 | else if (angle < -180) |
| 552 | angle += 360; |
| 553 | if (angle <= -90 || angle > 90) |
| 554 | painter->rotate(180); |
| 555 | painter->drawText( |
| 556 | QRectF( |
| 557 | - fm.horizontalAdvance(radiusText) / 2, |
| 558 | - rect().height() / 2, |
| 559 | fm.horizontalAdvance(radiusText), |
| 560 | rect().height()), |
| 561 | Qt::AlignVCenter, |
| 562 | radiusText); |
| 563 | painter->restore(); |
| 564 | } |
| 565 | |
| 566 | QCursor UBGraphicsCompass::moveCursor() const |
| 567 | { |
nothing calls this directly
no test coverage detected