mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Remove QgsLabelingEngineInterface base class and implementation in QgsPalLabeling
It was ready to go for some time, just waiting for QgsMapRender that still used it.
This commit is contained in:
parent
398249806f
commit
8e5fb436b7
@ -245,7 +245,8 @@ Use QgsComposerAttributeTableV2 instead.
|
||||
so there is no longer a need for the separate cache class. Code which previously called QgsCRSCache::updateCRSCache()
|
||||
should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinateTransformCache::instance()->invalidateCrs( authid ).
|
||||
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
|
||||
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngineV2.
|
||||
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngine.
|
||||
- QgsLabelingEngineInterface. Replaced by QgsLabelingEngine.
|
||||
- QgsLegendInterface was removed. It was replaced by layer tree API (QgsLayerTreeNode class and others).
|
||||
Methods that deal with custom actions in main window's layer tree context menu were moved to QgisInterface:
|
||||
- addLegendLayerAction() moved to QgisInterface::addCustomActionForLayerType()
|
||||
@ -1113,7 +1114,7 @@ screenUpdateRequested() were removed. These members have had no effect for a num
|
||||
- theMinScale and theMaxScale parameters in setMinimumScale and setMaximumScale were renamed to scale
|
||||
- The layerCrsChanged() signal was renamed to crsChanged()
|
||||
- theError parameter in appendError() and setError() were renamed to 'error'.
|
||||
- drawLabels() method was removed. It used old deprecated labeling. Replaced by labeling based on PAL library, see QgsLabelingEngineV2.
|
||||
- drawLabels() method was removed. It used old deprecated labeling. Replaced by labeling based on PAL library, see QgsLabelingEngine.
|
||||
- readLayerXML() was renamed to readLayerXml()
|
||||
- writeLayerXML() was renamed to writeLayerXml()
|
||||
|
||||
@ -1145,7 +1146,7 @@ QgsMapRendererJob {#qgis_api_break_3_0_QgsMapRendererJob}
|
||||
|
||||
- reprojectToLayerExtent() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should
|
||||
be used instead of a null pointer if no transformation is required.
|
||||
- prepareJobs() and drawLabeling() (neither available in PyQGIS) do not take QgsPalLabeling parameter anymore. All drawing of labels is done by QgsLabelingEngineV2.
|
||||
- prepareJobs() and drawLabeling() (neither available in PyQGIS) do not take QgsPalLabeling parameter anymore. All drawing of labels is done by QgsLabelingEngine.
|
||||
- drawOldLabeling(), drawNewLabeling() were removed. The method drawLabeling() should be used instead.
|
||||
|
||||
|
||||
@ -1253,6 +1254,7 @@ QgsPalettedRasterRenderer {#qgis_api_break_3_0_QgsPalettedRasterRenderer}
|
||||
QgsPalLabeling {#qgis_api_break_3_0_QgsPalLabeling}
|
||||
--------------
|
||||
|
||||
- all methods implemented from QgsLabelingEngineInterface have been removed: init(), willUseLayer(), clearActiveLayers(), clearActiveLayer(), prepareLayer(), prepareDiagramLayer(), registerFeature(), registerDiagramFeature(), drawLabeling(), exit(), clone(). Labeling is now driven by QgsLabelingEngine.
|
||||
- init(QgsMapRenderer*) has been removed. Use init(const QgsMapSettings&) instead.
|
||||
- prepareGeometry and geometryRequiresPreparation now take geometry references, not pointers.
|
||||
- layer() was removed. If direct access to QgsPalLayerSettings is necessary, use QgsPalLayerSettings::fromLayer()
|
||||
@ -1596,7 +1598,7 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
|
||||
- addTopologicalPoints() now takes a geometry reference, not a pointer.
|
||||
- commitErrors() now returns an object, rather than a reference. This has no effect on PyQGIS code.
|
||||
- subsetString() was made const. This has no effect on PyQGIS code, but c++ code implementing derived layer classes will need to update the signature of this method to match.
|
||||
- label(), enableLabels(), hasLabelsEnabled(), drawLabels() have been removed. Replaced by labeling based on PAL library, see QgsLabelingEngineV2.
|
||||
- label(), enableLabels(), hasLabelsEnabled(), drawLabels() have been removed. Replaced by labeling based on PAL library, see QgsLabelingEngine.
|
||||
- Signal layerDeleted() has been removed. Replaced by Qt signal destroyed().
|
||||
- Deprecated editor widget methods and enums and structs: struct RangeData, enum FeatureFormSuppress, enum EditType, addAttributeEditorWidget(), editorWidgetV2(), editorWidgetConfig(), attributeEditorElements(), editType(), setEditType(), editorLayout(), setEditorLayout, setEditorWidgetV2Config(), setCheckedState(), editForm(), setEditForm(), featureFormSuppress(), setFeatureFormSuppress(), editFormInit(), setEditFormInit(), valueMap(), range(), dateFormat(), fieldEditable(), labelOnTop(), setFieldEditable() and setLabelOnTop(). Use editFormConfig()
|
||||
- select() replaced by selectByRect()
|
||||
|
@ -102,44 +102,6 @@ class QgsLabelPosition
|
||||
QString providerID;
|
||||
};
|
||||
|
||||
/** Labeling engine interface. */
|
||||
class QgsLabelingEngineInterface
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgspallabeling.h>
|
||||
%End
|
||||
|
||||
public:
|
||||
|
||||
virtual ~QgsLabelingEngineInterface();
|
||||
|
||||
//! called when we're going to start with rendering
|
||||
virtual void init( const QgsMapSettings& mapSettings ) = 0;
|
||||
//! called to find out whether the layer is used for labeling
|
||||
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
|
||||
//! clears all PAL layer settings for registered layers
|
||||
virtual void clearActiveLayers() = 0;
|
||||
//! clears data defined objects from PAL layer settings for a registered layer
|
||||
virtual void clearActiveLayer( const QString& layerID ) = 0;
|
||||
//! called when starting rendering of a layer
|
||||
virtual int prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) = 0;
|
||||
//! adds a diagram layer to the labeling engine
|
||||
//! @note added in QGIS 2.12
|
||||
virtual int prepareDiagramLayer( QgsVectorLayer *layer, QSet<QString>& attrNames, QgsRenderContext& ctx );
|
||||
//! called for every feature
|
||||
virtual void registerFeature( const QString &layerID, QgsFeature& feat, QgsRenderContext& context ) = 0;
|
||||
//! called for every diagram feature
|
||||
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context );
|
||||
//! called when the map is drawn and labels should be placed
|
||||
virtual void drawLabeling( QgsRenderContext& context ) = 0;
|
||||
//! called when we're done with rendering
|
||||
virtual void exit() = 0;
|
||||
|
||||
//! called when passing engine among map renderers
|
||||
virtual QgsLabelingEngineInterface* clone() = 0 /Factory/;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QgsPalLayerSettings
|
||||
{
|
||||
@ -674,7 +636,7 @@ class QgsLabelingResults
|
||||
};
|
||||
|
||||
|
||||
class QgsPalLabeling : QgsLabelingEngineInterface
|
||||
class QgsPalLabeling
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgspallabeling.h>
|
||||
@ -721,49 +683,11 @@ class QgsPalLabeling : QgsLabelingEngineInterface
|
||||
*/
|
||||
void setDrawLabelRectOnly( bool drawRect );
|
||||
|
||||
// implemented methods from labeling engine interface
|
||||
|
||||
//! called when we're going to start with rendering
|
||||
virtual void init( const QgsMapSettings& mapSettings );
|
||||
//! called to find out whether the layer is used for labeling
|
||||
virtual bool willUseLayer( QgsVectorLayer* layer );
|
||||
|
||||
//! called to find out whether the layer is used for labeling
|
||||
//! @note added in 2.4
|
||||
static bool staticWillUseLayer( QgsVectorLayer* layer );
|
||||
static bool staticWillUseLayer( const QString& layerID );
|
||||
|
||||
//! clears all PAL layer settings for registered layers
|
||||
virtual void clearActiveLayers();
|
||||
//! clears data defined objects from PAL layer settings for a registered layer
|
||||
virtual void clearActiveLayer( const QString& layerID );
|
||||
//! hook called when drawing layer before issuing select()
|
||||
virtual int prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx );
|
||||
//! adds a diagram layer to the labeling engine
|
||||
//! @note added in QGIS 2.12
|
||||
virtual int prepareDiagramLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx );
|
||||
|
||||
/** Register a feature for labelling.
|
||||
* @param layerID string identifying layer associated with label
|
||||
* @param feat feature to label
|
||||
* @param context render context. The QgsExpressionContext contained within the render context
|
||||
* must have already had the feature and fields sets prior to calling this method.
|
||||
*/
|
||||
virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context );
|
||||
|
||||
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context );
|
||||
//! called when the map is drawn and labels should be placed
|
||||
virtual void drawLabeling( QgsRenderContext& context );
|
||||
//! called when we're done with rendering
|
||||
virtual void exit();
|
||||
|
||||
//! Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to the caller
|
||||
//! @note added in 2.4
|
||||
QgsLabelingResults* takeResults() /TransferBack/;
|
||||
|
||||
//! called when passing engine among map renderers
|
||||
virtual QgsPalLabeling* clone() /Factory/;
|
||||
|
||||
//! @note not available in python bindings
|
||||
// void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform );
|
||||
|
||||
|
@ -85,11 +85,9 @@ class QgsRenderContext
|
||||
|
||||
double rendererScale() const;
|
||||
|
||||
QgsLabelingEngineInterface* labelingEngine();
|
||||
|
||||
//! Get access to new labeling engine (may be nullptr)
|
||||
//! @note not available in Python bindings
|
||||
// QgsLabelingEngine* labelingEngineV2() const { return mLabelingEngine2; }
|
||||
// QgsLabelingEngine* labelingEngine() const;
|
||||
|
||||
QColor selectionColor() const;
|
||||
|
||||
@ -119,10 +117,9 @@ class QgsRenderContext
|
||||
|
||||
void setForceVectorOutput( bool force );
|
||||
|
||||
void setLabelingEngine( QgsLabelingEngineInterface* iface );
|
||||
//! Assign new labeling engine
|
||||
//! @note not available in Python bindings
|
||||
// void setLabelingEngineV2( QgsLabelingEngine* engine2 ) { mLabelingEngine2 = engine2; }
|
||||
// void setLabelingEngine( QgsLabelingEngine* engine2 );
|
||||
void setSelectionColor( const QColor& color );
|
||||
|
||||
/** Sets whether vector selections should be shown in the rendered map
|
||||
|
@ -246,7 +246,7 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsLabelingEn
|
||||
|
||||
job.context = QgsRenderContext::fromMapSettings( mSettings );
|
||||
job.context.setPainter( painter );
|
||||
job.context.setLabelingEngineV2( labelingEngine2 );
|
||||
job.context.setLabelingEngine( labelingEngine2 );
|
||||
job.context.setCoordinateTransform( ct );
|
||||
job.context.setExtent( r1 );
|
||||
|
||||
|
@ -3207,11 +3207,6 @@ QgsPalLabeling::~QgsPalLabeling()
|
||||
mEngine = nullptr;
|
||||
}
|
||||
|
||||
bool QgsPalLabeling::willUseLayer( QgsVectorLayer* layer )
|
||||
{
|
||||
return staticWillUseLayer( layer );
|
||||
}
|
||||
|
||||
bool QgsPalLabeling::staticWillUseLayer( const QString& layerID )
|
||||
{
|
||||
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsProject::instance()->mapLayer( layerID ) );
|
||||
@ -3234,66 +3229,6 @@ bool QgsPalLabeling::staticWillUseLayer( QgsVectorLayer* layer )
|
||||
}
|
||||
|
||||
|
||||
void QgsPalLabeling::clearActiveLayers()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsPalLabeling::clearActiveLayer( const QString &layerID )
|
||||
{
|
||||
Q_UNUSED( layerID );
|
||||
}
|
||||
|
||||
|
||||
int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx )
|
||||
{
|
||||
if ( !willUseLayer( layer ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !layer->labeling() )
|
||||
return 0;
|
||||
|
||||
QgsVectorLayerLabelProvider* lp = layer->labeling()->provider( layer );
|
||||
if ( !lp )
|
||||
return 0;
|
||||
|
||||
//QgsVectorLayerLabelProvider* lp = new QgsVectorLayerLabelProvider( layer, false );
|
||||
// need to be added before calling prepare() - uses map settings from engine
|
||||
mEngine->addProvider( lp );
|
||||
mLabelProviders[layer->id()] = lp; // fast lookup table by layer ID
|
||||
|
||||
if ( !lp->prepare( ctx, attrNames ) )
|
||||
{
|
||||
mEngine->removeProvider( lp );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1; // init successful
|
||||
}
|
||||
|
||||
int QgsPalLabeling::prepareDiagramLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx )
|
||||
{
|
||||
QgsVectorLayerDiagramProvider* dp = new QgsVectorLayerDiagramProvider( layer, false );
|
||||
// need to be added before calling prepare() - uses map settings from engine
|
||||
mEngine->addProvider( dp );
|
||||
mDiagramProviders[layer->id()] = dp; // fast lookup table by layer ID
|
||||
|
||||
if ( !dp->prepare( ctx, attrNames ) )
|
||||
{
|
||||
mEngine->removeProvider( dp );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void QgsPalLabeling::registerFeature( const QString& layerID, QgsFeature& f, QgsRenderContext &context )
|
||||
{
|
||||
if ( QgsVectorLayerLabelProvider* provider = mLabelProviders.value( layerID, nullptr ) )
|
||||
provider->registerFeature( f, context );
|
||||
}
|
||||
|
||||
bool QgsPalLabeling::geometryRequiresPreparation( const QgsGeometry& geometry, QgsRenderContext &context, const QgsCoordinateTransform& ct, QgsGeometry* clipGeometry )
|
||||
{
|
||||
if ( geometry.isEmpty() )
|
||||
@ -3470,23 +3405,6 @@ bool QgsPalLabeling::checkMinimumSizeMM( const QgsRenderContext& context, const
|
||||
return true; //should never be reached. Return true in this case to label such geometries anyway.
|
||||
}
|
||||
|
||||
void QgsPalLabeling::registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext &context )
|
||||
{
|
||||
if ( QgsVectorLayerDiagramProvider* provider = mDiagramProviders.value( layerID, nullptr ) )
|
||||
provider->registerFeature( feat, context );
|
||||
}
|
||||
|
||||
|
||||
void QgsPalLabeling::init( const QgsMapSettings& mapSettings )
|
||||
{
|
||||
mEngine->setMapSettings( mapSettings );
|
||||
}
|
||||
|
||||
void QgsPalLabeling::exit()
|
||||
{
|
||||
delete mEngine;
|
||||
mEngine = new QgsLabelingEngine();
|
||||
}
|
||||
|
||||
void QgsPalLabeling::dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues )
|
||||
@ -3901,21 +3819,10 @@ void QgsPalLabeling::dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QgsPalLabeling::drawLabeling( QgsRenderContext& context )
|
||||
{
|
||||
mEngine->run( context );
|
||||
}
|
||||
|
||||
void QgsPalLabeling::deleteTemporaryData()
|
||||
{
|
||||
}
|
||||
|
||||
QgsLabelingResults *QgsPalLabeling::takeResults()
|
||||
{
|
||||
return mEngine->takeResults();
|
||||
}
|
||||
|
||||
void QgsPalLabeling::numCandidatePositions( int& candPoint, int& candLine, int& candPolygon )
|
||||
{
|
||||
mEngine->numCandidatePositions( candPoint, candLine, candPolygon );
|
||||
@ -4067,18 +3974,6 @@ void QgsPalLabeling::clearEngineSettings()
|
||||
QgsProject::instance()->removeEntry( QStringLiteral( "PAL" ), QStringLiteral( "/DrawOutlineLabels" ) );
|
||||
}
|
||||
|
||||
QgsPalLabeling* QgsPalLabeling::clone()
|
||||
{
|
||||
QgsPalLabeling* lbl = new QgsPalLabeling();
|
||||
lbl->setShowingAllLabels( isShowingAllLabels() );
|
||||
lbl->setShowingCandidates( isShowingCandidates() );
|
||||
lbl->setDrawLabelRectOnly( drawLabelRectOnly() );
|
||||
lbl->setShowingPartialsLabels( isShowingPartialsLabels() );
|
||||
lbl->setDrawingOutlineLabels( isDrawingOutlineLabels() );
|
||||
return lbl;
|
||||
}
|
||||
|
||||
|
||||
QgsLabelingResults::QgsLabelingResults()
|
||||
{
|
||||
mLabelSearchTree = new QgsLabelSearchTree();
|
||||
|
@ -118,45 +118,6 @@ class CORE_EXPORT QgsLabelPosition
|
||||
QString providerID;
|
||||
};
|
||||
|
||||
/** \ingroup core
|
||||
* Labeling engine interface.
|
||||
*/
|
||||
class CORE_EXPORT QgsLabelingEngineInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~QgsLabelingEngineInterface() {}
|
||||
|
||||
//! called when we're going to start with rendering
|
||||
virtual void init( const QgsMapSettings& mapSettings ) = 0;
|
||||
//! called to find out whether the layer is used for labeling
|
||||
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
|
||||
//! clears all PAL layer settings for registered layers
|
||||
virtual void clearActiveLayers() = 0;
|
||||
//! clears data defined objects from PAL layer settings for a registered layer
|
||||
virtual void clearActiveLayer( const QString& layerID ) = 0;
|
||||
//! called when starting rendering of a layer
|
||||
virtual int prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) = 0;
|
||||
|
||||
//! adds a diagram layer to the labeling engine
|
||||
//! @note added in QGIS 2.12
|
||||
virtual int prepareDiagramLayer( QgsVectorLayer *layer, QSet<QString>& attrNames, QgsRenderContext &ctx )
|
||||
{ Q_UNUSED( layer ); Q_UNUSED( attrNames ); Q_UNUSED( ctx ); return 0; }
|
||||
|
||||
//! called for every feature
|
||||
virtual void registerFeature( const QString &layerID, QgsFeature &feat, QgsRenderContext &context ) = 0;
|
||||
//! called for every diagram feature
|
||||
virtual void registerDiagramFeature( const QString &layerID, QgsFeature &feat, QgsRenderContext &context )
|
||||
{ Q_UNUSED( layerID ); Q_UNUSED( feat ); Q_UNUSED( context ); }
|
||||
//! called when the map is drawn and labels should be placed
|
||||
virtual void drawLabeling( QgsRenderContext& context ) = 0;
|
||||
//! called when we're done with rendering
|
||||
virtual void exit() = 0;
|
||||
|
||||
//! called when passing engine among map renderers
|
||||
virtual QgsLabelingEngineInterface* clone() = 0;
|
||||
};
|
||||
|
||||
|
||||
/** \ingroup core
|
||||
* \class QgsPalLayerSettings
|
||||
@ -763,7 +724,7 @@ class CORE_EXPORT QgsLabelingResults
|
||||
/** \ingroup core
|
||||
* \class QgsPalLabeling
|
||||
*/
|
||||
class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
|
||||
class CORE_EXPORT QgsPalLabeling
|
||||
{
|
||||
public:
|
||||
|
||||
@ -806,49 +767,11 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
|
||||
*/
|
||||
void setDrawLabelRectOnly( bool drawRect );
|
||||
|
||||
// implemented methods from labeling engine interface
|
||||
|
||||
//! called when we're going to start with rendering
|
||||
virtual void init( const QgsMapSettings& mapSettings ) override;
|
||||
//! called to find out whether the layer is used for labeling
|
||||
virtual bool willUseLayer( QgsVectorLayer* layer ) override;
|
||||
|
||||
//! called to find out whether the layer is used for labeling
|
||||
//! @note added in 2.4
|
||||
static bool staticWillUseLayer( QgsVectorLayer* layer );
|
||||
static bool staticWillUseLayer( const QString& layerID );
|
||||
|
||||
//! clears all PAL layer settings for registered layers
|
||||
virtual void clearActiveLayers() override;
|
||||
//! clears data defined objects from PAL layer settings for a registered layer
|
||||
virtual void clearActiveLayer( const QString& layerID ) override;
|
||||
//! hook called when drawing layer before issuing select()
|
||||
virtual int prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) override;
|
||||
//! adds a diagram layer to the labeling engine
|
||||
//! @note added in QGIS 2.12
|
||||
virtual int prepareDiagramLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) override;
|
||||
|
||||
/** Register a feature for labelling.
|
||||
* @param layerID string identifying layer associated with label
|
||||
* @param feat feature to label
|
||||
* @param context render context. The QgsExpressionContext contained within the render context
|
||||
* must have already had the feature and fields sets prior to calling this method.
|
||||
*/
|
||||
virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
|
||||
|
||||
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
|
||||
//! called when the map is drawn and labels should be placed
|
||||
virtual void drawLabeling( QgsRenderContext& context ) override;
|
||||
//! called when we're done with rendering
|
||||
virtual void exit() override;
|
||||
|
||||
//! Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to the caller
|
||||
//! @note added in 2.4
|
||||
QgsLabelingResults* takeResults();
|
||||
|
||||
//! called when passing engine among map renderers
|
||||
virtual QgsPalLabeling* clone() override;
|
||||
|
||||
//! @note not available in python bindings
|
||||
static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = nullptr );
|
||||
|
||||
|
@ -31,7 +31,6 @@ QgsRenderContext::QgsRenderContext()
|
||||
, mRasterScaleFactor( 1.0 )
|
||||
, mRendererScale( 1.0 )
|
||||
, mLabelingEngine( nullptr )
|
||||
, mLabelingEngine2( nullptr )
|
||||
, mGeometry( nullptr )
|
||||
, mFeatureFilterProvider( nullptr )
|
||||
, mSegmentationTolerance( M_PI_2 / 90 )
|
||||
@ -51,7 +50,6 @@ QgsRenderContext::QgsRenderContext( const QgsRenderContext& rh )
|
||||
, mRasterScaleFactor( rh.mRasterScaleFactor )
|
||||
, mRendererScale( rh.mRendererScale )
|
||||
, mLabelingEngine( rh.mLabelingEngine )
|
||||
, mLabelingEngine2( rh.mLabelingEngine2 )
|
||||
, mSelectionColor( rh.mSelectionColor )
|
||||
, mVectorSimplifyMethod( rh.mVectorSimplifyMethod )
|
||||
, mExpressionContext( rh.mExpressionContext )
|
||||
@ -74,7 +72,6 @@ QgsRenderContext&QgsRenderContext::operator=( const QgsRenderContext & rh )
|
||||
mRasterScaleFactor = rh.mRasterScaleFactor;
|
||||
mRendererScale = rh.mRendererScale;
|
||||
mLabelingEngine = rh.mLabelingEngine;
|
||||
mLabelingEngine2 = rh.mLabelingEngine2;
|
||||
mSelectionColor = rh.mSelectionColor;
|
||||
mVectorSimplifyMethod = rh.mVectorSimplifyMethod;
|
||||
mExpressionContext = rh.mExpressionContext;
|
||||
|
@ -30,7 +30,6 @@
|
||||
class QPainter;
|
||||
|
||||
class QgsAbstractGeometry;
|
||||
class QgsLabelingEngineInterface;
|
||||
class QgsLabelingEngine;
|
||||
class QgsMapSettings;
|
||||
class QgsFeatureFilterProvider;
|
||||
@ -127,11 +126,9 @@ class CORE_EXPORT QgsRenderContext
|
||||
|
||||
double rendererScale() const {return mRendererScale;}
|
||||
|
||||
QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
|
||||
|
||||
//! Get access to new labeling engine (may be nullptr)
|
||||
//! @note not available in Python bindings
|
||||
QgsLabelingEngine* labelingEngineV2() const { return mLabelingEngine2; }
|
||||
QgsLabelingEngine* labelingEngine() const { return mLabelingEngine; }
|
||||
|
||||
QColor selectionColor() const { return mSelectionColor; }
|
||||
|
||||
@ -160,10 +157,9 @@ class CORE_EXPORT QgsRenderContext
|
||||
|
||||
void setForceVectorOutput( bool force );
|
||||
|
||||
void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
|
||||
//! Assign new labeling engine
|
||||
//! @note not available in Python bindings
|
||||
void setLabelingEngineV2( QgsLabelingEngine* engine2 ) { mLabelingEngine2 = engine2; }
|
||||
void setLabelingEngine( QgsLabelingEngine* engine2 ) { mLabelingEngine = engine2; }
|
||||
void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
|
||||
|
||||
/** Sets whether vector selections should be shown in the rendered map
|
||||
@ -263,11 +259,8 @@ class CORE_EXPORT QgsRenderContext
|
||||
//! Map scale
|
||||
double mRendererScale;
|
||||
|
||||
//! Labeling engine (can be nullptr)
|
||||
QgsLabelingEngineInterface* mLabelingEngine;
|
||||
|
||||
//! Newer labeling engine implementation (can be nullptr)
|
||||
QgsLabelingEngine* mLabelingEngine2;
|
||||
QgsLabelingEngine* mLabelingEngine;
|
||||
|
||||
//! Color used for features that are marked as selected
|
||||
QColor mSelectionColor;
|
||||
|
@ -314,19 +314,8 @@ void QgsVectorLayerRenderer::drawRenderer( QgsFeatureIterator& fit )
|
||||
// labeling - register feature
|
||||
if ( rendered )
|
||||
{
|
||||
if ( mContext.labelingEngine() )
|
||||
{
|
||||
if ( mLabeling )
|
||||
{
|
||||
mContext.labelingEngine()->registerFeature( mLayerID, fet, mContext );
|
||||
}
|
||||
if ( mDiagrams )
|
||||
{
|
||||
mContext.labelingEngine()->registerDiagramFeature( mLayerID, fet, mContext );
|
||||
}
|
||||
}
|
||||
// new labeling engine
|
||||
if ( mContext.labelingEngineV2() && ( mLabelProvider || mDiagramProvider ) )
|
||||
if ( mContext.labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
|
||||
{
|
||||
QScopedPointer<QgsGeometry> obstacleGeometry;
|
||||
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, mContext );
|
||||
@ -415,20 +404,8 @@ void QgsVectorLayerRenderer::drawRendererLevels( QgsFeatureIterator& fit )
|
||||
mCache->cacheGeometry( fet.id(), fet.geometry() );
|
||||
}
|
||||
|
||||
if ( mContext.labelingEngine() )
|
||||
{
|
||||
mContext.expressionContext().setFeature( fet );
|
||||
if ( mLabeling )
|
||||
{
|
||||
mContext.labelingEngine()->registerFeature( mLayerID, fet, mContext );
|
||||
}
|
||||
if ( mDiagrams )
|
||||
{
|
||||
mContext.labelingEngine()->registerDiagramFeature( mLayerID, fet, mContext );
|
||||
}
|
||||
}
|
||||
// new labeling engine
|
||||
if ( mContext.labelingEngineV2() )
|
||||
if ( mContext.labelingEngine() )
|
||||
{
|
||||
QScopedPointer<QgsGeometry> obstacleGeometry;
|
||||
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, mContext );
|
||||
@ -536,89 +513,68 @@ void QgsVectorLayerRenderer::stopRenderer( QgsSingleSymbolRenderer* selRenderer
|
||||
|
||||
void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer* layer, QSet<QString>& attributeNames )
|
||||
{
|
||||
if ( !mContext.labelingEngine() )
|
||||
if ( QgsLabelingEngine* engine2 = mContext.labelingEngine() )
|
||||
{
|
||||
if ( QgsLabelingEngine* engine2 = mContext.labelingEngineV2() )
|
||||
if ( layer->labeling() )
|
||||
{
|
||||
if ( layer->labeling() )
|
||||
mLabelProvider = layer->labeling()->provider( layer );
|
||||
if ( mLabelProvider )
|
||||
{
|
||||
mLabelProvider = layer->labeling()->provider( layer );
|
||||
if ( mLabelProvider )
|
||||
engine2->addProvider( mLabelProvider );
|
||||
if ( !mLabelProvider->prepare( mContext, attributeNames ) )
|
||||
{
|
||||
engine2->addProvider( mLabelProvider );
|
||||
if ( !mLabelProvider->prepare( mContext, attributeNames ) )
|
||||
{
|
||||
engine2->removeProvider( mLabelProvider );
|
||||
mLabelProvider = nullptr; // deleted by engine
|
||||
}
|
||||
engine2->removeProvider( mLabelProvider );
|
||||
mLabelProvider = nullptr; // deleted by engine
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mContext.labelingEngine()->prepareLayer( layer, attributeNames, mContext ) )
|
||||
{
|
||||
mLabeling = true;
|
||||
|
||||
#if 0 // TODO: limit of labels, font not found
|
||||
QgsPalLayerSettings& palyr = mContext.labelingEngine()->layer( mLayerID );
|
||||
QgsPalLayerSettings& palyr = mContext.labelingEngine()->layer( mLayerID );
|
||||
|
||||
// see if feature count limit is set for labeling
|
||||
if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
|
||||
// see if feature count limit is set for labeling
|
||||
if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
|
||||
{
|
||||
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
|
||||
.setFilterRect( mContext.extent() )
|
||||
.setSubsetOfAttributes( QgsAttributeList() ) );
|
||||
|
||||
// total number of features that may be labeled
|
||||
QgsFeature f;
|
||||
int nFeatsToLabel = 0;
|
||||
while ( fit.nextFeature( f ) )
|
||||
{
|
||||
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
|
||||
.setFilterRect( mContext.extent() )
|
||||
.setSubsetOfAttributes( QgsAttributeList() ) );
|
||||
|
||||
// total number of features that may be labeled
|
||||
QgsFeature f;
|
||||
int nFeatsToLabel = 0;
|
||||
while ( fit.nextFeature( f ) )
|
||||
{
|
||||
nFeatsToLabel++;
|
||||
}
|
||||
palyr.mFeaturesToLabel = nFeatsToLabel;
|
||||
nFeatsToLabel++;
|
||||
}
|
||||
|
||||
// notify user about any font substitution
|
||||
if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
|
||||
{
|
||||
emit labelingFontNotFound( this, palyr.mTextFontFamily );
|
||||
mLabelFontNotFoundNotified = true;
|
||||
}
|
||||
#endif
|
||||
palyr.mFeaturesToLabel = nFeatsToLabel;
|
||||
}
|
||||
|
||||
// notify user about any font substitution
|
||||
if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
|
||||
{
|
||||
emit labelingFontNotFound( this, palyr.mTextFontFamily );
|
||||
mLabelFontNotFoundNotified = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QSet<QString>& attributeNames )
|
||||
{
|
||||
if ( !mContext.labelingEngine() )
|
||||
if ( QgsLabelingEngine* engine2 = mContext.labelingEngine() )
|
||||
{
|
||||
if ( QgsLabelingEngine* engine2 = mContext.labelingEngineV2() )
|
||||
if ( layer->diagramsEnabled() )
|
||||
{
|
||||
if ( layer->diagramsEnabled() )
|
||||
mDiagramProvider = new QgsVectorLayerDiagramProvider( layer );
|
||||
// need to be added before calling prepare() - uses map settings from engine
|
||||
engine2->addProvider( mDiagramProvider );
|
||||
if ( !mDiagramProvider->prepare( mContext, attributeNames ) )
|
||||
{
|
||||
mDiagramProvider = new QgsVectorLayerDiagramProvider( layer );
|
||||
// need to be added before calling prepare() - uses map settings from engine
|
||||
engine2->addProvider( mDiagramProvider );
|
||||
if ( !mDiagramProvider->prepare( mContext, attributeNames ) )
|
||||
{
|
||||
engine2->removeProvider( mDiagramProvider );
|
||||
mDiagramProvider = nullptr; // deleted by engine
|
||||
}
|
||||
engine2->removeProvider( mDiagramProvider );
|
||||
mDiagramProvider = nullptr; // deleted by engine
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !layer->diagramsEnabled() )
|
||||
return;
|
||||
|
||||
mDiagrams = true;
|
||||
|
||||
mContext.labelingEngine()->prepareDiagramLayer( layer, attributeNames, mContext ); // will make internal copy of diagSettings + initialize it
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user