QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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"
20
21#include <QObject>
22
24#include "qgsmaplayer.h"
25#include "qgsmapsettings.h"
27#include "qgspoint.h"
28#include "qgsrectangle.h"
29
30class QgsProject;
31
47class QUICK_EXPORT QgsQuickMapSettings : public QObject
48{
49 Q_OBJECT
50
58 Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
59
60
63 Q_PROPERTY( QgsPoint center READ center WRITE setCenter NOTIFY extentChanged )
64
65
73 Q_PROPERTY( QgsRectangle extent READ extent WRITE setExtent NOTIFY extentChanged )
75 Q_PROPERTY( QgsRectangle visibleExtent READ visibleExtent NOTIFY visibleExtentChanged )
77 Q_PROPERTY( double mapUnitsPerPixel READ mapUnitsPerPixel NOTIFY mapUnitsPerPixelChanged )
79 Q_PROPERTY( double mapUnitsPerPoint READ mapUnitsPerPoint NOTIFY mapUnitsPerPointChanged )
80
81
85 Q_PROPERTY( double rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
86
87
92 Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged )
93
94
99 Q_PROPERTY( QSize outputSize READ outputSize WRITE setOutputSize NOTIFY outputSizeChanged )
100
101
106 Q_PROPERTY( double outputDpi READ outputDpi WRITE setOutputDpi NOTIFY outputDpiChanged )
107
108
113 Q_PROPERTY( QgsCoordinateReferenceSystem destinationCrs READ destinationCrs WRITE setDestinationCrs NOTIFY destinationCrsChanged )
114
115
123 Q_PROPERTY( QList<QgsMapLayer *> layers READ layers WRITE setLayers NOTIFY layersChanged )
124
125
128 Q_PROPERTY( bool isTemporal READ isTemporal WRITE setIsTemporal NOTIFY temporalStateChanged )
129
130
133 Q_PROPERTY( QDateTime temporalBegin READ temporalBegin WRITE setTemporalBegin NOTIFY temporalStateChanged )
134
135
138 Q_PROPERTY( QDateTime temporalEnd READ temporalEnd WRITE setTemporalEnd NOTIFY temporalStateChanged )
139
140 public:
142 explicit QgsQuickMapSettings( QObject *parent = nullptr );
144
146 QgsMapSettings mapSettings() const;
147
149 QgsRectangle extent() const;
150
152 void setExtent( const QgsRectangle &extent );
153
155 void setProject( QgsProject *project );
156
158 QgsProject *project() const;
159
161 QgsPoint center() const;
162
164 Q_INVOKABLE void setCenter( const QgsPoint &center );
165
167 double mapUnitsPerPixel() const;
168
170 Q_INVOKABLE void setCenterToLayer( QgsMapLayer *layer, bool shouldZoom = true );
171
173 double mapUnitsPerPoint() const;
174
176 QgsRectangle visibleExtent() const;
177
179 Q_INVOKABLE QgsCoordinateTransformContext transformContext() const;
180
188 Q_INVOKABLE QPointF coordinateToScreen( const QgsPoint &point ) const;
189
197 Q_INVOKABLE QgsPoint screenToCoordinate( const QPointF &point ) const;
198
200 void setTransformContext( const QgsCoordinateTransformContext &context );
201
203 double rotation() const;
204
206 void setRotation( double rotation );
207
209 QColor backgroundColor() const;
210
212 void setBackgroundColor( const QColor &color );
213
219 QSize outputSize() const;
220
226 void setOutputSize( QSize outputSize );
227
229 double outputDpi() const;
230
232 void setOutputDpi( double outputDpi );
233
235 QgsCoordinateReferenceSystem destinationCrs() const;
236
238 void setDestinationCrs( const QgsCoordinateReferenceSystem &destinationCrs );
239
247 QList<QgsMapLayer *> layers() const;
248
258 void setLayers( const QList<QgsMapLayer *> &layers );
259
265 qreal devicePixelRatio() const;
266
267
273 void setDevicePixelRatio( const qreal &devicePixelRatio );
274
276 bool isTemporal() const;
277
279 void setIsTemporal( bool temporal );
280
282 QDateTime temporalBegin() const;
283
285 void setTemporalBegin( const QDateTime &begin );
286
288 QDateTime temporalEnd() const;
289
291 void setTemporalEnd( const QDateTime &end );
292
293 signals:
296
299
302
307
310
313
316
319
322
325
333
336
337 private slots:
338
344 void onReadProject( const QDomDocument &doc );
345
349 void onCrsChanged();
350
351 private:
352 QgsProject *mProject = nullptr;
353 QgsMapSettings mMapSettings;
354 qreal mDevicePixelRatio = 1.0;
355};
356
357#endif // QGSQUICKMAPSETTINGS_H
This class 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:73
The QgsMapSettings class contains configuration for rendering of the map.
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:104
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
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.
void outputSizeChanged()
The size of the resulting map image.
void projectChanged()
A project property should be used as a primary source of project all other components in the applicat...
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 devicePixelRatioChanged()
Returns the ratio between physical pixels and device-independent pixels.
~QgsQuickMapSettings()=default
void mapUnitsPerPixelChanged()
Returns the distance in geographical coordinates that equals to one pixel in the map.
void backgroundColorChanged()
The background color used to render the map.
void rotationChanged()
The rotation of the resulting map image, in degrees clockwise.
A rectangle specified with double values.
Definition: qgsrectangle.h:42