@@ -24,6 +24,7 @@ QgsDxfPaintEngine::QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxf
24
24
: QPaintEngine( QPaintEngine::AllFeatures /* QPaintEngine::PainterPaths | QPaintEngine::PaintOutsidePaintEvent*/ )
25
25
, mPaintDevice( dxfDevice )
26
26
, mDxf( dxf )
27
+ , mOpacity( 1.0 )
27
28
{
28
29
}
29
30
@@ -64,6 +65,11 @@ void QgsDxfPaintEngine::updateState( const QPaintEngineState& state )
64
65
65
66
if ( state.state () & QPaintEngine::DirtyBrush )
66
67
mBrush = state.brush ();
68
+
69
+ if ( state.state () & QPaintEngine::DirtyOpacity )
70
+ {
71
+ mOpacity = state.opacity ();
72
+ }
67
73
}
68
74
69
75
void QgsDxfPaintEngine::setRing ( QgsPointSequenceV2 &polyline, const QPointF *points, int pointCount )
@@ -86,12 +92,12 @@ void QgsDxfPaintEngine::drawPolygon( const QPointF *points, int pointCount, Poly
86
92
if ( mode == QPaintEngine::PolylineMode )
87
93
{
88
94
if ( mPen .style () != Qt::NoPen && mPen .brush ().style () != Qt::NoBrush )
89
- mDxf ->writePolyline ( polygon.at ( 0 ), mLayer , " CONTINUOUS" , mPen . color (), currentWidth () );
95
+ mDxf ->writePolyline ( polygon.at ( 0 ), mLayer , " CONTINUOUS" , penColor (), currentWidth () );
90
96
}
91
97
else
92
98
{
93
99
if ( mBrush .style () != Qt::NoBrush )
94
- mDxf ->writePolygon ( polygon, mLayer , " SOLID" , mBrush . color () );
100
+ mDxf ->writePolygon ( polygon, mLayer , " SOLID" , brushColor () );
95
101
}
96
102
}
97
103
@@ -122,7 +128,7 @@ void QgsDxfPaintEngine::drawPath( const QPainterPath& path )
122
128
endPolygon ();
123
129
124
130
if ( !mPolygon .isEmpty () && mBrush .style () != Qt::NoBrush )
125
- mDxf ->writePolygon ( mPolygon , mLayer , " SOLID" , mBrush . color () );
131
+ mDxf ->writePolygon ( mPolygon , mLayer , " SOLID" , brushColor () );
126
132
127
133
mPolygon .clear ();
128
134
}
@@ -198,7 +204,7 @@ void QgsDxfPaintEngine::drawLines( const QLineF* lines, int lineCount )
198
204
{
199
205
mDxf ->writeLine ( toDxfCoordinates ( lines[i].p1 () ),
200
206
toDxfCoordinates ( lines[i].p2 () ),
201
- mLayer , " CONTINUOUS" , mPen . color (), currentWidth () );
207
+ mLayer , " CONTINUOUS" , penColor (), currentWidth () );
202
208
}
203
209
}
204
210
@@ -291,3 +297,25 @@ int QgsDxfPaintEngine::faculty( int n )
291
297
292
298
return result;
293
299
}
300
+
301
+ QColor QgsDxfPaintEngine::penColor () const
302
+ {
303
+ if ( qgsDoubleNear ( mOpacity , 1.0 ) )
304
+ {
305
+ return mPen .color ();
306
+ }
307
+ QColor c = mPen .color ();
308
+ c.setAlphaF ( c.alphaF () * mOpacity );
309
+ return c;
310
+ }
311
+
312
+ QColor QgsDxfPaintEngine::brushColor () const
313
+ {
314
+ if ( qgsDoubleNear ( mOpacity , 1.0 ) )
315
+ {
316
+ return mBrush .color ();
317
+ }
318
+ QColor c = mBrush .color ();
319
+ c.setAlphaF ( c.alphaF () * mOpacity );
320
+ return c;
321
+ }
0 commit comments