QGIS API Documentation  3.0.2-Girona (307d082)
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
6  email : [email protected]
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 <QRectF>
22 #include <QList>
23 
24 class QgsRenderContext;
26 
37 class CORE_EXPORT QgsScaleBarRenderer
38 {
39  public:
40 
45  {
47  double segmentWidth { 0.0 };
48 
54  QSizeF size;
55 
57  double scale { 1.0 };
58 
59  };
60 
64  QgsScaleBarRenderer() = default;
65  virtual ~QgsScaleBarRenderer() = default;
66 
70  virtual QString name() const = 0;
71 
75  virtual void draw( QgsRenderContext &context,
76  const QgsScaleBarSettings &settings,
77  const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const = 0;
78 
82  virtual QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
83  const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
84 
85  protected:
86 
90  void drawDefaultLabels( QgsRenderContext &context,
91  const QgsScaleBarSettings &settings,
92  const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
93 
97  QString firstLabelString( const QgsScaleBarSettings &settings ) const;
98 
102  double firstLabelXOffset( const QgsScaleBarSettings &settings ) const;
103 
107  QList<double> segmentPositions( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
108 
112  QList<double> segmentWidths( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
113 
114 };
115 
116 #endif //QGSSCALEBARRENDERER_H
QSizeF size
Destination size for scalebar.
Contains information about the context of a rendering operation.
Abstract base class for scale bar renderers.
The QgsScaleBarSettings class stores the appearance and layout settings for scalebar drawing with Qgs...
Contains parameters regarding scalebar calculations.