summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp13
-rw-r--r--noncore/graphics/drawpad/drawpad.h4
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp57
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.cpp60
-rw-r--r--noncore/graphics/drawpad/linetool.cpp55
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp54
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
@@ -68,5 +68,5 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar);
- QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
+ QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
@@ -94,4 +94,10 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
pageInformationAction->addTo(toolsPopupMenu);
+ 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);
@@ -276,4 +282,9 @@ 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
@@ -39,4 +39,6 @@ public:
QBrush brush() { return m_brush; }
+ bool antiAliasing();
+
private slots:
void newPage();
@@ -75,4 +77,6 @@ private:
QBrush m_brush;
+ QAction* m_pAntiAliasingAction;
+
QAction* m_pUndoAction;
QAction* m_pRedoAction;
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
@@ -33,38 +33,43 @@ void EllipseTool::drawFinalShape(QPainter& p)
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
- QRect r = m_polyline.boundingRect();
- r = r.normalize();
- r.setLeft(r.left() - m_pDrawPad->pen().width());
- r.setTop(r.top() - m_pDrawPad->pen().width());
- r.setRight(r.right() + m_pDrawPad->pen().width());
- r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ if (m_pDrawPad->antiAliasing()) {
+ QRect r = m_polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft(r.left() - m_pDrawPad->pen().width());
+ r.setTop(r.top() - m_pDrawPad->pen().width());
+ r.setRight(r.right() + m_pDrawPad->pen().width());
+ r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
- bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
- bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
- bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
- bigAreaPainter.end();
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
+ bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
+ bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
+ bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
+ bigAreaPainter.end();
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- p.setRasterOp(Qt::CopyROP);
- p.drawPixmap(r.x(), r.y(), areaPixmap);
+ 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
@@ -33,39 +33,45 @@ void FilledEllipseTool::drawFinalShape(QPainter& p)
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
- QRect r = m_polyline.boundingRect();
- r = r.normalize();
- r.setLeft(r.left() - m_pDrawPad->pen().width());
- r.setTop(r.top() - m_pDrawPad->pen().width());
- r.setRight(r.right() + m_pDrawPad->pen().width());
- r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ if (m_pDrawPad->antiAliasing()) {
+ QRect r = m_polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft(r.left() - m_pDrawPad->pen().width());
+ r.setTop(r.top() - m_pDrawPad->pen().width());
+ r.setRight(r.right() + m_pDrawPad->pen().width());
+ r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
- bigAreaPainter.setBrush(m_pDrawPad->brush());
- bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
- bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
- bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
- bigAreaPainter.end();
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
+ bigAreaPainter.setBrush(m_pDrawPad->brush());
+ bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
+ bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
+ bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
+ bigAreaPainter.end();
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- p.setRasterOp(Qt::CopyROP);
- p.drawPixmap(r.x(), r.y(), areaPixmap);
+ 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
@@ -33,39 +33,44 @@ void LineTool::drawFinalShape(QPainter& p)
p.setRasterOp(Qt::NotROP);
p.drawLine(m_polyline[2], m_polyline[0]);
+ p.setRasterOp(Qt::CopyROP);
- QRect r = m_polyline.boundingRect();
- r = r.normalize();
- r.setLeft(r.left() - m_pDrawPad->pen().width());
- r.setTop(r.top() - m_pDrawPad->pen().width());
- r.setRight(r.right() + m_pDrawPad->pen().width());
- r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ if (m_pDrawPad->antiAliasing()) {
+ QRect r = m_polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft(r.left() - m_pDrawPad->pen().width());
+ r.setTop(r.top() - m_pDrawPad->pen().width());
+ r.setRight(r.right() + m_pDrawPad->pen().width());
+ r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
- bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1,
- (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
+ bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1,
+ (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
- bigAreaPainter.end();
+ bigAreaPainter.end();
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- p.setRasterOp(Qt::CopyROP);
- p.drawPixmap(r.x(), r.y(), areaPixmap);
+ 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
@@ -54,7 +54,4 @@ void PointTool::mouseMoveEvent(QMouseEvent* e)
m_polyline[0] = e->pos();
- QPainter painter;
- painter.begin(m_pDrawPadCanvas->currentPage());
-
QRect r = m_polyline.boundingRect();
r = r.normalize();
@@ -64,33 +61,42 @@ void PointTool::mouseMoveEvent(QMouseEvent* e)
r.setBottom(r.bottom() + m_pDrawPad->pen().width());
- QPixmap areaPixmap(r.width(), r.height());
- bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r);
+ QPainter painter;
+ painter.begin(m_pDrawPadCanvas->currentPage());
+
+ if (m_pDrawPad->antiAliasing()) {
+ QPixmap areaPixmap(r.width(), r.height());
+ bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r);
+
+ QImage areaImage = areaPixmap.convertToImage();
+ QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
- QImage areaImage = areaPixmap.convertToImage();
- QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
+ QPixmap bigAreaPixmap;
+ bigAreaPixmap.convertFromImage(bigAreaImage);
- QPixmap bigAreaPixmap;
- bigAreaPixmap.convertFromImage(bigAreaImage);
+ QPen bigAreaPen = m_pDrawPad->pen();
+ bigAreaPen.setWidth(bigAreaPen.width() * 3);
- QPen bigAreaPen = m_pDrawPad->pen();
- bigAreaPen.setWidth(bigAreaPen.width() * 3);
+ QPainter bigAreaPainter;
+ bigAreaPainter.begin(&bigAreaPixmap);
+ bigAreaPainter.setPen(bigAreaPen);
- QPainter bigAreaPainter;
- bigAreaPainter.begin(&bigAreaPixmap);
- bigAreaPainter.setPen(bigAreaPen);
+ QPointArray bigAreaPolyline(3);
+ bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
+ bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1);
+ bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1);
- QPointArray bigAreaPolyline(3);
- bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1);
- bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1);
- bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1);
+ bigAreaPainter.drawPolyline(bigAreaPolyline);
+ bigAreaPainter.end();
- bigAreaPainter.drawPolyline(bigAreaPolyline);
- bigAreaPainter.end();
+ bigAreaImage = bigAreaPixmap.convertToImage();
+ areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
+ areaPixmap.convertFromImage(areaImage);
- bigAreaImage = bigAreaPixmap.convertToImage();
- areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
- areaPixmap.convertFromImage(areaImage);
+ painter.drawPixmap(r.x(), r.y(), areaPixmap);
+ } else {
+ painter.setPen(m_pDrawPad->pen());
+ painter.drawPolyline(m_polyline);
+ }
- painter.drawPixmap(r.x(), r.y(), areaPixmap);
painter.end();