Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Groups nearby points into a single rendered marker symbol. QgsPointDisplacementRenderer has been split into a new pure virtual QgsPointDistanceRenderer base class which handles the detection of clusters and grouping of points. The new cluster renderer reuses this base class to avoid code duplication. Additionally, some improvements have been made to the displacement renderer, specifically: - points are now assigned to the group which is "nearest" them, rather then just assigning them first group within the search distance. In some cases this was assigning features to a more distant cluster, resulting in less predictable cluster patterns - individual points are now correctly shown in their own selection state Lots of code cleanup + documentation too. Sponsored by: - Andreas Neumann - Qtibia Engineering (Tudor Barascu) - Karl-Magnus Jönsson - Geonesia (Nicolas Ponzo) - Plus numerous additional anonymous backers whose generous contributions are also highly valued!
- Loading branch information
1 parent
19585ee
commit 36e276f
Showing
25 changed files
with
1,826 additions
and
735 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** \class QgsPointClusterRenderer | ||
* \ingroup core | ||
* A renderer that automatically clusters points with the same geographic position. | ||
* \note added in QGIS 3.0 | ||
*/ | ||
class QgsPointClusterRenderer : QgsPointDistanceRenderer | ||
{ | ||
%TypeHeaderCode | ||
#include <qgspointclusterrenderer.h> | ||
%End | ||
public: | ||
|
||
QgsPointClusterRenderer(); | ||
|
||
virtual QgsPointClusterRenderer* clone() const /Factory/; | ||
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ); | ||
void stopRender( QgsRenderContext& context ); | ||
QDomElement save( QDomDocument& doc ); | ||
|
||
//! Create a renderer from XML element | ||
static QgsFeatureRenderer* create( QDomElement& symbologyElem ) /Factory/; | ||
|
||
/** Returns the symbol used for rendering clustered groups (but not ownership of the symbol). | ||
* @see setClusterSymbol() | ||
*/ | ||
QgsMarkerSymbol* clusterSymbol(); | ||
|
||
/** Sets the symbol for rendering clustered groups. | ||
* @param symbol new cluster symbol. Ownership is transferred to the renderer. | ||
* @see clusterSymbol() | ||
*/ | ||
void setClusterSymbol( QgsMarkerSymbol* symbol /Transfer/ ); | ||
|
||
/** Creates a QgsPointDisplacementRenderer from an existing renderer. | ||
* @note added in 2.5 | ||
* @returns a new renderer if the conversion was possible, otherwise nullptr. | ||
*/ | ||
static QgsPointClusterRenderer* convertFromRenderer( const QgsFeatureRenderer *renderer ) /Factory/; | ||
|
||
private: | ||
QgsPointClusterRenderer( const QgsPointClusterRenderer & ); | ||
QgsPointClusterRenderer & operator=( const QgsPointClusterRenderer & ); | ||
|
||
void drawGroup( QPointF centerPoint, QgsRenderContext& context, const QgsPointDistanceRenderer::ClusteredGroup& group ); | ||
}; |
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.