QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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"
26#include "qgspoint.h"
27#include "qgsrectangle.h"
28#include "qgsproject.h"
29
45class QUICK_EXPORT QgsQuickMapSettings : public QObject
46{
47 Q_OBJECT
48
56 Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
57
58
61 Q_PROPERTY( QgsPoint center READ center WRITE setCenter NOTIFY extentChanged )
62
63
71 Q_PROPERTY( QgsRectangle extent READ extent WRITE setExtent NOTIFY extentChanged )
73 Q_PROPERTY( QgsRectangle visibleExtent READ visibleExtent NOTIFY visibleExtentChanged )
75 Q_PROPERTY( double mapUnitsPerPixel READ mapUnitsPerPixel NOTIFY mapUnitsPerPixelChanged )
77 Q_PROPERTY( double mapUnitsPerPoint READ mapUnitsPerPoint NOTIFY mapUnitsPerPointChanged )
78
79
83 Q_PROPERTY( double rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
84
85
90 Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged )
91
92
97 Q_PROPERTY( QSize outputSize READ outputSize WRITE setOutputSize NOTIFY outputSizeChanged )
98
99
104 Q_PROPERTY( double outputDpi READ outputDpi WRITE setOutputDpi NOTIFY outputDpiChanged )
105
106
111 Q_PROPERTY( QgsCoordinateReferenceSystem destinationCrs READ destinationCrs WRITE setDestinationCrs NOTIFY destinationCrsChanged )
112
113
121 Q_PROPERTY( QList<QgsMapLayer *> layers READ layers WRITE setLayers NOTIFY layersChanged )
122
123
126 Q_PROPERTY( bool isTemporal READ isTemporal WRITE setIsTemporal NOTIFY temporalStateChanged )
127
128
131 Q_PROPERTY( QDateTime temporalBegin READ temporalBegin WRITE setTemporalBegin NOTIFY temporalStateChanged )
132
133
136 Q_PROPERTY( QDateTime temporalEnd READ temporalEnd WRITE setTemporalEnd NOTIFY temporalStateChanged )
137
138
141 Q_PROPERTY( double zRangeLower READ zRangeLower WRITE setZRangeLower NOTIFY zRangeChanged )
142
143
146 Q_PROPERTY( double zRangeUpper READ zRangeUpper WRITE setZRangeUpper NOTIFY zRangeChanged )
147
148 public:
150 explicit QgsQuickMapSettings( QObject *parent = nullptr );
152
154 QgsMapSettings mapSettings() const;
155
157 QgsRectangle extent() const;
158
160 void setExtent( const QgsRectangle &extent );
161
163 void setProject( QgsProject *project );
164
166 QgsProject *project() const;
167
169 QgsPoint center() const;
170
172 Q_INVOKABLE void setCenter( const QgsPoint &center );
173
175 double mapUnitsPerPixel() const;
176
178 Q_INVOKABLE void setCenterToLayer( QgsMapLayer *layer, bool shouldZoom = true );
179
181 double mapUnitsPerPoint() const;
182
184 QgsRectangle visibleExtent() const;
185
187 Q_INVOKABLE QgsCoordinateTransformContext transformContext() const;
188
196 Q_INVOKABLE QPointF coordinateToScreen( const QgsPoint &point ) const;
197
205 Q_INVOKABLE QgsPoint screenToCoordinate( const QPointF &point ) const;
206
208 void setTransformContext( const QgsCoordinateTransformContext &context );
209
211 double rotation() const;
212
214 void setRotation( double rotation );
215
217 QColor backgroundColor() const;
218
220 void setBackgroundColor( const QColor &color );
221
227 QSize outputSize() const;
228
234 void setOutputSize( QSize outputSize );
235
237 double outputDpi() const;
238
240 void setOutputDpi( double outputDpi );
241
243 QgsCoordinateReferenceSystem destinationCrs() const;
244
246 void setDestinationCrs( const QgsCoordinateReferenceSystem &destinationCrs );
247
255 QList<QgsMapLayer *> layers() const;
256
266 void setLayers( const QList<QgsMapLayer *> &layers );
267
273 qreal devicePixelRatio() const;
274
275
281 void setDevicePixelRatio( const qreal &devicePixelRatio );
282
284 bool isTemporal() const;
285
287 void setIsTemporal( bool temporal );
288
290 QDateTime temporalBegin() const;
291
293 void setTemporalBegin( const QDateTime &begin );
294
296 QDateTime temporalEnd() const;
297
299 void setTemporalEnd( const QDateTime &end );
300
302 double zRangeLower() const;
303
305 void setZRangeLower( const double &lower );
306
308 double zRangeUpper() const;
309
311 void setZRangeUpper( const double &upper );
312
313 signals:
316
319
322
327
330
333
336
339
342
345
353
361
364
365 private slots:
366
372 void onReadProject( const QDomDocument &doc );
373
377 void onCrsChanged();
378
379 private:
380 QgsProject *mProject = nullptr;
381 QgsMapSettings mMapSettings;
382 qreal mDevicePixelRatio = 1.0;
383};
384
385#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:75
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:107
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 zRangeChanged()
Emitted when the Z range has changed.
void rotationChanged()
The rotation of the resulting map image, in degrees clockwise.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
int ANALYSIS_EXPORT lower(int n, int i)
Lower function.
Definition: MathUtils.cpp:337