30 mFeatures.resize( fids.size() );
42 if ( !
rubberBand || !mLayer || !mLayer->labelsEnabled() || !mLayer->labeling() || mFeatures.empty() )
94 QSet<QString> attributeNames;
95 if ( !provider->prepare( context, attributeNames ) )
103 for (
const QgsFeature &feature : std::as_const( mFeatures ) )
105 if ( index >= previewGeomParts.size() )
111 tempFeature.
setGeometry( previewGeomParts.at( index ) );
115 provider->registerFeature( tempFeature, context );
123 engine.
run( context );
127 mBoundingRect = QRectF();
128 const QList<QgsLabelPosition> labelPosList = results->allLabels();
134 for (
int i = 0; i < 4; ++i )
138 const QPointF localPt = canvasPt - itemPos;
139 if ( mBoundingRect.isEmpty() )
140 mBoundingRect = QRectF( localPt, QSizeF( 1, 1 ) );
142 mBoundingRect = mBoundingRect.united( QRectF( localPt, QSizeF( 1, 1 ) ) );
152 return mBoundingRect;
@ DisableSearchTree
Disable the creation of the label search tree.
@ IgnoreObstacles
Disable obstacle handling.
@ SingleCandidateOnly
Generate only the single least-cost candidate for each feature. Useful for fast labeling,...
@ IgnoreOverlaps
Disable overlap detection and search solver, immediately returning lowest cost candidate per feature.
@ UsePartialCandidates
Whether to use also label candidates that are partially outside of the map view.
@ RecordProfile
Enable run-time profiling while rendering.
@ Reverse
Reverse/inverse transform (from destination to source).
@ RecordProfile
Enable run-time profiling while rendering.
Default QgsLabelingEngine implementation, which completes the whole labeling operation (including lab...
void run(QgsRenderContext &context) override
Runs the labeling job.
RAII class to pop scope from an expression context on destruction.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Abstract base class for all 2D vector feature renderers.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Represents the calculated placement of a map label.
Stores global configuration for labeling engine.
void setFlag(Qgis::LabelingFlag f, bool enabled=true)
Sets whether a particual flag is enabled.
QString addProvider(QgsAbstractLabelProvider *provider)
Adds a provider of label features.
QgsLabelingResults * results() const
For internal use by the providers.
Stores computed placement from labeling engine.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Contains configuration for rendering maps.
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns the global configuration of the labeling engine.
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets the global configuration of the labeling engine.
void setFlag(Qgis::MapSettingsFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected).
Perform transforms between map coordinates and device coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
Contains settings for how a map layer will be labeled.
QPointF toQPointF() const
Converts a point to a QPointF.
Contains information about the context of a rendering operation.
double symbologyReferenceScale() const
Returns the symbology reference scale.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected).
void setSymbologyReferenceScale(double scale)
Sets the symbology reference scale.
QgsRubberBandPreviewItem(QgsRubberBand *rubberBand)
Constructor for a QgsRubberBandPreviewItem, attached to the specified rubberBand.
QgsRubberBand * rubberBand()
Returns the rubber band associated with the item.
Responsible for drawing transient features (e.g.
Scoped object for saving and restoring a QPainter object's state.
Implements a label provider for vector layers.
QRectF boundingRect() const override
Returns the bounding rect required for drawing the preview item.
void render(QgsRenderContext &context) final
Renders the custom preview overlay using the specified render context.
QgsVectorLayerLabelRubberBandPreview(QgsRubberBand *rubberBand, const QList< QgsFeatureId > &fids, QgsVectorLayer *layer)
Constructor for QgsVectorLayerLabelRubberBandPreview.
Represents a vector layer which manages a vector based dataset.