48 , mFields( layer->fields() )
80 QString markerTypeString = settings.
value( QStringLiteral(
"qgis/digitizing/marker_style" ),
"Cross" ).toString();
81 if ( markerTypeString == QLatin1String(
"Cross" ) )
85 else if ( markerTypeString == QLatin1String(
"SemiTransparentCircle" ) )
113 mAttrNames.unite( handler->usedAttributes( layer, context ) );
140 mErrors.append( QObject::tr(
"No renderer for drawing." ) );
155 mInterruptionChecker = qgis::make_unique< QgsVectorLayerRendererInterruptionChecker >( context );
156 bool usingEffect =
false;
188 if ( featureFilterProvider )
192 if ( !rendererFilter.isEmpty() && rendererFilter != QLatin1String(
"TRUE" ) )
201 bool validTransform =
true;
219 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ), 4 );
221 if ( !sourceRect.
isEmpty() && sourceRect.
isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
225 QgsPointXY minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
226 QgsPointXY maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
228 double sourceHypothenuse = std::sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
229 double targetHypothenuse = std::sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
231 QgsDebugMsgLevel( QStringLiteral(
"Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ), 4 );
232 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ), 4 );
235 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
241 validTransform =
false;
245 if ( validTransform )
280 drawRendererLevels( fit );
286 mErrors.append( QStringLiteral(
"Data source invalid" ) );
312 QgsDebugMsg( QStringLiteral(
"Drawing of vector layer %1 canceled." ).arg(
layerId() ) );
341 if ( !symbols.isEmpty() )
343 symbol = symbols.at( 0 );
361 QgsDebugMsg( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
362 .arg( fet.
id() ).arg( cse.
what() ) );
368 stopRenderer(
nullptr );
373 QHash< QgsSymbol *, QList<QgsFeature> > features;
386 std::unique_ptr< QgsExpressionContextScopePopper > scopePopper = qgis::make_unique< QgsExpressionContextScopePopper >( context.
expressionContext(), symbolScope );
394 qDebug(
"rendering stop!" );
395 stopRenderer( selRenderer );
399 if ( !fet.hasGeometry() )
409 if ( !features.contains( sym ) )
411 features.insert( sym, QList<QgsFeature>() );
413 features[sym].append( fet );
420 std::unique_ptr< QgsSymbol > symbol;
426 if ( !symbols.isEmpty() )
428 symbol.reset( symbols.at( 0 )->clone() );
445 if ( features.empty() )
448 stopRenderer( selRenderer );
455 for (
int i = 0; i < symbols.count(); i++ )
461 if ( level < 0 || level >= 1000 )
464 while ( level >= levels.count() )
466 levels[level].append( item );
471 for (
int l = 0; l < levels.count(); l++ )
474 for (
int i = 0; i < level.count(); i++ )
477 if ( !features.contains( item.
symbol() ) )
479 QgsDebugMsg( QStringLiteral(
"level item's symbol not found!" ) );
482 int layer = item.
layer();
483 QList<QgsFeature> &lst = features[item.
symbol()];
484 QList<QgsFeature>::iterator fit;
485 for ( fit = lst.begin(); fit != lst.end(); ++fit )
489 stopRenderer( selRenderer );
506 QgsDebugMsg( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
507 .arg( fet.id() ).arg( cse.
what() ) );
513 stopRenderer( selRenderer );
531 void QgsVectorLayerRenderer::prepareLabeling(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
552 #if 0 // TODO: limit of labels, font not found 559 .setFilterRect( mContext.extent() )
560 .setNoAttributes() );
564 int nFeatsToLabel = 0;
573 if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
575 emit labelingFontNotFound(
this, palyr.mTextFontFamily );
576 mLabelFontNotFoundNotified =
true;
581 void QgsVectorLayerRenderer::prepareDiagrams(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
606 : mContext( context )
607 , mTimer(
new QTimer(
this ) )
609 connect( mTimer, &QTimer::timeout,
this, [ = ]
611 if ( mContext.renderingStopped() )
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
Wrapper for iterator of features from vector data provider or vector layer.
void setThreshold(float threshold)
Sets the simplification threshold in pixels. Represents the maximum distance in pixels between two co...
A rectangle specified with double values.
QgsVectorLayer * mLayer
The rendered layer.
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
Abstract base class for all rendered symbols.
virtual bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
This class is a composition of two QSettings instances:
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsFeatureIds mSelectedFeatureIds
The geometries can be simplified using the current map2pixel context state.
A class to represent a 2D point.
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) override
Gets an iterator for features matching the specified request.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
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...
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
QPainter::CompositionMode mFeatureBlendMode
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
A geometry is the spatial representation of a feature.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
~QgsVectorLayerRenderer() override
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QgsVectorSimplifyMethod mSimplifyMethod
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
All simplification hints can be applied ( Geometry + AA-disabling )
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
QList< QgsSymbolLevel > QgsSymbolLevelOrder
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Perform transforms between map coordinates and device coordinates.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Returns a list of attributes required by this renderer.
QgsWkbTypes::GeometryType mGeometryType
Simplify using the map2pixel data to optimize the rendering of geometries.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
int renderingPass() const
Specifies the rendering pass in which this symbol layer should be rendered.
No simplification can be applied.
QgsVectorLayerRendererInterruptionChecker(const QgsRenderContext &context)
Constructor.
QList< QgsSymbol * > QgsSymbolList
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
QgsFeatureRenderer * mRenderer
#define QgsDebugMsgLevel(str, level)
bool isEmpty() const
Returns true if the rectangle is empty.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
QgsVectorLayerLabelProvider * mLabelProvider
used with new labeling engine (QgsLabelingEngine): provider for labels.
bool mVertexMarkerOnlyForSelection
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
std::unique_ptr< QgsVectorLayerRendererInterruptionChecker > mInterruptionChecker
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
An interface for classes which provider custom handlers for features rendered as part of a map render...
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped...
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsVectorLayerFeatureSource * mSource
QColor selectionColor() const
Returns the color to use when rendering selected features.
float threshold() const
Gets the simplification threshold of the vector layer managed.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Abstract interface for use by classes that filter the features of a layer.
QgsFeatureRenderer * renderer()
Returns renderer.
bool enabled() const
Returns whether the effect is enabled.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
Single scope for storing variables and functions for use within a QgsExpressionContext.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const
Factory for label provider implementation.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) SIP_THROW(QgsCsException)
Render a feature using this renderer in the given context.
int maxNumLabels
The maximum number of labels which should be drawn for this layer.
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
virtual void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest) const =0
Add additional filters to the feature request to further restrict the features returned by the reques...
virtual void registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
The QgsLabelingEngine class provides map labeling functionality.
bool render() override
Do the rendering (based on data stored in the class)
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
bool usingSymbolLevels() const
QPainter * painter()
Returns the destination QPainter for the render operation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
QList< QgsSymbolLevelItem > QgsSymbolLevel
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures...
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
QString layerId() const
Gets access to the ID of the layer rendered by this class.
void setMethodType(MethodType methodType)
Sets the simplification type.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
QSet< QString > mAttrNames
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Base class for utility classes that encapsulate information necessary for rendering of map layers...
bool limitNumLabels
true if the number of labels drawn should be limited.
void setVertexMarkerAppearance(int type, double size)
Sets type and size of editing vertex markers for subsequent rendering.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
QgsWkbTypes::GeometryType type
Custom exception class for Coordinate Reference System related exceptions.
QgsPointXY center() const
Returns the center point of the rectangle.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
bool nextFeature(QgsFeature &f)
QgsVectorLayerDiagramProvider * mDiagramProvider
used with new labeling engine (QgsLabelingEngine): provider for diagrams.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
Represents a vector layer which manages a vector based data sets.
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
QgsSymbol * symbol() const
Returns the symbol which will be rendered for every feature.
virtual bool isValid() const
Will return if this iterator is valid.
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
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.
void setColor(const QColor &color)
Sets the color for the symbol.
virtual QString dump() const
Returns debug information about this renderer.