QGIS API Documentation  3.2.0-Bonn (bc43194)
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...
 

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

Note
QML Type: ScaleBarKit
Since
QGIS 3.2

Definition at line 44 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) 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.

◆ units()

QString QgsQuickScaleBarKit::units ( ) const

Units of distance (e.g.

km or m) 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. To be used with units property for labels. Read-only (result).

Definition at line 66 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 51 of file qgsquickscalebarkit.h.

◆ preferredWidth

int QgsQuickScaleBarKit::preferredWidth

Preferred width of scalebar in pixels.

Default set to 300.

Definition at line 56 of file qgsquickscalebarkit.h.

◆ units

QString QgsQuickScaleBarKit::units
read

Units of distance (e.g.

km or m) Read-only (result).

Definition at line 61 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 72 of file qgsquickscalebarkit.h.


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