35 : mSettings( *diagSettings )
36 , mDiagRenderer( diagRenderer->clone() )
41 , mOwnsSource( ownsSource )
48 : mSettings( *layer->diagramLayerSettings() )
49 , mDiagRenderer( layer->diagramRenderer()->clone() )
50 , mLayerId( layer->id() )
51 , mFields( layer->fields() )
52 , mLayerCrs( layer->crs() )
54 , mOwnsSource( ownFeatureLoop )
90 if ( !
prepare( context, attributeNames ) )
139 for (
int i = 0; i < 4; ++i )
141 centerX += label->
getX( i );
142 centerY += label->
getY( i );
144 QgsPoint outPt( centerX / 4.0, centerY / 4.0 );
184 for ( ; attIt != att.
constEnd(); ++attIt )
189 for ( ; columnsIterator != columns.
constEnd(); ++columnsIterator )
191 if ( !attributeNames.
contains( *columnsIterator ) )
192 attributeNames << *columnsIterator;
197 if ( linearlyInterpolatedDiagramRenderer != NULL )
204 for ( ; columnsIterator != columns.
constEnd(); ++columnsIterator )
206 if ( !attributeNames.
contains( *columnsIterator ) )
207 attributeNames << *columnsIterator;
213 if ( !attributeNames.
contains( name ) )
214 attributeNames << name;
244 if ( settingList.
size() > 0 && settingList.
at( 0 ).scaleBasedVisibility )
246 double minScale = settingList.
at( 0 ).minScaleDenominator;
252 double maxScale = settingList.
at( 0 ).maxScaleDenominator;
269 const GEOSGeometry* geos_geom = 0;
274 if ( !preparedGeom.
data() )
276 geos_geom = preparedGeom.
data()->asGeos();
280 geos_geom = geom->
asGeos();
283 if ( geos_geom == 0 )
290 double diagramWidth = 0;
291 double diagramHeight = 0;
297 diagramWidth = diagSize.
width();
298 diagramHeight = diagSize.
height();
308 bool ddPos = ( ddColX >= 0 && ddColY >= 0 );
314 if ( !posXOk || !posYOk )
327 ddPosX -= diagramWidth / 2.0;
328 ddPosY -= diagramHeight / 2.0;
QgsFeatureId id() const
Get the feature ID for this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
const QString & name() const
Gets the name of the field.
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.
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
A rectangle specified with double values.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures...
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.
QgsFeatureId featureId() const
Returns the unique ID of the feature.
const QgsRectangle & extent() const
const QgsMapToPixel & mapToPixel() const
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const 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.
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) ...
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
static bool geometryRequiresPreparation(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
Checks whether a geometry requires preparation before registration with PAL.
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 setFeatureId(QgsFeatureId id)
Sets the feature ID for this feature.
double getY(int i=0) const
get the down-left y coordinate
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
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)
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.
QgsCoordinateReferenceSystem mLayerCrs
Layer's CRS.
bool insertLabel(LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
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
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.
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
static QgsGeometry * prepareGeometry(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
Prepares a geometry for registration with PAL.
double y() const
Get the y value of the point.
double toDouble(bool *ok) const
double getX(int i=0) const
get the down-left x coordinate
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
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.
QgsLabelFeature * registerDiagram(QgsFeature &feat, QgsRenderContext &context)
helper method to register one diagram feautre
QPointF toQPointF() const
Converts a point to a QPointF.