Skip to content

Commit 23c01de

Browse files
committed
dxf export: fix svg scaling
(cherry picked from commit 4b55dbe)
1 parent 9f97f34 commit 23c01de

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

‎src/core/dxf/qgsdxfexport.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ void QgsDxfExport::writeEntities()
992992
}
993993
else
994994
{
995-
QgsDebugMsg( QStringLiteral( "%1: not override style" ).arg( vl->id() ) );
995+
QgsDebugMsg( QStringLiteral( "%1: no override style" ).arg( vl->id() ) );
996996
}
997997

998998
if ( !vl->renderer() )

‎src/core/symbology/qgsmarkersymbollayer.cpp‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,9 +2354,6 @@ QgsSymbolLayer *QgsSvgMarkerSymbolLayer::createFromSld( QDomElement &element )
23542354

23552355
bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift ) const
23562356
{
2357-
Q_UNUSED( layerName );
2358-
Q_UNUSED( shift ); //todo...
2359-
23602357
//size
23612358
double size = mSize;
23622359

@@ -2386,8 +2383,6 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
23862383
size *= mmMapUnitScaleFactor;
23872384
}
23882385

2389-
double halfSize = size / 2.0;
2390-
23912386
//offset, angle
23922387
QPointF offset = mOffset;
23932388

@@ -2409,7 +2404,7 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
24092404
context.setOriginalValueVariable( mAngle );
24102405
angle = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyAngle, context.renderContext().expressionContext(), mAngle ) + mLineAngle;
24112406
}
2412-
//angle = -angle; //rotation in Qt is counterclockwise
2407+
24132408
if ( angle )
24142409
outputOffset = _rotatedOffset( outputOffset, angle );
24152410

@@ -2448,18 +2443,16 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
24482443
const QByteArray &svgContent = QgsApplication::svgCache()->svgContent( path, size, fillColor, strokeColor, strokeWidth,
24492444
context.renderContext().scaleFactor(), mFixedAspectRatio );
24502445

2451-
//if current entry image is 0: cache image for entry
2452-
// checks to see if image will fit into cache
2453-
//update stats for memory usage
24542446
QSvgRenderer r( svgContent );
24552447
if ( !r.isValid() )
2456-
{
24572448
return false;
2458-
}
24592449

24602450
QgsDxfPaintDevice pd( &e );
24612451
pd.setDrawingSize( QSizeF( r.defaultSize() ) );
24622452

2453+
QSizeF outSize( r.defaultSize() );
2454+
outSize.scale( size, size, Qt::KeepAspectRatio );
2455+
24632456
QPainter p;
24642457
p.begin( &pd );
24652458
if ( !qgsDoubleNear( angle, 0.0 ) )
@@ -2469,7 +2462,7 @@ bool QgsSvgMarkerSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFa
24692462
p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
24702463
}
24712464
pd.setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2472-
pd.setOutputSize( QRectF( -halfSize, -halfSize, size, size ) );
2465+
pd.setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
24732466
pd.setLayer( layerName );
24742467
r.render( &p );
24752468
p.end();

0 commit comments

Comments
 (0)