QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 <QObject>
20 
22 #include "qgsmapsettings.h"
23 #include "qgsmapthemecollection.h"
24 #include "qgspoint.h"
25 #include "qgsrectangle.h"
26 
27 #include "qgis_quick.h"
28 
29 class QgsProject;
30 
46 class QUICK_EXPORT QgsQuickMapSettings : public QObject
47 {
48  Q_OBJECT
49 
57  Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
58 
59 
67  Q_PROPERTY( QgsRectangle extent READ extent WRITE setExtent NOTIFY extentChanged )
69  Q_PROPERTY( QgsRectangle visibleExtent READ visibleExtent NOTIFY visibleExtentChanged )
71  Q_PROPERTY( double mapUnitsPerPixel READ mapUnitsPerPixel NOTIFY mapUnitsPerPixelChanged )
72 
73 
77  Q_PROPERTY( double rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
78 
79 
84  Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged )
85 
86 
91  Q_PROPERTY( QSize outputSize READ outputSize WRITE setOutputSize NOTIFY outputSizeChanged )
92 
93 
98  Q_PROPERTY( double outputDpi READ outputDpi WRITE setOutputDpi NOTIFY outputDpiChanged )
99 
100 
105  Q_PROPERTY( QgsCoordinateReferenceSystem destinationCrs READ destinationCrs WRITE setDestinationCrs NOTIFY destinationCrsChanged )
106 
107 
115  Q_PROPERTY( QList<QgsMapLayer *> layers READ layers WRITE setLayers NOTIFY layersChanged )
116 
117  public:
119  QgsQuickMapSettings( QObject *parent = nullptr );
120  ~QgsQuickMapSettings() = default;
121 
123  QgsMapSettings mapSettings() const;
124 
126  QgsRectangle extent() const;
127 
129  void setExtent( const QgsRectangle &extent );
130 
132  void setProject( QgsProject *project );
133 
135  QgsProject *project() const;
136 
138  Q_INVOKABLE void setCenter( const QgsPoint &center );
139 
141  double mapUnitsPerPixel() const;
142 
144  QgsRectangle visibleExtent() const;
145 
147  Q_INVOKABLE QgsCoordinateTransformContext transformContext() const;
148 
156  Q_INVOKABLE QPointF coordinateToScreen( const QgsPoint &point ) const;
157 
158 
166  Q_INVOKABLE QgsPoint screenToCoordinate( const QPointF &point ) const;
167 
169  void setTransformContext( const QgsCoordinateTransformContext &context );
170 
172  double rotation() const;
173 
175  void setRotation( double rotation );
176 
178  QColor backgroundColor() const;
179 
181  void setBackgroundColor( const QColor &color );
182 
188  QSize outputSize() const;
189 
195  void setOutputSize( const QSize &outputSize );
196 
198  double outputDpi() const;
199 
201  void setOutputDpi( double outputDpi );
202 
204  QgsCoordinateReferenceSystem destinationCrs() const;
205 
207  void setDestinationCrs( const QgsCoordinateReferenceSystem &destinationCrs );
208 
216  QList<QgsMapLayer *> layers() const;
217 
227  void setLayers( const QList<QgsMapLayer *> &layers );
228 
229  signals:
232 
235 
238 
241 
244 
247 
250 
253 
256 
259 
260  private slots:
261 
267  void onReadProject( const QDomDocument &doc );
268 
269  private:
270  QgsProject *mProject = nullptr;
271  QgsMapSettings mMapSettings;
272 
273 };
274 
275 #endif // QGSQUICKMAPSETTINGS_H
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
The QgsMapSettings class contains configuration for rendering of the map.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:99
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
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 takes output image size into accou...
~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