QGIS API Documentation  3.20.0-Odense (decaadbb31)
Signals | Public Member Functions | Properties | List of all members
QgsQuickMapSettings Class Reference

The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of map rendering via QML properties. More...

#include <qgsquickmapsettings.h>

Inheritance diagram for QgsQuickMapSettings:
Inheritance graph
[legend]

Signals

void backgroundColorChanged ()
 The background color used to render the map. More...
 
void destinationCrsChanged ()
 CRS of destination coordinate reference system. More...
 
void extentChanged ()
 Geographical coordinates of the rectangle that should be rendered. More...
 
void layersChanged ()
 Set list of layers for map rendering. More...
 
void mapUnitsPerPixelChanged ()
 Returns the distance in geographical coordinates that equals to one pixel in the map. More...
 
void mapUnitsPerPointChanged ()
 Returns the distance in geographical coordinates that equals to one point unit in the map. More...
 
void outputDpiChanged ()
 Output DPI used for conversion between real world units (e.g. More...
 
void outputSizeChanged ()
 The size of the resulting map image. More...
 
void projectChanged ()
 A project property should be used as a primary source of project all other components in the application. More...
 
void rotationChanged ()
 The rotation of the resulting map image, in degrees clockwise. More...
 
void visibleExtentChanged ()
 Returns the actual extent derived from requested extent that takes takes output image size into account. More...
 

Public Member Functions

 QgsQuickMapSettings (QObject *parent=nullptr)
 Create new map settings. More...
 
 ~QgsQuickMapSettings ()=default
 
QColor backgroundColor () const
 The background color used to render the map. More...
 
Q_INVOKABLE QPointF coordinateToScreen (const QgsPoint &point) const
 Convert a map coordinate to screen pixel coordinates. More...
 
QgsCoordinateReferenceSystem destinationCrs () const
 Returns the destination coordinate reference system for the map render. More...
 
qreal devicePixelRatio () const
 Returns the ratio between physical pixels and device-independent pixels. More...
 
QgsRectangle extent () const
 Returns geographical coordinates of the rectangle that should be rendered. More...
 
QList< QgsMapLayer * > layers () const
 Returns the list of layers which will be rendered in the map. More...
 
QgsMapSettings mapSettings () const
 Clone map settings. More...
 
double mapUnitsPerPixel () const
 Returns the distance in geographical coordinates that equals to one pixel in the map. More...
 
double mapUnitsPerPoint () const
 Returns the distance in geographical coordinates that equals to one point unit in the map. More...
 
double outputDpi () const
 Returns the DPI (dots per inch) used for conversion between real world units (e.g. More...
 
QSize outputSize () const
 Returns the size of the resulting map image, in pixels. More...
 
QgsProjectproject () const
 A project property should be used as a primary source of project all other components in the application. More...
 
double rotation () const
 The rotation of the resulting map image, in degrees clockwise. More...
 
Q_INVOKABLE QgsPoint screenToCoordinate (const QPointF &point) const
 Convert a screen coordinate to a map coordinate. More...
 
void setBackgroundColor (const QColor &color)
 The background color used to render the map. More...
 
Q_INVOKABLE void setCenter (const QgsPoint &center)
 Move current map extent to have center point defined by center. More...
 
Q_INVOKABLE void setCenterToLayer (QgsMapLayer *layer, bool shouldZoom=true)
 Move current map extent to have center point defined by layer. Optionally only pan to the layer if shouldZoom is false. More...
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &destinationCrs)
 Sets the destination crs (coordinate reference system) for the map render. More...
 
void setDevicePixelRatio (const qreal &devicePixelRatio)
 Sets the ratio between physical pixels and device-independent pixels. More...
 
void setExtent (const QgsRectangle &extent)
 Sets the coordinates of the rectangle which should be rendered. More...
 
void setLayers (const QList< QgsMapLayer * > &layers)
 Sets the list of layers to render in the map. More...
 
void setOutputDpi (double outputDpi)
 Sets the dpi (dots per inch) used for conversion between real world units (e.g. More...
 
void setOutputSize (QSize outputSize)
 Sets the size of the resulting map image, in pixels. More...
 
void setProject (QgsProject *project)
 A project property should be used as a primary source of project all other components in the application. More...
 
void setRotation (double rotation)
 The rotation of the resulting map image, in degrees clockwise. More...
 
void setTransformContext (const QgsCoordinateTransformContext &context)
 Sets the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system. More...
 
Q_INVOKABLE QgsCoordinateTransformContext transformContext () const
 Returns the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system. More...
 
QgsRectangle visibleExtent () const
 Returns the actual extent derived from requested extent that takes takes output image size into account. More...
 

Properties

QColor backgroundColor
 The background color used to render the map. More...
 
QgsCoordinateReferenceSystem destinationCrs
 CRS of destination coordinate reference system. More...
 
QgsRectangle extent
 Geographical coordinates of the rectangle that should be rendered. More...
 
QList< QgsMapLayer * > layers
 Set list of layers for map rendering. More...
 
double mapUnitsPerPixel
 Returns the distance in geographical coordinates that equals to one pixel in the map. More...
 
double mapUnitsPerPoint
 Returns the distance in geographical coordinates that equals to one point unit in the map. More...
 
double outputDpi
 Output DPI used for conversion between real world units (e.g. More...
 
QSize outputSize
 The size of the resulting map image. More...
 
QgsProjectproject
 A project property should be used as a primary source of project all other components in the application. More...
 
double rotation
 The rotation of the resulting map image, in degrees clockwise. More...
 
QgsRectangle visibleExtent
 Returns the actual extent derived from requested extent that takes takes output image size into account. More...
 

Detailed Description

The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of map rendering via QML properties.

On top of QgsMapSettings functionality, when QgsProject is attached, it automatically loads its default settings from the project. QgsProject should be attached before it is read.

Note
QML Type: MapSettings
See also
QgsMapCanvas
Since
QGIS 3.2

Definition at line 47 of file qgsquickmapsettings.h.

Constructor & Destructor Documentation

◆ QgsQuickMapSettings()

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

Create new map settings.

Definition at line 25 of file qgsquickmapsettings.cpp.

◆ ~QgsQuickMapSettings()

QgsQuickMapSettings::~QgsQuickMapSettings ( )
default

Member Function Documentation

◆ backgroundColor()

QColor QgsQuickMapSettings::backgroundColor ( ) const

The background color used to render the map.

The value is set to the project's background color setting on QgsProject::readProject

Definition at line 270 of file qgsquickmapsettings.cpp.

◆ backgroundColorChanged

void QgsQuickMapSettings::backgroundColorChanged ( )
signal

The background color used to render the map.

The value is set to the project's background color setting on QgsProject::readProject

◆ coordinateToScreen()

QPointF QgsQuickMapSettings::coordinateToScreen ( const QgsPoint point) const

Convert a map coordinate to screen pixel coordinates.

Parameters
pointA coordinate in map coordinates
Returns
A coordinate in pixel / screen space

Definition at line 134 of file qgsquickmapsettings.cpp.

◆ destinationCrs()

QgsCoordinateReferenceSystem QgsQuickMapSettings::destinationCrs ( ) const

Returns the destination coordinate reference system for the map render.

See also
setDestinationCrs()

Definition at line 185 of file qgsquickmapsettings.cpp.

◆ destinationCrsChanged

void QgsQuickMapSettings::destinationCrsChanged ( )
signal

CRS of destination coordinate reference system.

Automatically loaded from project on QgsProject::readProject

◆ devicePixelRatio()

qreal QgsQuickMapSettings::devicePixelRatio ( ) const

Returns the ratio between physical pixels and device-independent pixels.

This value is dependent on the screen the window is on, and may change when the window is moved. Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays.

Definition at line 284 of file qgsquickmapsettings.cpp.

◆ extent()

QgsRectangle QgsQuickMapSettings::extent ( ) const

Returns geographical coordinates of the rectangle that should be rendered.

Warning
The actual visible extent used for rendering can be significantly different from this value, since the given extent may be expanded in order to fit the aspect ratio of the outputSize(). Use visibleExtent() to get the actual extent which will be rendered.
See also
visibleExtent()
setExtent()

Definition at line 77 of file qgsquickmapsettings.cpp.

◆ extentChanged

void QgsQuickMapSettings::extentChanged ( )
signal

Geographical coordinates of the rectangle that should be rendered.

The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use QgsQuickMapSettings::visibleExtent to get the resulting extent.

Automatically loaded from project on QgsProject::readProject

◆ layers()

QList< QgsMapLayer * > QgsQuickMapSettings::layers ( ) const

Returns the list of layers which will be rendered in the map.

The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)

See also
setLayers()

Definition at line 199 of file qgsquickmapsettings.cpp.

◆ layersChanged

void QgsQuickMapSettings::layersChanged ( )
signal

Set list of layers for map rendering.

The layers must be registered in QgsProject. The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)

Note
Any non-spatial layers will be automatically stripped from the list (since they cannot be rendered!).

Not loaded automatically from the associated project

◆ mapSettings()

QgsMapSettings QgsQuickMapSettings::mapSettings ( ) const

Clone map settings.

Definition at line 149 of file qgsquickmapsettings.cpp.

◆ mapUnitsPerPixel()

double QgsQuickMapSettings::mapUnitsPerPixel ( ) const

Returns the distance in geographical coordinates that equals to one pixel in the map.

Definition at line 104 of file qgsquickmapsettings.cpp.

◆ mapUnitsPerPixelChanged

void QgsQuickMapSettings::mapUnitsPerPixelChanged ( )
signal

Returns the distance in geographical coordinates that equals to one pixel in the map.

◆ mapUnitsPerPoint()

double QgsQuickMapSettings::mapUnitsPerPoint ( ) const

Returns the distance in geographical coordinates that equals to one point unit in the map.

Definition at line 124 of file qgsquickmapsettings.cpp.

◆ mapUnitsPerPointChanged

void QgsQuickMapSettings::mapUnitsPerPointChanged ( )
signal

Returns the distance in geographical coordinates that equals to one point unit in the map.

◆ outputDpi()

double QgsQuickMapSettings::outputDpi ( ) const

Returns the DPI (dots per inch) used for conversion between real world units (e.g.

mm) and pixels.

The default value is 96 dpi.

See also
setOutputDpi()

Definition at line 170 of file qgsquickmapsettings.cpp.

◆ outputDpiChanged

void QgsQuickMapSettings::outputDpiChanged ( )
signal

Output DPI used for conversion between real world units (e.g.

mm) and pixels

Automatically loaded from project on QgsProject::readProject

◆ outputSize()

QSize QgsQuickMapSettings::outputSize ( ) const

Returns the size of the resulting map image, in pixels.

See also
setOutputSize()

Definition at line 154 of file qgsquickmapsettings.cpp.

◆ outputSizeChanged

void QgsQuickMapSettings::outputSizeChanged ( )
signal

The size of the resulting map image.

Automatically loaded from project on QgsProject::readProject

◆ project()

QgsProject * QgsQuickMapSettings::project ( ) const

A project property should be used as a primary source of project all other components in the application.

QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::read)

