49 , mFields( layer->fields() )
69 QString markerTypeString = settings.
value( QStringLiteral(
"qgis/digitizing/marker_style" ),
"Cross" ).toString();
70 if ( markerTypeString == QLatin1String(
"Cross" ) )
74 else if ( markerTypeString == QLatin1String(
"SemiTransparentCircle" ) )
123 mErrors.append( QObject::tr(
"No renderer for drawing." ) );
127 bool usingEffect =
false;
159 if ( featureFilterProvider )
163 if ( !rendererFilter.isEmpty() && rendererFilter != QLatin1String(
"TRUE" ) )
172 bool validTransform =
true;
190 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ), 4 );
192 if ( !sourceRect.
isEmpty() && sourceRect.
isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
196 QgsPointXY minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
197 QgsPointXY maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
199 double sourceHypothenuse = std::sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
200 double targetHypothenuse = std::sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
202 QgsDebugMsgLevel( QStringLiteral(
"Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ), 4 );
203 QgsDebugMsgLevel( QStringLiteral(
"Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ), 4 );
206 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
212 validTransform =
false;
216 if ( validTransform )
251 drawRendererLevels( fit );
257 mErrors.append( QStringLiteral(
"Data source invalid" ) );
281 QgsDebugMsg( QStringLiteral(
"Drawing of vector layer %1 canceled." ).arg(
layerId() ) );
310 if ( !symbols.isEmpty() )
329 QgsDebugMsg( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
330 .arg( fet.
id() ).arg( cse.
what() ) );
336 stopRenderer(
nullptr );
341 QHash< QgsSymbol *, QList<QgsFeature> > features;
361 qDebug(
"rendering stop!" );
362 stopRenderer( selRenderer );
377 if ( !features.contains( sym ) )
379 features.insert( sym, QList<QgsFeature>() );
381 features[sym].append( fet );
394 if ( !symbols.isEmpty() )
412 if ( features.empty() )
415 stopRenderer( selRenderer );
422 for (
int i = 0; i < symbols.count(); i++ )
428 if ( level < 0 || level >= 1000 )
431 while ( level >= levels.count() )
433 levels[level].append( item );
438 for (
int l = 0; l < levels.count(); l++ )
441 for (
int i = 0; i < level.count(); i++ )
444 if ( !features.contains( item.
symbol() ) )
446 QgsDebugMsg( QStringLiteral(
"level item's symbol not found!" ) );
449 int layer = item.
layer();
450 QList<QgsFeature> &lst = features[item.
symbol()];
451 QList<QgsFeature>::iterator fit;
452 for ( fit = lst.begin(); fit != lst.end(); ++fit )
456 stopRenderer( selRenderer );
473 QgsDebugMsg( QStringLiteral(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
474 .arg( fet.
id() ).arg( cse.
what() ) );
480 stopRenderer( selRenderer );
497 void QgsVectorLayerRenderer::prepareLabeling(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
516 #if 0 // TODO: limit of labels, font not found 524 .setNoAttributes() );
528 int nFeatsToLabel = 0;
537 if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
539 emit labelingFontNotFound(
this, palyr.mTextFontFamily );
540 mLabelFontNotFoundNotified =
true;
545 void QgsVectorLayerRenderer::prepareDiagrams(
QgsVectorLayer *layer, QSet<QString> &attributeNames )
570 , mTimer(
new QTimer(
this ) )
572 connect( mTimer, &QTimer::timeout,
this, [ = ]
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.
Abstract base class for all rendered symbols.
Interruption checker used by QgsVectorLayerRenderer::render()
This class is a composition of two QSettings instances:
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
virtual void registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
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.
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
QPainter::CompositionMode mFeatureBlendMode
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
A geometry is the spatial representation of a feature.
QgsRenderContext & mContext
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 null)
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...
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 cancelation 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
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.
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
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.
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...
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
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsVectorLayerFeatureSource * mSource
QColor selectionColor() const
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 a specific symbol layer contained in the symbol.
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.
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())
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
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
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.
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.