QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
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( 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( "Entering." );
53 }
54 
56 {
57  QgsDebugMsg( "Entering." );
58  Q_UNUSED( withFeatureLoop );
59  return new QgsDxfLabelProvider( layer, providerId, mDxfExport, settings );
60 }
61 
63 {
64  QgsDebugMsg( "Entering." );
65  Q_ASSERT( mDxfExport );
66  mDxfExport->drawLabel( layerId(), context, label, mSettings );
67 }
68 
70 {
71  registerFeature( feature, context );
72  mDxfExport->registerDxfLayer( layerId(), feature.id(), dxfLayerName );
73 }
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
label providers are owned by labeling engine
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
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:187
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Re-implementation that writes to DXF file instead of drawing with QPainter.
QgsDxfLabelProvider(QgsVectorLayer *layer, const QString &providerId, QgsDxfExport *dxf, const QgsPalLayerSettings *settings)
construct the provider
void reinit(QgsVectorLayer *layer)
Reinitialize the subproviders with QgsDxfLabelProviders.
void drawLabel(QString layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label.
QgsPalLayerSettings mSettings
Layer's labeling configuration.
virtual 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...
QgsFeatureId id() const
Get the feature ID for this feature.
Definition: qgsfeature.cpp:65
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=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
QgsRuleBasedLabeling mRules
owned copy
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr) override
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
LabelPosition is a candidate feature label position.
Definition: labelposition.h:51
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e...
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
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.
void createSubProviders(QgsVectorLayer *layer, RuleToProviderMap &subProviders, QgsRuleBasedLabelProvider *provider)
add providers
void registerDxfLayer(QString layerId, QgsFeatureId fid, QString layer)
Register name of layer for feature.