@@ -2356,9 +2356,6 @@ QgsSymbolLayer *QgsSvgMarkerSymbolLayer::createFromSld( QDomElement &element )
2356
2356
2357
2357
bool QgsSvgMarkerSymbolLayer::writeDxf ( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift ) const
2358
2358
{
2359
- Q_UNUSED ( layerName );
2360
- Q_UNUSED ( shift ); // todo...
2361
-
2362
2359
// size
2363
2360
double size = mSize ;
2364
2361
@@ -2388,8 +2385,6 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
2388
2385
size *= mmMapUnitScaleFactor;
2389
2386
}
2390
2387
2391
- double halfSize = size / 2.0 ;
2392
-
2393
2388
// offset, angle
2394
2389
QPointF offset = mOffset ;
2395
2390
@@ -2411,7 +2406,7 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
2411
2406
context.setOriginalValueVariable ( mAngle );
2412
2407
angle = mDataDefinedProperties .valueAsDouble ( QgsSymbolLayer::PropertyAngle, context.renderContext ().expressionContext (), mAngle ) + mLineAngle ;
2413
2408
}
2414
- // angle = -angle; //rotation in Qt is counterclockwise
2409
+
2415
2410
if ( angle )
2416
2411
outputOffset = _rotatedOffset ( outputOffset, angle );
2417
2412
@@ -2450,18 +2445,16 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
2450
2445
const QByteArray &svgContent = QgsApplication::svgCache ()->svgContent ( path, size, fillColor, strokeColor, strokeWidth,
2451
2446
context.renderContext ().scaleFactor (), mFixedAspectRatio );
2452
2447
2453
- // if current entry image is 0: cache image for entry
2454
- // checks to see if image will fit into cache
2455
- // update stats for memory usage
2456
2448
QSvgRenderer r ( svgContent );
2457
2449
if ( !r.isValid () )
2458
- {
2459
2450
return false ;
2460
- }
2461
2451
2462
2452
QgsDxfPaintDevice pd ( &e );
2463
2453
pd.setDrawingSize ( QSizeF ( r.defaultSize () ) );
2464
2454
2455
+ QSizeF outSize ( r.defaultSize () );
2456
+ outSize.scale ( size, size, Qt::KeepAspectRatio );
2457
+
2465
2458
QPainter p;
2466
2459
p.begin ( &pd );
2467
2460
if ( !qgsDoubleNear ( angle, 0.0 ) )
@@ -2471,7 +2464,7 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
2471
2464
p.translate ( -r.defaultSize ().width () / 2.0 , -r.defaultSize ().height () / 2.0 );
2472
2465
}
2473
2466
pd.setShift ( shift + QPointF ( outputOffset.x (), -outputOffset.y () ) );
2474
- pd.setOutputSize ( QRectF ( -halfSize , -halfSize, size, size ) );
2467
+ pd.setOutputSize ( QRectF ( -outSize. width () / 2.0 , -outSize. height () / 2.0 , outSize. width (), outSize. height () ) );
2475
2468
pd.setLayer ( layerName );
2476
2469
r.render ( &p );
2477
2470
p.end ();
0 commit comments