diff --git a/src/core/qgsmaskpaintdevice.cpp b/src/core/qgsmaskpaintdevice.cpp index cf15d1898baf..58f20122b93f 100644 --- a/src/core/qgsmaskpaintdevice.cpp +++ b/src/core/qgsmaskpaintdevice.cpp @@ -34,18 +34,17 @@ QPainterPath QgsMaskPaintEngine::maskPainterPath() const void QgsMaskPaintEngine::drawPath( const QPainterPath &path ) { + QPainterPath realPath = path; if ( mUsePathStroker ) { QPen pen = painter()->pen(); QPainterPathStroker stroker( pen ); QPainterPath strokedPath = stroker.createStroke( path ); - strokedPath = painter()->combinedTransform().map( strokedPath ); - mMaskPainterPath.addPath( strokedPath ); - } - else - { - mMaskPainterPath.addPath( path ); + realPath = strokedPath; } + + const QTransform transform = painter()->combinedTransform(); + mMaskPainterPath.addPath( transform.map( realPath ) ); } void QgsMaskPaintEngine::drawPolygon( const QPointF *points, int numPoints, QPaintEngine::PolygonDrawMode mode ) @@ -56,7 +55,9 @@ void QgsMaskPaintEngine::drawPolygon( const QPointF *points, int numPoints, QPai polygon.reserve( numPoints ); for ( int i = 0; i < numPoints; ++i ) polygon << points[i]; - mMaskPainterPath.addPolygon( polygon ); + + const QTransform transform = painter()->transform(); + mMaskPainterPath.addPolygon( transform.map( polygon ) ); } ///@endcond diff --git a/tests/src/python/test_selective_masking.py b/tests/src/python/test_selective_masking.py index 9edd867b74bd..c90c5724ddb8 100644 --- a/tests/src/python/test_selective_masking.py +++ b/tests/src/python/test_selective_masking.py @@ -35,12 +35,14 @@ QgsMaskMarkerSymbolLayer, QgsOuterGlowEffect, QgsPalLayerSettings, + QgsPathResolver, QgsProject, QgsProjectFileTransform, QgsProperty, QgsRectangle, QgsRenderContext, QgsSingleSymbolRenderer, + QgsSvgMarkerSymbolLayer, QgsSymbolLayerId, QgsSymbolLayerReference, QgsSymbolLayerUtils, @@ -1315,6 +1317,34 @@ def test_vector_random_generator_fill(self): self.check_layout_export("layout_export_random_generator_fill", 0, [layer], extent=extent) + def test_layout_export_svg_marker_masking(self): + """Test layout export with a svg marker symbol masking""" + + svgPath = QgsSymbolLayerUtils.svgSymbolNameToPath('gpsicons/plane.svg', QgsPathResolver()) + + sl = QgsSvgMarkerSymbolLayer(svgPath, 5) + sl.setFillColor(QColor("blue")) + + p = QgsMarkerSymbol() + p.changeSymbolLayer(0, sl) + + self.points_layer.setRenderer(QgsSingleSymbolRenderer(p)) + + mask_layer = QgsMaskMarkerSymbolLayer() + maskSl = QgsSvgMarkerSymbolLayer(svgPath, 8) + pSl = QgsMarkerSymbol() + pSl.changeSymbolLayer(0, maskSl) + mask_layer.setSubSymbol(pSl) + mask_layer.setMasks([ + # the black part of roads + self.get_symbollayer_ref(self.lines_layer, "", [0]), + ]) + # add this mask layer to the point layer + self.points_layer.renderer().symbol().appendSymbolLayer(mask_layer) + + # no rasters + self.check_layout_export("layout_export_svg_marker_masking", 0, [self.points_layer, self.lines_layer]) + if __name__ == '__main__': start_app() diff --git a/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png b/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png new file mode 100644 index 000000000000..18075ca47d73 Binary files /dev/null and b/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png differ