Diffstat (limited to 'noncore/graphics/drawpad/pointtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index 22bb089..a4f846e 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -48,55 +48,61 @@ void PointTool::mouseReleaseEvent(QMouseEvent* e) | |||
48 | 48 | ||
49 | void PointTool::mouseMoveEvent(QMouseEvent* e) | 49 | void PointTool::mouseMoveEvent(QMouseEvent* e) |
50 | { | 50 | { |
51 | if (m_mousePressed) { | 51 | if (m_mousePressed) { |
52 | m_polyline[2] = m_polyline[1]; | 52 | m_polyline[2] = m_polyline[1]; |
53 | m_polyline[1] = m_polyline[0]; | 53 | m_polyline[1] = m_polyline[0]; |
54 | m_polyline[0] = e->pos(); | 54 | m_polyline[0] = e->pos(); |
55 | 55 | ||
56 | QPainter painter; | ||
57 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
58 | |||
59 | QRect r = m_polyline.boundingRect(); | 56 | QRect r = m_polyline.boundingRect(); |
60 | r = r.normalize(); | 57 | r = r.normalize(); |
61 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 58 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
62 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 59 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
63 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 60 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
64 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 61 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
65 | 62 | ||
66 | QPixmap areaPixmap(r.width(), r.height()); | 63 | QPainter painter; |
67 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); | 64 | painter.begin(m_pDrawPadCanvas->currentPage()); |
65 | |||
66 | if (m_pDrawPad->antiAliasing()) { | ||
67 | QPixmap areaPixmap(r.width(), r.height()); | ||
68 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); | ||
69 | |||
70 | QImage areaImage = areaPixmap.convertToImage(); | ||
71 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | ||
68 | 72 | ||
69 | QImage areaImage = areaPixmap.convertToImage(); | 73 | QPixmap bigAreaPixmap; |
70 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 74 | bigAreaPixmap.convertFromImage(bigAreaImage); |
71 | 75 | ||
72 | QPixmap bigAreaPixmap; | 76 | QPen bigAreaPen = m_pDrawPad->pen(); |
73 | bigAreaPixmap.convertFromImage(bigAreaImage); | 77 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
74 | 78 | ||
75 | QPen bigAreaPen = m_pDrawPad->pen(); | 79 | QPainter bigAreaPainter; |
76 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 80 | bigAreaPainter.begin(&bigAreaPixmap); |
81 | bigAreaPainter.setPen(bigAreaPen); | ||
77 | 82 | ||
78 | QPainter bigAreaPainter; | 83 | QPointArray bigAreaPolyline(3); |
79 | bigAreaPainter.begin(&bigAreaPixmap); | 84 | bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); |
80 | bigAreaPainter.setPen(bigAreaPen); | 85 | bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); |
86 | bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1); | ||
81 | 87 | ||
82 | QPointArray bigAreaPolyline(3); | 88 | bigAreaPainter.drawPolyline(bigAreaPolyline); |
83 | bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); | 89 | bigAreaPainter.end(); |
84 | bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); | ||
85 | bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1); | ||
86 | 90 | ||
87 | bigAreaPainter.drawPolyline(bigAreaPolyline); | 91 | bigAreaImage = bigAreaPixmap.convertToImage(); |
88 | bigAreaPainter.end(); | 92 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
93 | areaPixmap.convertFromImage(areaImage); | ||
89 | 94 | ||
90 | bigAreaImage = bigAreaPixmap.convertToImage(); | 95 | painter.drawPixmap(r.x(), r.y(), areaPixmap); |
91 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 96 | } else { |
92 | areaPixmap.convertFromImage(areaImage); | 97 | painter.setPen(m_pDrawPad->pen()); |
98 | painter.drawPolyline(m_polyline); | ||
99 | } | ||
93 | 100 | ||
94 | painter.drawPixmap(r.x(), r.y(), areaPixmap); | ||
95 | painter.end(); | 101 | painter.end(); |
96 | 102 | ||
97 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 103 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
98 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 104 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
99 | 105 | ||
100 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 106 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
101 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 107 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); |
102 | 108 | ||