When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.

Definition at line 67 of file qgsquickmapsettings.cpp.

◆ projectChanged

void QgsQuickMapSettings::projectChanged ( )
signal

A project property should be used as a primary source of project all other components in the application.

QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::read)

When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.

◆ rotation()

double QgsQuickMapSettings::rotation ( ) const

The rotation of the resulting map image, in degrees clockwise.

Map canvas rotation support is not implemented, 0 is used

Definition at line 259 of file qgsquickmapsettings.cpp.

◆ rotationChanged

void QgsQuickMapSettings::rotationChanged ( )
signal

The rotation of the resulting map image, in degrees clockwise.

Map canvas rotation support is not implemented, 0 is used

◆ screenToCoordinate()

QgsPoint QgsQuickMapSettings::screenToCoordinate ( const QPointF &  point) const

Convert a screen coordinate to a map coordinate.

Parameters
pointA coordinate in pixel / screen coordinates
Returns
A coordinate in map coordinates

Definition at line 143 of file qgsquickmapsettings.cpp.

◆ setBackgroundColor()

void QgsQuickMapSettings::setBackgroundColor ( const QColor &  color)

The background color used to render the map.

The value is set to the project's background color setting on QgsProject::readProject

Definition at line 275 of file qgsquickmapsettings.cpp.

