QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
20#include <QString>
21
22using namespace Qt::StringLiterals;
23
24const QString QgsStackedDiagram::DIAGRAM_NAME_STACKED = u"StackedDiagram"_s;
25
28
30{
31 return new QgsStackedDiagram( *this );
32}
33
34void QgsStackedDiagram::subDiagramPosition( QPointF &newPos, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramSettings &subSettings )
35{
36 QSizeF size = sizePainterUnits( subSettings.size, subSettings, c );
37 const double spacing = c.convertToPainterUnits( s.stackedDiagramSpacing(), s.stackedDiagramSpacingUnit(), s.stackedDiagramSpacingMapUnitScale() );
38
40 {
41 newPos += QPointF( size.width() + spacing, 0 );
42 }
43 else
44 {
45 newPos -= QPointF( 0, size.height() + spacing );
46 }
47}
48
50{
51 Q_UNUSED( feature )
52 Q_UNUSED( c )
53 Q_UNUSED( s )
54 Q_UNUSED( is )
55 return QSize( 0, 0 );
56}
57
59{
60 Q_UNUSED( value )
61 Q_UNUSED( s )
62 Q_UNUSED( is )
63 return 0;
64}
65
70
72{
73 Q_UNUSED( attributes )
74 Q_UNUSED( c )
75 Q_UNUSED( s )
76 return QSizeF( 0, 0 );
77}
78
79void QgsStackedDiagram::renderDiagram( const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position )
80{
81 Q_UNUSED( feature )
82 Q_UNUSED( c )
83 Q_UNUSED( s )
84 Q_UNUSED( position )
85}
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:60
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