Diffstat (limited to 'noncore/graphics/drawpad/filledellipsetool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/filledellipsetool.cpp | 60 |
1 files changed, 33 insertions, 27 deletions
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 | |||
@@ -11,67 +11,73 @@ | |||
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "filledellipsetool.h" | 14 | #include "filledellipsetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | 21 | ||
22 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 23 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | FilledEllipseTool::~FilledEllipseTool() | 27 | FilledEllipseTool::~FilledEllipseTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void FilledEllipseTool::drawFinalShape(QPainter& p) | 31 | 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 | ||
36 | QRect r = m_polyline.boundingRect(); | 37 | if (m_pDrawPad->antiAliasing()) { |
37 | r = r.normalize(); | 38 | QRect r = m_polyline.boundingRect(); |
38 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r = r.normalize(); |
39 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
40 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
41 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | ||
42 | 44 | ||
43 | QPixmap areaPixmap(r.width(), r.height()); | 45 | QPixmap areaPixmap(r.width(), r.height()); |
44 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
45 | 47 | ||
46 | QImage areaImage = areaPixmap.convertToImage(); | 48 | QImage areaImage = areaPixmap.convertToImage(); |
47 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
48 | 50 | ||
49 | QPixmap bigAreaPixmap; | 51 | QPixmap bigAreaPixmap; |
50 | bigAreaPixmap.convertFromImage(bigAreaImage); | 52 | bigAreaPixmap.convertFromImage(bigAreaImage); |
51 | 53 | ||
52 | QPen bigAreaPen = m_pDrawPad->pen(); | 54 | QPen bigAreaPen = m_pDrawPad->pen(); |
53 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
54 | 56 | ||
55 | QPainter bigAreaPainter; | 57 | QPainter bigAreaPainter; |
56 | bigAreaPainter.begin(&bigAreaPixmap); | 58 | bigAreaPainter.begin(&bigAreaPixmap); |
57 | bigAreaPainter.setPen(bigAreaPen); | 59 | bigAreaPainter.setPen(bigAreaPen); |
58 | bigAreaPainter.setBrush(m_pDrawPad->brush()); | 60 | bigAreaPainter.setBrush(m_pDrawPad->brush()); |
59 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 61 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
60 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 62 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
61 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 63 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
62 | bigAreaPainter.end(); | 64 | bigAreaPainter.end(); |
63 | 65 | ||
64 | bigAreaImage = bigAreaPixmap.convertToImage(); | 66 | bigAreaImage = bigAreaPixmap.convertToImage(); |
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); | 70 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
69 | 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) |
73 | { | 79 | { |
74 | p.setRasterOp(Qt::NotROP); | 80 | p.setRasterOp(Qt::NotROP); |
75 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); | 81 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); |
76 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 82 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
77 | } | 83 | } |