QGIS API Documentation
3.4.15-Madeira (e83d02e274)
|
The class QgsQuickScaleBarKit encapsulates the utilies to calculate scale bar properties. More...
#include <qgsquickscalebarkit.h>
Public Slots | |
void | updateScaleBar () |
recalculate width, distance and units. More... | |
Signals | |
void | mapSettingsChanged () |
Associated map settings. More... | |
void | preferredWidthChanged () |
Preferred width of scalebar in pixels. More... | |
void | scaleBarChanged () |
width, distance and/or units changed More... | |
void | systemOfMeasurementChanged () |
Preferred system of measurement for the result. More... | |
Public Member Functions | |
QgsQuickScaleBarKit (QObject *parent=nullptr) | |
create new scale bar kit More... | |
~QgsQuickScaleBarKit ()=default | |
int | distance () const |
Units of distance (e.g. More... | |
void | setMapSettings (QgsQuickMapSettings *mapSettings) |
Associated map settings. More... | |
QString | units () const |
Units of distance (e.g. More... | |
int | width () const |
Calculated width of scalebar in pixels representing distance + units. More... | |
Properties | |
int | distance |
Distance rounded to "nice" number (e.g. More... | |
QgsQuickMapSettings | mapSettings |
Associated map settings. More... | |
int | preferredWidth |
Preferred width of scalebar in pixels. More... | |
QgsUnitTypes::SystemOfMeasurement | systemOfMeasurement |
Preferred system of measurement for the result. More... | |
QString | units |
Units of distance (e.g. More... | |
int | width |
Calculated width of scalebar in pixels representing distance + units. More... | |
The class QgsQuickScaleBarKit encapsulates the utilies to calculate scale bar properties.
It requires connection to mapSettings of the active canvas to automatically update text and width
From preferred width in pixel, it calculates the width (pixel) of scalebar distance in meters or kilometers (int) rounded to "nice" number (e.g. 72.4 to 100) and units text (e.g. km)
System of measurement for result could be set too, so for example the resulting scalebar can show results in the imperial units.
Definition at line 47 of file qgsquickscalebarkit.h.
|
explicit |
create new scale bar kit
Definition at line 27 of file qgsquickscalebarkit.cpp.
|
default |
int QgsQuickScaleBarKit::distance | ( | ) | const |
Units of distance (e.g.
km or m) of result in desired systemOfMeasurement Read-only (result).
|
signal |
Associated map settings.
Should be initialized before the first use from mapcanvas map settings.
|
signal |
Preferred width of scalebar in pixels.
Default set to 300.
|
signal |
width, distance and/or units changed
void QgsQuickScaleBarKit::setMapSettings | ( | QgsQuickMapSettings * | mapSettings | ) |
Associated map settings.
Should be initialized before the first use from mapcanvas map settings.
Definition at line 38 of file qgsquickscalebarkit.cpp.
|
signal |
Preferred system of measurement for the result.
QString QgsQuickScaleBarKit::units | ( | ) | const |
Units of distance (e.g.
km or m) of result in desired systemOfMeasurement Read-only (result).
|
slot |
recalculate width, distance and units.
Definition at line 80 of file qgsquickscalebarkit.cpp.
int QgsQuickScaleBarKit::width | ( | ) | const |
Calculated width of scalebar in pixels representing distance + units.
Differs minimum possible from preferredWidth to Gets "nice" distance number.
|
read |
Distance rounded to "nice" number (e.g.
100, 20) corresponding to width and system of measurement
To be used with units property for labels. Read-only (result).
Definition at line 76 of file qgsquickscalebarkit.h.
|
write |
Associated map settings.
Should be initialized before the first use from mapcanvas map settings.
Definition at line 54 of file qgsquickscalebarkit.h.
int QgsQuickScaleBarKit::preferredWidth |
Preferred width of scalebar in pixels.
Default set to 300.
Definition at line 59 of file qgsquickscalebarkit.h.
QgsUnitTypes::SystemOfMeasurement QgsQuickScaleBarKit::systemOfMeasurement |
Preferred system of measurement for the result.
Definition at line 64 of file qgsquickscalebarkit.h.
|
read |
Units of distance (e.g.
km or m) of result in desired systemOfMeasurement Read-only (result).
Definition at line 69 of file qgsquickscalebarkit.h.
|
read |
Calculated width of scalebar in pixels representing distance + units.
Differs minimum possible from preferredWidth to Gets "nice" distance number.
Definition at line 82 of file qgsquickscalebarkit.h.