Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move QgsLabelingResults out to its own file
- Loading branch information
1 parent
a513f5a
commit 4f39cf6
Showing
17 changed files
with
205 additions
and
136 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
python/core/auto_generated/labeling/qgslabelingresults.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
#include "qgslabeling.h" | ||
|
||
class QgsLabelingEngine; | ||
class QgsLabelingResults; | ||
|
||
namespace pal | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.