QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
69 struct CORE_EXPORT ScaleBarContext
70 {
71
76 double segmentWidth { 0.0 };
77
83 QSizeF size;
84
86 double scale { 1.0 };
87
90
96 bool isValid() const;
97
98 };
99
101 virtual ~QgsScaleBarRenderer() = default;
102
107 Q_DECL_DEPRECATED QString name() const SIP_DEPRECATED { return id(); }
108
113 virtual QString id() const = 0;
114
119 virtual QString visibleName() const = 0;
120
126 virtual Flags flags() const;
127
133 virtual int sortKey() const;
134
139
143 virtual void draw( QgsRenderContext &context,
144 const QgsScaleBarSettings &settings,
145 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const = 0;
146
151 Q_DECL_DEPRECATED virtual QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
152 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const SIP_DEPRECATED;
153
159 virtual QSizeF calculateBoxSize( QgsRenderContext &context,
160 const QgsScaleBarSettings &settings,
161 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
162
170 virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
171
172 protected:
173
177 void drawDefaultLabels( QgsRenderContext &context,
178 const QgsScaleBarSettings &settings,
179 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
180
184 QString firstLabelString( const QgsScaleBarSettings &settings ) const;
185
190 Q_DECL_DEPRECATED double firstLabelXOffset( const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
191
196 double firstLabelXOffset( const QgsScaleBarSettings &settings, const QgsRenderContext &context, const ScaleBarContext &scaleContext ) const;
197
202 Q_DECL_DEPRECATED QList<double> segmentPositions( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
203
208 QList<double> segmentPositions( QgsRenderContext &context, const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
209
213 QList<double> segmentWidths( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
214
215};
216
218
219#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
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.