-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 11 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/ellipsetool.cpp | 7 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filledellipsetool.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/drawpad/linetool.cpp | 7 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 12 |
6 files changed, 43 insertions, 6 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 | |||
@@ -93,6 +93,12 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
94 | pageInformationAction->addTo(toolsPopupMenu); | 94 | pageInformationAction->addTo(toolsPopupMenu); |
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); |
97 | 103 | ||
98 | // init page toolbar | 104 | // init page toolbar |
@@ -275,6 +281,11 @@ DrawPad::~DrawPad() | |||
275 | } | 281 | } |
276 | } | 282 | } |
277 | 283 | ||
284 | bool DrawPad::antiAliasing() | ||
285 | { | ||
286 | return (m_pAntiAliasingAction->isOn()); | ||
287 | } | ||
288 | |||
278 | void DrawPad::newPage() | 289 | void DrawPad::newPage() |
279 | { | 290 | { |
280 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 291 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
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 | |||
@@ -38,6 +38,8 @@ public: | |||
38 | QPen pen() { return m_pen; } | 38 | QPen pen() { return m_pen; } |
39 | QBrush brush() { return m_brush; } | 39 | QBrush brush() { return m_brush; } |
40 | 40 | ||
41 | bool antiAliasing(); | ||
42 | |||
41 | private slots: | 43 | private slots: |
42 | void newPage(); | 44 | void newPage(); |
43 | void clearPage(); | 45 | void clearPage(); |
@@ -74,6 +76,8 @@ private: | |||
74 | QPen m_pen; | 76 | QPen m_pen; |
75 | QBrush m_brush; | 77 | QBrush m_brush; |
76 | 78 | ||
79 | QAction* m_pAntiAliasingAction; | ||
80 | |||
77 | QAction* m_pUndoAction; | 81 | QAction* m_pUndoAction; |
78 | QAction* m_pRedoAction; | 82 | QAction* m_pRedoAction; |
79 | 83 | ||
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 | |||
@@ -32,7 +32,9 @@ void EllipseTool::drawFinalShape(QPainter& p) | |||
32 | { | 32 | { |
33 | p.setRasterOp(Qt::NotROP); | 33 | p.setRasterOp(Qt::NotROP); |
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 | ||
37 | if (m_pDrawPad->antiAliasing()) { | ||
36 | QRect r = m_polyline.boundingRect(); | 38 | QRect r = m_polyline.boundingRect(); |
37 | r = r.normalize(); | 39 | r = r.normalize(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
@@ -64,8 +66,11 @@ void EllipseTool::drawFinalShape(QPainter& p) | |||
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); | ||
68 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 69 | 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 | } |
70 | 75 | ||
71 | void EllipseTool::drawTemporaryShape(QPainter& p) | 76 | void EllipseTool::drawTemporaryShape(QPainter& p) |
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 | |||
@@ -32,7 +32,9 @@ void FilledEllipseTool::drawFinalShape(QPainter& p) | |||
32 | { | 32 | { |
33 | p.setRasterOp(Qt::NotROP); | 33 | p.setRasterOp(Qt::NotROP); |
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 | ||
37 | if (m_pDrawPad->antiAliasing()) { | ||
36 | QRect r = m_polyline.boundingRect(); | 38 | QRect r = m_polyline.boundingRect(); |
37 | r = r.normalize(); | 39 | r = r.normalize(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
@@ -65,8 +67,12 @@ void FilledEllipseTool::drawFinalShape(QPainter& p) | |||
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); | ||
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 70 | 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 | } |
71 | 77 | ||
72 | void FilledEllipseTool::drawTemporaryShape(QPainter& p) | 78 | void FilledEllipseTool::drawTemporaryShape(QPainter& p) |
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 | |||
@@ -32,7 +32,9 @@ void LineTool::drawFinalShape(QPainter& p) | |||
32 | { | 32 | { |
33 | p.setRasterOp(Qt::NotROP); | 33 | p.setRasterOp(Qt::NotROP); |
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 | ||
37 | if (m_pDrawPad->antiAliasing()) { | ||
36 | QRect r = m_polyline.boundingRect(); | 38 | QRect r = m_polyline.boundingRect(); |
37 | r = r.normalize(); | 39 | r = r.normalize(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
@@ -65,8 +67,11 @@ void LineTool::drawFinalShape(QPainter& p) | |||
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); | ||
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 70 | 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 | } |
71 | 76 | ||
72 | void LineTool::drawTemporaryShape(QPainter& p) | 77 | void LineTool::drawTemporaryShape(QPainter& p) |
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 | |||
@@ -53,9 +53,6 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
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()); |
@@ -63,6 +60,10 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
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 | ||
63 | QPainter painter; | ||
64 | painter.begin(m_pDrawPadCanvas->currentPage()); | ||
65 | |||
66 | if (m_pDrawPad->antiAliasing()) { | ||
66 | QPixmap areaPixmap(r.width(), r.height()); | 67 | QPixmap areaPixmap(r.width(), r.height()); |
67 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); | 68 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); |
68 | 69 | ||
@@ -92,6 +93,11 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
92 | areaPixmap.convertFromImage(areaImage); | 93 | areaPixmap.convertFromImage(areaImage); |
93 | 94 | ||
94 | painter.drawPixmap(r.x(), r.y(), areaPixmap); | 95 | painter.drawPixmap(r.x(), r.y(), areaPixmap); |
96 | } else { | ||
97 | painter.setPen(m_pDrawPad->pen()); | ||
98 | painter.drawPolyline(m_polyline); | ||
99 | } | ||
100 | |||
95 | painter.end(); | 101 | painter.end(); |
96 | 102 | ||
97 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 103 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |