QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsdxfpallabeling.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdxfpallabeling.cpp
3  ---------------------
4  begin : January 2014
5  copyright : (C) 2014 by Marco Hugentobler
6  email : marco at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsdxfpallabeling.h"
19 #include "qgsdxfexport.h"
20 #include "qgspallabeling.h"
21 #include "qgsmapsettings.h"
22 #include "qgslogger.h"
23 
24 
25 QgsDxfLabelProvider::QgsDxfLabelProvider( QgsVectorLayer *layer, const QString &providerId, QgsDxfExport *dxf, const QgsPalLayerSettings *settings )
26  : QgsVectorLayerLabelProvider( layer, providerId, false, settings )
27  , mDxfExport( dxf )
28 {
29 }
30 
32 {
33  Q_ASSERT( mDxfExport );
34  mDxfExport->drawLabel( layerId(), context, label, mSettings );
35 }
36 
37 void QgsDxfLabelProvider::registerDxfFeature( const QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName )
38 {
39  registerFeature( feature, context );
40  mDxfExport->registerDxfLayer( layerId(), feature.id(), dxfLayerName );
41 }
42 
44  : QgsRuleBasedLabelProvider( rules, layer, false )
45  , mDxfExport( dxf )
46 {
47 }
48 
50 {
51  QgsDebugMsg( QStringLiteral( "Entering." ) );
52  mRules->rootRule()->createSubProviders( layer, mSubProviders, this );
53 }
54 
56 {
57  QgsDebugMsg( QStringLiteral( "Entering." ) );
58  Q_UNUSED( withFeatureLoop )
59  return new QgsDxfLabelProvider( layer, providerId, mDxfExport, settings );
60 }
61 
63 {
64  QgsDebugMsg( QStringLiteral( "Entering." ) );
65  Q_ASSERT( mDxfExport );
66  mDxfExport->drawLabel( layerId(), context, label, mSettings );
67 }
68 
69 void QgsDxfRuleBasedLabelProvider::registerDxfFeature( QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName )
70 {
71  registerFeature( feature, context );
72  mDxfExport->registerDxfLayer( layerId(), feature.id(), dxfLayerName );
73 }
QgsFeatureId id
Definition: qgsfeature.h:64
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
label providers are owned by labeling engine
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
void registerDxfLayer(const QString &layerId, QgsFeatureId fid, const QString &layer)
Register name of layer for feature.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Re-implementation that writes to DXF file instead of drawing with QPainter.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Re-implementation that writes to DXF file instead of drawing with QPainter.
void registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr) override
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
QgsDxfLabelProvider(QgsVectorLayer *layer, const QString &providerId, QgsDxfExport *dxf, const QgsPalLayerSettings *settings)
construct the provider
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
void reinit(QgsVectorLayer *layer)
Reinitialize the subproviders with QgsDxfLabelProviders.
std::unique_ptr< QgsRuleBasedLabeling > mRules
owned copy
QgsPalLayerSettings mSettings
Layer&#39;s labeling configuration.
void registerDxfFeature(const QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
const QgsPalLayerSettings & settings() const
Returns the layer&#39;s settings.
QgsVectorLayerLabelProvider * createProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings) override
create QgsDxfLabelProvider
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider...
void drawLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label.
virtual void registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
Contains information about the context of a rendering operation.
QgsDxfExport * mDxfExport
pointer to parent DXF export where this instance is used
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e...
QgsDxfRuleBasedLabelProvider(const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, QgsDxfExport *dxf)
construct the provider
Implements a derived label provider internally used for DXF export.
QgsDxfExport * mDxfExport
pointer to parent DXF export where this instance is used
Represents a vector layer which manages a vector based data sets.