QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsstackeddiagram.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsstackediagram.cpp
3 ---------------------
4 begin : June 2024
5 copyright : (C) 2024 by Germán Carrillo
6 email : german at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#include "qgsstackeddiagram.h"
16
17#include "qgsdiagramrenderer.h"
18#include "qgsrendercontext.h"
19
20const QString QgsStackedDiagram::DIAGRAM_NAME_STACKED = QStringLiteral( "StackedDiagram" );
21
25
27{
28 return new QgsStackedDiagram( *this );
29}
30
31void QgsStackedDiagram::subDiagramPosition( QPointF &newPos, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramSettings &subSettings )
32{
33 QSizeF size = sizePainterUnits( subSettings.size, subSettings, c );
34 const double spacing = c.convertToPainterUnits( s.stackedDiagramSpacing(), s.stackedDiagramSpacingUnit(), s.stackedDiagramSpacingMapUnitScale() );
35
37 {
38 newPos += QPointF( size.width() + spacing, 0 );
39 }
40 else
41 {
42 newPos -= QPointF( 0, size.height() + spacing );
43 }
44}
45
47{
48 Q_UNUSED( feature )
49 Q_UNUSED( c )
50 Q_UNUSED( s )
51 Q_UNUSED( is )
52 return QSize( 0, 0 );
53}
54
56{
57 Q_UNUSED( value )
58 Q_UNUSED( s )
59 Q_UNUSED( is )
60 return 0;
61}
62
67
69{
70 Q_UNUSED( attributes )
71 Q_UNUSED( c )
72 Q_UNUSED( s )
73 return QSizeF( 0, 0 );
74}
75
76void QgsStackedDiagram::renderDiagram( const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position )
77{
78 Q_UNUSED( feature )
79 Q_UNUSED( c )
80 Q_UNUSED( s )
81 Q_UNUSED( position )
82}
A vector of attributes.
Additional diagram settings for interpolated size rendering.
Stores the settings for rendering a single diagram.
StackedDiagramMode stackedDiagramMode
Qgis::RenderUnit stackedDiagramSpacingUnit() const
Returns the units for the spacing between subdiagrams in a stacked diagram.
const QgsMapUnitScale & stackedDiagramSpacingMapUnitScale() const
Returns the map unit scale for the spacing between subdiagrams in a stacked diagram.
double stackedDiagramSpacing() const
Returns the spacing between subdiagrams in a stacked diagram.
QSizeF sizePainterUnits(QSizeF size, const QgsDiagramSettings &s, const QgsRenderContext &c)
Calculates a size to match the current settings and rendering context.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Contains information about the context of a rendering operation.
static const QString DIAGRAM_NAME_STACKED
QgsStackedDiagram * clone() const override
Returns an instance that is equivalent to this one.
void subDiagramPosition(QPointF &newPos, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramSettings &subSettings)
Calculates the position for the next subdiagram, updating the newPos object.
QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s) override
Returns the size in map units the diagram will use to render.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position) override
Draws the diagram at the given position (in pixel coordinates).
QString diagramName() const override
Gets a descriptive name for this diagram type.
double legendSize(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is) const override
Returns the size of the legend item for the diagram corresponding to a specified value.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c