Skip to content

Commit

Permalink
fix(SelectiveMasking): Call parent method to install masks
Browse files Browse the repository at this point in the history
Fixes qgis#57564
Parent method startFeatureRenderer needs to be called so masks could
be installed.
  • Loading branch information
troopa81 committed Jun 6, 2024
1 parent 7c69f92 commit ba2dd12
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/symbology/qgslinesymbollayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,8 +1536,10 @@ bool QgsTemplatedLineSymbolLayerBase::canCauseArtifactsBetweenAdjacentTiles() co
|| ( mPlacements & Qgis::MarkerLinePlacement::SegmentCenter );
}

void QgsTemplatedLineSymbolLayerBase::startFeatureRender( const QgsFeature &, QgsRenderContext & )
void QgsTemplatedLineSymbolLayerBase::startFeatureRender( const QgsFeature &, QgsRenderContext &context )
{
installMasks( context, true );

mRenderingFeature = true;
mHasRenderedFirstPart = false;
}
Expand Down Expand Up @@ -4100,4 +4102,3 @@ Qgis::RenderUnit QgsFilledLineSymbolLayer::outputUnit() const
}
return Qgis::RenderUnit::Unknown;
}

27 changes: 27 additions & 0 deletions tests/src/python/test_selective_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
QgsLayoutItemMap,
QgsLayoutItemPage,
QgsLayoutSize,
QgsLineSymbol,
QgsMapRendererCache,
QgsMapRendererCustomPainterJob,
QgsMapRendererParallelJob,
QgsMapRendererSequentialJob,
QgsMapSettings,
QgsMarkerLineSymbolLayer,
QgsMarkerSymbol,
QgsMaskMarkerSymbolLayer,
QgsNullSymbolRenderer,
QgsOuterGlowEffect,
QgsPalLayerSettings,
QgsPathResolver,
Expand Down Expand Up @@ -1349,6 +1352,30 @@ def test_layout_export_svg_marker_masking(self):
# no rasters
self.check_layout_export("layout_export_svg_marker_masking", 0, [self.points_layer, self.lines_layer])

def test_markerline_masked(self):
"""
Test a layout export where a QgsMarkerLineSymbolLayer is masked
"""

sl = QgsMarkerLineSymbolLayer(True, 7)
circle_symbol = QgsMarkerSymbol.createSimple({'size': '3'})
sl.setSubSymbol(circle_symbol)

self.lines_layer.setRenderer(QgsSingleSymbolRenderer(QgsLineSymbol([sl])))
self.polys_layer.setRenderer(QgsNullSymbolRenderer())

label_settings = self.polys_layer.labeling().settings()
fmt = label_settings.format()
# enable a mask
fmt.mask().setEnabled(True)
fmt.mask().setSize(4.0)
# and mask other symbol layers underneath
fmt.mask().setMaskedSymbolLayers([QgsSymbolLayerReference(self.lines_layer.id(), sl.id())])
label_settings.setFormat(fmt)
self.polys_layer.labeling().setSettings(label_settings)

self.check_layout_export("layout_export_markerline_masked", 0, [self.polys_layer, self.lines_layer])


if __name__ == '__main__':
start_app()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ba2dd12

Please sign in to comment.