◆ setCenter()

void QgsQuickMapSettings::setCenter ( const QgsPoint center)

Move current map extent to have center point defined by center.

Definition at line 91 of file qgsquickmapsettings.cpp.

◆ setCenterToLayer()

void QgsQuickMapSettings::setCenterToLayer ( QgsMapLayer layer,
bool  shouldZoom = true 
)

Move current map extent to have center point defined by layer. Optionally only pan to the layer if shouldZoom is false.

Definition at line 109 of file qgsquickmapsettings.cpp.

◆ setDestinationCrs()

void QgsQuickMapSettings::setDestinationCrs ( const QgsCoordinateReferenceSystem destinationCrs)

Sets the destination crs (coordinate reference system) for the map render.

See also
destinationCrs()

Definition at line 190 of file qgsquickmapsettings.cpp.

◆ setDevicePixelRatio()

void QgsQuickMapSettings::setDevicePixelRatio ( const qreal &  devicePixelRatio)

Sets the ratio between physical pixels and device-independent pixels.

This value is dependent on the screen the window is on, and may change when the window is moved. Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays.

Definition at line 289 of file qgsquickmapsettings.cpp.

◆ setExtent()

void QgsQuickMapSettings::setExtent ( const QgsRectangle extent)

Sets the coordinates of the rectangle which should be rendered.

Warning
The actual visible extent used for rendering can be significantly different from the specified extent, since the given extent may be expanded in order to match the aspect ratio of outputSize(). Use visibleExtent() to retrieve the actual extent to be rendered.
See also
visibleExtent()
extent()

Definition at line 82 of file qgsquickmapsettings.cpp.

◆ setLayers()

void QgsQuickMapSettings::setLayers ( const QList< QgsMapLayer * > &  layers)

Sets the list of layers to render in the map.

The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)

Note
Any non-spatial layers will be automatically stripped from the list (since they cannot be rendered!).
See also
layers()

