Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Move QgsLabelingResults out to its own file
- Loading branch information
|
|
@@ -0,0 +1,54 @@ |
|
|
/************************************************************************ |
|
|
* This file has been generated automatically from * |
|
|
* * |
|
|
* src/core/labeling/qgslabelingresults.h * |
|
|
* * |
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again * |
|
|
************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
class QgsLabelingResults |
|
|
{ |
|
|
%Docstring |
|
|
Class that stores computed placement from labeling engine. |
|
|
|
|
|
.. versionadded:: 2.4 |
|
|
%End |
|
|
|
|
|
%TypeHeaderCode |
|
|
#include "qgslabelingresults.h" |
|
|
%End |
|
|
public: |
|
|
QgsLabelingResults(); |
|
|
~QgsLabelingResults(); |
|
|
|
|
|
|
|
|
QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const; |
|
|
%Docstring |
|
|
Returns the details of any labels placed at the specifed point (in map coordinates). |
|
|
%End |
|
|
|
|
|
QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const; |
|
|
%Docstring |
|
|
Returns the details of any labels placed within the specifed rectangle (in map coordinates). |
|
|
%End |
|
|
|
|
|
void setMapSettings( const QgsMapSettings &settings ); |
|
|
%Docstring |
|
|
Sets the map ``settings`` associated with the labeling run. |
|
|
|
|
|
.. versionadded:: 3.4.8 |
|
|
%End |
|
|
|
|
|
private: |
|
|
QgsLabelingResults( const QgsLabelingResults & ); |
|
|
}; |
|
|
|
|
|
/************************************************************************ |
|
|
* This file has been generated automatically from * |
|
|
* * |
|
|
* src/core/labeling/qgslabelingresults.h * |
|
|
* * |
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again * |
|
|
************************************************************************/ |
|
@@ -675,45 +675,6 @@ Represents a label candidate. |
|
|
double cost; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsLabelingResults |
|
|
{ |
|
|
%Docstring |
|
|
Class that stores computed placement from labeling engine. |
|
|
|
|
|
.. versionadded:: 2.4 |
|
|
%End |
|
|
|
|
|
%TypeHeaderCode |
|
|
#include "qgspallabeling.h" |
|
|
%End |
|
|
public: |
|
|
QgsLabelingResults(); |
|
|
~QgsLabelingResults(); |
|
|
|
|
|
|
|
|
QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const; |
|
|
%Docstring |
|
|
Returns infos about labels at a given (map) position |
|
|
%End |
|
|
QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const; |
|
|
%Docstring |
|
|
Returns infos about labels within a given (map) rectangle |
|
|
%End |
|
|
|
|
|
void setMapSettings( const QgsMapSettings &settings ); |
|
|
%Docstring |
|
|
Sets the map ``settings`` associated with the labeling run. |
|
|
|
|
|
.. versionadded:: 3.4.8 |
|
|
%End |
|
|
|
|
|
private: |
|
|
QgsLabelingResults( const QgsLabelingResults & ); |
|
|
}; |
|
|
|
|
|
class QgsPalLabeling |
|
|
{ |
|
|
%Docstring |
|
|
|
@@ -327,6 +327,7 @@ |
|
|
%Include auto_generated/gps/qgsnmeaconnection.sip |
|
|
%Include auto_generated/labeling/qgslabeling.sip |
|
|
%Include auto_generated/labeling/qgslabelingenginesettings.sip |
|
|
%Include auto_generated/labeling/qgslabelingresults.sip |
|
|
%Include auto_generated/labeling/qgslabellinesettings.sip |
|
|
%Include auto_generated/labeling/qgslabelobstaclesettings.sip |
|
|
%Include auto_generated/labeling/qgslabelposition.sip |
|
@@ -629,4 +630,5 @@ |
|
|
%Include auto_generated/gps/qgsqtlocationconnection.sip |
|
|
%Include auto_generated/gps/qgsgpsconnectionregistry.sip |
|
|
%Include auto_generated/symbology/qgsmasksymbollayer.sip |
|
|
%Include auto_generated/labeling/qgslabelthinningsettings.sip |
|
|
%Include auto_generated/qgsuserprofile.sip |
|
@@ -26,6 +26,7 @@ |
|
|
#include "qgsmaptoolselectutils.h" |
|
|
#include "qgsrubberband.h" |
|
|
#include "qgslogger.h" |
|
|
#include "qgslabelingresults.h" |
|
|
|
|
|
|
|
|
QgsMapToolPinLabels::QgsMapToolPinLabels( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock ) |
|
|
|
@@ -647,6 +647,7 @@ set(QGIS_CORE_SRCS |
|
|
labeling/qgslabelfeature.cpp |
|
|
labeling/qgslabelingengine.cpp |
|
|
labeling/qgslabelingenginesettings.cpp |
|
|
labeling/qgslabelingresults.cpp |
|
|
labeling/qgslabellinesettings.cpp |
|
|
labeling/qgslabelobstaclesettings.cpp |
|
|
labeling/qgslabelsearchtree.cpp |
|
@@ -1215,6 +1216,7 @@ set(QGIS_CORE_HDRS |
|
|
labeling/qgslabeling.h |
|
|
labeling/qgslabelingengine.h |
|
|
labeling/qgslabelingenginesettings.h |
|
|
labeling/qgslabelingresults.h |
|
|
labeling/qgslabellinesettings.h |
|
|
labeling/qgslabelobstaclesettings.h |
|
|
labeling/qgslabelposition.h |
|
|
|
@@ -28,6 +28,7 @@ |
|
|
#include "qgssymbol.h" |
|
|
#include "qgsexpressioncontextutils.h" |
|
|
#include "qgsvectorlayerlabelprovider.h" |
|
|
#include "qgslabelingresults.h" |
|
|
|
|
|
// helper function for checking for job cancellation within PAL |
|
|
static bool _palIsCanceled( void *ctx ) |
|
|
|
@@ -26,6 +26,7 @@ |
|
|
#include "qgslabeling.h" |
|
|
|
|
|
class QgsLabelingEngine; |
|
|
class QgsLabelingResults; |
|
|
|
|
|
namespace pal |
|
|
{ |
|
|
|
|
@@ -0,0 +1,65 @@ |
|
|
/*************************************************************************** |
|
|
qgslabelingresults.cpp |
|
|
------------------- |
|
|
begin : February 2021 |
|
|
copyright : (C) Nyall Dawson |
|
|
email : nyall dot dawson at gmail dot com |
|
|
*************************************************************************** |
|
|
* * |
|
|
* This program is free software; you can redistribute it and/or modify * |
|
|
* it under the terms of the GNU General Public License as published by * |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
|
|
* (at your option) any later version. * |
|
|
* * |
|
|
***************************************************************************/ |
|
|
|
|
|
#include "qgslabelingresults.h" |
|
|
#include "qgslabelsearchtree.h" |
|
|
|
|
|
QgsLabelingResults::QgsLabelingResults() |
|
|
: mLabelSearchTree( qgis::make_unique< QgsLabelSearchTree >() ) |
|
|
{ |
|
|
} |
|
|
|
|
|
QgsLabelingResults::~QgsLabelingResults() = default; |
|
|
|
|
|
QList<QgsLabelPosition> QgsLabelingResults::labelsAtPosition( const QgsPointXY &p ) const |
|
|
{ |
|
|
QList<QgsLabelPosition> positions; |
|
|
|
|
|
QList<QgsLabelPosition *> positionPointers; |
|
|
if ( mLabelSearchTree ) |
|
|
{ |
|
|
mLabelSearchTree->label( p, positionPointers ); |
|
|
QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin(); |
|
|
for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt ) |
|
|
{ |
|
|
positions.push_back( QgsLabelPosition( **pointerIt ) ); |
|
|
} |
|
|
} |
|
|
|
|
|
return positions; |
|
|
} |
|
|
|
|
|
QList<QgsLabelPosition> QgsLabelingResults::labelsWithinRect( const QgsRectangle &r ) const |
|
|
{ |
|
|
QList<QgsLabelPosition> positions; |
|
|
|
|
|
QList<QgsLabelPosition *> positionPointers; |
|
|
if ( mLabelSearchTree ) |
|
|
{ |
|
|
mLabelSearchTree->labelsInRect( r, positionPointers ); |
|
|
QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin(); |
|
|
for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt ) |
|
|
{ |
|
|
positions.push_back( QgsLabelPosition( **pointerIt ) ); |
|
|
} |
|
|
} |
|
|
|
|
|
return positions; |
|
|
} |
|
|
|
|
|
void QgsLabelingResults::setMapSettings( const QgsMapSettings &settings ) |
|
|
{ |
|
|
mLabelSearchTree->setMapSettings( settings ); |
|
|
} |
|
|
@@ -0,0 +1,71 @@ |
|
|
/*************************************************************************** |
|
|
qgslabelingresults.h |
|
|
------------------- |
|
|
begin : February 2021 |
|
|
copyright : (C) Nyall Dawson |
|
|
email : nyall dot dawson at gmail dot com |
|
|
*************************************************************************** |
|
|
* * |
|
|
* This program is free software; you can redistribute it and/or modify * |
|
|
* it under the terms of the GNU General Public License as published by * |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
|
|
* (at your option) any later version. * |
|
|
* * |
|
|
***************************************************************************/ |
|
|
|
|
|
#ifndef QGSLABELINGRESULTS_H |
|
|
#define QGSLABELINGRESULTS_H |
|
|
|
|
|
#include "qgis_core.h" |
|
|
#include "qgis_sip.h" |
|
|
#include "qgslabelposition.h" |
|
|
|
|
|
#include <memory> |
|
|
|
|
|
class QgsLabelSearchTree; |
|
|
|
|
|
/** |
|
|
* \ingroup core |
|
|
* \brief Class that stores computed placement from labeling engine. |
|
|
* \since QGIS 2.4 |
|
|
*/ |
|
|
class CORE_EXPORT QgsLabelingResults |
|
|
{ |
|
|
public: |
|
|
QgsLabelingResults(); |
|
|
~QgsLabelingResults(); |
|
|
|
|
|
//! QgsLabelingResults cannot be copied. |
|
|
QgsLabelingResults( const QgsLabelingResults & ) = delete; |
|
|
//! QgsLabelingResults cannot be copied. |
|
|
QgsLabelingResults &operator=( const QgsLabelingResults &rh ) = delete; |
|
|
|
|
|
/** |
|
|
* Returns the details of any labels placed at the specifed point (in map coordinates). |
|
|
*/ |
|
|
QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const; |
|
|
|
|
|
/** |
|
|
* Returns the details of any labels placed within the specifed rectangle (in map coordinates). |
|
|
*/ |
|
|
QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const; |
|
|
|
|
|
/** |
|
|
* Sets the map \a settings associated with the labeling run. |
|
|
* \since QGIS 3.4.8 |
|
|
*/ |
|
|
void setMapSettings( const QgsMapSettings &settings ); |
|
|
|
|
|
private: |
|
|
#ifdef SIP_RUN |
|
|
QgsLabelingResults( const QgsLabelingResults & ); |
|
|
#endif |
|
|
|
|
|
std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree; |
|
|
|
|
|
friend class QgsPalLabeling; |
|
|
friend class QgsVectorLayerLabelProvider; |
|
|
friend class QgsVectorLayerDiagramProvider; |
|
|
}; |
|
|
|
|
|
#endif // QGSLABELINGRESULTS_H |
|
@@ -23,7 +23,7 @@ |
|
|
#include "qgis_sip.h" |
|
|
#include <QList> |
|
|
#include <QVector> |
|
|
#include "qgspallabeling.h" |
|
|
#include "qgslabelposition.h" |
|
|
#include "qgsgenericspatialindex.h" |
|
|
#include "qgsmapsettings.h" |
|
|
|
|
|
|
@@ -4279,7 +4279,6 @@ void QgsPalLabeling::dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void QgsPalLabeling::drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates ) |
|
|
{ |
|
|
QgsPointXY outPt = xform->transform( lp->getX(), lp->getY() ); |
|
@@ -4338,51 +4337,3 @@ void QgsPalLabeling::drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *p |
|
|
if ( lp->nextPart() ) |
|
|
drawLabelCandidateRect( lp->nextPart(), painter, xform, candidates ); |
|
|
} |
|
|
|
|
|
QgsLabelingResults::QgsLabelingResults() |
|
|
: mLabelSearchTree( qgis::make_unique< QgsLabelSearchTree >() ) |
|
|
{ |
|
|
} |
|
|
|
|
|
QgsLabelingResults::~QgsLabelingResults() = default; |
|
|
|
|
|
QList<QgsLabelPosition> QgsLabelingResults::labelsAtPosition( const QgsPointXY &p ) const |
|
|
{ |
|
|
QList<QgsLabelPosition> positions; |
|
|
|
|
|
QList<QgsLabelPosition *> positionPointers; |
|
|
if ( mLabelSearchTree ) |
|
|
{ |
|
|
mLabelSearchTree->label( p, positionPointers ); |
|
|
QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin(); |
|
|
for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt ) |
|
|
{ |
|
|
positions.push_back( QgsLabelPosition( **pointerIt ) ); |
|
|
} |
|
|
} |
|
|
|
|
|
return positions; |
|
|
} |
|
|
|
|
|
QList<QgsLabelPosition> QgsLabelingResults::labelsWithinRect( const QgsRectangle &r ) const |
|
|
{ |
|
|
QList<QgsLabelPosition> positions; |
|
|
|
|
|
QList<QgsLabelPosition *> positionPointers; |
|
|
if ( mLabelSearchTree ) |
|
|
{ |
|
|
mLabelSearchTree->labelsInRect( r, positionPointers ); |
|
|
QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin(); |
|
|
for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt ) |
|
|
{ |
|
|
positions.push_back( QgsLabelPosition( **pointerIt ) ); |
|
|
} |
|
|
} |
|
|
|
|
|
return positions; |
|
|
} |
|
|
|
|
|
void QgsLabelingResults::setMapSettings( const QgsMapSettings &settings ) |
|
|
{ |
|
|
mLabelSearchTree->setMapSettings( settings ); |
|
|
} |
Oops, something went wrong.