QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsquickmapsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsquickmapsettings.h
3 --------------------------------------
4 Date : 27.12.2014
5 Copyright : (C) 2014 by Matthias Kuhn
6 Email : matthias (at) opengis.ch
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 QGSQUICKMAPSETTINGS_H
17#define QGSQUICKMAPSETTINGS_H
18
19#include "qgis_quick.h"
21#include "qgsmaplayer.h"
22#include "qgsmapsettings.h"
23#include "qgspoint.h"
24#include "qgsproject.h"
25#include "qgsrectangle.h"
26
27#include <QObject>
28
44class QUICK_EXPORT QgsQuickMapSettings : public QObject
45{
46 Q_OBJECT
47
55 Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
56
57
60 Q_PROPERTY( QgsPoint center READ center WRITE setCenter NOTIFY extentChanged )
61
70 Q_PROPERTY( QgsRectangle extent READ extent WRITE setExtent NOTIFY extentChanged )
77
82 Q_PROPERTY( double rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
83
90
96 Q_PROPERTY( QSize outputSize READ outputSize WRITE setOutputSize NOTIFY outputSizeChanged )
97
103 Q_PROPERTY( double outputDpi READ outputDpi WRITE setOutputDpi NOTIFY outputDpiChanged )
104
111
120 Q_PROPERTY( QList<QgsMapLayer *> layers READ layers WRITE setLayers NOTIFY layersChanged )
121
125 Q_PROPERTY( bool isTemporal READ isTemporal WRITE setIsTemporal NOTIFY temporalStateChanged )
126
130 Q_PROPERTY( QDateTime temporalBegin READ temporalBegin WRITE setTemporalBegin NOTIFY temporalStateChanged )
131
135 Q_PROPERTY( QDateTime temporalEnd READ temporalEnd WRITE setTemporalEnd NOTIFY temporalStateChanged )
136
140 Q_PROPERTY( double zRangeLower READ zRangeLower WRITE setZRangeLower NOTIFY zRangeChanged )
141
145 Q_PROPERTY( double zRangeUpper READ zRangeUpper WRITE setZRangeUpper NOTIFY zRangeChanged )
146
147 public:
149 explicit QgsQuickMapSettings( QObject *parent = nullptr );
151
154
156 QgsRectangle extent() const;
157
159 void setExtent( const QgsRectangle &extent );
160
163
165 QgsProject *project() const;
166
168 QgsPoint center() const;
169
171 Q_INVOKABLE void setCenter( const QgsPoint &center );
172
174 double mapUnitsPerPixel() const;
175
177 Q_INVOKABLE void setCenterToLayer( QgsMapLayer *layer, bool shouldZoom = true );
178
180 double mapUnitsPerPoint() const;
181
184
187
195 Q_INVOKABLE QPointF coordinateToScreen( const QgsPoint &point ) const;
196
204 Q_INVOKABLE QgsPoint screenToCoordinate( const QPointF &point ) const;
205
208
210 double rotation() const;
211
213 void setRotation( double rotation );
214
216 QColor backgroundColor() const;
217
219 void setBackgroundColor( const QColor &color );
220
226 QSize outputSize() const;
227
233 void setOutputSize( QSize outputSize );
234
236 double outputDpi() const;
237
239 void setOutputDpi( double outputDpi );
240
243
246
254 QList<QgsMapLayer *> layers() const;
255
265 void setLayers( const QList<QgsMapLayer *> &layers );
266
272 qreal devicePixelRatio() const;
273
274
280 void setDevicePixelRatio( const qreal &devicePixelRatio );
281
283 bool isTemporal() const;
284
286 void setIsTemporal( bool temporal );
287
289 QDateTime temporalBegin() const;
290
292 void setTemporalBegin( const QDateTime &begin );
293
295 QDateTime temporalEnd() const;
296
298 void setTemporalEnd( const QDateTime &end );
299
301 double zRangeLower() const;
302
304 void setZRangeLower( const double &lower );
305
307 double zRangeUpper() const;
308
310 void setZRangeUpper( const double &upper );
311
312 signals:
315
318
321
326
329
332
335
338
341
344
352
360
363
364 private slots:
365
371 void onReadProject( const QDomDocument &doc );
372
376 void onCrsChanged();
377
378 private:
379 QgsProject *mProject = nullptr;
380 QgsMapSettings mMapSettings;
381 qreal mDevicePixelRatio = 1.0;
382};
383
384#endif // QGSQUICKMAPSETTINGS_H
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Contains configuration for rendering maps.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
double outputDpi
Output DPI used for conversion between real world units (e.g.
void setIsTemporal(bool temporal)
Returns true if a temporal filtering is enabled.
QgsQuickMapSettings(QObject *parent=nullptr)
Create new map settings.
void setOutputSize(QSize outputSize)
Sets the size of the resulting map image, in pixels.
void setRotation(double rotation)
The rotation of the resulting map image, in degrees clockwise.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
void mapUnitsPerPointChanged()
Returns the distance in geographical coordinates that equals to one point unit in the map.
void extentChanged()
Geographical coordinates of the rectangle that should be rendered.
double rotation
The rotation of the resulting map image, in degrees clockwise.
QgsRectangle extent
Geographical coordinates of the rectangle that should be rendered.
void outputSizeChanged()
The size of the resulting map image.
double zRangeLower
The Z range's lower value (since QGIS 3.38).
QDateTime temporalBegin
The temporal range's begin (i.e.
void projectChanged()
A project property should be used as a primary source of project all other components in the applicat...
Q_INVOKABLE QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
bool isTemporal
Returns true if a temporal filtering is enabled.
QgsRectangle visibleExtent
Returns the actual extent derived from requested extent that takes output image size into account.
void outputDpiChanged()
Output DPI used for conversion between real world units (e.g.
void layersChanged()
Set list of layers for map rendering.
void destinationCrsChanged()
CRS of destination coordinate reference system.
void visibleExtentChanged()
Returns the actual extent derived from requested extent that takes output image size into account.
void temporalStateChanged()
Emitted when the temporal state has changed.
void setExtent(const QgsRectangle &extent)
Sets the coordinates of the rectangle which should be rendered.
Q_INVOKABLE QgsPoint screenToCoordinate(const QPointF &point) const
Convert a screen coordinate to a map coordinate.
Q_INVOKABLE void setCenter(const QgsPoint &center)
Move current map extent to have center point defined by center.
void devicePixelRatioChanged()
Returns the ratio between physical pixels and device-independent pixels.
double zRangeUpper
The Z range's upper value (since QGIS 3.38).
void setZRangeUpper(const double &upper)
The Z range's lower value (since QGIS 3.38).
QColor backgroundColor
The background color used to render the map.
double mapUnitsPerPixel
Returns the distance in geographical coordinates that equals to one pixel in the map.
void setDevicePixelRatio(const qreal &devicePixelRatio)
Sets the ratio between physical pixels and device-independent pixels.
double mapUnitsPerPoint
Returns the distance in geographical coordinates that equals to one point unit in the map.
QgsMapSettings mapSettings() const
Clone map settings.
void setProject(QgsProject *project)
A project property should be used as a primary source of project all other components in the applicat...
void mapUnitsPerPixelChanged()
Returns the distance in geographical coordinates that equals to one pixel in the map.
void setZRangeLower(const double &lower)
The Z range's lower value (since QGIS 3.38).
void setOutputDpi(double outputDpi)
Sets the dpi (dots per inch) used for conversion between real world units (e.g.
qreal devicePixelRatio() const
Returns the ratio between physical pixels and device-independent pixels.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers to render in the map.
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 sh...
QgsCoordinateReferenceSystem destinationCrs
CRS of destination coordinate reference system.
QDateTime temporalEnd
The temporal range's end (i.e.
QList< QgsMapLayer * > layers
Set list of layers for map rendering.
void setDestinationCrs(const QgsCoordinateReferenceSystem &destinationCrs)
Sets the destination crs (coordinate reference system) for the map render.
QSize outputSize
The size of the resulting map image.
void backgroundColorChanged()
The background color used to render the map.
void setTemporalEnd(const QDateTime &end)
The temporal range's end (i.e.
void zRangeChanged()
Emitted when the Z range has changed.
void rotationChanged()
The rotation of the resulting map image, in degrees clockwise.
Q_INVOKABLE QPointF coordinateToScreen(const QgsPoint &point) const
Convert a map coordinate to screen pixel coordinates.
QgsPoint center
Geographical coordinate representing the center point of the current extent.
void setTemporalBegin(const QDateTime &begin)
The temporal range's begin (i.e.
QgsProject * project
A project property should be used as a primary source of project all other components in the applicat...
void setBackgroundColor(const QColor &color)
The background color used to render the map.
A rectangle specified with double values.