summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-23 17:47:47 (UTC)
committer leseb <leseb>2002-06-23 17:47:47 (UTC)
commit6fd46f6d23538ec6e0f48209f6c0f0d939a2effe (patch) (side-by-side diff)
tree2a5d407155f72dc5496d3a7d412922cc6be97e61
parent3251c55f854ecbd4ece8bf169177ffac28081aaa (diff)
downloadopie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.zip
opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.gz
opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.bz2
Anti-aliasing as an option
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp11
-rw-r--r--noncore/graphics/drawpad/drawpad.h4
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp7
-rw-r--r--noncore/graphics/drawpad/filledellipsetool.cpp8
-rw-r--r--noncore/graphics/drawpad/linetool.cpp7
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp12
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)
connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
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);
// init page toolbar
@@ -275,6 +281,11 @@ DrawPad::~DrawPad()
}
}
+bool DrawPad::antiAliasing()
+{
+ return (m_pAntiAliasingAction->isOn());
+}
+
void DrawPad::newPage()
{
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:
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
+ bool antiAliasing();
+
private slots:
void newPage();
void clearPage();
@@ -74,6 +76,8 @@ private:
QPen m_pen;
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
@@ -32,7 +32,9 @@ void EllipseTool::drawFinalShape(QPainter& p)
{
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
+ if (m_pDrawPad->antiAliasing()) {
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
@@ -64,8 +66,11 @@ void EllipseTool::drawFinalShape(QPainter& p)
areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
areaPixmap.convertFromImage(areaImage);
- 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]));
+ }
}
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)
{
p.setRasterOp(Qt::NotROP);
p.drawRect(QRect(m_polyline[2], m_polyline[0]));
+ p.setRasterOp(Qt::CopyROP);
+ if (m_pDrawPad->antiAliasing()) {
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
@@ -65,8 +67,12 @@ void FilledEllipseTool::drawFinalShape(QPainter& p)
areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
areaPixmap.convertFromImage(areaImage);
- 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]));
+ }
}
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)
{
p.setRasterOp(Qt::NotROP);
p.drawLine(m_polyline[2], m_polyline[0]);
+ p.setRasterOp(Qt::CopyROP);
+ if (m_pDrawPad->antiAliasing()) {
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
@@ -65,8 +67,11 @@ void LineTool::drawFinalShape(QPainter& p)
areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
areaPixmap.convertFromImage(areaImage);
- 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]);
+ }
}
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)
m_polyline[1] = m_polyline[0];
m_polyline[0] = e->pos();
- QPainter painter;
- painter.begin(m_pDrawPadCanvas->currentPage());
-
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
@@ -63,6 +60,10 @@ void PointTool::mouseMoveEvent(QMouseEvent* e)
r.setRight(r.right() + m_pDrawPad->pen().width());
r.setBottom(r.bottom() + m_pDrawPad->pen().width());
+ 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);
@@ -92,6 +93,11 @@ void PointTool::mouseMoveEvent(QMouseEvent* e)
areaPixmap.convertFromImage(areaImage);
painter.drawPixmap(r.x(), r.y(), areaPixmap);
+ } else {
+ painter.setPen(m_pDrawPad->pen());
+ painter.drawPolyline(m_polyline);
+ }
+
painter.end();
QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),