| 635 | } |
| 636 | |
| 637 | void paint(QPainter *painter, double xScale, double yScale, const QRect & /*clipRect*/) override |
| 638 | { |
| 639 | if (points.count() < 1) { |
| 640 | return; |
| 641 | } |
| 642 | |
| 643 | if (m_block && points.count() == 2) { |
| 644 | const Okular::NormalizedPoint first = points[0]; |
| 645 | const Okular::NormalizedPoint second = points[1]; |
| 646 | // draw a semitransparent block around the 2 points |
| 647 | painter->setPen(m_engineColor); |
| 648 | painter->setBrush(QBrush(m_engineColor.lighter(), Qt::Dense4Pattern)); |
| 649 | painter->drawRect((int)(first.x * (double)xScale), (int)(first.y * (double)yScale), (int)((second.x - first.x) * (double)xScale), (int)((second.y - first.y) * (double)yScale)); |
| 650 | } else { |
| 651 | // draw a polyline that connects the constructed points |
| 652 | painter->setPen(QPen(m_engineColor, 2)); |
| 653 | for (int i = 1; i < points.count(); ++i) { |
| 654 | painter->drawLine((int)(points[i - 1].x * (double)xScale), (int)(points[i - 1].y * (double)yScale), (int)(points[i].x * (double)xScale), (int)(points[i].y * (double)yScale)); |
| 655 | } |
| 656 | painter->drawLine((int)(points.last().x * (double)xScale), (int)(points.last().y * (double)yScale), (int)(movingpoint.x * (double)xScale), (int)(movingpoint.y * (double)yScale)); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | QList<Okular::Annotation *> end() override |
| 661 | { |