QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsscalebarrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsscalebarrenderer.h
3 ---------------------
4 begin : June 2008
5 copyright : (C) 2008 by Marco Hugentobler
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSSCALEBARRENDERER_H
18#define QGSSCALEBARRENDERER_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include <QRectF>
23#include <QList>
24
27
37class CORE_EXPORT QgsScaleBarRenderer
38{
39 public:
40
45 enum class Flag : int SIP_ENUM_BASETYPE( IntFlag )
46 {
47 FlagUsesLineSymbol = 1 << 0,
48 FlagUsesFillSymbol = 1 << 1,
49 FlagUsesAlternateFillSymbol = 1 << 2,
50 FlagRespectsUnits = 1 << 3,
51 FlagRespectsMapUnitsPerScaleBarUnit = 1 << 4,
52 FlagUsesUnitLabel = 1 << 5,
53 FlagUsesSegments = 1 << 6,
54 FlagUsesLabelBarSpace = 1 << 7,
55 FlagUsesLabelVerticalPlacement = 1 << 8,
56 FlagUsesLabelHorizontalPlacement = 1 << 8,
57 FlagUsesAlignment = 1 << 9,
58 FlagUsesSubdivisions = 1 << 10,
59 FlagUsesDivisionSymbol = 1 << 11,
60 FlagUsesSubdivisionSymbol = 1 << 12,
61 FlagUsesSubdivisionsHeight = 1 << 13,
62 };
63 Q_DECLARE_FLAGS( Flags, Flag )
64
65
70 {
71
76 double segmentWidth { 0.0 };
77
83 QSizeF size;
84
86 double scale { 1.0 };
87
90
91 };
92
97 virtual ~QgsScaleBarRenderer() = default;
98
103 Q_DECL_DEPRECATED QString name() const SIP_DEPRECATED { return id(); }
104
109 virtual QString id() const = 0;
110
115 virtual QString visibleName() const = 0;
116
122 virtual Flags flags() const;
123
129 virtual int sortKey() const;
130
135
139 virtual void draw( QgsRenderContext &context,
140 const QgsScaleBarSettings &settings,
141 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const = 0;
142
147 Q_DECL_DEPRECATED virtual QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
148 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const SIP_DEPRECATED;
149
155 virtual QSizeF calculateBoxSize( QgsRenderContext &context,
156 const QgsScaleBarSettings &settings,
157 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
158
166 virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
167
168 protected:
169
173 void drawDefaultLabels( QgsRenderContext &context,
174 const QgsScaleBarSettings &settings,
175 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
176
180 QString firstLabelString( const QgsScaleBarSettings &settings ) const;
181
186 Q_DECL_DEPRECATED double firstLabelXOffset( const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
187
192 double firstLabelXOffset( const QgsScaleBarSettings &settings, const QgsRenderContext &context, const ScaleBarContext &scaleContext ) const;
193
198 Q_DECL_DEPRECATED QList<double> segmentPositions( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
199
204 QList<double> segmentPositions( QgsRenderContext &context, const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
205
209 QList<double> segmentWidths( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
210
211};
212
214
215#endif //QGSSCALEBARRENDERER_H
Contains information about the context of a rendering operation.
Abstract base class for scale bar renderers.
virtual void draw(QgsRenderContext &context, const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const =0
Draws the scalebar using the specified settings and scaleContext to a destination render context.
Q_DECL_DEPRECATED QString name() const
Returns the unique name for this style.
virtual ~QgsScaleBarRenderer()=default
virtual QString visibleName() const =0
Returns the user friendly, translated name for the renderer.
QgsScaleBarRenderer()=default
Constructor for QgsScaleBarRenderer.
virtual QgsScaleBarRenderer * clone() const =0
Returns a clone of the renderer.
Flag
Flags which control scalebar renderer behavior.
virtual QString id() const =0
Returns the unique ID for this renderer.
The QgsScaleBarSettings class stores the appearance and layout settings for scalebar drawing with Qgs...
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
#define SIP_FACTORY
Definition qgis_sip.h:76
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
Contains parameters regarding scalebar calculations.
Flags flags
Scalebar renderer flags.
QSizeF size
Destination size for scalebar.