QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
61 
64  Q_PROPERTY( QgsUnitTypes::SystemOfMeasurement systemOfMeasurement MEMBER mSystemOfMeasurement NOTIFY systemOfMeasurementChanged )
65 
66 
69  Q_PROPERTY( QString units READ units NOTIFY scaleBarChanged )
70 
71 
76  Q_PROPERTY( int distance READ distance NOTIFY scaleBarChanged )
77 
78 
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 
113 
116 
119 
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
134 };
135 
136 
137 #endif // QGSQUICKSCALEBARKIT_H
QgsQuickScaleBarKit::mapSettingsChanged
void mapSettingsChanged()
Associated map settings.
QgsQuickScaleBarKit::systemOfMeasurementChanged
void systemOfMeasurementChanged()
Preferred system of measurement for the result.
QgsUnitTypes::SystemOfMeasurement
SystemOfMeasurement
Systems of unit measurement.
Definition: qgsunittypes.h:45
QgsQuickMapSettings
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
Definition: qgsquickmapsettings.h:47
QgsQuickScaleBarKit::preferredWidthChanged
void preferredWidthChanged()
Preferred width of scalebar in pixels.
QgsUnitTypes::MetricSystem
@ MetricSystem
International System of Units (SI)
Definition: qgsunittypes.h:47
QgsQuickScaleBarKit::scaleBarChanged
void scaleBarChanged()
width, distance and/or units changed
QgsQuickScaleBarKit
The class QgsQuickScaleBarKit encapsulates the utilities to calculate scale bar properties.
Definition: qgsquickscalebarkit.h:48
qgsquickutils.h
QgsQuickScaleBarKit::~QgsQuickScaleBarKit
~QgsQuickScaleBarKit()=default