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 )
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.
QgsDiagram * diagram() const
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.
double rendererScale() const
QgsPoint center() const
Center point of the rectangle.
QgsAttributes attributes() const
Returns the feature's attributes.
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
QString mLayerId
ID of the layer.
QgsPalLayerSettings::Placement mPlacement
Placement strategy.
QgsFeatureId featureId() const
Returns the unique ID of the feature.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
QgsLabelFeature * feature()
Returns the parent feature.
QPointF toQPointF() const
Converts a point to a QPointF.
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
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
double getY(int i=0) const
get the down-left y coordinate
QStringList referencedColumns() const
Get list of columns referenced by the expression.
unsigned int placementFlags
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.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
QgsVectorLayerDiagramProvider(QgsVectorLayer *layer, bool ownFeatureLoop=true)
Convenience constructor to initialize the provider from given vector layer.
Container of fields for a vector layer.
QgsPoint toMapCoordinates(int x, int y) const
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, QPointF pos)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
int classificationAttribute() const
QgsDiagramRendererV2 * mDiagRenderer
Diagram renderer instance (owned by mSettings)
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 QgsMapSettings & mapSettings() const
Get associated map settings.
void setAlwaysShow(bool enabled)
Set whether label should be always shown (sets very high label priority)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QString name() const
Gets the name of the field.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
double y() const
Get the y value of the point.
QString classificationAttributeExpression() const
Returns diagram settings for a feature.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
bool classificationAttributeIsExpression() const
The QgsMapSettings class contains configuration for rendering of the map.
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
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.
const QgsRectangle & extent() const
unsigned int mLinePlacementFlags
Extra placement flags for linestring geometries.
~QgsVectorLayerDiagramProvider()
Clean up.
void setFixedAngle(double angle)
Set angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) ...
const QgsCoordinateTransform * coordinateTransform() const
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.
Base class that can be used for any class that is capable of returning features.
QgsFields mFields
Layer's fields.
A class to represent a point.
const QgsMapToPixel & mapToPixel() const
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.
QgsFeatureId id() const
Get the feature ID for this feature.
QgsLabelingResults * results() const
For internal use by the providers.
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.
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...
const QgsMapToPixel & mapToPixel() const
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
QString mName
Name of the layer.
double getX(int i=0) const
get the down-left x coordinate
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.
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
void setObstacleGeometry(GEOSGeometry *obstacleGeom)
Sets the label's obstacle geometry, if different to the feature geometry.
Class for storing a coordinate reference system (CRS)
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
LabelPosition is a candidate feature label position.
double toDouble(bool *ok) const
double sqrDist(double x, double y) const
Returns the squared distance between this point and x,y.
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
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsDiagramLayerSettings mSettings
Diagram layer settings.
const QgsCoordinateTransform * ct
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
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.
double x() const
Get the x value of the point.