-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/ellipsetool.cpp | 57 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filledellipsetool.cpp | 60 | ||||
-rw-r--r-- | noncore/graphics/drawpad/linetool.cpp | 55 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 54 |
6 files changed, 140 insertions, 103 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 45fb886..b29f5ba 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -69,3 +69,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
69 | 69 | ||
70 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 70 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
71 | 71 | ||
@@ -95,2 +95,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
95 | 95 | ||
96 | toolsPopupMenu->insertSeparator(); | ||
97 | |||
98 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); | ||
99 | m_pAntiAliasingAction->setToggleAction(true); | ||
100 | m_pAntiAliasingAction->addTo(toolsPopupMenu); | ||
101 | |||
96 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 102 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
@@ -277,2 +283,7 @@ DrawPad::~DrawPad() | |||
277 | 283 | ||
284 | bool DrawPad::antiAliasing() | ||
285 | { | ||
286 | return (m_pAntiAliasingAction->isOn()); | ||
287 | } | ||
288 | |||
278 | void DrawPad::newPage() | 289 | void DrawPad::newPage() |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index ce62802..8e29c61 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -40,2 +40,4 @@ public: | |||
40 | 40 | ||
41 | bool antiAliasing(); | ||
42 | |||
41 | private slots: | 43 | private slots: |
@@ -76,2 +78,4 @@ private: | |||
76 | 78 | ||
79 | QAction* m_pAntiAliasingAction; | ||
80 | |||
77 | QAction* m_pUndoAction; | 81 | QAction* m_pUndoAction; |
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp index 733bade..0cdb731 100644 --- a/noncore/graphics/drawpad/ellipsetool.cpp +++ b/noncore/graphics/drawpad/ellipsetool.cpp | |||
@@ -34,36 +34,41 @@ void EllipseTool::drawFinalShape(QPainter& p) | |||
34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
35 | p.setRasterOp(Qt::CopyROP); | ||
35 | 36 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 60 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
59 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 61 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
60 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 62 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
61 | bigAreaPainter.end(); | 63 | bigAreaPainter.end(); |
62 | 64 | ||
63 | bigAreaImage = bigAreaPixmap.convertToImage(); | 65 | bigAreaImage = bigAreaPixmap.convertToImage(); |
64 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 66 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
65 | areaPixmap.convertFromImage(areaImage); | 67 | areaPixmap.convertFromImage(areaImage); |
66 | 68 | ||
67 | p.setRasterOp(Qt::CopyROP); | 69 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
68 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 70 | } else { |
71 | p.setPen(m_pDrawPad->pen()); | ||
72 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | ||
73 | } | ||
69 | } | 74 | } |
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp index 2f7ec8f..6b5bbc6 100644 --- a/noncore/graphics/drawpad/filledellipsetool.cpp +++ b/noncore/graphics/drawpad/filledellipsetool.cpp | |||
@@ -34,37 +34,43 @@ void FilledEllipseTool::drawFinalShape(QPainter& p) | |||
34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
35 | p.setRasterOp(Qt::CopyROP); | ||
35 | 36 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | bigAreaPainter.setBrush(m_pDrawPad->brush()); | 60 | bigAreaPainter.setBrush(m_pDrawPad->brush()); |
59 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 61 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
60 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 62 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
61 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 63 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
62 | bigAreaPainter.end(); | 64 | bigAreaPainter.end(); |
63 | 65 | ||
64 | bigAreaImage = bigAreaPixmap.convertToImage(); | 66 | bigAreaImage = bigAreaPixmap.convertToImage(); |
65 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 67 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
66 | areaPixmap.convertFromImage(areaImage); | 68 | areaPixmap.convertFromImage(areaImage); |
67 | 69 | ||
68 | p.setRasterOp(Qt::CopyROP); | 70 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 71 | } else { |
72 | p.setPen(m_pDrawPad->pen()); | ||
73 | p.setBrush(m_pDrawPad->brush()); | ||
74 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | ||
75 | } | ||
70 | } | 76 | } |
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp index 99cd6de..b6baa2a 100644 --- a/noncore/graphics/drawpad/linetool.cpp +++ b/noncore/graphics/drawpad/linetool.cpp | |||
@@ -34,37 +34,42 @@ void LineTool::drawFinalShape(QPainter& p) | |||
34 | p.drawLine(m_polyline[2], m_polyline[0]); | 34 | p.drawLine(m_polyline[2], m_polyline[0]); |
35 | p.setRasterOp(Qt::CopyROP); | ||
35 | 36 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | 60 | ||
59 | bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, | 61 | bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, |
60 | (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); | 62 | (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); |
61 | 63 | ||
62 | bigAreaPainter.end(); | 64 | bigAreaPainter.end(); |
63 | 65 | ||
64 | bigAreaImage = bigAreaPixmap.convertToImage(); | 66 | bigAreaImage = bigAreaPixmap.convertToImage(); |
65 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 67 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
66 | areaPixmap.convertFromImage(areaImage); | 68 | areaPixmap.convertFromImage(areaImage); |
67 | 69 | ||
68 | p.setRasterOp(Qt::CopyROP); | 70 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 71 | } else { |
72 | p.setPen(m_pDrawPad->pen()); | ||
73 | p.drawLine(m_polyline[2], m_polyline[0]); | ||
74 | } | ||
70 | } | 75 | } |
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 | |||
@@ -55,5 +55,2 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
55 | 55 | ||
56 | QPainter painter; | ||
57 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
58 | |||
59 | QRect r = m_polyline.boundingRect(); | 56 | QRect r = m_polyline.boundingRect(); |
@@ -65,31 +62,40 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
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(); |