30 : mSettings( settings )
31 , mLayerFilterExpression( layerFilterExpression )
32 , mOnlyExpressions( false )
41 : mSettings( settings )
42 , mLayerFilterExpression( layerFilterExpression )
43 , mOnlyExpressions( true )
51 tmpImage.setDotsPerMeterX( mSettings.
outputDpi() * 25.4 );
52 tmpImage.setDotsPerMeterY( mSettings.
outputDpi() * 25.4 );
53 QPainter painter( &tmpImage );
64 if ( !mOnlyExpressions )
68 mHitTest[vl] = SymbolSet();
69 mHitTestRuleKey[vl] = SymbolSet();
78 SymbolSet &usedSymbols = mHitTest[vl];
79 SymbolSet &usedSymbolsRuleKey = mHitTestRuleKey[vl];
80 runHitTestLayer( vl, usedSymbols, usedSymbolsRuleKey, context );
88 if ( !symbol || !layer || !mHitTest.contains( layer ) )
96 if ( !layer || !mHitTestRuleKey.contains( layer ) )
99 return mHitTestRuleKey.value( layer ).contains( ruleKey );
108 std::unique_ptr< QgsFeatureRenderer > r( vl->
renderer()->
clone() );
110 r->startRender( context, vl->
fields() );
113 if ( !mOnlyExpressions && !mPolygon.
isNull() )
124 std::unique_ptr< QgsGeometryEngine > polygonEngine;
125 if ( !mOnlyExpressions )
136 polygonEngine->prepareGeometry();
141 SymbolSet lUsedSymbols;
142 SymbolSet lUsedSymbolsRuleKey;
143 bool allExpressionFalse =
false;
144 bool hasExpression = mLayerFilterExpression.contains( vl->
id() );
145 std::unique_ptr<QgsExpression> expr;
169 allExpressionFalse =
false;
174 Q_FOREACH (
const QString &legendKey, r->legendKeysForFeature( f, context ) )
176 lUsedSymbolsRuleKey.insert( legendKey );
179 if ( moreSymbolsPerFeature )
181 Q_FOREACH (
QgsSymbol *s, r->originalSymbolsForFeature( f, context ) )
189 QgsSymbol *s = r->originalSymbolForFeature( f, context );
196 if ( !allExpressionFalse )
199 usedSymbols = lUsedSymbols;
200 usedSymbolsRuleKey = lUsedSymbolsRuleKey;
Class for parsing and evaluation of expressions (formerly called "search strings").
bool symbolVisible(QgsSymbol *symbol, QgsVectorLayer *layer) const
Tests whether a symbol is visible for a specified layer.
Wrapper for iterator of features from vector data provider or vector layer.
May use more than one symbol to render a feature: symbolsForFeature() will return them...
Base class for all map layer types.
double scale() const
Returns the calculated map scale.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
Abstract base class for all rendered symbols.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
Use exact geometry intersection (slower) instead of bounding boxes.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
Restore overridden layer style on destruction.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
bool legendKeyVisible(const QString &ruleKey, QgsVectorLayer *layer) const
Tests whether a given legend key is visible for a specified layer.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
QMap< QString, QString > layerStyleOverrides() const
Gets map of map layer style overrides (key: layer ID, value: style name) where a different style shou...
A geometry is the spatial representation of a feature.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
The QgsMapSettings class contains configuration for rendering of the map.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
QgsMapHitTest(const QgsMapSettings &settings, const QgsGeometry &polygon=QgsGeometry(), const QgsMapHitTest::LayerFilterExpression &layerFilterExpression=QgsMapHitTest::LayerFilterExpression())
QSize outputSize() const
Returns the size of the resulting map image.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QgsFeatureRenderer * renderer()
Returns renderer.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
QgsExpressionContext & expressionContext()
Gets the expression context.
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol.
void run()
Runs the map hit test.
Contains information about the context of a rendering operation.
QMap< QString, QString > LayerFilterExpression
Maps an expression string to a layer id.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
bool nextFeature(QgsFeature &f)
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
void setOverrideStyle(const QString &style)
Temporarily apply a different style to the layer.
Represents a vector layer which manages a vector based data sets.
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QgsCoordinateReferenceSystem crs
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.