48 , mFields( layer->fields() )
68 QString markerTypeString = settings.
value( QStringLiteral(
"qgis/digitizing/marker_style" ),
"Cross" ).toString();
69 if ( markerTypeString == QLatin1String(
"Cross" ) )
73 else if ( markerTypeString == QLatin1String(
"SemiTransparentCircle" ) )
122 mErrors.append( QObject::tr(
"No renderer for drawing." ) );
126 bool usingEffect =
false;
158 if ( featureFilterProvider )
162 if ( !rendererFilter.isEmpty() && rendererFilter != QLatin1String(
"TRUE" ) )
171 bool validTransform =
true;
189 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ), 4 );
191 if ( !sourceRect.
isEmpty() && sourceRect.
isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
195 QgsPointXY minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
196 QgsPointXY maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
198 double sourceHypothenuse = std::sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
199 double targetHypothenuse = std::sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
201 QgsDebugMsgLevel( QStringLiteral(
"Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ), 4 );
202 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ), 4 );
205 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
211 validTransform =
false;
215 if ( validTransform )
250 drawRendererLevels( fit );
275 QgsDebugMsg( QStringLiteral(
"Drawing of vector layer %1 canceled." ).arg(
layerId() ) );
304 if ( !symbols.isEmpty() )
323 QgsDebugMsg( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
324 .arg( fet.
id() ).arg( cse.
what() ) );
330 stopRenderer(
nullptr );
335 QHash< QgsSymbol *, QList<QgsFeature> > features;
355 qDebug(
"rendering stop!" );
356 stopRenderer( selRenderer );
371 if ( !features.contains( sym ) )
373 features.insert( sym, QList<QgsFeature>() );
375 features[sym].append( fet );
388 if ( !symbols.isEmpty() )
406 if ( features.empty() )
409 stopRenderer( selRenderer );
416 for (
int i = 0; i < symbols.count(); i++ )
422 if ( level < 0 || level >= 1000 )
425 while ( level >= levels.count() )
427 levels[level].append( item );
432 for (
int l = 0; l < levels.count(); l++ )
435 for (
int i = 0; i < level.count(); i++ )
438 if ( !features.contains( item.
symbol() ) )
440 QgsDebugMsg( QStringLiteral(
"level item's symbol not found!" ) );
443 int layer = item.
layer();
444 QList<QgsFeature> &lst = features[item.
symbol()];
445 QList<QgsFeature>::iterator fit;
446 for ( fit = lst.begin(); fit != lst.end(); ++fit )
450 stopRenderer( selRenderer );
467 QgsDebugMsg( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
468 .arg( fet.
id() ).arg( cse.
what() ) );
474 stopRenderer( selRenderer );
491 void QgsVectorLayerRenderer::prepareLabeling(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
510 #if 0 // TODO: limit of labels, font not found 518 .setNoAttributes() );
522 int nFeatsToLabel = 0;
531 if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
533 emit labelingFontNotFound(
this, palyr.mTextFontFamily );
534 mLabelFontNotFoundNotified =
true;
539 void QgsVectorLayerRenderer::prepareDiagrams(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
564 , mTimer(
new QTimer(
this ) )
566 connect( mTimer, &QTimer::timeout,
this, [ = ]
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.
QgsSymbol * symbol() const
Returns the symbol which will be rendered for every feature.
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.
bool isEmpty() const
Returns true if the rectangle is empty.
float threshold() const
Gets the simplification threshold of the vector layer managed.
QgsVectorLayer * mLayer
The rendered layer.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
Abstract base class for all rendered symbols.
Interruption checker used by QgsVectorLayerRenderer::render()
This class is a composition of two QSettings instances:
QColor selectionColor() const
Returns the color to use when rendering selected features.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsFeatureIds mSelectedFeatureIds
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
The geometries can be simplified using the current map2pixel context state.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
A class to represent a 2D point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const
Factory for label provider implementation.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) override
Gets an iterator for features matching the specified request.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
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.
bool usingSymbolLevels() const
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...
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
bool enabled() const
Returns whether the effect is enabled.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QPainter::CompositionMode mFeatureBlendMode
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
A geometry is the spatial representation of a feature.
QgsRenderContext & mContext
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
~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 null)
QgsVectorSimplifyMethod mSimplifyMethod
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
QList< QgsSymbolLevel > QgsSymbolLevelOrder
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
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.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
No simplification can be applied.
QgsVectorLayerRendererInterruptionChecker(const QgsRenderContext &context)
Constructor.
QList< QgsSymbol * > QgsSymbolList
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
QgsFeatureRenderer * mRenderer
double xMaximum() const
Returns the x maximum value (right side of rectangle).
#define QgsDebugMsgLevel(str, level)
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
bool renderingStopped() const
Returns TRUE if the rendering operation has been stopped and any ongoing rendering should be canceled...
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.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
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...
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...
QgsPointXY center() const
Returns the center point of the rectangle.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsVectorLayerFeatureSource * mSource
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
double mapUnitsPerPixel() const
Returns current map units per pixel.
int renderingPass() const
Abstract interface for use by classes that filter the features of a layer.
QgsFeatureRenderer * renderer()
Returns renderer.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
Single scope for storing variables and functions for use within a QgsExpressionContext.
QgsSymbolLayer * symbolLayer(int layer)
Returns a specific symbol layer contained in the symbol.
bool drawEditingInformation() const
Returns TRUE if edit markers should be drawn during the render operation.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
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...
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
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.
QPainter * painter()
Returns the destination QPainter for the render operation.
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...
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
virtual QString dump() const
Returns debug information about this renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
void setMethodType(MethodType methodType)
Sets the simplification type.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
QSet< QString > mAttrNames
bool hasGeometry() const
Returns true if the feature has an associated geometry.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
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.
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
Custom exception class for Coordinate Reference System related exceptions.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
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)
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
QgsVectorLayerDiagramProvider * mDiagramProvider
used with new labeling engine (QgsLabelingEngine): provider for diagrams.
Represents a vector layer which manages a vector based data sets.
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
bool isGeographic() const
Returns whether the CRS is a geographic CRS (using lat/lon coordinates)
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
double xMinimum() const
Returns the x minimum value (left side of rectangle).
QString layerId() const
Gets access to the ID of the layer rendered by this class.
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.
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.