55 , mLayerName( layer->name() )
56 , mFields( layer->fields() )
58 , mNoSetLayerExpressionContext( layer->customProperty( QStringLiteral(
"_noset_layer_expression_context" ) ).toBool() )
59 , mEnableProfile( context.
flags() &
Qgis::RenderContextFlag::RecordProfile )
63 std::unique_ptr< QgsFeatureRenderer > mainRenderer( layer->
renderer() ? layer->
renderer()->
clone() :
nullptr );
74 const QColor layerSelectionColor = selectionProperties->
selectionColor();
75 if ( layerSelectionColor.isValid() )
82 if (
QgsSymbol *selectionSymbol = qobject_cast< QgsVectorLayerSelectionProperties * >( layer->
selectionProperties() )->selectionSymbol() )
83 mSelectionSymbol.reset( selectionSymbol->clone() );
94 return g1->level() < g2->level();
97 bool insertedMainRenderer =
false;
98 double prevLevel = std::numeric_limits< double >::lowest();
100 mRenderer = mainRenderer.get();
103 if ( generator->level() >= 0 && prevLevel < 0 && !insertedMainRenderer )
106 mRenderers.emplace_back( std::move( mainRenderer ) );
107 insertedMainRenderer =
true;
109 mRenderers.emplace_back( generator->createRenderer() );
110 prevLevel = generator->level();
116 mRenderers.emplace_back( std::move( mainRenderer ) );
121 mDrawVertexMarkers =
nullptr != layer->
editBuffer();
131 mTemporalFilter = qobject_cast< const QgsVectorLayerTemporalProperties * >( layer->
temporalProperties() )->createFilterString( temporalContext, context.
temporalRange() );
132 QgsDebugMsgLevel(
"Rendering with Temporal Filter: " + mTemporalFilter, 2 );
152 if ( markerTypeString == QLatin1String(
"Cross" ) )
156 else if ( markerTypeString == QLatin1String(
"SemiTransparentCircle" ) )
170 if ( mDrawVertexMarkers )
173 mRenderer->setVertexMarkerAppearance( mVertexMarkerStyle, mVertexMarkerSize );
176 for (
const std::unique_ptr< QgsFeatureRenderer > &renderer : mRenderers )
178 mAttrNames.unite( renderer->usedAttributes( context ) );
184 mAttrNames.unite( handler->usedAttributes( layer, context ) );
188 prepareLabeling( layer, mAttrNames );
189 prepareDiagrams( layer, mAttrNames );
193 if ( std::any_of( mRenderers.begin(), mRenderers.end(), [](
const auto & renderer ) { return renderer->forceRasterRender(); } ) )
196 mForceRasterRender =
true;
200 if ( allowFlattening &&
201 ( ( layer->
blendMode() != QPainter::CompositionMode_SourceOver )
206 mForceRasterRender =
true;
210 mPreparationTime = timer.elapsed();
217 mRenderTimeHint = time;
222 return mFeedback.get();
227 return mForceRasterRender;
248 if ( mRenderers.empty() )
251 mErrors.append( QObject::tr(
"No renderer for drawing." ) );
255 std::unique_ptr< QgsScopedRuntimeProfile > profile;
256 if ( mEnableProfile )
258 profile = std::make_unique< QgsScopedRuntimeProfile >( mLayerName, QStringLiteral(
"rendering" ),
layerId() );
259 if ( mPreparationTime > 0 )
267 mBlockRenderUpdates =
true;
268 mElapsedTimer.start();
272 int rendererIndex = 0;
273 for (
const std::unique_ptr< QgsFeatureRenderer > &renderer : mRenderers )
275 if ( mFeedback->isCanceled() || !res )
279 res = renderInternal( renderer.get(), rendererIndex++ ) && res;
286bool QgsVectorLayerRenderer::renderInternal(
QgsFeatureRenderer *renderer,
int rendererIndex )
288 const bool isMainRenderer = renderer == mRenderer;
293 if ( renderer->
type() == QLatin1String(
"nullSymbol" ) )
297 if ( !isMainRenderer ||
298 ( !mDrawVertexMarkers && !mLabelProvider && !mDiagramProvider && mSelectedFeatureIds.isEmpty() ) )
302 std::unique_ptr< QgsScopedRuntimeProfile > preparingProfile;
303 if ( mEnableProfile )
306 if ( mRenderers.size() > 1 )
307 title = QObject::tr(
"Preparing render %1" ).arg( rendererIndex + 1 );
309 title = QObject::tr(
"Preparing render" );
310 preparingProfile = std::make_unique< QgsScopedRuntimeProfile >( title, QStringLiteral(
"rendering" ) );
313 QgsScopedQPainterState painterState( context.
painter() );
315 bool usingEffect =
false;
324 && mFeatureBlendMode != QPainter::CompositionMode_SourceOver )
328 context.
painter()->setCompositionMode( mFeatureBlendMode );
340 QString rendererFilter = renderer->
filter( mFields );
342 QgsRectangle requestExtent = context.
extent();
343 if ( !mClippingRegions.empty() )
346 requestExtent = requestExtent.
intersect( mClipFilterGeom.boundingBox() );
350 bool needsPainterClipPath =
false;
352 if ( needsPainterClipPath )
353 context.
painter()->setClipPath( path, Qt::IntersectClip );
357 if ( mDiagramProvider )
358 mDiagramProvider->setClipFeatureGeometry( mLabelClipFeatureGeom );
363 QgsFeatureRequest featureRequest = QgsFeatureRequest()
364 .setFilterRect( requestExtent )
365 .setSubsetOfAttributes( mAttrNames, mFields )
373 if ( featureFilterProvider )
386 if ( !rendererFilter.isEmpty() && rendererFilter != QLatin1String(
"TRUE" ) )
390 if ( !mTemporalFilter.isEmpty() )
401 if ( mSimplifyGeometry )
403 double map2pixelTol = mSimplifyMethod.threshold();
404 bool validTransform =
true;
406 const QgsMapToPixel &mtp = context.
mapToPixel();
415 QgsCoordinateTransform toleranceTransform = ct;
419 QgsRectangle sourceRect = QgsRectangle( center.
x(), center.
y(), center.
x() + rectSize, center.
y() + rectSize );
421 QgsRectangle targetRect = toleranceTransform.
transform( sourceRect );
433 double sourceHypothenuse = std::sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
434 double targetHypothenuse = std::sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
436 QgsDebugMsgLevel( QStringLiteral(
"Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ), 4 );
437 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ), 4 );
440 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
443 catch ( QgsCsException &cse )
446 validTransform =
false;
450 if ( validTransform )
452 QgsSimplifyMethod simplifyMethod;
455 simplifyMethod.
setThreshold( mSimplifyMethod.threshold() );
459 QgsVectorSimplifyMethod vectorMethod = mSimplifyMethod;
465 QgsVectorSimplifyMethod vectorMethod;
472 QgsVectorSimplifyMethod vectorMethod;
482 std::unique_ptr< QgsScopedRuntimeProfile > preparingFeatureItProfile;
483 if ( mEnableProfile )
485 preparingFeatureItProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Prepare feature iteration" ), QStringLiteral(
"rendering" ) );
488 QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
496 preparingFeatureItProfile.reset();
497 preparingProfile.reset();
499 std::unique_ptr< QgsScopedRuntimeProfile > renderingProfile;
500 if ( mEnableProfile )
502 renderingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Rendering" ), QStringLiteral(
"rendering" ) );
506 drawRendererLevels( renderer, fit );
508 drawRenderer( renderer, fit );
512 mErrors.append( QStringLiteral(
"Data source invalid" ) );
529 quint64 totalLabelTime = 0;
531 const bool isMainRenderer = renderer == mRenderer;
537 std::unique_ptr< QgsGeometryEngine > clipEngine;
538 if ( mApplyClipFilter )
541 clipEngine->prepareGeometry();
544 if ( mSelectionSymbol && isMainRenderer )
545 mSelectionSymbol->startRender( context, mFields );
564 if ( mApplyClipGeometries )
567 if ( ! mNoSetLayerExpressionContext )
570 const bool featureIsSelected = isMainRenderer && context.
showSelection() && mSelectedFeatureIds.contains( fet.
id() );
571 bool drawMarker = isMainRenderer && ( mDrawVertexMarkers && context.
drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || featureIsSelected ) );
574 bool rendered =
false;
577 if ( featureIsSelected && mSelectionSymbol )
581 mSelectionSymbol->renderFeature( fet, context, -1,
false, drawMarker );
586 rendered = renderer->
renderFeature( fet, context, -1, featureIsSelected, drawMarker );
606 if ( isMainRenderer && context.
labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
608 const quint64 startLabelTime = timer.elapsed();
609 QgsGeometry obstacleGeometry;
611 QgsSymbol *symbol =
nullptr;
617 if ( !symbols.isEmpty() )
619 symbol = symbols.at( 0 );
623 if ( mApplyLabelClipGeometries )
626 if ( mLabelProvider )
628 mLabelProvider->registerFeature( fet, context, obstacleGeometry, symbol );
630 if ( mDiagramProvider )
632 mDiagramProvider->registerFeature( fet, context, obstacleGeometry );
635 if ( mApplyLabelClipGeometries )
638 totalLabelTime += ( timer.elapsed() - startLabelTime );
642 catch (
const QgsCsException &cse )
645 QgsDebugError( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
646 .arg( fet.
id() ).arg( cse.
what() ) );
652 std::unique_ptr< QgsScopedRuntimeProfile > cleanupProfile;
653 if ( mEnableProfile )
655 QgsApplication::profiler()->
record( QObject::tr(
"Rendering features" ), ( timer.elapsed() - totalLabelTime ) / 1000.0, QStringLiteral(
"rendering" ) );
656 if ( totalLabelTime > 0 )
660 cleanupProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Finalizing" ), QStringLiteral(
"rendering" ) );
663 if ( mSelectionSymbol && isMainRenderer )
664 mSelectionSymbol->stopRender( context );
666 stopRenderer( renderer,
nullptr );
671 const bool isMainRenderer = renderer == mRenderer;
684 QList<QHash< QgsSymbol *, QList<QgsFeature> >> features;
687 features.push_back( {} );
689 QSet<int> orderByAttributeIdx;
697 QgsSingleSymbolRenderer *selRenderer =
nullptr;
698 if ( !mSelectedFeatureIds.isEmpty() )
707 auto scopePopper = std::make_unique< QgsExpressionContextScopePopper >( context.
expressionContext(), symbolScope );
710 std::unique_ptr< QgsGeometryEngine > clipEngine;
711 if ( mApplyClipFilter )
714 clipEngine->prepareGeometry();
717 if ( mApplyLabelClipGeometries )
720 std::unique_ptr< QgsScopedRuntimeProfile > fetchFeaturesProfile;
721 if ( mEnableProfile )
723 fetchFeaturesProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Fetching features" ), QStringLiteral(
"rendering" ) );
728 quint64 totalLabelTime = 0;
732 QVector<QVariant> prevValues;
737 qDebug(
"rendering stop!" );
738 stopRenderer( renderer, selRenderer );
748 if ( ! mNoSetLayerExpressionContext )
758 QVector<QVariant> currentValues;
759 for (
const int idx : std::as_const( orderByAttributeIdx ) )
761 currentValues.push_back( fet.
attribute( idx ) );
763 if ( prevValues.empty() )
765 prevValues = std::move( currentValues );
767 else if ( currentValues != prevValues )
771 prevValues = std::move( currentValues );
772 features.push_back( {} );
778 QHash<QgsSymbol *, QList<QgsFeature> > &featuresBack = features.back();
779 auto featuresBackIt = featuresBack.find( sym );
780 if ( featuresBackIt == featuresBack.end() )
782 featuresBackIt = featuresBack.insert( sym, QList<QgsFeature>() );
784 featuresBackIt->append( fet );
788 if ( isMainRenderer && context.
labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
790 const quint64 startLabelTime = timer.elapsed();
792 QgsGeometry obstacleGeometry;
794 QgsSymbol *symbol =
nullptr;
800 if ( !symbols.isEmpty() )
802 symbol = symbols.at( 0 );
806 if ( mLabelProvider )
808 mLabelProvider->registerFeature( fet, context, obstacleGeometry, symbol );
810 if ( mDiagramProvider )
812 mDiagramProvider->registerFeature( fet, context, obstacleGeometry );
815 totalLabelTime += ( timer.elapsed() - startLabelTime );
819 fetchFeaturesProfile.reset();
820 if ( mEnableProfile )
822 if ( totalLabelTime > 0 )
828 if ( mApplyLabelClipGeometries )
833 if ( features.back().empty() )
836 stopRenderer( renderer, selRenderer );
841 std::unique_ptr< QgsScopedRuntimeProfile > sortingProfile;
842 if ( mEnableProfile )
844 sortingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Sorting features" ), QStringLiteral(
"rendering" ) );
849 for (
int i = 0; i < symbols.count(); i++ )
851 QgsSymbol *sym = symbols[i];
855 if ( level < 0 || level >= 1000 )
857 QgsSymbolLevelItem item( sym, j );
858 while ( level >= levels.count() )
860 levels[level].append( item );
863 sortingProfile.reset();
865 if ( mApplyClipGeometries )
869 for (
const QHash< QgsSymbol *, QList<QgsFeature> > &featureLists : features )
871 for (
int l = 0; l < levels.count(); l++ )
874 std::unique_ptr< QgsScopedRuntimeProfile > renderingProfile;
875 if ( mEnableProfile )
877 renderingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Rendering symbol level %1" ).arg( l + 1 ), QStringLiteral(
"rendering" ) );
880 for (
int i = 0; i < level.count(); i++ )
882 const QgsSymbolLevelItem &item = level[i];
883 if ( !featureLists.contains( item.
symbol() ) )
885 QgsDebugError( QStringLiteral(
"level item's symbol not found!" ) );
888 const int layer = item.
layer();
889 const QList<QgsFeature> &lst = featureLists[item.
symbol()];
890 for (
const QgsFeature &feature : lst )
894 stopRenderer( renderer, selRenderer );
898 const bool featureIsSelected = isMainRenderer && context.
showSelection() && mSelectedFeatureIds.contains( feature.id() );
899 if ( featureIsSelected && mSelectionSymbol )
903 const bool drawMarker = isMainRenderer && ( mDrawVertexMarkers && context.
drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || featureIsSelected ) );
905 if ( ! mNoSetLayerExpressionContext )
910 renderer->
renderFeature( feature, context, layer, featureIsSelected, drawMarker );
920 catch (
const QgsCsException &cse )
923 QgsDebugError( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
924 .arg( fet.
id() ).arg( cse.
what() ) );
931 if ( mSelectionSymbol && !mSelectedFeatureIds.empty() && isMainRenderer && context.
showSelection() )
933 mSelectionSymbol->startRender( context, mFields );
935 for (
const QHash< QgsSymbol *, QList<QgsFeature> > &featureLists : features )
937 for (
auto it = featureLists.constBegin(); it != featureLists.constEnd(); ++it )
939 const QList<QgsFeature> &lst = it.value();
940 for (
const QgsFeature &feature : lst )
947 const bool featureIsSelected = mSelectedFeatureIds.contains( feature.id() );
948 if ( !featureIsSelected )
954 mSelectionSymbol->renderFeature( feature, context, -1,
false, drawMarker );
959 mSelectionSymbol->stopRender( context );
962 std::unique_ptr< QgsScopedRuntimeProfile > cleanupProfile;
963 if ( mEnableProfile )
965 cleanupProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Finalizing" ), QStringLiteral(
"rendering" ) );
968 stopRenderer( renderer, selRenderer );
982void QgsVectorLayerRenderer::prepareLabeling(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
992 if (
const QgsRuleBasedLabeling *rbl =
dynamic_cast<const QgsRuleBasedLabeling *
>( layer->
labeling() ) )
994 mLabelProvider =
new QgsRuleBasedLabelSinkProvider( *rbl, layer, context.
labelSink() );
999 mLabelProvider =
new QgsLabelSinkProvider( layer, QString(), context.
labelSink(), &settings );
1006 if ( mLabelProvider )
1008 engine2->addProvider( mLabelProvider );
1009 if ( !mLabelProvider->prepare( context, attributeNames ) )
1011 engine2->removeProvider( mLabelProvider );
1012 mLabelProvider =
nullptr;
1019 QgsPalLayerSettings &palyr = mContext.labelingEngine()->layer(
mLayerID );
1022 if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
1024 QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
1025 .setFilterRect( mContext.extent() )
1026 .setNoAttributes() );
1030 int nFeatsToLabel = 0;
1039 if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
1041 emit labelingFontNotFound(
this, palyr.mTextFontFamily );
1042 mLabelFontNotFoundNotified =
true;
1047void QgsVectorLayerRenderer::prepareDiagrams(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
1054 mDiagramProvider =
new QgsVectorLayerDiagramProvider( layer );
1056 engine2->addProvider( mDiagramProvider );
1057 if ( !mDiagramProvider->prepare( context, attributeNames ) )
1059 engine2->removeProvider( mDiagramProvider );
1060 mDiagramProvider =
nullptr;
Provides global constants and enumerations for use throughout the application.
@ ForceVector
Always force vector-based rendering, even when the result will be visually different to a raster-base...
QFlags< MapLayerRendererFlag > MapLayerRendererFlags
Flags which control how map layer renderers behave.
QFlags< VectorRenderingSimplificationFlag > VectorRenderingSimplificationFlags
Simplification flags for vector feature rendering.
@ NoSimplification
No simplification can be applied.
@ FullSimplification
All simplification hints can be applied ( Geometry + AA-disabling ).
@ GeometrySimplification
The geometries can be simplified using the current map2pixel context state.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ EmbeddedSymbols
Retrieve any embedded feature symbology.
@ AffectsLabeling
If present, indicates that the renderer will participate in the map labeling problem.
@ AffectsLabeling
The layer rendering will interact with the map labeling.
@ SkipSymbolRendering
Disable symbol rendering while still drawing labels if enabled.
@ SemiTransparentCircle
Semi-transparent circle marker.
@ CustomColor
Use default symbol with a custom selection color.
@ CustomSymbol
Use a custom symbol.
@ Default
Use default symbol and selection colors.
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const
Factory for label provider implementation.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
Qgis::DistanceUnit mapUnits
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the expression engine to check if expressio...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
virtual Q_DECL_DEPRECATED void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest) const
Add additional filters to the feature request to further restrict the features returned by the reques...
virtual Q_DECL_DEPRECATED bool isFilterThreadSafe() const
Returns true if the filterFeature function is thread safe, which will lead to reliance on layer ID in...
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped.
bool isValid() const
Will return if this iterator is valid.
An interface for objects which generate feature renderers for vector layers.
Abstract base class for all 2D vector feature renderers.
virtual bool canSkipRender()
Returns true if the renderer can be entirely skipped, i.e.
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
virtual QString filter(const QgsFields &fields=QgsFields())
If a renderer does not require all the features this method may be overridden and return an expressio...
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
virtual bool usesEmbeddedSymbols() const
Returns true if the renderer uses embedded symbols for features.
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
double referenceScale() const
Returns the symbology reference scale.
bool usingSymbolLevels() const
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature()).
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
void setVertexMarkerAppearance(Qgis::VertexMarkerType type, double size)
Sets type and size of editing vertex markers for subsequent rendering.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QSet< int > CORE_EXPORT usedAttributeIndices(const QgsFields &fields) const
Returns a set of used, validated attribute indices.
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
Qgis::FeatureRequestFlags flags() const
Returns the flags which affect how features are fetched.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the iterator to check if it should be cance...
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
static QPainterPath calculatePainterClipRegion(const QList< QgsMapClippingRegion > ®ions, const QgsRenderContext &context, Qgis::LayerType layerType, bool &shouldClip)
Returns a QPainterPath representing the intersection of clipping regions from context which should be...
static QList< QgsMapClippingRegion > collectClippingRegionsForLayer(const QgsRenderContext &context, const QgsMapLayer *layer)
Collects the list of map clipping regions from a context which apply to a map layer.
static QgsGeometry calculateLabelIntersectionGeometry(const QList< QgsMapClippingRegion > ®ions, const QgsRenderContext &context, bool &shouldClip)
Returns the geometry representing the intersection of clipping regions from context which should be u...
static QgsGeometry calculateFeatureIntersectionGeometry(const QList< QgsMapClippingRegion > ®ions, const QgsRenderContext &context, bool &shouldClip)
Returns the geometry representing the intersection of clipping regions from context which should be u...
static QgsGeometry calculateFeatureRequestGeometry(const QList< QgsMapClippingRegion > ®ions, const QgsRenderContext &context, bool &shouldFilter)
Returns the geometry representing the intersection of clipping regions from context.
bool mReadyToCompose
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws funct...
static constexpr int MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE
Maximum time (in ms) to allow display of a previously cached preview image while rendering layers,...
QString layerId() const
Gets access to the ID of the layer rendered by this class.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
QgsMapLayerRenderer(const QString &layerID, QgsRenderContext *context=nullptr)
Constructor for QgsMapLayerRenderer, with the associated layerID and render context.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
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())
Adds a message to the log instance (and creates it if necessary).
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
bool enabled() const
Returns whether the effect is enabled.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
Contains information about the context of a rendering operation.
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
QgsVectorSimplifyMethod & vectorSimplifyMethod()
Returns the simplification settings to use when rendering vector layers.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
QgsLabelSink * labelSink() const
Returns the associated label sink, or nullptr if not set.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
void setFeatureClipGeometry(const QgsGeometry &geometry)
Sets a geometry to use to clip features at render time.
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
void setSymbologyReferenceScale(double scale)
Sets the symbology reference scale.
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QColor selectionColor() const
Returns the color to use when rendering selected features.
Qgis::RasterizedRenderingPolicy rasterizedRenderingPolicy() const
Returns the policy controlling when rasterisation of content during renders is permitted.
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr).
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
An interface for classes which provide custom handlers for features rendered as part of a map render ...
void record(const QString &name, double time, const QString &group="startup", const QString &id=QString())
Manually adds a profile event with the given name and total time (in seconds).
Scoped object for setting the current thread name.
static const QgsSettingsEntryDouble * settingsDigitizingMarkerSizeMm
Settings entry digitizing marker size mm.
static const QgsSettingsEntryBool * settingsDigitizingMarkerOnlyForSelected
Settings entry digitizing marker only for selected.
static const QgsSettingsEntryString * settingsDigitizingMarkerStyle
Settings entry digitizing marker style.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
void setThreshold(float threshold)
Sets the simplification threshold in pixels. Represents the maximum distance in pixels between two co...
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider,...
void setMethodType(MethodType methodType)
Sets the simplification type.
@ OptimizeForRendering
Simplify using the map2pixel data to optimize the rendering of geometries.
A feature renderer which renders all features with the same symbol.
QgsSymbol * symbol() const
Returns the symbol which will be rendered for every feature.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
int renderingPass() const
Specifies the rendering pass in which this symbol layer should be rendered.
int layer() const
The layer of this symbol level.
QgsSymbol * symbol() const
The symbol of this symbol level.
Abstract base class for all rendered symbols.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
void setColor(const QColor &color) const
Sets the color for the symbol.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
bool isTemporal() const
Returns true if the object's temporal range is enabled, and the object will be filtered when renderin...
Partial snapshot of vector layer's state (only the members necessary for access to features).
static QgsGeometry getPointObstacleGeometry(QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols)
Returns the geometry for a point feature which should be used as an obstacle for labels.
Qgis::MapLayerRendererFlags flags() const override
Returns flags which control how the map layer rendering behaves.
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
~QgsVectorLayerRenderer() override
void setLayerRenderingTimeHint(int time) override
Sets approximate render time (in ms) for the layer to render.
bool render() override
Do the rendering (based on data stored in the class).
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr).
Implementation of layer selection properties for vector layers.
Qgis::SelectionRenderingMode selectionRenderingMode
Encapsulates the context in which a QgsVectorLayer's temporal capabilities will be applied.
void setLayer(QgsVectorLayer *layer)
Sets the associated layer.
Represents a vector layer which manages a vector based dataset.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, Qgis::VectorRenderingSimplificationFlag simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QList< const QgsFeatureRendererGenerator * > featureRendererGenerators() const
Returns a list of the feature renderer generators owned by the layer.
QgsMapLayerSelectionProperties * selectionProperties() override
Returns the layer's selection properties.
Qgis::VectorRenderingSimplificationFlags simplifyHints() const
Gets the simplification hints of the vector layer managed.
void setSimplifyHints(Qgis::VectorRenderingSimplificationFlags simplifyHints)
Sets the simplification hints of the vector layer managed.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
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)
QList< QgsSymbolLevel > QgsSymbolLevelOrder
QList< QgsSymbolLevelItem > QgsSymbolLevel
QList< QgsSymbol * > QgsSymbolList