QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
38class CORE_EXPORT QgsScaleBarRenderer
39{
40 public:
41
46 enum class Flag
47 {
48 FlagUsesLineSymbol = 1 << 0,
49 FlagUsesFillSymbol = 1 << 1,
50 FlagUsesAlternateFillSymbol = 1 << 2,
51 FlagRespectsUnits = 1 << 3,
52 FlagRespectsMapUnitsPerScaleBarUnit = 1 << 4,
53 FlagUsesUnitLabel = 1 << 5,
54 FlagUsesSegments = 1 << 6,
55 FlagUsesLabelBarSpace = 1 << 7,
56 FlagUsesLabelVerticalPlacement = 1 << 8,
57 FlagUsesLabelHorizontalPlacement = 1 << 8,
58 FlagUsesAlignment = 1 << 9,
59 FlagUsesSubdivisions = 1 << 10,
60 FlagUsesDivisionSymbol = 1 << 11,
61 FlagUsesSubdivisionSymbol = 1 << 12,
62 FlagUsesSubdivisionsHeight = 1 << 13,
63 };
64 Q_DECLARE_FLAGS( Flags, Flag )
65
66
71 {
72
77 double segmentWidth { 0.0 };
78
84 QSizeF size;
85
87 double scale { 1.0 };
88
90 Flags flags;
91
92 };
93
98 virtual ~QgsScaleBarRenderer() = default;
99
104 Q_DECL_DEPRECATED QString name() const SIP_DEPRECATED { return id(); }
105
110 virtual QString id() const = 0;
111
116 virtual QString visibleName() const = 0;
117
123 virtual Flags flags() const;
124
130 virtual int sortKey() const;
131
136
140 virtual void draw( QgsRenderContext &context,
141 const QgsScaleBarSettings &settings,
142 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const = 0;
143
148 Q_DECL_DEPRECATED virtual QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
149 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const SIP_DEPRECATED;
150
156 virtual QSizeF calculateBoxSize( QgsRenderContext &context,
157 const QgsScaleBarSettings &settings,
158 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
159
167 virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
168
169 protected:
170
174 void drawDefaultLabels( QgsRenderContext &context,
175 const QgsScaleBarSettings &settings,
176 const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
177
181 QString firstLabelString( const QgsScaleBarSettings &settings ) const;
182
187 Q_DECL_DEPRECATED double firstLabelXOffset( const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
188
193 double firstLabelXOffset( const QgsScaleBarSettings &settings, const QgsRenderContext &context, const ScaleBarContext &scaleContext ) const;
194
199 Q_DECL_DEPRECATED QList<double> segmentPositions( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
200
205 QList<double> segmentPositions( QgsRenderContext &context, const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
206
210 QList<double> segmentWidths( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
211
212};
213
214Q_DECLARE_OPERATORS_FOR_FLAGS( QgsScaleBarRenderer::Flags )
215
216#endif //QGSSCALEBARRENDERER_H
Contains information about the context of a rendering operation.
Abstract base class for scale bar renderers.
Flag
Flags which control scalebar renderer behavior.
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.
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_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.