Skip to content
Permalink
Browse files

[FEATURE] New API for labeling engine (QgsLabelingEngineV2)

The idea is to make the engine more flexible compared to QgsPalLabeling implementation:
- abstract dealing with text labels / diagrams from the engine itself
- allow multiple types of labels per layer
- support custom label providers (e.g. implemented by plugins)
- make the labeling engine independent from map rendering engine
- make it easier to auto-test the labeling engine and its components

This code has been funded by Tuscany Region (Italy) - SITA (CIG: 63526840AE) and commissioned to Gis3W s.a.s.
  • Loading branch information
wonder-sk committed Sep 21, 2015
1 parent 13fe3a0 commit 1d0d0e06622563502fc24973256f427f9eb6ebc8
@@ -112,6 +112,7 @@ SET(QGIS_CORE_SRCS
qgslayerdefinition.cpp
qgslabel.cpp
qgslabelattributes.cpp
qgslabelingenginev2.cpp
qgslabelsearchtree.cpp
qgslegacyhelpers.cpp
qgslegendrenderer.cpp
@@ -178,12 +179,14 @@ SET(QGIS_CORE_SRCS
qgsvectorfilewriter.cpp
qgsvectorlayer.cpp
qgsvectorlayercache.cpp
qgsvectorlayerdiagramprovider.cpp
qgsvectorlayereditbuffer.cpp
qgsvectorlayereditpassthrough.cpp
qgsvectorlayereditutils.cpp
qgsvectorlayerfeatureiterator.cpp
qgsvectorlayerimport.cpp
qgsvectorlayerjoinbuffer.cpp
qgsvectorlayerlabelprovider.cpp
qgsvectorlayerrenderer.cpp
qgsvectorlayerundocommand.cpp
qgsvectorsimplifymethod.cpp
@@ -562,6 +565,7 @@ SET(QGIS_CORE_HDRS
qgslayerdefinition.h
qgslabel.h
qgslabelattributes.h
qgslabelingenginev2.h
qgslabelsearchtree.h
qgslegacyhelpers.h
qgslegendrenderer.h
@@ -612,9 +616,11 @@ SET(QGIS_CORE_HDRS
qgsvectordataprovider.h
qgsvectorlayercache.h
qgsvectorfilewriter.h
qgsvectorlayerdiagramprovider.h
qgsvectorlayereditutils.h
qgsvectorlayerfeatureiterator.h
qgsvectorlayerimport.h
qgsvectorlayerlabelprovider.h
qgsvectorlayerrenderer.h
qgsvectorlayerundocommand.h
qgsvectorsimplifymethod.h
@@ -40,6 +40,9 @@
#include <cmath>
#include <vector>

#include "qgslabelingenginev2.h"
#include "qgspalgeometry.h"

namespace pal
{

@@ -261,6 +264,22 @@ namespace pal
return addedFeature; // true if we've added something
}

bool Layer::registerFeature( QgsLabelFeature* label )
{
QgsPalGeometry* g = label->geometry();
if ( !registerFeature( g->strId(), g, label->size().width(), label->size().height() ) )
return false;

pal::Feature* pf = getFeature( g->strId() );
pf->setLabelInfo( g->info() );
pf->setPriority( label->priority() );
pf->setDistLabel( label->distLabel() );
pf->setFixedQuadrant( label->hasFixedQuadrant() );
pf->setIsObstacle( label->isObstacle() );
pf->setObstacleFactor( label->obstacleFactor() );
return true;
}

void Layer::addFeaturePart( FeaturePart* fpart, const QString& labelText )
{
double bmin[2];
@@ -37,6 +37,8 @@
#include <QHash>
#include <fstream>

class QgsLabelFeature;

namespace pal
{

@@ -266,6 +268,8 @@ namespace pal
int xQuadOffset = 0, int yQuadOffset = 0, double xOffset = 0.0, double yOffset = 0.0,
bool alwaysShow = false, double repeatDistance = 0 );

bool registerFeature( QgsLabelFeature* label );

/** Return pointer to feature or NULL if doesn't exist */
Feature* getFeature( const QString &geom_id );

0 comments on commit 1d0d0e0

Please sign in to comment.
You can’t perform that action at this time.