QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
31 : mSettings( settings )
32 , mLayerFilterExpression( layerFilterExpression )
33 , mOnlyExpressions( false )
42 : mSettings( settings )
43 , mLayerFilterExpression( layerFilterExpression )
44 , mOnlyExpressions( true )
52 tmpImage.setDotsPerMeterX( mSettings.
outputDpi() * 25.4 );
53 tmpImage.setDotsPerMeterY( mSettings.
outputDpi() * 25.4 );
54 QPainter painter( &tmpImage );
59 const auto constLayers = mSettings.
layers();
66 if ( !mOnlyExpressions )
70 mHitTest[vl] = SymbolSet();
71 mHitTestRuleKey[vl] = SymbolSet();
80 SymbolSet &usedSymbols = mHitTest[vl];
81 SymbolSet &usedSymbolsRuleKey = mHitTestRuleKey[vl];
82 runHitTestLayer( vl, usedSymbols, usedSymbolsRuleKey, context );
90 if ( !symbol || !layer || !mHitTest.contains( layer ) )
98 if ( !layer || !mHitTestRuleKey.contains( layer ) )
101 return mHitTestRuleKey.value( layer ).contains( ruleKey );
110 std::unique_ptr< QgsFeatureRenderer > r( vl->
renderer()->
clone() );
112 r->startRender( context, vl->
fields() );
115 if ( !mOnlyExpressions && !mPolygon.
isNull() )
126 std::unique_ptr< QgsGeometryEngine > polygonEngine;
127 if ( !mOnlyExpressions )
138 polygonEngine->prepareGeometry();
143 SymbolSet lUsedSymbols;
144 SymbolSet lUsedSymbolsRuleKey;
145 bool allExpressionFalse =
false;
146 bool hasExpression = mLayerFilterExpression.contains( vl->
id() );
147 std::unique_ptr<QgsExpression> expr;
171 allExpressionFalse =
false;
176 const auto constLegendKeysForFeature = r->legendKeysForFeature( f, context );
177 for (
const QString &legendKey : constLegendKeysForFeature )
179 lUsedSymbolsRuleKey.insert( legendKey );
182 if ( moreSymbolsPerFeature )
184 const auto constOriginalSymbolsForFeature = r->originalSymbolsForFeature( f, context );
185 for (
QgsSymbol *s : constOriginalSymbolsForFeature )
193 QgsSymbol *s = r->originalSymbolForFeature( f, context );
200 if ( !allExpressionFalse )
203 usedSymbols = lUsedSymbols;
204 usedSymbolsRuleKey = lUsedSymbolsRuleKey;
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
bool symbolVisible(QgsSymbol *symbol, QgsVectorLayer *layer) const
Tests whether a symbol is visible for a specified layer.
QgsCoordinateReferenceSystem crs
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.
QgsExpressionContext & expressionContext()
Gets the expression context.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
QSize outputSize() const
Returns the size of the resulting map image.
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QMap< QString, QString > LayerFilterExpression
Maps an expression string to a layer id.
QMap< QString, QString > layerStyleOverrides() const
Gets map of map layer style overrides (key: layer ID, value: style name) where a different style shou...
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
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.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
void stopRender(QgsRenderContext &context)
Ends the rendering process.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
@ MoreSymbolsPerFeature
May use more than one symbol to render a feature: symbolsForFeature() will return them.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
double scale() const
Returns the calculated map scale.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
void run()
Runs the map hit test.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
bool legendKeyVisible(const QString &ruleKey, QgsVectorLayer *layer) const
Tests whether a given legend key is visible for a specified layer.
bool nextFeature(QgsFeature &f)
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsMapHitTest(const QgsMapSettings &settings, const QgsGeometry &polygon=QgsGeometry(), const QgsMapHitTest::LayerFilterExpression &layerFilterExpression=QgsMapHitTest::LayerFilterExpression())
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
QgsWkbTypes::GeometryType type
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsFeatureRenderer * renderer()
Returns renderer.