QGIS API Documentation 3.41.0-Master (cea29feecf2)
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#include "qgsdiagramrenderer.h"
17#include "qgsrendercontext.h"
18
19const QString QgsStackedDiagram::DIAGRAM_NAME_STACKED = QStringLiteral( "StackedDiagram" );
20
24
26{
27 return new QgsStackedDiagram( *this );
28}
29
30void QgsStackedDiagram::subDiagramPosition( QPointF &newPos, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramSettings &subSettings )
31{
32 QSizeF size = sizePainterUnits( subSettings.size, subSettings, c );
33 const double spacing = c.convertToPainterUnits( s.stackedDiagramSpacing(), s.stackedDiagramSpacingUnit(), s.stackedDiagramSpacingMapUnitScale() );
34
36 {
37 newPos += QPointF( size.width() + spacing, 0 );
38 }
39 else
40 {
41 newPos -= QPointF( 0, size.height() + spacing );
42 }
43}
44
46{
47 Q_UNUSED( feature )
48 Q_UNUSED( c )
49 Q_UNUSED( s )
50 Q_UNUSED( is )
51 return QSize( 0, 0 );
52}
53
55{
56 Q_UNUSED( value )
57 Q_UNUSED( s )
58 Q_UNUSED( is )
59 return 0;
60}
61
66
68{
69 Q_UNUSED( attributes )
70 Q_UNUSED( c )
71 Q_UNUSED( s )
72 return QSizeF( 0, 0 );
73}
74
75void QgsStackedDiagram::renderDiagram( const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position )
76{
77 Q_UNUSED( feature )
78 Q_UNUSED( c )
79 Q_UNUSED( s )
80 Q_UNUSED( position )
81}
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.
A diagram composed of several subdiagrams, located side by side.
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