| 585 | } |
| 586 | |
| 587 | QRect event(EventType type, Button button, Modifiers modifiers, double nX, double nY, double xScale, double yScale, const Okular::Page * /*page*/) override |
| 588 | { |
| 589 | // only proceed if pressing left button |
| 590 | // if ( button != Left ) |
| 591 | // return rect; |
| 592 | |
| 593 | // Constrain to 15° steps, except first point of course. |
| 594 | if (modifiers.constrainRatioAndAngle && !points.isEmpty()) { |
| 595 | const Okular::NormalizedPoint constrainedPoint = constrainAngle(points.constLast(), nX, nY, xScale, yScale, M_PI / 12.); |
| 596 | nX = constrainedPoint.x; |
| 597 | nY = constrainedPoint.y; |
| 598 | } |
| 599 | // process button press |
| 600 | if (type == Press) { |
| 601 | newPoint.x = nX; |
| 602 | newPoint.y = nY; |
| 603 | if (button == Right) { |
| 604 | last = true; |
| 605 | } |
| 606 | } |
| 607 | // move the second point |
| 608 | else if (type == Move) { |
| 609 | movingpoint.x = nX; |
| 610 | movingpoint.y = nY; |
| 611 | const QRect oldmovingrect = movingrect; |
| 612 | movingrect = rect | QRect((int)(movingpoint.x * xScale), (int)(movingpoint.y * yScale), 1, 1); |
| 613 | return oldmovingrect | movingrect; |
| 614 | } else if (type == Release) { |
| 615 | const Okular::NormalizedPoint tmppoint(nX, nY); |
| 616 | if (fabs(tmppoint.x - newPoint.x) + fabs(tmppoint.y - newPoint.y) > 1e-2) { |
| 617 | return rect; |
| 618 | } |
| 619 | |
| 620 | if (numofpoints == -1 && points.count() > 1 && (fabs(points[0].x - newPoint.x) + fabs(points[0].y - newPoint.y) < 1e-2)) { |
| 621 | last = true; |
| 622 | } else { |
| 623 | points.append(newPoint); |
| 624 | rect |= QRect((int)(newPoint.x * xScale), (int)(newPoint.y * yScale), 1, 1); |
| 625 | } |
| 626 | // end creation if we have constructed the last point of enough points |
| 627 | if (last || points.count() == numofpoints) { |
| 628 | m_creationCompleted = true; |
| 629 | last = false; |
| 630 | normRect = Okular::NormalizedRect(rect, xScale, yScale); |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | return rect; |
| 635 | } |
| 636 | |
| 637 | void paint(QPainter *painter, double xScale, double yScale, const QRect & /*clipRect*/) override |
| 638 | { |
no test coverage detected