47 , mInterruptionChecker( context )
49 , mFields( layer->fields() )
50 , mRendererV2( nullptr )
54 , mLabelProvider( nullptr )
55 , mDiagramProvider( nullptr )
74 QString markerTypeString = settings.
value(
"/qgis/digitizing/marker_style",
"Cross" ).
toString();
75 if ( markerTypeString ==
"Cross" )
79 else if ( markerTypeString ==
"SemiTransparentCircle" )
130 bool usingEffect =
false;
162 if ( featureFilterProvider )
166 if ( !rendererFilter.
isEmpty() && rendererFilter !=
"TRUE" )
175 bool validTransform =
true;
193 QgsDebugMsg(
QString(
"Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
195 if ( !sourceRect.
isEmpty() && sourceRect.
isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
199 QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
200 QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
202 double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
203 double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
209 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
215 validTransform =
false;
219 if ( validTransform )
254 drawRendererV2Levels( fit );
256 drawRendererV2( fit );
356 QgsDebugMsg(
QString(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
357 .arg( fet.
id() ).arg( cse.
what() ) );
363 stopRendererV2(
nullptr );
388 qDebug(
"rendering stop!" );
389 stopRendererV2( selRenderer );
408 features[sym].append( fet );
460 for (
int i = 0; i < symbols.
count(); i++ )
466 if ( level < 0 || level >= 1000 )
469 while ( level >= levels.
count() )
471 levels[level].
append( item );
476 for (
int l = 0; l < levels.
count(); l++ )
479 for (
int i = 0; i < level.
count(); i++ )
487 int layer = item.
layer();
490 for ( fit = lst.
begin(); fit != lst.
end(); ++fit )
494 stopRendererV2( selRenderer );
511 QgsDebugMsg(
QString(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
512 .arg( fet.
id() ).arg( cse.
what() ) );
518 stopRendererV2( selRenderer );
562 #if 0 // TODO: limit of labels, font not found 574 int nFeatsToLabel = 0;
586 mLabelFontNotFoundNotified =
true;
QgsVectorLayerRendererInterruptionChecker mInterruptionChecker
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.
QgsPoint center() const
Center point of the rectangle.
iterator insert(const Key &key, const T &value)
QgsVectorLayer * mLayer
The rendered layer.
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)=0
called when starting rendering of a layer
void setCompositionMode(CompositionMode mode)
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
virtual void stopRender(QgsRenderContext &context) override
Needs to be called when a render cycle has finished to clean up.
QgsSymbolV2 * symbol() const
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.
virtual Q_DECL_DEPRECATED QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
virtual int prepareDiagramLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)
adds a diagram layer to the labeling engine
const T & at(int i) const
void setGeometryCachePointer(QgsGeometryCache *cache)
where to save the cached geometries
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
bool renderingStopped() const
QPainter::CompositionMode mFeatureBlendMode
The QgsLabelingEngineV2 class provides map labeling functionality.
static QgsGeometry * getPointObstacleGeometry(QgsFeature &fet, QgsRenderContext &context, const QgsSymbolV2List &symbols)
Returns the geometry for a point feature which should be used as an obstacle for labels.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
QgsRenderContext & mContext
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
bool mustStop() const override
return true if the iterator must stop as soon as possible
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
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...
void setCachedGeometriesRect(const QgsRectangle &extent)
QgsVectorSimplifyMethod mSimplifyMethod
void setSimplifyHints(const SimplifyHints &simplifyHints)
Sets the simplification hints of the vector layer managed.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
QString tr(const char *sourceText, const char *disambiguation, int n)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
bool mLabeling
used with old labeling engine (QgsPalLabeling): whether labeling is enabled
virtual void registerFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context)=0
called for every feature
double y() const
Get the y value of the point.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
int renderingPass() const
Perform transforms between map coordinates and device coordinates.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
void setColor(const QColor &color)
Simplify using the map2pixel data to optimize the rendering of geometries.
virtual QgsFeatureRendererV2 * clone() const =0
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
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.
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
virtual QString dump() const
for debugging
int toInt(bool *ok) const
bool isEmpty() const
test if rectangle is empty.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units.
const QgsRectangle & extent() const
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
QgsVectorLayerLabelProvider * mLabelProvider
used with new labeling engine (QgsLabelingEngineV2): provider for labels.
bool mVertexMarkerOnlyForSelection
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
QgsLabelingEngineInterface * labelingEngine() const
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::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
const QgsCoordinateTransform * coordinateTransform() const
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
QList< int > QgsAttributeList
float threshold() const
Gets the simplification threshold of the vector layer managed.
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
QgsFeatureRendererV2 * mRendererV2
Abstract interface for use by classes that filter the features of a layer.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
bool enabled() const
Returns whether the effect is enabled.
bool usingSymbolLevels() const
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
Single scope for storing variables and functions for use within a QgsExpressionContext.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
double mapUnitsPerPixel() const
Return current map units per pixel.
A class to represent a point.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures...
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
QgsFeatureId id() const
Get the feature ID for this feature.
const QgsFeatureFilterProvider * featureFilterProvider() const
Get the filter feature provider used for additional filtering of rendered features.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
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...
double yMinimum() const
Get 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
Get the x maximum value (right side of rectangle)
bool contains(const T &value) const
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsLabelingEngineV2 * labelingEngineV2() const
Get access to new labeling engine (may be nullptr)
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.
virtual bool render() override
Do the rendering (based on data stored in the class)
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context)
called for every diagram feature
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
QVariant value(const QString &key, const QVariant &defaultValue) const
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
const QgsMapToPixel & mapToPixel() const
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request) override
Get an iterator for features matching the specified request.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
QGis::GeometryType mGeometryType
QString layerID() const
Get access to the ID of the layer rendered by this class.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
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.
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
void cacheGeometry(QgsFeatureId fid, const QgsGeometry &geom)
store a geometry in the cache
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
double xMinimum() const
Get the x minimum value (left side of rectangle)
Base class for utility classes that encapsulate information necessary for rendering of map layers...
double yMaximum() const
Get the y maximum value (top side of rectangle)
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
bool contains(const Key &key) const
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
Custom exception class for Coordinate Reference System related exceptions.
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
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.
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
QgsVectorLayerDiagramProvider * mDiagramProvider
used with new labeling engine (QgsLabelingEngineV2): provider for diagrams.
Represents a vector layer which manages a vector based data sets.
QgsGeometryCache * mCache
virtual void startRender(QgsRenderContext &context, const QgsFields &fields) override
Needs to be called when a new render cycle is started.
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbolV2 *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbolV2 to an expression context.
bool mDiagrams
used with new labeling engine (QgsPalLabeling): whether diagrams are enabled
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const =0
Factory for label provider implementation.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
double x() const
Get the x value of the point.
void setInterruptionChecker(QgsInterruptionChecker *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped...
~QgsVectorLayerRenderer()
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
bool geographicFlag() const
Returns whether the CRS is a geographic CRS.