51#include <QElapsedTimer>
57#include "moc_qgsmaprendererjob.cpp"
59using namespace Qt::StringLiterals;
70LayerRenderJob &LayerRenderJob::operator=( LayerRenderJob &&other )
75 mContext = std::move( other.mContext );
76 destinationImage = std::move( other.destinationImage );
77 destinationPainter = std::move( other.destinationPainter );
78 renderer = std::move( other.renderer );
79 previewRenderImage = std::move( other.previewRenderImage );
80 previewRenderPainter = std::move( other.previewRenderPainter );
82 imageInitialized = other.imageInitialized;
83 previewRenderImageInitialized = other.previewRenderImageInitialized;
85 blendMode = other.blendMode;
86 opacity = other.opacity;
87 cached = other.cached;
89 renderAboveLabels = other.renderAboveLabels;
90 completed = other.completed;
91 renderingTime = other.renderingTime;
92 estimatedRenderingTime = other.estimatedRenderingTime;
93 errors = other.errors;
94 layerId = other.layerId;
96 maskPaintDevice = std::move( other.maskPaintDevice );
97 maskRenderFormat = other.maskRenderFormat;
99 firstPassJob = other.firstPassJob;
100 other.firstPassJob =
nullptr;
102 picture = std::move( other.picture );
104 maskJobs = other.maskJobs;
106 elevationMap = std::move( other.elevationMap );
107 maskPainter = std::move( other.maskPainter );
112LayerRenderJob::LayerRenderJob( LayerRenderJob &&other )
113 : imageInitialized( other.imageInitialized )
114 , previewRenderImageInitialized( other.previewRenderImageInitialized )
115 , blendMode( other.blendMode )
116 , opacity( other.opacity )
117 , cached( other.cached )
118 , renderAboveLabels( other.renderAboveLabels )
119 , layer( other.layer )
120 , completed( other.completed )
121 , renderingTime( other.renderingTime )
122 , estimatedRenderingTime( other.estimatedRenderingTime )
123 , errors( other.errors )
124 , layerId( other.layerId )
125 , maskRenderFormat( other.maskRenderFormat )
126 , maskPainter( std::move( other.maskPainter ) )
127 , maskJobs( other.maskJobs )
129 mContext = std::move( other.mContext );
130 destinationImage = std::move( other.destinationImage );
131 destinationPainter = std::move( other.destinationPainter );
132 previewRenderImage = std::move( other.previewRenderImage );
133 previewRenderPainter = std::move( other.previewRenderPainter );
134 renderer = std::move( other.renderer );
135 elevationMap = std::move( other.elevationMap );
136 maskPaintDevice = std::move( other.maskPaintDevice );
138 firstPassJob = other.firstPassJob;
139 other.firstPassJob =
nullptr;
141 picture = std::move( other.picture );
144bool LayerRenderJob::imageCanBeComposed()
const
146 if ( imageInitialized )
150 return renderer->isReadyToCompose();
164 : mSettings( settings )
177 mErrors.append( QgsMapRendererJob::Error( QString(), tr(
"Invalid map settings" ) ) );
209 return mLabelingEngineFeedback;
214 QHash<QgsMapLayer *, int> result;
217 if (
auto &&lKey = it.key() )
218 result.insert( lKey, it.value() );
238 QSet< QgsMapLayer * > labeledLayers;
239 const QList<QgsMapLayer *> layers =
mSettings.layers();
240 for ( QgsMapLayer *ml : layers )
245 switch ( ml->type() )
249 QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( ml );
259 QgsMeshLayer *l = qobject_cast< QgsMeshLayer *>( ml );
269 QgsRasterLayer *l = qobject_cast< QgsRasterLayer *>( ml );
301 bool canUseCache = canCache && QSet< QgsMapLayer * >( labelDependentLayers.begin(), labelDependentLayers.end() ) == labeledLayers;
313 const QList<QgsMapLayer *> layers =
mSettings.layers();
314 for ( QgsMapLayer *ml : layers )
319 switch ( ml->type() )
323 QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( ml );
333 QgsMeshLayer *l = qobject_cast< QgsMeshLayer *>( ml );
343 QgsRasterLayer *l = qobject_cast< QgsRasterLayer *>( ml );
374 QgsCoordinateTransform approxTransform = ct;
387 static const double SPLIT_COORD = 180.0;
400 u
"\n0:%1 %2x%3\n1:%4\n2:%5 %6x%7 (w:%8 h:%9)"_s.arg( extent.
toString() )
401 .arg( extent.
width() )
404 .arg( extent2.
width() )
406 .arg( std::fabs( 1.0 - extent2.
width() / extent.
width() ) )
407 .arg( std::fabs( 1.0 - extent2.
height() / extent.
height() ) ),
421 extent = QgsRectangle( -180.0, -90.0, 180.0, 90.0 );
439 if ( ll.
x() > ur.
x() )
466 extent = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
473 catch ( QgsCsException &e )
476 extent = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
477 r2 = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
484std::unique_ptr<QImage> QgsMapRendererJob::allocateImage(
const QString &layerId )
486 auto image = std::make_unique< QImage >(
mSettings.deviceOutputSize(),
mSettings.outputImageFormat() );
487 image->setDevicePixelRatio(
static_cast<qreal
>(
mSettings.devicePixelRatio() ) );
488 image->setDotsPerMeterX(
static_cast< int >( 1000 *
mSettings.outputDpi() / 25.4 ) );
489 image->setDotsPerMeterY(
static_cast< int >( 1000 *
mSettings.outputDpi() / 25.4 ) );
490 if ( image->isNull() )
493 mErrors.append(
Error( layerId, tr(
"Insufficient memory for image %1x%2" ).arg(
mSettings.outputSize().width() ).arg(
mSettings.outputSize().height() ) ) );
499std::unique_ptr<QgsElevationMap> QgsMapRendererJob::allocateElevationMap(
const QString &layerId )
501 auto elevationMap = std::make_unique<QgsElevationMap>(
mSettings.deviceOutputSize(),
mSettings.devicePixelRatio() );
502 if ( !elevationMap->isValid() )
505 mErrors.append(
Error( layerId, tr(
"Insufficient memory for elevation map %1x%2" ).arg(
mSettings.outputSize().width() ).arg(
mSettings.outputSize().height() ) ) );
511std::tuple< std::unique_ptr< QImage >, std::unique_ptr< QPainter > > QgsMapRendererJob::allocateImageAndPainter(
const QString &layerId,
const QgsRenderContext &context )
513 std::unique_ptr< QPainter > painter;
514 std::unique_ptr< QImage > image = allocateImage( layerId );
517 painter = std::make_unique< QPainter >( image.get() );
520 return { std::move( image ), std::move( painter ) };
523std::tuple<std::unique_ptr<QPicture>, std::unique_ptr< QPainter > > QgsMapRendererJob::allocatePictureAndPainter(
const QgsRenderContext &context )
525 auto picture = std::make_unique<QPicture>();
526 auto painter = std::make_unique< QPainter >( picture.get() );
528 return { std::move( picture ), std::move( painter ) };
533 std::vector< LayerRenderJob > layerJobs;
536 QListIterator<QgsMapLayer *> li(
mSettings.layers() );
542 Q_UNUSED( cacheValid )
548 while ( li.hasPrevious() )
550 QgsMapLayer *ml = li.previous();
553 u
"layer %1: minscale:%2 maxscale:%3 scaledepvis:%4 blendmode:%5 isValid:%6"_s.arg( ml->
name() )
565 mErrors.append(
Error( ml->
id(), QString(
"Layer %1 is invalid, skipped" ).arg( ml->
name() ) ) );
571 QgsDebugMsgLevel( u
"Layer not rendered because it is not within the defined visibility scale range"_s, 3 );
577 QgsDebugMsgLevel( u
"Layer not rendered because it is not visible within the map's time range"_s, 3 );
583 QgsDebugMsgLevel( u
"Layer not rendered because it is not visible within the layer's time range"_s, 3 );
587 if ( !
mSettings.zRange().isInfinite() && ml->elevationProperties() && !ml->elevationProperties()->isVisibleInZRange(
mSettings.zRange(), ml ) )
589 QgsDebugMsgLevel( u
"Layer not rendered because it is not visible within the map's z range"_s, 3 );
593 QgsRectangle r1 =
mSettings.visibleExtent(), r2;
595 QgsCoordinateTransform ct;
598 bool haveExtentInLayerCrs =
true;
601 haveExtentInLayerCrs = reprojectToLayerExtent( ml, ct, r1, r2 );
606 mErrors.append(
Error( ml->id(), tr(
"There was a problem transforming the layer's extent. Layer skipped." ) ) );
610 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
617 if ( ( vl && vl->
isEditable() ) || requiresLabeling )
619 mCache->clearCacheImage( ml->id() );
623 layerJobs.emplace_back( LayerRenderJob() );
624 LayerRenderJob &job = layerJobs.back();
626 job.layerId = ml->id();
627 job.renderAboveLabels = ml->customProperty( u
"rendering/renderAboveLabels"_s ).toBool();
631 if ( !ml->customProperty( u
"_noset_layer_expression_context"_s ).toBool() )
633 job.context()->setPainter( painter );
634 job.context()->setLabelingEngine( labelingEngine2 );
635 job.context()->setLabelSink(
labelSink() );
636 job.context()->setCoordinateTransform( ct );
637 job.context()->setExtent( r1 );
643 if ( mFeatureFilterProvider )
645 job.context()->setFeatureFilterProvider( mFeatureFilterProvider );
648 if ( mPerLayerTemporalRange.contains( ml ) )
650 job.context()->setTemporalRange( mPerLayerTemporalRange.value( ml ) );
653 QgsMapLayerStyleOverride styleOverride( ml );
654 if (
mSettings.layerStyleOverrides().contains( ml->id() ) )
655 styleOverride.setOverrideStyle(
mSettings.layerStyleOverrides().value( ml->id() ) );
657 job.blendMode = ml->blendMode();
662 QgsRasterLayer *rl = qobject_cast< QgsRasterLayer * >( ml );
669 job.opacity = ml->opacity();
674 job.opacity = ml->opacity();
677 const QgsElevationShadingRenderer shadingRenderer =
mSettings.elevationShadingRenderer();
681 if ( canUseCache &&
mCache->hasCacheImage( ml->id() ) )
684 job.imageInitialized =
true;
685 job.destinationImage = std::make_unique< QImage >(
mCache->cacheImage( ml->id() ) );
688 job.destinationImage->setDevicePixelRatio(
static_cast<qreal
>(
mSettings.devicePixelRatio() ) );
689 job.renderer.reset();
690 job.context()->setPainter(
nullptr );
695 QElapsedTimer layerTime;
697 job.renderer.reset( ml->createMapRenderer( *( job.context() ) ) );
700 job.renderer->setLayerRenderingTimeHint( job.estimatedRenderingTime );
701 job.context()->setFeedback( job.renderer->feedback() );
712 if ( canUseCache || ( !painter && !deferredPainterSet ) || ( job.renderer && job.renderer->forceRasterRender() ) )
715 auto [image, painter] = allocateImageAndPainter( ml->id(), *job.context() );
716 job.destinationImage = std::move( image );
717 job.destinationPainter = std::move( painter );
718 job.context()->setPainter( job.destinationPainter.get() );
719 if ( !job.destinationImage )
721 job.renderer.reset();
722 layerJobs.pop_back();
727 if ( shadingRenderer.
isActive() && ml->elevationProperties() && ml->elevationProperties()->hasElevation() )
729 job.elevationMap = allocateElevationMap( ml->id() );
730 job.context()->setElevationMap( job.elevationMap.get() );
737 const QImage cachedImage =
mCache->transformedCacheImage( job.layerId + u
"_preview"_s,
mSettings.mapToPixel() );
738 if ( !cachedImage.isNull() )
740 job.previewRenderImage = std::make_unique< QImage >( cachedImage );
741 job.previewRenderImageInitialized =
true;
742 job.context()->setPreviewRenderPainter(
new QPainter( job.previewRenderImage.get() ) );
743 job.context()->setPainterFlagsUsingContext( painter );
746 if ( !job.previewRenderImage )
748 auto [image, painter] = allocateImageAndPainter( ml->id(), *job.context() );
749 job.previewRenderImage = std::move( image );
750 job.previewRenderPainter = std::move( painter );
751 job.previewRenderImageInitialized =
false;
752 job.context()->setPreviewRenderPainter( job.previewRenderPainter.get() );
755 if ( !job.previewRenderImage )
757 job.context()->setPreviewRenderPainter(
nullptr );
758 job.previewRenderPainter.reset();
762 job.renderingTime =
static_cast< int >( layerTime.elapsed() );
770 std::vector< LayerRenderJob > secondPassJobs;
773 QHash<QString, LayerRenderJob *> layerJobMapping;
776 QMap<QString, bool> maskLayerHasEffects;
777 QMap<int, bool> labelHasEffects;
785 MaskSource(
const QString &layerId_,
const QString &labelRuleId_,
int labelMaskId_,
bool hasEffects_ )
786 : layerId( layerId_ )
787 , labelRuleId( labelRuleId_ )
788 , labelMaskId( labelMaskId_ )
789 , hasEffects( hasEffects_ )
793 struct MaskedSymbolLayers
795 QSet<QString> maskedSymbolLayerIds;
796 QList<MaskSource> maskSourceList;
802 QHash<QString, MaskedSymbolLayers> maskedSymbolLayers;
806 for ( LayerRenderJob &job : firstPassJobs )
808 layerJobMapping[job.layerId] = &job;
813 QVector< QgsVectorLayer * > allRenderedVectorLayers;
814 for ( LayerRenderJob &job : firstPassJobs )
816 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( job.layer );
820 allRenderedVectorLayers << vl;
825 for ( LayerRenderJob &job : firstPassJobs )
827 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( job.layer );
832 auto collectMasks = [&maskedSymbolLayers,
833 &maskLayerHasEffects](
const QgsMaskedLayers &objectsToBeMaskedByLayer,
const QString &idOfLayerCreatingMask,
const QString &ruleId = QString(),
int labelMaskId = -1 ) {
834 bool hasEffects =
false;
835 for (
auto it = objectsToBeMaskedByLayer.begin(); it != objectsToBeMaskedByLayer.end(); ++it )
837 const QString maskedLayerId = it.key();
838 auto lit = maskedSymbolLayers.find( maskedLayerId );
839 if ( lit == maskedSymbolLayers.end() )
841 MaskedSymbolLayers maskedObjects;
842 maskedObjects.maskedSymbolLayerIds = it.value().symbolLayerIdsToMask;
843 maskedObjects.maskSourceList = QList<MaskSource>() << MaskSource( idOfLayerCreatingMask, ruleId, labelMaskId, it.value().hasEffects );
844 maskedSymbolLayers[maskedLayerId] = maskedObjects;
848 if ( lit->maskedSymbolLayerIds != it.value().symbolLayerIdsToMask )
850 QgsLogger::warning( u
"Layer %1 : Different sets of symbol layers are masked by different sources ! Only one (arbitrary) set will be retained !"_s.arg( it.key() ) );
853 lit->maskSourceList.push_back( MaskSource( idOfLayerCreatingMask, ruleId, labelMaskId, hasEffects ) );
855 hasEffects |= it.value().hasEffects;
857 if ( !objectsToBeMaskedByLayer.isEmpty() && labelMaskId == -1 )
858 maskLayerHasEffects[idOfLayerCreatingMask] = hasEffects;
863 for (
auto it = labelMasks.begin(); it != labelMasks.end(); it++ )
865 QString labelRule = it.key();
871 for (
auto mit = masks.begin(); mit != masks.end(); mit++ )
873 const QString sourceLayerId = mit.key();
875 if ( !layerJobMapping.contains( sourceLayerId ) )
878 usableMasks.insert( sourceLayerId, mit.value() );
881 if ( usableMasks.empty() )
885 QSet<QgsSymbolLayerReference> slRefs;
886 bool hasEffects =
false;
887 for (
auto mit = usableMasks.begin(); mit != usableMasks.end(); mit++ )
889 const QString sourceLayerId = mit.key();
891 if ( !layerJobMapping.contains( sourceLayerId ) )
894 for (
const QString &symbolLayerId : std::as_const( mit.value().symbolLayerIdsToMask ) )
895 slRefs.insert( QgsSymbolLayerReference( sourceLayerId, symbolLayerId ) );
897 hasEffects |= mit.value().hasEffects;
900 int labelMaskId = labelJob.maskIdProvider.insertLabelLayer( vl->
id(), it.key(), slRefs );
901 labelHasEffects[labelMaskId] = hasEffects;
904 collectMasks( usableMasks, vl->
id(), labelRule, labelMaskId );
909 collectMasks( objectsToBeMaskedByLayer, vl->
id() );
912 if ( maskedSymbolLayers.isEmpty() )
913 return secondPassJobs;
916 QMap<int, bool> labelMaskRequiresRaster;
917 QMap<QString, bool> layerMaskRequiresRaster;
918 for (
auto it = maskedSymbolLayers.constBegin(); it != maskedSymbolLayers.constEnd(); ++it )
920 const QString maskedLayerId = it.key();
921 LayerRenderJob *targetJob = layerJobMapping.value( maskedLayerId );
924 const bool targetForcesRaster = !targetJob || ( targetJob->renderer && targetJob->renderer->forceRasterRender() ) || ( targetJob->blendMode != QPainter::CompositionMode_SourceOver );
925 for (
const MaskSource &source : it->maskSourceList )
927 bool sourceRequiresRaster = source.hasEffects || targetForcesRaster;
928 if ( source.labelMaskId != -1 )
930 if ( labelHasEffects[source.labelMaskId] || sourceRequiresRaster )
931 labelMaskRequiresRaster[source.labelMaskId] =
true;
935 if ( maskLayerHasEffects.value( source.layerId,
false ) || sourceRequiresRaster )
936 layerMaskRequiresRaster[source.layerId] =
true;
942 for (
int maskId = 0; maskId < labelJob.maskIdProvider.size(); maskId++ )
944 std::unique_ptr< QPaintDevice > maskPaintDevice;
945 std::unique_ptr< QPainter > maskPainter;
948 switch (
mapSettings().rasterizedRenderingPolicy() )
961 switch ( renderFormat )
966 auto geomPaintDevice = std::make_unique< QgsGeometryPaintDevice >(
true );
967 geomPaintDevice->setStrokedPathSegments( 4 );
968 geomPaintDevice->setSimplificationTolerance( labelJob.context.maskSettings().simplifyTolerance() );
969 maskPaintDevice = std::move( geomPaintDevice );
970 maskPainter = std::make_unique< QPainter >( maskPaintDevice.get() );
976 auto [maskImage, painter] = allocateImageAndPainter( u
"label mask"_s, labelJob.context );
980 maskImage->fill( 0 );
981 maskPaintDevice = std::move( maskImage );
982 maskPainter = std::move( painter );
987 labelJob.context.setMaskPainter( maskPainter.get(), maskId );
988 labelJob.maskPainters.emplace_back( std::move( maskPainter ) );
989 labelJob.maskPaintDevices.emplace_back( std::move( maskPaintDevice ) );
991 labelJob.context.setMaskIdProvider( &labelJob.maskIdProvider );
1008 switch (
mapSettings().rasterizedRenderingPolicy() )
1020 switch ( labelJobRenderFormat )
1024 if ( !labelJob.img )
1026 labelJob.img = allocateImage( u
"labels"_s );
1033 if ( !labelJob.picture )
1035 labelJob.picture = std::make_unique<QPicture>();
1042 for ( LayerRenderJob &job : firstPassJobs )
1044 bool maskRequiresLayerRasterization =
false;
1046 auto it = maskedSymbolLayers.find( job.layerId );
1047 if ( it != maskedSymbolLayers.end() )
1049 const QList<MaskSource> &sourceList = it->maskSourceList;
1050 for (
const MaskSource &source : sourceList )
1052 maskRequiresLayerRasterization |= source.hasEffects;
1058 switch (
mapSettings().rasterizedRenderingPolicy() )
1066 || maskRequiresLayerRasterization
1067 || ( job.renderer && job.renderer->forceRasterRender() )
1068 || ( job.blendMode != QPainter::CompositionMode_SourceOver ) )
1079 switch ( job.maskRenderFormat )
1083 if ( !job.destinationImage )
1085 auto [img, painter] = allocateImageAndPainter( job.layerId, *job.context() );
1086 Q_ASSERT( !job.destinationPainter );
1087 job.destinationPainter = std::move( painter );
1088 job.context()->setPainter( job.destinationPainter.get() );
1089 job.destinationImage = std::move( img );
1098 auto [picture, painter] = allocatePictureAndPainter( *job.context() );
1099 job.picture = std::move( picture );
1100 if ( job.context()->painter()->hasClipping() )
1103 painter->setClipping(
true );
1104 painter->setClipPath( job.context()->painter()->clipPath() );
1106 Q_ASSERT( !job.destinationPainter );
1107 job.destinationPainter = std::move( painter );
1108 job.context()->setPainter( job.destinationPainter.get() );
1111 job.context()->setFeedback(
nullptr );
1112 job.renderer.reset( job.layer->createMapRenderer( *( job.context() ) ) );
1115 job.context()->setFeedback( job.renderer->feedback() );
1123 if ( maskLayerHasEffects.contains( job.layerId ) )
1125 std::unique_ptr< QPaintDevice > maskPaintDevice;
1126 std::unique_ptr< QPainter > maskPainter;
1127 switch (
mapSettings().rasterizedRenderingPolicy() )
1141 switch ( job.maskRenderFormat )
1146 auto geomPaintDevice = std::make_unique< QgsGeometryPaintDevice >();
1147 geomPaintDevice->setStrokedPathSegments( 4 );
1148 geomPaintDevice->setSimplificationTolerance( job.context()->maskSettings().simplifyTolerance() );
1149 maskPaintDevice = std::move( geomPaintDevice );
1150 maskPainter = std::make_unique< QPainter >( maskPaintDevice.get() );
1157 auto [maskImage, painter] = allocateImageAndPainter( job.layerId, *job.context() );
1158 maskImage->fill( 0 );
1159 maskPaintDevice = std::move( maskImage );
1160 maskPainter = std::move( painter );
1165 job.context()->setMaskPainter( maskPainter.get() );
1166 job.maskPainter = std::move( maskPainter );
1167 job.maskPaintDevice = std::move( maskPaintDevice );
1171 for ( LayerRenderJob &job : firstPassJobs )
1173 QgsMapLayer *ml = job.layer;
1175 auto it = maskedSymbolLayers.find( job.layerId );
1176 if ( it == maskedSymbolLayers.end() )
1179 const QList<MaskSource> maskedSourceList = it->maskSourceList;
1180 const QSet<QString> maskedSymbolLayerIds = it->maskedSymbolLayerIds;
1182 secondPassJobs.emplace_back( LayerRenderJob() );
1183 LayerRenderJob &job2 = secondPassJobs.back();
1185 job2.maskRenderFormat = job.maskRenderFormat;
1188 for (
const MaskSource &source : maskedSourceList )
1190 LayerRenderJob::MaskJob maskJob;
1192 if ( source.labelMaskId != -1 )
1194 maskJob.maskPaintDeviceId = source.labelMaskId;
1198 maskJob.layerRenderJob = layerJobMapping[source.layerId];
1200 job2.maskJobs.emplace_back( maskJob );
1204 job2.setContext( std::make_unique< QgsRenderContext >( *job.context() ) );
1206 job2.layer = job.layer;
1207 job2.renderAboveLabels = job.renderAboveLabels;
1208 job2.layerId = job.layerId;
1211 job2.firstPassJob = &job;
1213 switch ( job2.maskRenderFormat )
1217 Q_ASSERT( !job2.destinationImage );
1218 Q_ASSERT( !job2.destinationPainter );
1219 auto [img, painter] = allocateImageAndPainter( job.layerId, *job2.context() );
1220 job2.context()->setPainter( painter.get() );
1221 job2.destinationImage = std::move( img );
1222 job2.destinationPainter = std::move( painter );
1228 auto [picture, painter] = allocatePictureAndPainter( *job2.context() );
1229 if ( job.context()->painter()->hasClipping() )
1232 painter->setClipping(
true );
1233 painter->setClipPath( job.context()->painter()->clipPath() );
1235 job2.picture = std::move( picture );
1236 Q_ASSERT( !job2.destinationPainter );
1237 job2.destinationPainter = std::move( painter );
1238 job2.context()->setPainter( job2.destinationPainter.get() );
1243 if ( !job2.destinationImage && !job2.picture )
1245 secondPassJobs.pop_back();
1251 job2.context()->setFeedback(
nullptr );
1253 if ( job2.renderer )
1255 job2.context()->setFeedback( job2.renderer->feedback() );
1260 job2.context()->setDisabledSymbolLayersV2( maskedSymbolLayerIds );
1263 return secondPassJobs;
1268 QList<QPointer<QgsMapLayer> > res = _qgis_listRawToQPointer( engine->
participatingLayers() );
1272 if ( !res.contains( it ) )
1281 for ( LayerRenderJob &job : secondPassJobs )
1283 switch ( job.maskRenderFormat )
1293 for (
const LayerRenderJob::MaskJob &p : std::as_const( job.maskJobs ) )
1295 QPainter *maskPainter = p.layerRenderJob ? p.layerRenderJob->maskPainter.get() : labelJob.maskPainters[p.maskPaintDeviceId].get();
1297 const QSet<QString> layers = job.context()->disabledSymbolLayersV2();
1298 if ( QgsGeometryPaintDevice *geometryDevice =
dynamic_cast<QgsGeometryPaintDevice *
>( maskPainter->device() ) )
1300 QgsGeometry geometry( geometryDevice->geometry().clone() );
1302#if GEOS_VERSION_NUM < GEOS_COMPUTE_VERSION( 3, 10, 0 )
1309 for (
const QString &symbolLayerId : layers )
1311 job.context()->addSymbolLayerClipGeometry( symbolLayerId, geometry );
1316 job.context()->setDisabledSymbolLayersV2( QSet<QString>() );
1327 job.context.setPainter( painter );
1328 job.context.setLabelingEngine( labelingEngine2 );
1329 job.context.setFeedback( mLabelingEngineFeedback );
1330 if ( labelingEngine2 )
1331 job.context.labelingEngine()->prepare( job.context );
1333 QgsRectangle r1 =
mSettings.visibleExtent();
1335 job.context.setExtent( r1 );
1337 job.context.setFeatureFilterProvider( mFeatureFilterProvider );
1338 QgsCoordinateTransform ct;
1340 job.context.setCoordinateTransform( ct );
1351 job.complete =
true;
1353 job.context.setPainter(
nullptr );
1357 if ( canUseLabelCache && (
mCache || !painter ) )
1359 job.img = allocateImage( u
"labels"_s );
1369 for ( LayerRenderJob &job : jobs )
1371 if ( job.destinationImage )
1373 job.context()->setPainter(
nullptr );
1374 job.destinationPainter.reset();
1376 if (
mCache && !job.cached && job.completed && job.layer )
1379 mCache->setCacheImageWithParameters( job.layerId, *job.destinationImage,
mSettings.visibleExtent(),
mSettings.mapToPixel(), QList< QgsMapLayer * >() << job.layer );
1380 mCache->setCacheImageWithParameters( job.layerId + u
"_preview"_s, *job.destinationImage,
mSettings.visibleExtent(),
mSettings.mapToPixel(), QList< QgsMapLayer * >() << job.layer );
1383 job.destinationImage.reset();
1386 if ( job.previewRenderImage )
1388 job.context()->setPreviewRenderPainter(
nullptr );
1389 job.previewRenderPainter.reset();
1390 job.previewRenderImage.reset();
1393 if ( job.elevationMap )
1395 job.context()->setElevationMap(
nullptr );
1396 if (
mCache && !job.cached && job.completed && job.layer )
1398 QgsDebugMsgLevel( u
"caching elevation map for %1"_s.arg( job.layerId ), 2 );
1399 mCache->setCacheImageWithParameters(
1402 mCache->setCacheImageWithParameters(
1407 job.elevationMap.reset();
1412 job.context()->setPainter(
nullptr );
1413 job.destinationPainter.reset();
1414 job.picture.reset(
nullptr );
1419 const QStringList
errors = job.renderer->errors();
1420 for (
const QString &message :
errors )
1421 mErrors.append(
Error( job.renderer->layerId(), message ) );
1423 mRenderedItemResults->appendResults( job.renderer->takeRenderedItemDetails(), *job.context() );
1425 job.context()->setFeedback(
nullptr );
1426 job.renderer.reset();
1432 job.maskPainter.reset(
nullptr );
1433 job.maskPaintDevice.reset(
nullptr );
1441 for ( LayerRenderJob &job : jobs )
1443 if ( job.destinationImage )
1445 job.context()->setPainter(
nullptr );
1446 job.destinationPainter.reset();
1447 job.destinationImage.reset();
1450 if ( job.previewRenderImage )
1452 job.context()->setPreviewRenderPainter(
nullptr );
1453 job.previewRenderPainter.reset();
1454 job.previewRenderImage.reset();
1459 job.context()->setPainter(
nullptr );
1460 job.destinationPainter.reset();
1465 job.context()->setFeedback(
nullptr );
1466 job.renderer.reset();
1480 if (
mCache && !job.cached && !job.context.renderingStopped() )
1490 job.picture.reset(
nullptr );
1491 job.maskPainters.clear();
1492 job.maskPaintDevices.clear();
1496#define DEBUG_RENDERING 0
1502 image.setDotsPerMeterX(
static_cast<int>( settings.
outputDpi() * 39.37 ) );
1503 image.setDotsPerMeterY(
static_cast<int>( settings.
outputDpi() * 39.37 ) );
1507 std::unique_ptr<QgsElevationMap> mainElevationMap;
1508 if ( mapShadingRenderer.
isActive() )
1511 QPainter painter( &image );
1516 for (
const LayerRenderJob &job : jobs )
1518 if ( job.renderAboveLabels )
1525 painter.setCompositionMode( job.blendMode );
1526 painter.setOpacity( job.opacity );
1528 if ( mainElevationMap )
1531 if ( layerElevationMap.
isValid() )
1537 img.save( QString(
"/tmp/final_%1.png" ).arg( i ) );
1541 painter.drawImage( 0, 0, img );
1544 if ( mapShadingRenderer.
isActive() && mainElevationMap )
1552 if ( labelJob.img && labelJob.complete )
1554 painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
1555 painter.setOpacity( 1.0 );
1556 painter.drawImage( 0, 0, *labelJob.img );
1558 else if ( labelJob.picture && labelJob.complete )
1560 painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
1561 painter.setOpacity( 1.0 );
1570 painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
1571 painter.setOpacity( 1.0 );
1572 painter.drawImage( 0, 0, labelCacheImage );
1576 for (
const LayerRenderJob &job : jobs )
1578 if ( !job.renderAboveLabels )
1585 painter.setCompositionMode( job.blendMode );
1586 painter.setOpacity( job.opacity );
1588 painter.drawImage( 0, 0, img );
1593 image.save(
"/tmp/final.png" );
1600 if ( job.imageCanBeComposed() )
1602 if ( job.previewRenderImage && !job.completed )
1603 return *job.previewRenderImage;
1605 Q_ASSERT( job.destinationImage );
1606 return *job.destinationImage;
1621 if ( job.imageCanBeComposed() && job.elevationMap )
1623 return *job.elevationMap;
1630 return QgsElevationMap();
1637 for ( LayerRenderJob &job : secondPassJobs )
1639 if ( job.maskJobs.empty() )
1642 switch ( job.maskRenderFormat )
1647 LayerRenderJob::MaskJob firstJob = *job.maskJobs.begin();
1648 QPaintDevice *firstMaskPaintDevice =
nullptr;
1649 QPainter *firstMaskPainter =
nullptr;
1650 if ( firstJob.layerRenderJob )
1652 firstMaskPaintDevice = firstJob.layerRenderJob->maskPaintDevice.get();
1653 firstMaskPainter = firstJob.layerRenderJob->maskPainter.get();
1657 Q_ASSERT( firstJob.maskPaintDeviceId >= 0 && firstJob.maskPaintDeviceId <
static_cast< int >( labelJob.maskPaintDevices.size() ) );
1658 firstMaskPaintDevice = labelJob.maskPaintDevices[firstJob.maskPaintDeviceId].get();
1659 firstMaskPainter = labelJob.maskPainters[firstJob.maskPaintDeviceId].get();
1662 QImage *firstMaskImage =
dynamic_cast<QImage *
>( firstMaskPaintDevice );
1663 if ( !firstMaskImage )
1665 QgsDebugError( u
"FORMAT MISMATCH -- expected a raster mask format, but mask paint device is not a QImage!!"_s );
1670 for (
size_t i = 1; i < job.maskJobs.size(); ++i )
1672 const LayerRenderJob::MaskJob &nextJob = job.maskJobs[i];
1673 QPaintDevice *nextJobPaintDevice =
nullptr;
1674 if ( nextJob.layerRenderJob )
1676 nextJobPaintDevice = nextJob.layerRenderJob->maskPaintDevice.get();
1680 Q_ASSERT( nextJob.maskPaintDeviceId >= 0 && nextJob.maskPaintDeviceId <
static_cast< int >( labelJob.maskPaintDevices.size() ) );
1681 nextJobPaintDevice = labelJob.maskPaintDevices[nextJob.maskPaintDeviceId].get();
1683 Q_ASSERT( nextJobPaintDevice );
1685 QImage *nextJobImage =
dynamic_cast<QImage *
>( nextJobPaintDevice );
1686 if ( !nextJobImage )
1688 QgsDebugError( u
"FORMAT MISMATCH -- expected a raster mask format, but mask paint device is not a QImage!!"_s );
1692 firstMaskPainter->drawImage( 0, 0, *nextJobImage );
1696 QPainter *painter = job.context()->painter();
1698 painter->setCompositionMode( QPainter::CompositionMode_DestinationIn );
1703 QImage maskBinAlpha = firstMaskImage->createMaskFromColor( 0 );
1704 QVector<QRgb> mswTable;
1705 mswTable.push_back( qRgba( 0, 0, 0, 255 ) );
1706 mswTable.push_back( qRgba( 0, 0, 0, 0 ) );
1707 maskBinAlpha.setColorTable( mswTable );
1708 painter->drawImage( 0, 0, maskBinAlpha );
1712 QPainter tempPainter;
1715 QPainter *painter1 = job.firstPassJob->context()->painter();
1718 tempPainter.begin( job.firstPassJob->destinationImage.get() );
1719 painter1 = &tempPainter;
1723 painter1->setCompositionMode( QPainter::CompositionMode_DestinationOut );
1724 painter1->drawImage( 0, 0, *firstMaskImage );
1727 painter1->setCompositionMode( QPainter::CompositionMode_DestinationOver );
1728 painter1->drawImage( 0, 0, *job.destinationImage );
1735 job.firstPassJob->picture = std::move( job.picture );
1736 job.picture =
nullptr;
1748 QMultiMap<int, QString> elapsed;
1749 for (
const LayerRenderJob &job : jobs )
1750 elapsed.insert( job.renderingTime, job.layerId );
1751 for (
const LayerRenderJob &job : secondPassJobs )
1752 elapsed.insert( job.renderingTime, job.layerId + QString(
" (second pass)" ) );
1754 elapsed.insert( labelJob.renderingTime, tr(
"Labeling" ) );
1756 QList<int> tt( elapsed.uniqueKeys() );
1757 std::sort( tt.begin(), tt.end(), std::greater<int>() );
1758 for (
int t : std::as_const( tt ) )
1760 QgsMessageLog::logMessage( tr(
"%1 ms: %2" ).arg( t ).arg( QStringList( elapsed.values( t ) ).join(
", "_L1 ) ), tr(
"Rendering" ) );
1769 std::unique_ptr< QgsScopedRuntimeProfile > labelingProfile;
1772 labelingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"(labeling)" ), u
"rendering"_s );
1779 painter->setCompositionMode( QPainter::CompositionMode_SourceOver );
1783 if ( labelingEngine2 )
1785 labelingEngine2->
run( renderContext );
1788 QgsDebugMsgLevel( u
"Draw labeling took (seconds): %1"_s.arg( t.elapsed() / 1000. ), 2 );
1793 Q_UNUSED( settings )
1795 drawLabeling( renderContext, labelingEngine2, painter );
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
@ ForceVector
Always force vector-based rendering, even when the result will be visually different to a raster-base...
@ InternalLayerOpacityHandling
The renderer internally handles the raster layer's opacity, so the default layer level opacity handli...
RenderFormat
Rendering formats.
@ Vector
Vector-based rendering.
@ Raster
Raster-based rendering.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
@ AffectsLabeling
The layer rendering will interact with the map labeling.
@ RenderPartialOutputOverPreviousCachedImage
When rendering temporary in-progress preview renders, these preview renders can be drawn over any pre...
@ RenderPartialOutputs
The renderer benefits from rendering temporary in-progress preview renders. These are temporary resul...
@ ApplyClipAfterReprojection
Feature geometry clipping to mapExtent() must be performed after the geometries are transformed using...
@ RecordProfile
Enable run-time profiling while rendering.
@ Linework
Combines all rings into a set of noded lines and then extracts valid polygons from that linework.
@ Structure
Structured method, first makes all rings valid and then merges shells and subtracts holes from shells...
@ Forward
Forward transform (from source to destination).
@ Reverse
Reverse/inverse transform (from destination to source).
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
@ ForceRasterMasks
Force symbol masking to be applied using a raster method. This is considerably faster when compared t...
virtual bool hasNonDefaultCompositionMode() const =0
Returns true the labeling requires a non-default composition mode.
virtual bool requiresAdvancedEffects() const =0
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
virtual bool hasNonDefaultCompositionMode() const =0
Returns true the labeling requires a non-default composition mode.
virtual bool requiresAdvancedEffects() const =0
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
virtual bool hasNonDefaultCompositionMode() const =0
Returns true the labeling requires a non-default composition mode.
virtual bool requiresAdvancedEffects() const =0
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
Stores a digital elevation model in a raster image which may get updated as a part of the map layer r...
bool isValid() const
Returns whether the elevation map is valid.
Qgis::ElevationMapCombineMethod combinedElevationMethod() const
Returns the method used when conbining different elevation sources.
bool isActive() const
Returns whether this shading renderer is active.
void renderShading(const QgsElevationMap &elevation, QImage &image, const QgsRenderContext &context) const
Render shading on image condidering the elevation map elevation and the renderer context context If e...
static std::unique_ptr< QgsExpressionContextScope > layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QgsFeedback subclass for granular reporting of labeling engine progress.
Provides map labeling functionality.
virtual void run(QgsRenderContext &context)=0
Runs the labeling job.
QList< QgsMapLayer * > participatingLayers() const
Returns a list of layers with providers in the engine.
static void warning(const QString &msg)
Goes to qWarning.
virtual bool isVisibleInTemporalRange(const QgsDateTimeRange &range) const
Returns true if the layer should be visible and rendered for the specified time range.
Base class for all map layer types.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
QgsCoordinateReferenceSystem crs
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
double minimumScale() const
Returns the minimum map scale (i.e.
double maximumScale() const
Returns the maximum map scale (i.e.
Responsible for keeping a cache of rendered images resulting from a map rendering job.
bool hasAnyCacheImage(const QString &cacheKey, double minimumScaleThreshold=0, double maximumScaleThreshold=0) const
Returns true if the cache contains an image with the specified cacheKey with any cache's parameters (...
QImage transformedCacheImage(const QString &cacheKey, const QgsMapToPixel &mtp) const
Returns the cached image for the specified cacheKey transformed to the particular extent and scale.
Abstract base class for map rendering implementations.
void logRenderingTime(const std::vector< LayerRenderJob > &jobs, const std::vector< LayerRenderJob > &secondPassJobs, const LabelRenderJob &labelJob)
static void composeSecondPass(std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob)
Compose second pass images into first pass images.
QList< QPointer< QgsMapLayer > > participatingLabelLayers(QgsLabelingEngine *engine)
Returns a list of the layers participating in the map labeling.
static QgsElevationMap layerElevationToBeComposed(const QgsMapSettings &settings, const LayerRenderJob &job, const QgsMapRendererCache *cache)
static QImage composeImage(const QgsMapSettings &settings, const std::vector< LayerRenderJob > &jobs, const LabelRenderJob &labelJob, const QgsMapRendererCache *cache=nullptr)
void cleanupSecondPassJobs(std::vector< LayerRenderJob > &jobs)
void setCache(QgsMapRendererCache *cache)
Assign a cache to be used for reading and storing rendered images of individual layers.
QHash< QgsMapLayer *, int > perLayerRenderingTime() const
Returns the render time (in ms) per layer.
void initSecondPassJobs(std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob) const
Initialize secondPassJobs according to what have been rendered (mask clipping path e....
static QImage layerImageToBeComposed(const QgsMapSettings &settings, const LayerRenderJob &job, const QgsMapRendererCache *cache)
QHash< QString, int > mLayerRenderingTimeHints
Approximate expected layer rendering time per layer, by layer ID.
std::unique_ptr< QgsRenderedItemResults > mRenderedItemResults
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
static Q_DECL_DEPRECATED void drawLabeling(const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter)
static const QString LABEL_PREVIEW_CACHE_ID
QgsMapRendererCache ID string for cached label image during preview compositions only.
QList< QPointer< QgsMapLayer > > mAdditionalLabelLayers
Additional layers participating in labeling problem.
std::vector< LayerRenderJob > prepareJobs(QPainter *painter, QgsLabelingEngine *labelingEngine2, bool deferredPainterSet=false)
Creates a list of layer rendering jobs and prepares them for later render.
void cleanupJobs(std::vector< LayerRenderJob > &jobs)
const QgsMapSettings & mapSettings() const
Returns map settings with which this job was started.
QgsMapRendererCache * mCache
void finished()
emitted when asynchronous rendering is finished (or canceled).
bool labelingHasNonDefaultCompositionModes() const
Returns true if any component of the map labeling requires non-default composition modes.
static const QgsSettingsEntryBool * settingsLogCanvasRefreshEvent
Settings entry log canvas refresh event.
QgsMapRendererJob(const QgsMapSettings &settings)
~QgsMapRendererJob() override
void start()
Start the rendering job and immediately return.
QStringList mLayersRedrawnFromCache
QStringList layersRedrawnFromCache() const
Returns a list of the layer IDs for all layers which were redrawn from cached images.
QList< QgsMapRendererJob::Error > Errors
static const QString LABEL_CACHE_ID
QgsMapRendererCache ID string for cached label image.
static const QString ELEVATION_MAP_CACHE_PREFIX
QgsMapRendererCache prefix string for cached elevation map image.
QHash< QgsWeakMapLayerPointer, int > mPerLayerRenderingTime
Render time (in ms) per layer, by layer ID.
QgsRenderedItemResults * takeRenderedItemResults()
Takes the rendered item results from the map render job and returns them.
QgsLabelingEngineFeedback * labelingEngineFeedback()
Returns the associated labeling engine feedback object.
std::vector< LayerRenderJob > prepareSecondPassJobs(std::vector< LayerRenderJob > &firstPassJobs, LabelRenderJob &labelJob)
Prepares jobs for a second pass, if selective masks exist (from labels or symbol layers).
static const QgsSettingsEntryString * settingsMaskBackend
Settings entry for mask painting backend engine.
LabelRenderJob prepareLabelingJob(QPainter *painter, QgsLabelingEngine *labelingEngine2, bool canUseLabelCache=true)
Prepares a labeling job.
void setLayerRenderingTimeHints(const QHash< QString, int > &hints)
Sets approximate render times (in ms) for map layers.
void cleanupLabelJob(LabelRenderJob &job)
Handles clean up tasks for a label job, including deletion of images and storing cached label results...
QgsLabelSink * labelSink() const
Returns the label sink associated to this rendering job.
bool prepareLabelCache() const
Prepares the cache for storing the result of labeling.
QgsMapRendererQImageJob(const QgsMapSettings &settings)
Contains configuration for rendering maps.
QSize deviceOutputSize() const
Returns the device output size of the map render.
QColor backgroundColor() const
Returns the background color of the map.
const QgsMapToPixel & mapToPixel() const
float devicePixelRatio() const
Returns the device pixel ratio.
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
const QgsElevationShadingRenderer & elevationShadingRenderer() const
Returns the shading renderer used to render shading on the entire map.
QHash< QString, QgsSelectiveMaskingSourceSet > selectiveMaskingSourceSets() const
Returns a hash of all selective masking source sets defined for the map.
double outputDpi() const
Returns the DPI (dots per inch) used for conversion between real world units (e.g.
bool testFlag(Qgis::MapSettingsFlag flag) const
Check whether a particular flag is enabled.
const QgsAbstractMeshLayerLabeling * labeling() const
Access to const labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
static void drawPicture(QPainter *painter, const QPointF &point, const QPicture &picture)
Draws a picture onto a painter, correctly applying workarounds to avoid issues with incorrect scaling...
static bool staticWillUseLayer(const QgsMapLayer *layer)
Called to find out whether a specified layer is used for labeling.
QString toString(int precision=-1) const
Returns a string representation of the point (x, y) with a preset precision.
const QgsAbstractRasterLayerLabeling * labeling() const
Access to const labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
virtual Qgis::RasterRendererFlags flags() const
Returns flags which dictate renderer behavior.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be rounded to the spec...
void setXMinimum(double x)
Set the minimum x value.
void setXMaximum(double x)
Set the maximum x value.
void grow(double delta)
Grows the rectangle in place by the specified amount.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
Contains information about the context of a rendering operation.
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
Stores collated details of rendered items during a map rendering operation.
A boolean settings entry.
static QgsSettingsTreeNode * sTreeMap
static QgsMaskedLayers collectObjectsMaskedBySymbolLayersFromLayer(const QgsVectorLayer *layer, const QHash< QString, QgsSelectiveMaskingSourceSet > &selectiveMaskingSourceSets, const QVector< QgsVectorLayer * > &allRenderedVectorLayers)
Returns all objects that will be masked by the symbol layers for a given vector layer.
static QHash< QString, QgsMaskedLayers > collectObjectsMaskedByLabelsFromLayer(const QgsVectorLayer *layer, const QHash< QString, QgsSelectiveMaskingSourceSet > &selectiveMaskingSourceSets, const QVector< QgsVectorLayer * > &allRenderedVectorLayers)
Returns all objects that will be masked by the labels for a given vector layer.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
bool isEditable() const final
Returns true if the provider is in editing mode.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QHash< QString, QgsMaskedLayer > QgsMaskedLayers
masked layers where key is the layer id of the layer that WILL be masked