37 : mFlags( RenderOutlineLabels | UsePartialCandidates )
81 default: Q_ASSERT(
"unsupported placement" && 0 );
return;
84 QgsAbstractLabelProvider::Flags
flags = provider->
flags();
128 default: Q_ASSERT(
"unsupported upside-down label setting" && 0 );
return;
141 catch ( std::exception &e )
211 std::list<pal::LabelPosition*>* labels;
217 catch ( std::exception& e )
275 std::list<pal::LabelPosition*>::iterator it = labels->begin();
276 for ( ; it != labels->end(); ++it )
351 , mGeometry( geometry )
354 , mHasFixedPosition( false )
355 , mHasFixedAngle( false )
357 , mHasFixedQuadrant( false )
359 , mRepeatDistance( 0 )
360 , mAlwaysShow( false )
361 , mIsObstacle( false )
362 , mObstacleFactor( 1 )
383 , mFlags( DrawLabels )
385 , mLinePlacementFlags( 0 )
QgsLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, const QSizeF &size)
Create label feature, takes ownership of the geometry instance.
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
A rectangle specified with double values.
void processProvider(QgsAbstractLabelProvider *provider, QgsRenderContext &context, pal::Pal &p)
std::list< LabelPosition * > * solveProblem(Problem *prob, bool displayAll)
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
static bool _palIsCancelled(void *ctx)
void setCompositionMode(CompositionMode mode)
int getFeatureCandidateCount(int i)
unsigned int linePlacementFlags() const
For layers with linestring geometries - extra placement flags (or-ed combination of QgsPalLayerSettin...
void setRenderHint(RenderHint hint, bool on)
virtual ~QgsLabelFeature()
Clean up geometry and curved label info (if present)
arranges candidates around a point (centroid for polygon)
~QgsLabelingEngineV2()
Clean up everything (especially the registered providers)
double yMaximum() const
Get the y maximum value (top side of rectangle)
Whether to show debugging rectangles for drop shadows.
QgsAbstractLabelProvider * provider() const
Return provider of this instance.
A layer of spacial entites.
void setPointP(int point_p)
set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend...
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
void setObstacleType(ObstacleType obstacleType)
Sets the obstacle type, which controls how features within the layer act as obstacles for labels...
void setPolyP(int poly_p)
set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller w...
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
pal::LabelInfo * mInfo
extra information for curved labels (may be null)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
is slower and best than TABU, worse and faster than TABU_CHAIN
A geometry is the spatial representation of a feature.
int mCandPoint
Number of candedate positions that will be generated for features.
void setUpsidedownLabels(UpsideDownLabels ud)
Sets how upside down labels will be handled within the layer.
const QgsMapToPixel & mapToPixel() const
whether to label each part of multi-part features separately
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file.
Only for polygon, arranges candidates with respect of polygon orientation.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=0) const
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels() const
How to handle labels that would be upside down.
virtual QList< QgsAbstractLabelProvider * > subProviders()
Return list of child providers - useful if the provider needs to put labels into more layers with dif...
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=0) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
void setCentroidInside(bool forceInside)
Sets whether labels placed at the centroid of features within the layer are forced to be placed insid...
is a little bit better than CHAIN but slower
void setFitInPolygonOnly(bool fitInPolygon)
Sets whether labels which do not fit completely within a polygon feature are discarded.
whether adjacent lines (with the same label text) should be merged
int indexOf(const T &value, int from) const
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider's initialization failed. Provider instance is deleted.
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Return list of label features (they are owned by the provider and thus deleted on its destruction) ...
Perform transforms between map coordinates and device coordinates.
bool writeEntry(const QString &scope, const QString &key, bool value)
QgsPalLayerSettings::Placement placement() const
What placement strategy to use for the labels.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void setSearch(SearchMethod method)
Select the search method to use.
double xMaximum() const
Get the x maximum value (right side of rectangle)
#define QgsDebugMsgLevel(str, level)
QgsMapSettings mMapSettings
Associated map settings instance.
QList< QgsAbstractLabelProvider * > mProviders
List of providers (the are owned by the labeling engine)
bool renderingStopped() const
Whether to draw rectangles of generated candidates (good for debugging)
Flags flags() const
Get flags of the labeling engine.
GEOSGeometry * mGeometry
Geometry of the feature to be labelled.
whether location of centroid must be inside of polygons
QgsPalLabeling::Search mSearchMethod
search method to use for removal collisions between labels
void setBrush(const QBrush &brush)
double priority() const
Default priority of labels (may be overridden by individual labels)
Problem * extractProblem(double bbox[4])
Reads and writes project states.
QgsLabelingResults * mResults
Resulting labeling layout.
Flags flags() const
Flags associated with the provider.
void setEngine(const QgsLabelingEngineV2 *engine)
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngineV2)...
QgsAbstractLabelProvider * provider() const
Returns pointer to the associated provider.
whether labels must fall completely within the polygon
whether all features will be labelled even though overlaps occur
QgsAbstractLabelProvider()
Construct the provider with default values.
QgsLabelingEngineV2()
Construct the labeling engine with default settings.
The QgsAbstractLabelProvider class is an interface class.
void setArrangementFlags(const LineArrangementFlags &flags)
Sets the layer's arrangement flags.
void writeSettingsToProject()
Write configuration of the labeling engine to the current project file.
void setShowPartial(bool show)
Set flag show partial label.
Only for lines, labels along the line.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
Whether to draw all labels even if there would be collisions.
Whether to use also label candidates that are partially outside of the map view.
Arrangement
The way to arrange labels against spatial entities.
Contains information about the context of a rendering operation.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
Whether to only draw the label rect and not the actual label text (used for unit tests) ...
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
QgsPalLayerSettings::ObstacleType obstacleType() const
How the feature geometries will work as obstacles.
bool registerFeature(QgsLabelFeature *label)
Register a feature in the layer.
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
static QgsProject * instance()
access to canonical QgsProject instance
void setLabelMode(LabelMode mode)
Sets the layer's labeling mode.
Layer * addLayer(QgsAbstractLabelProvider *provider, const QString &layerName, Arrangement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll=false)
add a new layer
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
LabelPosition is a candidate feature label position.
pal::Layer * mLayer
Pointer to PAL layer (assigned when registered to PAL)
QString fromLatin1(const char *str, int size)
void setLineP(int line_p)
set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller wil...
whether the labels should be rendered
static void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=0)
LabelPosition * getFeatureCandidate(int fi, int ci)
Class that stores computed placement from labeling engine.
SearchMethod
Search method to use.
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
draw this label at the position determined by the labeling engine
is the worst but fastest method
double xMinimum() const
Get the x minimum value (left side of rectangle)
Whether to render labels as text or outlines.
QgsPoint center() const
Center point of the rectangle.
QList< QgsAbstractLabelProvider * > mSubProviders
QgsLabelingResults * takeResults()
Return pointer to recently computed results and pass the ownership of results to the caller...
arranges candidates over a point (centroid for polygon)
void registerCancellationCallback(FnIsCancelled fnCancelled, void *context)
Register a function that returns whether this job has been cancelled - PAL calls it during the comput...
void setMergeConnectedLines(bool merge)
Sets whether connected lines should be merged before labeling.
QgsFeatureId id() const
Identifier of the label (unique within the parent label provider)