32 return ( reinterpret_cast< QgsRenderContext* >( ctx ) )->renderingStopped();
41 : mMapSettings( mapSettings )
55 if ( layer1Pos != layer2Pos && layer1Pos >= 0 && layer2Pos >= 0 )
56 return layer1Pos > layer2Pos;
69 : mFlags( RenderOutlineLabels | UsePartialCandidates )
103 QgsAbstractLabelProvider::Flags
flags = provider->
flags();
143 Q_ASSERT(
"unsupported upside-down label setting" && 0 );
157 catch ( std::exception &e )
243 catch ( std::exception& e )
305 for ( ; it != labels->
end(); ++it )
377 return mLayer ? mLayer->provider() :
nullptr;
383 , mLayerId( layerId )
386 , mLinePlacementFlags( 0 )
406 predefinedOrderString <<
"TL";
409 predefinedOrderString <<
"TSL";
412 predefinedOrderString <<
"T";
415 predefinedOrderString <<
"TSR";
418 predefinedOrderString <<
"TR";
421 predefinedOrderString <<
"L";
424 predefinedOrderString <<
"R";
427 predefinedOrderString <<
"BL";
430 predefinedOrderString <<
"BSL";
433 predefinedOrderString <<
"B";
436 predefinedOrderString <<
"BSR";
439 predefinedOrderString <<
"BR";
443 return predefinedOrderString.
join(
"," );
450 Q_FOREACH (
const QString& position, predefinedOrderList )
453 if ( cleaned ==
"TL" )
455 else if ( cleaned ==
"TSL" )
457 else if ( cleaned ==
"T" )
459 else if ( cleaned ==
"TSR" )
461 else if ( cleaned ==
"TR" )
463 else if ( cleaned ==
"L" )
465 else if ( cleaned ==
"R" )
467 else if ( cleaned ==
"BL" )
469 else if ( cleaned ==
"BSL" )
471 else if ( cleaned ==
"B" )
473 else if ( cleaned ==
"BSR" )
475 else if ( cleaned ==
"BR" )
Label below point, slightly right of center.
Layer * addLayer(QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll=false)
add a new layer
A rectangle specified with double values.
Label on bottom-left of point.
QgsPoint center() const
Center point of the rectangle.
void processProvider(QgsAbstractLabelProvider *provider, QgsRenderContext &context, pal::Pal &p)
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
static bool _palIsCancelled(void *ctx)
QgsFeatureId id() const
Identifier of the label (unique within the parent label provider)
void setCompositionMode(CompositionMode mode)
int getFeatureCandidateCount(int i)
void setRenderHint(RenderHint hint, bool on)
QgsLabelFeature * feature()
Returns the parent feature.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
QgsAbstractLabelProvider * provider() const
Return provider of this instance.
Label on top-left of point.
~QgsLabelingEngineV2()
Clean up everything (especially the registered providers)
void registerCancellationCallback(FnIsCancelled fnCancelled, void *context)
Register a function that returns whether this job has been cancelled - PAL calls it during the comput...
Whether to show debugging rectangles for drop shadows.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
static void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=nullptr)
A set of features which influence the labelling process.
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode...
QgsPalLayerSettings::ObstacleType obstacleType() const
How the feature geometries will work as obstacles.
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
bool renderingStopped() const
Main Pal labelling class.
is slower and best than TABU, worse and faster than TABU_CHAIN
Label on top of point, slightly right of center.
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.
void setShowPartial(bool show)
Set flag show partial label.
QString join(const QString &separator) const
whether to label each part of multi-part features separately
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file.
virtual QList< QgsAbstractLabelProvider * > subProviders()
Return list of child providers - useful if the provider needs to put labels into more layers with dif...
void setObstacleType(QgsPalLayerSettings::ObstacleType obstacleType)
Sets the obstacle type, which controls how features within the layer act as obstacles for labels...
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)
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const
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
whether adjacent lines (with the same label text) should be merged
The QgsMapSettings class contains configuration for rendering of the map.
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.
unsigned int linePlacementFlags() const
For layers with linestring geometries - extra placement flags (or-ed combination of QgsPalLayerSettin...
bool writeEntry(const QString &scope, const QString &key, bool value)
double zIndex() const
Returns the label's z-index.
#define QgsDebugMsgLevel(str, level)
QgsMapSettings mMapSettings
Associated map settings instance.
QList< QgsAbstractLabelProvider * > mProviders
List of providers (the are owned by the labeling engine)
Whether to draw rectangles of generated candidates (good for debugging)
bool operator()(pal::LabelPosition *lp1, pal::LabelPosition *lp2) const
void setPointP(int point_p)
set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend...
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)
void setLineP(int line_p)
set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller wil...
Reads and writes project states.
QgsLabelingResults * mResults
Resulting labeling layout.
void setEngine(const QgsLabelingEngineV2 *engine)
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngineV2)...
whether all features will be labelled even though overlaps occur
QgsPalLayerSettings::Placement placement() const
What placement strategy to use for the labels.
QgsLabelingEngineV2()
Construct the labeling engine with default settings.
const QgsMapToPixel & mapToPixel() const
The QgsAbstractLabelProvider class is an interface class.
void setArrangementFlags(const LineArrangementFlags &flags)
Sets the layer's arrangement flags.
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider...
void writeSettingsToProject()
Write configuration of the labeling engine to the current project file.
QSizeF size() const
Size of the label (in map units)
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels() const
How to handle labels that would be upside down.
Flags flags() const
Get flags of the labeling engine.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
QgsLabelSorter(const QgsMapSettings &mapSettings)
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
double xMaximum() const
Get the x maximum value (right side of rectangle)
Whether to draw all labels even if there would be collisions.
bool registerFeature(QgsLabelFeature *label)
Register a feature in the layer.
Flags flags() const
Flags associated with the provider.
Whether to use also label candidates that are partially outside of the map view.
static QString encodePredefinedPositionOrder(const QVector< QgsPalLayerSettings::PredefinedPointPosition > &positions)
Encodes an ordered list of predefined point label positions to a string.
Contains information about the context of a rendering operation.
Problem * extractProblem(double bbox[4])
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
Whether to only draw the label rect and not the actual label text (used for unit tests) ...
void setPolyP(int poly_p)
set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller w...
QList< LabelPosition * > * solveProblem(Problem *prob, bool displayAll)
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
static QgsProject * instance()
access to canonical QgsProject instance
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
void setLabelMode(LabelMode mode)
Sets the layer's labeling mode.
QgsAbstractLabelProvider(const QString &layerId=QString())
Construct the provider with default values.
Label below point, slightly left of center.
double priority() const
Default priority of labels (may be overridden by individual labels)
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
LabelPosition is a candidate feature label position.
double xMinimum() const
Get the x minimum value (left side of rectangle)
Label on top of point, slightly left of center.
QString fromLatin1(const char *str, int size)
Representation of a labeling problem.
double yMaximum() const
Get the y maximum value (top side of rectangle)
int indexOf(const QRegExp &rx, int from) const
whether the labels should be rendered
LabelPosition * getFeatureCandidate(int fi, int ci)
Class that stores computed placement from labeling engine.
static QVector< QgsPalLayerSettings::PredefinedPointPosition > decodePredefinedPositionOrder(const QString &positionString)
Decodes a string to an ordered list of predefined point label positions.
SearchMethod
Search method to use.
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
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
Whether to render labels as text or outlines.
QList< QgsAbstractLabelProvider * > mSubProviders
QgsLabelingResults * takeResults()
Return pointer to recently computed results and pass the ownership of results to the caller...
void setSearch(SearchMethod method)
Select the search method to use.
void setMergeConnectedLines(bool merge)
Sets whether connected lines should be merged before labeling.