36 , mSettings( *diagSettings )
37 , mDiagRenderer( diagRenderer->clone() )
42 , mOwnsSource( ownsSource )
50 ,
mSettings( *layer->diagramLayerSettings() )
92 if ( !
prepare( context, attributeNames ) )
141 for (
int i = 0; i < 4; ++i )
143 centerX += label->
getX( i );
144 centerY += label->
getY( i );
146 QgsPoint outPt( centerX / 4.0, centerY / 4.0 );
186 for ( ; attIt != att.
constEnd(); ++attIt )
191 for ( ; columnsIterator != columns.
constEnd(); ++columnsIterator )
193 if ( !attributeNames.
contains( *columnsIterator ) )
194 attributeNames << *columnsIterator;
199 if ( linearlyInterpolatedDiagramRenderer )
206 for ( ; columnsIterator != columns.
constEnd(); ++columnsIterator )
208 if ( !attributeNames.
contains( *columnsIterator ) )
209 attributeNames << *columnsIterator;
215 if ( !attributeNames.
contains( name ) )
216 attributeNames << name;
246 if ( !settingList.
isEmpty() && settingList.
at( 0 ).scaleBasedVisibility )
248 double minScale = settingList.
at( 0 ).minScaleDenominator;
254 double maxScale = settingList.
at( 0 ).maxScaleDenominator;
271 const GEOSGeometry* geos_geom =
nullptr;
276 if ( !preparedGeom.
data() )
278 geos_geom = preparedGeom.
data()->asGeos();
282 geos_geom = geom->
asGeos();
290 const GEOSGeometry* geosObstacleGeom =
nullptr;
295 geosObstacleGeom = scopedObstacleGeom.
data()->asGeos();
299 geosObstacleGeom = obstacleGeometry->
asGeos();
301 GEOSGeometry* geosObstacleGeomClone =
nullptr;
302 if ( geosObstacleGeom )
308 double diagramWidth = 0;
309 double diagramHeight = 0;
315 diagramWidth = diagSize.
width();
316 diagramHeight = diagSize.
height();
326 bool ddPos = ( ddColX >= 0 && ddColY >= 0 );
332 if ( !posXOk || !posYOk )
345 ddPosX -= diagramWidth / 2.0;
346 ddPosY -= diagramHeight / 2.0;
358 if ( geosObstacleGeomClone )
QgsFeatureId id() const
Get the feature ID for this feature.
double zIndex
Z-index of diagrams, where diagrams with a higher z-index are drawn on top of diagrams with a lower z...
Class for parsing and evaluation of expressions (formerly called "search strings").
QgsLabelFeature * registerDiagram(QgsFeature &feat, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
helper method to register one diagram feautre
Wrapper for iterator of features from vector data provider or vector layer.
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
A rectangle specified with double values.
static QgsGeometry * prepareGeometry(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=nullptr)
Prepares a geometry for registration with PAL.
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
QString mLayerId
ID of the layer.
QStringList referencedColumns() const
Get list of columns referenced by the expression.
QgsPalLayerSettings::Placement mPlacement
Placement strategy.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
QgsLabelFeature * feature()
Returns the parent feature.
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
Q_DECL_DEPRECATED QgsExpression * getExpression(const QString &expression, const QgsFields *fields)
double mPriority
Default priority of labels.
void init()
initialization method - called from constructors
QgsDiagram * diagram() const
unsigned int placementFlags
double rendererScale() const
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
const T & at(int i) const
bool contains(const QString &str, Qt::CaseSensitivity cs) const
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
QgsVectorLayerDiagramProvider(QgsVectorLayer *layer, bool ownFeatureLoop=true)
Convenience constructor to initialize the provider from given vector layer.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
const QgsRectangle & extent() const
const QgsMapToPixel & mapToPixel() const
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, QPointF pos)
QgsDiagramRendererV2 * mDiagRenderer
Diagram renderer instance (owned by mSettings)
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setFixedPosition(const QgsPoint &point)
Set coordinates of the fixed position (relevant only if hasFixedPosition() returns true) ...
static bool geometryRequiresPreparation(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=nullptr)
Checks whether a geometry requires preparation before registration with PAL.
const QgsCoordinateTransform * coordinateTransform() const
void setAlwaysShow(bool enabled)
Set whether label should be always shown (sets very high label priority)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
double x() const
Get the x value of the point.
Returns diagram settings for a feature.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
The QgsMapSettings class contains configuration for rendering of the map.
QgsLabelingResults * results() const
For internal use by the providers.
Perform transforms between map coordinates and device coordinates.
const QgsMapToPixel * xform
bool mOwnsSource
Whether layer's feature source is owned.
void setIsObstacle(bool enabled)
Sets whether the feature will act as an obstacle for labels.
void setZIndex(double zIndex)
Sets the label's z-index.
void setFeatureId(QgsFeatureId id)
Sets the feature ID for this feature.
virtual QSizeF sizeMapUnits(const QgsFeature &feature, const QgsRenderContext &c)
Returns size of the diagram for a feature in map units.
unsigned int mLinePlacementFlags
Extra placement flags for linestring geometries.
QgsAttributes attributes() const
Returns the feature's attributes.
~QgsVectorLayerDiagramProvider()
Clean up.
const QgsMapSettings & mapSettings() const
Get associated map settings.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
QString name() const
Gets the name of the field.
double getY(int i=0) const
get the down-left y coordinate
void setFixedAngle(double angle)
Set angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) ...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
draw this label at the position determined by the labeling engine
const QgsLabelingEngineV2 * mEngine
Associated labeling engine.
QgsDiagramRendererV2 * renderer
void setDistLabel(double dist)
Applies to "around point" placement strategy or linestring features.
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
Base class that can be used for any class that is capable of returning features.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
double getX(int i=0) const
get the down-left x coordinate
QgsFields mFields
Layer's fields.
A class to represent a point.
Q_DECL_DEPRECATED void setFields(const QgsFields *fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
The QgsAbstractLabelProvider class is an interface class.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures...
QgsCoordinateReferenceSystem mLayerCrs
Layer's CRS.
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
QgsExpressionContext & expressionContext()
Gets the expression context.
Class that adds extra information to QgsLabelFeature for labeling of diagrams.
QgsPoint toMapCoordinates(int x, int y) const
int classificationAttribute() const
Placement
Placement modes which determine how label candidates are generated for a feature. ...
void setValid(bool validity)
Sets the validity of the feature.
Contains information about the context of a rendering operation.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
QString mName
Name of the layer.
void setHasFixedAngle(bool enabled)
Set whether the label should use a fixed angle instead of using angle from automatic placement...
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context) override
Return list of label features (they are owned by the provider and thus deleted on its destruction) ...
void setAttributes(const QgsAttributes &attrs)
Store feature's attributes - used for rendering of diagrams.
void setObstacleGeometry(GEOSGeometry *obstacleGeom)
Sets the label's obstacle geometry, if different to the feature geometry.
Class for storing a coordinate reference system (CRS)
bool classificationAttributeIsExpression() const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
LabelPosition is a candidate feature label position.
const QgsMapToPixel & mapToPixel() const
double y() const
Get the y value of the point.
double toDouble(bool *ok) const
const QgsAttributes & attributes()
Get feature's attributes - used for rendering of diagrams.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request)=0
Get an iterator for features matching the specified request.
const_iterator constEnd() const
QgsAbstractFeatureSource * mSource
Layer's feature source.
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
QString classificationAttributeExpression() const
bool insertLabel(pal::LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
Represents a vector layer which manages a vector based data sets.
QgsDiagramLayerSettings mSettings
Diagram layer settings.
QgsPoint center() const
Center point of the rectangle.
const QgsCoordinateTransform * ct
QList< QgsLabelFeature * > mFeatures
List of generated label features (owned by the provider)
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
QgsFeatureId featureId() const
Returns the unique ID of the feature.
QPointF toQPointF() const
Converts a point to a QPointF.