@@ -66,6 +66,7 @@ void QgsDxfPaintEngine::updateState( const QPaintEngineState& state )
66
66
67
67
void QgsDxfPaintEngine::drawPolygon ( const QPointF* points, int pointCount, PolygonDrawMode mode )
68
68
{
69
+ Q_UNUSED ( mode );
69
70
if ( !mDxf || !mPaintDevice )
70
71
{
71
72
return ;
@@ -77,7 +78,8 @@ void QgsDxfPaintEngine::drawPolygon( const QPointF* points, int pointCount, Poly
77
78
polyline[i] = toDxfCoordinates ( points[i] );
78
79
}
79
80
80
- mDxf ->writePolyline ( polyline, mLayer , " CONTINUOUS" , currentPenColor (), currentWidth (), mode != QPaintEngine::PolylineMode );
81
+ bool closed = ( pointCount > 3 && points[0 ] == points[pointCount - 1 ] );
82
+ mDxf ->writePolyline ( polyline, mLayer , " CONTINUOUS" , currentPenColor (), currentWidth (), closed );
81
83
}
82
84
83
85
void QgsDxfPaintEngine::drawRects ( const QRectF* rects, int rectCount )
@@ -116,12 +118,59 @@ void QgsDxfPaintEngine::drawEllipse( const QRectF& rect )
116
118
117
119
void QgsDxfPaintEngine::drawPath ( const QPainterPath& path )
118
120
{
119
- QList<QPolygonF> polygonList = path.toFillPolygons ();
121
+ /* QList<QPolygonF> polygonList = path.toFillPolygons();
120
122
QList<QPolygonF>::const_iterator pIt = polygonList.constBegin();
121
123
for ( ; pIt != polygonList.constEnd(); ++pIt )
122
124
{
123
125
drawPolygon( pIt->constData(), pIt->size(), pIt->isClosed() ? QPaintEngine::OddEvenMode : QPaintEngine::PolylineMode );
126
+ }*/
127
+
128
+ int pathLength = path.elementCount ();
129
+ for ( int i = 0 ; i < pathLength; ++i )
130
+ {
131
+ const QPainterPath::Element& pathElem = path.elementAt ( i );
132
+ if ( pathElem.isMoveTo () )
133
+ {
134
+ moveTo ( pathElem.x , pathElem.y );
135
+ }
136
+ else if ( pathElem.isLineTo () )
137
+ {
138
+ lineTo ( pathElem.x , pathElem.y );
139
+ }
140
+ else if ( pathElem.isCurveTo () )
141
+ {
142
+ curveTo ( pathElem.x , pathElem.y );
143
+ }
144
+ }
145
+ endPolygon ();
146
+ }
147
+
148
+ void QgsDxfPaintEngine::moveTo ( double dx, double dy )
149
+ {
150
+ if ( mCurrentPolygon .size () < 0 )
151
+ {
152
+ endPolygon ();
153
+ }
154
+ mCurrentPolygon .append ( QPointF ( dx, dy ) );
155
+ }
156
+
157
+ void QgsDxfPaintEngine::lineTo ( double dx, double dy )
158
+ {
159
+ mCurrentPolygon .append ( QPointF ( dx, dy ) );
160
+ }
161
+
162
+ void QgsDxfPaintEngine::curveTo ( double dx, double dy )
163
+ {
164
+ mCurrentPolygon .append ( QPointF ( dx, dy ) ); // todo...
165
+ }
166
+
167
+ void QgsDxfPaintEngine::endPolygon ()
168
+ {
169
+ if ( mCurrentPolygon .size () > 1 )
170
+ {
171
+ drawPolygon ( mCurrentPolygon .constData (), mCurrentPolygon .size (), QPaintEngine::OddEvenMode );
124
172
}
173
+ mCurrentPolygon .clear ();
125
174
}
126
175
127
176
void QgsDxfPaintEngine::drawLines ( const QLineF* lines, int lineCount )
0 commit comments