QGIS API Documentation  3.2.0-Bonn (bc43194)
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( 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." );
52  mRules->rootRule()->createSubProviders( layer, mSubProviders, this );
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 
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:71
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:62
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
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.
QgsVectorLayerLabelProvider * createProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings) override
create QgsDxfLabelProvider
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
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.
Contains information about the context of a rendering operation.
QgsDxfExport * mDxfExport
pointer to parent DXF export where this instance is used
void registerFeature(QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry()) 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:55
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.