Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

filledellipsetool.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   DrawPad - a drawing program for Opie Environment                      *
00004  *                                                                         *
00005  *   (C) 2002 by S. Prud'homme <prudhomme@laposte.net>                     *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "filledellipsetool.h"
00015 
00016 #include "drawpad.h"
00017 #include "drawpadcanvas.h"
00018 
00019 #include <qimage.h>
00020 
00021 FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
00022     : ShapeTool(drawPad, drawPadCanvas)
00023 {
00024 }
00025 
00026 FilledEllipseTool::~FilledEllipseTool()
00027 {
00028 }
00029 
00030 void FilledEllipseTool::drawFinalShape(QPainter& p)
00031 {
00032     p.setRasterOp(Qt::NotROP);
00033     p.drawRect(QRect(m_polyline[2], m_polyline[0]));
00034     p.setRasterOp(Qt::CopyROP);
00035 
00036     if (m_pDrawPad->antiAliasing()) {
00037         QRect r = m_polyline.boundingRect();
00038         r = r.normalize();
00039         r.setLeft(r.left() - m_pDrawPad->pen().width());
00040         r.setTop(r.top() - m_pDrawPad->pen().width());
00041         r.setRight(r.right() + m_pDrawPad->pen().width());
00042         r.setBottom(r.bottom() + m_pDrawPad->pen().width());
00043 
00044         QPixmap areaPixmap(r.width(), r.height());
00045         bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
00046 
00047         QImage areaImage = areaPixmap.convertToImage();
00048         QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
00049 
00050         QPixmap bigAreaPixmap;
00051         bigAreaPixmap.convertFromImage(bigAreaImage);
00052 
00053         QPen bigAreaPen = m_pDrawPad->pen();
00054         bigAreaPen.setWidth(bigAreaPen.width() * 3);
00055 
00056         QPainter bigAreaPainter;
00057         bigAreaPainter.begin(&bigAreaPixmap);
00058         bigAreaPainter.setPen(bigAreaPen);
00059         bigAreaPainter.setBrush(m_pDrawPad->brush());
00060         bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
00061                                         bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
00062                                         bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
00063         bigAreaPainter.end();
00064 
00065         bigAreaImage = bigAreaPixmap.convertToImage();
00066         areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
00067         areaPixmap.convertFromImage(areaImage);
00068 
00069         p.drawPixmap(r.x(), r.y(), areaPixmap);
00070     } else {
00071         p.setPen(m_pDrawPad->pen());
00072         p.setBrush(m_pDrawPad->brush());
00073         p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
00074     }
00075 }
00076 
00077 void FilledEllipseTool::drawTemporaryShape(QPainter& p)
00078 {
00079     p.setRasterOp(Qt::NotROP);
00080     p.drawRect(QRect(m_polyline[2], m_polyline[1]));
00081     p.drawRect(QRect(m_polyline[2], m_polyline[0]));
00082 }

Generated on Sat Nov 5 16:17:29 2005 for OPIE by  doxygen 1.4.2