QGIS API Documentation  3.2.0-Bonn (bc43194)
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 "qgis_sip.h"
22 #include <QRectF>
23 #include <QList>
24 
25 class QgsRenderContext;
27 
38 class CORE_EXPORT QgsScaleBarRenderer
39 {
40  public:
41 
47  {
48 
53  double segmentWidth { 0.0 };
54 
60  QSizeF size;
61 
63  double scale { 1.0 };
64 
65  };
66 
70  QgsScaleBarRenderer() = default;
71  virtual ~QgsScaleBarRenderer() = default;
72 
76  virtual QString name() const = 0;
77 
81  virtual void draw( QgsRenderContext &context,
82  const QgsScaleBarSettings &settings,
83  const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const = 0;
84 
88  virtual QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
89  const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
90 
91  protected:
92 
96  void drawDefaultLabels( QgsRenderContext &context,
97  const QgsScaleBarSettings &settings,
98  const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;
99 
103  QString firstLabelString( const QgsScaleBarSettings &settings ) const;
104 
109  Q_DECL_DEPRECATED double firstLabelXOffset( const QgsScaleBarSettings &settings ) const SIP_DEPRECATED;
110 
115  double firstLabelXOffset( const QgsScaleBarSettings &settings, const QgsRenderContext &context ) const;
116 
120  QList<double> segmentPositions( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
121 
125  QList<double> segmentWidths( const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings ) const;
126 
127 };
128 
129 #endif //QGSSCALEBARRENDERER_H
QSizeF size
Destination size for scalebar.
#define SIP_DEPRECATED
Definition: qgis_sip.h:99
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.