Skip to content
Permalink
Browse files

Merge pull request #36265 from m-kuhn/export_label_positions

Abstract dxf export label provider away
  • Loading branch information
m-kuhn committed May 8, 2020
2 parents ab2ec69 + cd8f1f1 commit 753a684c9f46db9b8db0359997b86a7a95e88e21
@@ -491,13 +491,16 @@ Returns list of available DXF encodings
%End


void registerDxfLayer( const QString &layerId, QgsFeatureId fid, const QString &layer );
void registerDxfLayer( const QString &layerId, QgsFeatureId fid, const QString &layer );
%Docstring
Register name of layer for feature

:param layerId: id of layer
:param fid: id of feature
:param layer: dxf layer of feature

.. deprecated::
Will be made private in QGIS 4
%End

private:
@@ -452,7 +452,6 @@ SET(QGIS_CORE_SRCS
dxf/qgsdxfexport.cpp
dxf/qgsdxfpaintdevice.cpp
dxf/qgsdxfpaintengine.cpp
dxf/qgsdxfpallabeling.cpp

layout/qgsabstractreportsection.cpp
layout/qgslayout.cpp
@@ -595,6 +594,7 @@ SET(QGIS_CORE_SRCS
labeling/qgslabelingenginesettings.cpp
labeling/qgslabelobstaclesettings.cpp
labeling/qgslabelsearchtree.cpp
labeling/qgslabelsink.cpp
labeling/qgslabelthinningsettings.cpp
labeling/qgspallabeling.cpp
labeling/qgsrulebasedlabeling.cpp
@@ -27,7 +27,6 @@
// AutoCAD 2014: http://images.autodesk.com/adsk/files/autocad_2014_pdf_dxf_reference_enu.pdf

#include "qgsdxfexport.h"
#include "qgsdxfpallabeling.h"
#include "qgsgeometrygeneratorsymbollayer.h"
#include "qgsgeometrycollection.h"
#include "qgscurvepolygon.h"
@@ -718,11 +717,17 @@ void QgsDxfExport::writeEntities()

if ( job->labelProvider )
{
job->labelProvider->registerDxfFeature( fet, mRenderContext, lName );
job->labelProvider->registerFeature( fet, mRenderContext );
Q_NOWARN_DEPRECATED_PUSH
registerDxfLayer( job->featureSource.id(), fet.id(), lName );
Q_NOWARN_DEPRECATED_POP
}
else if ( job->ruleBasedLabelProvider )
{
job->ruleBasedLabelProvider->registerDxfFeature( fet, mRenderContext, lName );
job->ruleBasedLabelProvider->registerFeature( fet, mRenderContext );
Q_NOWARN_DEPRECATED_PUSH
registerDxfLayer( job->featureSource.id(), fet.id(), lName );
Q_NOWARN_DEPRECATED_POP
}
}
}
@@ -24,6 +24,7 @@
#include "qgsgeometry.h"
#include "qgssymbol.h" // for OutputUnit enum
#include "qgsmapsettings.h"
#include "qgslabelsink.h"

#include <QColor>
#include <QList>
@@ -54,8 +55,13 @@ namespace pal // SIP_SKIP
* \ingroup core
* \class QgsDxfExport
*/
#ifdef SIP_RUN
class CORE_EXPORT QgsDxfExport
{
#else
class CORE_EXPORT QgsDxfExport : public QgsLabelSink
{
#endif
public:

/**
@@ -167,7 +173,7 @@ class CORE_EXPORT QgsDxfExport
*/
QgsDxfExport();

~QgsDxfExport();
~QgsDxfExport() override;

/**
* Set map settings and assign layer name attributes
@@ -505,22 +511,21 @@ class CORE_EXPORT QgsDxfExport
static QStringList encodings();

/**
* Output the label
* \param layerId id of the layer
* \param context render context
* \param label position of label
* \param settings label settings
* Add a label to the dxf output.
*
* \note not available in Python bindings
*/
void drawLabel( const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings ) SIP_SKIP;
void drawLabel( const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings ) SIP_SKIP override;

/**
* Register name of layer for feature
* \param layerId id of layer
* \param fid id of feature
* \param layer dxf layer of feature
*
* \deprecated Will be made private in QGIS 4
*/
void registerDxfLayer( const QString &layerId, QgsFeatureId fid, const QString &layer );
Q_DECL_DEPRECATED void registerDxfLayer( const QString &layerId, QgsFeatureId fid, const QString &layer );

private:

@@ -22,7 +22,7 @@
#include "qgsvectorlayerfeatureiterator.h"
#include "qgsrenderer.h"
#include "qgsvectorlayerlabeling.h"
#include "qgsdxfpallabeling.h"
#include "qgslabelsink.h"

/**
* Holds information about each layer in a DXF job.
@@ -62,7 +62,7 @@ struct DxfLayerJob
QgsLabelingEngine *labelingEngine = renderContext.labelingEngine();
if ( const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling *>( labeling.get() ) )
{
ruleBasedLabelProvider = new QgsDxfRuleBasedLabelProvider( *rbl, vl, dxfExport );
ruleBasedLabelProvider = new QgsRuleBasedLabelSinkProvider( *rbl, vl, dxfExport );
labelingEngine->addProvider( ruleBasedLabelProvider );

if ( !ruleBasedLabelProvider->prepare( renderContext, attributes ) )
@@ -74,7 +74,7 @@ struct DxfLayerJob
else
{
QgsPalLayerSettings settings = labeling->settings();
labelProvider = new QgsDxfLabelProvider( vl, QString(), dxfExport, &settings );
labelProvider = new QgsLabelSinkProvider( vl, QString(), dxfExport, &settings );
labelingEngine->addProvider( labelProvider );

if ( !labelProvider->prepare( renderContext, attributes ) )
@@ -98,8 +98,8 @@ struct DxfLayerJob
QgsDxfExport *dxfExport = nullptr;
QgsCoordinateReferenceSystem crs;
QString layerName;
QgsDxfLabelProvider *labelProvider = nullptr;
QgsDxfRuleBasedLabelProvider *ruleBasedLabelProvider = nullptr;
QgsLabelSinkProvider *labelProvider = nullptr;
QgsRuleBasedLabelSinkProvider *ruleBasedLabelProvider = nullptr;
QString splitLayerAttribute;
QString layerTitle;
QSet<QString> attributes;

This file was deleted.

This file was deleted.

0 comments on commit 753a684

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