QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsquickscalebarkit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsquickscalebarkit.h
3  --------------------------------------
4  Date : Nov 2017
5  Copyright : (C) 2017 by Peter Petrik
6  Email : zilolv at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSQUICKSCALEBARKIT_H
17 #define QGSQUICKSCALEBARKIT_H
18 
19 #include <QObject>
20 #include <QString>
21 
22 #include "qgis_quick.h"
23 #include "qgsquickutils.h"
24 
26 
47 class QUICK_EXPORT QgsQuickScaleBarKit : public QObject
48 {
49  Q_OBJECT
50 
54  Q_PROPERTY( QgsQuickMapSettings *mapSettings MEMBER mMapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )
55 
56 
59  Q_PROPERTY( int preferredWidth MEMBER mPreferredWidth NOTIFY preferredWidthChanged )
60 
64  Q_PROPERTY( QgsUnitTypes::SystemOfMeasurement systemOfMeasurement MEMBER mSystemOfMeasurement NOTIFY systemOfMeasurementChanged )
65 
69  Q_PROPERTY( QString units READ units NOTIFY scaleBarChanged )
70 
76  Q_PROPERTY( int distance READ distance NOTIFY scaleBarChanged )
77 
82  Q_PROPERTY( int width READ width NOTIFY scaleBarChanged )
83 
84  public:
86  explicit QgsQuickScaleBarKit( QObject *parent = nullptr );
87  ~QgsQuickScaleBarKit() = default;
88 
90  void setMapSettings( QgsQuickMapSettings *mapSettings );
91 
93  int width() const;
94 
99  int distance() const;
100 
105  QString units() const;
106 
107  signals:
108 
112  void scaleBarChanged();
113 
115  void mapSettingsChanged();
116 
118  void preferredWidthChanged();
119 
121  void systemOfMeasurementChanged();
122 
123  public slots:
125  void updateScaleBar();
126 
127  private:
128  QgsQuickMapSettings *mMapSettings = nullptr; // not owned
129  int mPreferredWidth; // pixels
130  int mWidth; // pixels
131  int mDistance; // in meters or kilometers, rounded
132  QString mUnits; // e.g. km or m
133  QgsUnitTypes::SystemOfMeasurement mSystemOfMeasurement = QgsUnitTypes::MetricSystem;
134 };
135 
136 
137 #endif // QGSQUICKSCALEBARKIT_H
The class QgsQuickScaleBarKit encapsulates the utilies to calculate scale bar properties.
Helper functions for various unit types.
Definition: qgsunittypes.h:37
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...