QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgsmapthemecollection.h"
27 #include "qgspoint.h"
28 #include "qgsrectangle.h"
29 
30 class QgsProject;
31 
47 class QUICK_EXPORT QgsQuickMapSettings : public QObject
48 {
49  Q_OBJECT
50 
58  Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
59 
60 
68  Q_PROPERTY( QgsRectangle extent READ extent WRITE setExtent NOTIFY extentChanged )
70  Q_PROPERTY( QgsRectangle visibleExtent READ visibleExtent NOTIFY visibleExtentChanged )
72  Q_PROPERTY( double mapUnitsPerPixel READ mapUnitsPerPixel NOTIFY mapUnitsPerPixelChanged )
74  Q_PROPERTY( double mapUnitsPerPoint READ mapUnitsPerPoint NOTIFY mapUnitsPerPointChanged )
75 
80  Q_PROPERTY( double rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
81 
87  Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged )
88 
94  Q_PROPERTY( QSize outputSize READ outputSize WRITE setOutputSize NOTIFY outputSizeChanged )
95 
101  Q_PROPERTY( double outputDpi READ outputDpi WRITE setOutputDpi NOTIFY outputDpiChanged )
102 
108  Q_PROPERTY( QgsCoordinateReferenceSystem destinationCrs READ destinationCrs WRITE setDestinationCrs NOTIFY destinationCrsChanged )
109 
118  Q_PROPERTY( QList<QgsMapLayer *> layers READ layers WRITE setLayers NOTIFY layersChanged )
119 
120  public:
122  explicit QgsQuickMapSettings( QObject *parent = nullptr );
123  ~QgsQuickMapSettings() = default;
124 
126  QgsMapSettings mapSettings() const;
127 
129  QgsRectangle extent() const;
130 
132  void setExtent( const QgsRectangle &extent );
133 
135  void setProject( QgsProject *project );
136 
138  QgsProject *project() const;
139 
141  Q_INVOKABLE void setCenter( const QgsPoint &center );
142 
144  double mapUnitsPerPixel() const;
145 
147  Q_INVOKABLE void setCenterToLayer( QgsMapLayer *layer, bool shouldZoom = true );
148 
150  double mapUnitsPerPoint() const;
151 
153  QgsRectangle visibleExtent() const;
154 
156  Q_INVOKABLE QgsCoordinateTransformContext transformContext() const;
157 
165  Q_INVOKABLE QPointF coordinateToScreen( const QgsPoint &point ) const;
166 
174  Q_INVOKABLE QgsPoint screenToCoordinate( const QPointF &point ) const;
175 
177  void setTransformContext( const QgsCoordinateTransformContext &context );
178 
180  double rotation() const;
181 
183  void setRotation( double rotation );
184 
186  QColor backgroundColor() const;
187 
189  void setBackgroundColor( const QColor &color );
190 
196  QSize outputSize() const;
197 
203  void setOutputSize( QSize outputSize );
204 
206  double outputDpi() const;
207 
209  void setOutputDpi( double outputDpi );
210 
212  QgsCoordinateReferenceSystem destinationCrs() const;
213 
215  void setDestinationCrs( const QgsCoordinateReferenceSystem &destinationCrs );
216 
224  QList<QgsMapLayer *> layers() const;
225 
235  void setLayers( const QList<QgsMapLayer *> &layers );
236 
242  qreal devicePixelRatio() const;
243 
244 
250  void setDevicePixelRatio( const qreal &devicePixelRatio );
251 
252  signals:
254  void projectChanged();
255 
257  void extentChanged();
258 
260  void destinationCrsChanged();
261 
263  void mapUnitsPerPixelChanged();
265  void mapUnitsPerPointChanged();
266 
268  void rotationChanged();
269 
271  void backgroundColorChanged();
272 
274  void visibleExtentChanged();
275 
277  void outputSizeChanged();
278 
280  void outputDpiChanged();
281 
283  void layersChanged();
284 
286  void devicePixelRatioChanged();
287 
288  private slots:
289 
295  void onReadProject( const QDomDocument &doc );
296 
300  void onCrsChanged();
301 
302  private:
303  QgsProject *mProject = nullptr;
304  QgsMapSettings mMapSettings;
305  qreal mDevicePixelRatio = 1.0;
306 };
307 
308 #endif // QGSQUICKMAPSETTINGS_H
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
qgsrectangle.h
qgsmapthemecollection.h
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
qgscoordinatetransformcontext.h
qgspoint.h
qgsmapsettings.h
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:103
QgsQuickMapSettings
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
Definition: qgsquickmapsettings.h:47
qgsmaplayer.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
Definition: qgsmapsettings.h:88