Changeset View
Changeset View
Standalone View
Standalone View
tools/polygonal/kpToolPolygon.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
51 | painter.setPen(QPen(fcolor.toQColor(), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); | 51 | painter.setPen(QPen(fcolor.toQColor(), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); | ||
52 | 52 | | |||
53 | if ( kpPixmapFX::Only1PixelInPointArray(points) ) | 53 | if ( kpPixmapFX::Only1PixelInPointArray(points) ) | ||
54 | { | 54 | { | ||
55 | painter.drawPoint(points[0]); | 55 | painter.drawPoint(points[0]); | ||
56 | return; | 56 | return; | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | if ( bcolor.isValid() ) | 59 | if ( bcolor.isValid() ) { | ||
60 | painter.setBrush(QBrush(bcolor.toQColor())); | 60 | painter.setBrush(QBrush(bcolor.toQColor())); | ||
61 | else | 61 | } | ||
62 | else { | ||||
62 | painter.setBrush(Qt::NoBrush); | 63 | painter.setBrush(Qt::NoBrush); | ||
64 | } | ||||
63 | 65 | | |||
64 | painter.drawPolygon(points, Qt::OddEvenFill); | 66 | painter.drawPolygon(points, Qt::OddEvenFill); | ||
65 | 67 | | |||
66 | if ( isFinal ) | 68 | if ( isFinal ) { | ||
67 | return; | 69 | return; | ||
70 | } | ||||
68 | 71 | | |||
69 | if ( points.count() <= 2 ) | 72 | if ( points.count() <= 2 ) { | ||
70 | return; | 73 | return; | ||
74 | } | ||||
71 | 75 | | |||
72 | painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination); | 76 | painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination); | ||
73 | painter.setPen(QPen(Qt::white)); | 77 | painter.setPen(QPen(Qt::white)); | ||
74 | painter.drawLine(points[0], points[points.count() - 1]); | 78 | painter.drawLine(points[0], points[points.count() - 1]); | ||
75 | } | 79 | } | ||
76 | 80 | | |||
77 | //-------------------------------------------------------------------------------- | 81 | //-------------------------------------------------------------------------------- | ||
78 | 82 | | |||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
144 | 148 | | |||
145 | 149 | | |||
146 | // public virtual [base kpTool] | 150 | // public virtual [base kpTool] | ||
147 | // TODO: dup with kpToolPolyline but we don't want to create another level of | 151 | // TODO: dup with kpToolPolyline but we don't want to create another level of | ||
148 | // inheritance and readability. | 152 | // inheritance and readability. | ||
149 | void kpToolPolygon::endDraw (const QPoint &, const QRect &) | 153 | void kpToolPolygon::endDraw (const QPoint &, const QRect &) | ||
150 | { | 154 | { | ||
151 | qCDebug(kpLogTools) << "kpToolPolygon::endDraw() points=" | 155 | qCDebug(kpLogTools) << "kpToolPolygon::endDraw() points=" | ||
152 | << points ()->toList () << endl; | 156 | << points ()->toList (); | ||
153 | 157 | | |||
154 | // A click of the other mouse button (to finish shape, instead of adding | 158 | // A click of the other mouse button (to finish shape, instead of adding | ||
155 | // another control point) would have caused endShape() to have been | 159 | // another control point) would have caused endShape() to have been | ||
156 | // called in kpToolPolygonalBase::beginDraw(). The points list would now | 160 | // called in kpToolPolygonalBase::beginDraw(). The points list would now | ||
157 | // be empty. We are being called by kpTool::mouseReleaseEvent(). | 161 | // be empty. We are being called by kpTool::mouseReleaseEvent(). | ||
158 | if (points ()->count () == 0) | 162 | if (points ()->count () == 0) { | ||
159 | return; | 163 | return; | ||
164 | } | ||||
160 | 165 | | |||
161 | if (points ()->count () >= kpToolPolygonalBase::MaxPoints) | 166 | if (points ()->count () >= kpToolPolygonalBase::MaxPoints) | ||
162 | { | 167 | { | ||
163 | qCDebug(kpLogTools) << "\tending shape"; | 168 | qCDebug(kpLogTools) << "\tending shape"; | ||
164 | endShape (); | 169 | endShape (); | ||
165 | return; | 170 | return; | ||
166 | } | 171 | } | ||
167 | 172 | | |||
Show All 11 Lines |