QGIS API Documentation  3.6.0-Noosa (5873452)
Public Slots | Signals | Public Member Functions | Properties | List of all members
QgsQuickScaleBarKit Class Reference

The class QgsQuickScaleBarKit encapsulates the utilies to calculate scale bar properties. More...

#include <qgsquickscalebarkit.h>

Inheritance diagram for QgsQuickScaleBarKit:
Inheritance graph
[legend]

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...
 

Detailed Description

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.

Note
QML Type: ScaleBarKit
Since
QGIS 3.2

Definition at line 47 of file qgsquickscalebarkit.h.

Constructor & Destructor Documentation

◆ QgsQuickScaleBarKit()

QgsQuickScaleBarKit::QgsQuickScaleBarKit ( QObject *  parent = nullptr)
explicit

create new scale bar kit

Definition at line 27 of file qgsquickscalebarkit.cpp.

◆ ~QgsQuickScaleBarKit()

QgsQuickScaleBarKit::~QgsQuickScaleBarKit ( )
default

Member Function Documentation

◆ distance()

int QgsQuickScaleBarKit::distance ( ) const

Units of distance (e.g.

km or m) of result in desired systemOfMeasurement Read-only (result).

See also
QgsQuickScaleBarKit::units()

◆ mapSettingsChanged

void QgsQuickScaleBarKit::mapSettingsChanged ( )
signal

Associated map settings.

Should be initialized before the first use from mapcanvas map settings.

◆ preferredWidthChanged

void QgsQuickScaleBarKit::preferredWidthChanged ( )
signal

Preferred width of scalebar in pixels.

Default set to 300.

◆ scaleBarChanged

void QgsQuickScaleBarKit::scaleBarChanged ( )
signal

width, distance and/or units changed

◆ setMapSettings()

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.

◆ systemOfMeasurementChanged

void QgsQuickScaleBarKit::systemOfMeasurementChanged ( )
signal

Preferred system of measurement for the result.

◆ units()

QString QgsQuickScaleBarKit::units ( ) const

Units of distance (e.g.

km or m) of result in desired systemOfMeasurement Read-only (result).

See also
QgsQuickScaleBarKit::distance()

◆ updateScaleBar

void QgsQuickScaleBarKit::updateScaleBar ( )
slot

recalculate width, distance and units.

Definition at line 80 of file qgsquickscalebarkit.cpp.

◆ width()

int QgsQuickScaleBarKit::width ( ) const

Calculated width of scalebar in pixels representing distance + units.

Differs minimum possible from preferredWidth to Gets "nice" distance number.

Property Documentation

◆ distance

int QgsQuickScaleBarKit::distance
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.

◆ mapSettings

QgsQuickMapSettings QgsQuickScaleBarKit::mapSettings
write

Associated map settings.

Should be initialized before the first use from mapcanvas map settings.

Definition at line 54 of file qgsquickscalebarkit.h.

◆ preferredWidth

int QgsQuickScaleBarKit::preferredWidth

Preferred width of scalebar in pixels.

Default set to 300.

Definition at line 59 of file qgsquickscalebarkit.h.

◆ systemOfMeasurement

QgsUnitTypes::SystemOfMeasurement QgsQuickScaleBarKit::systemOfMeasurement

Preferred system of measurement for the result.

Definition at line 64 of file qgsquickscalebarkit.h.

◆ units

QString QgsQuickScaleBarKit::units
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.

◆ width

int QgsQuickScaleBarKit::width
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.


The documentation for this class was generated from the following files: