| 581 | |
| 582 | |
| 583 | void UBGraphicsProtractor::paintAngleMarker(QPainter *painter) |
| 584 | { |
| 585 | painter->save(); |
| 586 | painter->translate(rect().center()); |
| 587 | painter->rotate(-mStartAngle); |
| 588 | painter->translate(-rect().center().x(), -rect().center().y()); |
| 589 | qreal co = cos(mCurrentAngle * PI/180); |
| 590 | qreal si = sin(mCurrentAngle * PI/180); |
| 591 | qreal rad = radius(); |
| 592 | |
| 593 | painter->drawLine(QLineF(rect().center(), QPointF(rect().center().x()+ (rad+ 20)*co, rect().center().y() - (rad + 20)*si))); |
| 594 | QPointF center = rect().center(); |
| 595 | painter->drawArc(QRectF(center.x() - rad/8, center.y() - rad/8, rad / 4, rad / 4), 0 |
| 596 | , (mCurrentAngle - (int)(mCurrentAngle/360)*360)*16); |
| 597 | painter->translate(rect().center()); |
| 598 | painter->rotate(-mCurrentAngle); |
| 599 | painter->translate(-rect().center().x(), -rect().center().y()); |
| 600 | |
| 601 | //Paint Angle text (horizontally) |
| 602 | |
| 603 | //restore transformations |
| 604 | painter->translate(rect().center()); |
| 605 | painter->rotate(mCurrentAngle); |
| 606 | painter->rotate(mStartAngle); |
| 607 | painter->translate(-rect().center().x(), -rect().center().y()); |
| 608 | |
| 609 | qreal angle = mCurrentAngle - (int)(mCurrentAngle/360)*360; |
| 610 | |
| 611 | if (angle != 0) |
| 612 | { |
| 613 | QString ang = QString("%1°").arg(angle,0, 'f', 1); |
| 614 | QFont font2 = painter->font(); |
| 615 | font2.setBold(true); |
| 616 | QFontMetricsF fm2(font2); |
| 617 | painter->setFont(font2); |
| 618 | if (angle < 50) |
| 619 | angle = 90; |
| 620 | else |
| 621 | angle = angle / 2; |
| 622 | |
| 623 | co = cos((mStartAngle + angle) * PI/180); |
| 624 | si = sin((mStartAngle + angle) * PI/180); |
| 625 | painter->drawText(QRectF(rect().center().x() + (rad*2.5/10)*co - fm2.horizontalAdvance(ang)/2, |
| 626 | rect().center().y() - (rad*2.5/10)*si - fm2.height()/2, |
| 627 | fm2.horizontalAdvance(ang), fm2.height()), Qt::AlignTop, ang); |
| 628 | } |
| 629 | |
| 630 | painter->restore(); |
| 631 | } |
| 632 | |
| 633 | UBGraphicsProtractor::Tool UBGraphicsProtractor::toolFromPos(QPointF pos) |
| 634 | { |