Definition at line 204 of file qgsquickmapsettings.cpp.

◆ setOutputDpi()

void QgsQuickMapSettings::setOutputDpi ( double  outputDpi)

Sets the dpi (dots per inch) used for conversion between real world units (e.g.

mm) and pixels.

See also
outputDpi()

Definition at line 175 of file qgsquickmapsettings.cpp.

◆ setOutputSize()

void QgsQuickMapSettings::setOutputSize ( QSize  outputSize)

Sets the size of the resulting map image, in pixels.

See also
outputSize()

Definition at line 159 of file qgsquickmapsettings.cpp.

◆ setProject()

void QgsQuickMapSettings::setProject ( QgsProject project)

A project property should be used as a primary source of project all other components in the application.

QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::read)

When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.

Definition at line 37 of file qgsquickmapsettings.cpp.

◆ setRotation()

void QgsQuickMapSettings::setRotation ( double  rotation)

The rotation of the resulting map image, in degrees clockwise.

Map canvas rotation support is not implemented, 0 is used

Definition at line 264 of file qgsquickmapsettings.cpp.

◆ setTransformContext()

void QgsQuickMapSettings::setTransformContext ( const QgsCoordinateTransformContext context)

Sets the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.

See also
transformContext()
Since
QGIS 3.0

◆ transformContext()

QgsCoordinateTransformContext QgsQuickMapSettings::transformContext ( ) const

Returns the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.

See also
setTransformContext()
Since
QGIS 3.0

Definition at line 72 of file qgsquickmapsettings.cpp.

◆ visibleExtent()

QgsRectangle QgsQuickMapSettings::visibleExtent ( ) const

Returns the actual extent derived from requested extent that takes takes output image size into account.

Definition at line 129 of file qgsquickmapsettings.cpp.

◆ visibleExtentChanged

void QgsQuickMapSettings::visibleExtentChanged ( )
signal

Returns the actual extent derived from requested extent that takes takes output image size into account.

Property Documentation

◆ backgroundColor

QColor QgsQuickMapSettings::backgroundColor
readwrite

The background color used to render the map.

The value is set to the project's background color setting on QgsProject::readProject

Definition at line 1 of file qgsquickmapsettings.h.

◆ destinationCrs

QgsCoordinateReferenceSystem QgsQuickMapSettings::destinationCrs
readwrite

CRS of destination coordinate reference system.

Automatically loaded from project on QgsProject::readProject

Definition at line 1 of file qgsquickmapsettings.h.

◆ extent

QgsRectangle QgsQuickMapSettings::extent
readwrite

Geographical coordinates of the rectangle that should be rendered.

The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use QgsQuickMapSettings::visibleExtent to get the resulting extent.

Automatically loaded from project on QgsProject::readProject

Definition at line 1 of file qgsquickmapsettings.h.

◆ layers

QList<QgsMapLayer *> QgsQuickMapSettings::layers
readwrite

Set list of layers for map rendering.

The layers must be registered in QgsProject. The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)

Note
Any non-spatial layers will be automatically stripped from the list (since they cannot be rendered!).

Not loaded automatically from the associated project

Definition at line 1 of file qgsquickmapsettings.h.

◆ mapUnitsPerPixel

double QgsQuickMapSettings::mapUnitsPerPixel
read

Returns the distance in geographical coordinates that equals to one pixel in the map.

Definition at line 1 of file qgsquickmapsettings.h.

◆ mapUnitsPerPoint

double QgsQuickMapSettings::mapUnitsPerPoint
read

Returns the distance in geographical coordinates that equals to one point unit in the map.

Definition at line 1 of file qgsquickmapsettings.h.

◆ outputDpi

double QgsQuickMapSettings::outputDpi
readwrite

Output DPI used for conversion between real world units (e.g.

mm) and pixels

Automatically loaded from project on QgsProject::readProject

Definition at line 1 of file qgsquickmapsettings.h.

◆ outputSize

QSize QgsQuickMapSettings::outputSize
readwrite

The size of the resulting map image.

Automatically loaded from project on QgsProject::readProject

Definition at line 1 of file qgsquickmapsettings.h.

◆ project

QgsProject * QgsQuickMapSettings::project
readwrite

A project property should be used as a primary source of project all other components in the application.

QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::read)

When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.

Definition at line 1 of file qgsquickmapsettings.h.

◆ rotation

double QgsQuickMapSettings::rotation
readwrite

The rotation of the resulting map image, in degrees clockwise.

Map canvas rotation support is not implemented, 0 is used

Definition at line 1 of file qgsquickmapsettings.h.

◆ visibleExtent

QgsRectangle QgsQuickMapSettings::visibleExtent
read

Returns the actual extent derived from requested extent that takes takes output image size into account.

Definition at line 1 of file qgsquickmapsettings.h.


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