Skip to content

Commit

Permalink
Move qgslabelsink to core/labeling and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 8, 2020
1 parent 50e63a7 commit 1514c08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Expand Up @@ -287,7 +287,6 @@ SET(QGIS_CORE_SRCS
qgsimagecache.cpp
qgsinterval.cpp
qgsjsonutils.cpp
qgslabelsink.cpp
qgslayerdefinition.cpp
qgslegendrenderer.cpp
qgslegendsettings.cpp
Expand Down Expand Up @@ -593,6 +592,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
Expand Down
File renamed without changes.
35 changes: 15 additions & 20 deletions src/core/qgslabelsink.h → src/core/labeling/qgslabelsink.h
Expand Up @@ -26,6 +26,14 @@
class QgsPalLayerSettings;
class QgsRuleBasedLabeling;

/**
* \ingroup core
* Abstract base class that can be used to intercept rendered labels from
* a labeling / rendering job.
*
* Internal class, not in public API. Added in QGIS 3.14
* \note not available in Python bindings
*/
class QgsLabelSink
{
public:
Expand All @@ -36,42 +44,35 @@ class QgsLabelSink

/**
* \ingroup core
* Implements a derived label provider internally used for DXF export
* Implements a derived label provider for use with QgsLabelSink.
*
* Internal class, not in public API. Added in QGIS 2.12
* \note not available in Python bindings
*/
class QgsLabelSinkProvider : public QgsVectorLayerLabelProvider
{
public:
//! construct the provider
explicit QgsLabelSinkProvider( QgsVectorLayer *layer, const QString &providerId, QgsLabelSink *dxf, const QgsPalLayerSettings *settings );
//! Creates a rule based label sink provider which will draw/register labels in \a sink.
explicit QgsLabelSinkProvider( QgsVectorLayer *layer, const QString &providerId, QgsLabelSink *sink, const QgsPalLayerSettings *settings );

/**
* Re-implementation that writes to DXF file instead of drawing with QPainter
* \param context render context
* \param label label
*/
void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;

private:
//! pointer to parent DXF export where this instance is used
QgsLabelSink *mLabelSink = nullptr;
};

/**
* \ingroup core
* Implements a derived label provider for rule based labels internally used
* for DXF export
* Implements a derived label provider for rule based labels for use with QgsLabelSink.
*
* Internal class, not in public API. Added in QGIS 2.15
* \note not available in Python bindings
*/
class QgsRuleBasedLabelSinkProvider : public QgsRuleBasedLabelProvider
{
public:
//! construct the provider
explicit QgsRuleBasedLabelSinkProvider( const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, QgsLabelSink *destination );
//! Creates a rule based label sink provider which will draw/register labels in \a sink.
explicit QgsRuleBasedLabelSinkProvider( const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, QgsLabelSink *sink );

/**
* Reinitialize the subproviders with QgsLabelSinkProviders
Expand All @@ -80,18 +81,12 @@ class QgsRuleBasedLabelSinkProvider : public QgsRuleBasedLabelProvider
*/
Q_DECL_DEPRECATED void reinit( QgsVectorLayer *layer );

/**
* Re-implementation that writes to DXF file instead of drawing with QPainter
* \param context render context
* \param label label
*/
void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;

//! create QgsRuleBasedLabelSinkProvider
//! Creates a QgsRuleBasedLabelSinkProvider
QgsVectorLayerLabelProvider *createProvider( QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings ) override;

private:
//! pointer to parent DXF export where this instance is used
QgsLabelSink *mLabelSink = nullptr;
};

Expand Down

0 comments on commit 1514c08

Please sign in to comment.