-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 @@ -95,2 +95,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name) + toolsPopupMenu->insertSeparator(); + + m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); + m_pAntiAliasingAction->setToggleAction(true); + m_pAntiAliasingAction->addTo(toolsPopupMenu); + menuBar->insertItem(tr("Tools"), toolsPopupMenu); @@ -277,2 +283,7 @@ DrawPad::~DrawPad() +bool DrawPad::antiAliasing() +{ + return (m_pAntiAliasingAction->isOn()); +} + 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: + bool antiAliasing(); + private slots: @@ -76,2 +78,4 @@ private: + QAction* m_pAntiAliasingAction; + 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,3 +34,5 @@ void EllipseTool::drawFinalShape(QPainter& p) p.drawRect(QRect(m_polyline[2], m_polyline[0])); + p.setRasterOp(Qt::CopyROP); + if (m_pDrawPad->antiAliasing()) { QRect r = m_polyline.boundingRect(); @@ -66,4 +68,7 @@ void EllipseTool::drawFinalShape(QPainter& p) - p.setRasterOp(Qt::CopyROP); p.drawPixmap(r.x(), r.y(), areaPixmap); + } else { + p.setPen(m_pDrawPad->pen()); + p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); + } } 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,3 +34,5 @@ void FilledEllipseTool::drawFinalShape(QPainter& p) p.drawRect(QRect(m_polyline[2], m_polyline[0])); + p.setRasterOp(Qt::CopyROP); + if (m_pDrawPad->antiAliasing()) { QRect r = m_polyline.boundingRect(); @@ -67,4 +69,8 @@ void FilledEllipseTool::drawFinalShape(QPainter& p) - p.setRasterOp(Qt::CopyROP); p.drawPixmap(r.x(), r.y(), areaPixmap); + } else { + p.setPen(m_pDrawPad->pen()); + p.setBrush(m_pDrawPad->brush()); + p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); + } } 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,3 +34,5 @@ void LineTool::drawFinalShape(QPainter& p) p.drawLine(m_polyline[2], m_polyline[0]); + p.setRasterOp(Qt::CopyROP); + if (m_pDrawPad->antiAliasing()) { QRect r = m_polyline.boundingRect(); @@ -67,4 +69,7 @@ void LineTool::drawFinalShape(QPainter& p) - p.setRasterOp(Qt::CopyROP); p.drawPixmap(r.x(), r.y(), areaPixmap); + } else { + p.setPen(m_pDrawPad->pen()); + p.drawLine(m_polyline[2], m_polyline[0]); + } } 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) - QPainter painter; - painter.begin(m_pDrawPadCanvas->currentPage()); - QRect r = m_polyline.boundingRect(); @@ -65,2 +62,6 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) + QPainter painter; + painter.begin(m_pDrawPadCanvas->currentPage()); + + if (m_pDrawPad->antiAliasing()) { QPixmap areaPixmap(r.width(), r.height()); @@ -94,2 +95,7 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) painter.drawPixmap(r.x(), r.y(), areaPixmap); + } else { + painter.setPen(m_pDrawPad->pen()); + painter.drawPolyline(m_polyline); + } + painter.end(); |