QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
44 class QUICK_EXPORT QgsQuickScaleBarKit : public QObject
45 {
46  Q_OBJECT
47 
51  Q_PROPERTY( QgsQuickMapSettings *mapSettings MEMBER mMapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )
52 
53 
56  Q_PROPERTY( int preferredWidth MEMBER mPreferredWidth NOTIFY preferredWidthChanged )
57 
61  Q_PROPERTY( QString units READ units NOTIFY scaleBarChanged )
62 
66  Q_PROPERTY( int distance READ distance NOTIFY scaleBarChanged )
67 
72  Q_PROPERTY( int width READ width NOTIFY scaleBarChanged )
73 
74  public:
76  explicit QgsQuickScaleBarKit( QObject *parent = nullptr );
77  ~QgsQuickScaleBarKit() = default;
78 
80  void setMapSettings( QgsQuickMapSettings *mapSettings );
81 
83  int width() const;
84 
89  int distance() const;
90 
95  QString units() const;
96 
97  signals:
98 
102  void scaleBarChanged();
103 
105  void mapSettingsChanged();
106 
108  void preferredWidthChanged();
109 
110  public slots:
112  void updateScaleBar();
113 
114  private:
115  QgsQuickMapSettings *mMapSettings = nullptr; // not owned
116  int mPreferredWidth; // pixels
117  int mWidth; // pixels
118  int mDistance; // in meters or kilometers, rounded
119  QString mUnits; // km or m
120 };
121 
122 
123 #endif // QGSQUICKSCALEBARKIT_H
The class QgsQuickScaleBarKit encapsulates the utilies to calculate scale bar properties.
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...