QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
170 
172  double rotation() const;
173 
175  void setRotation( double rotation );
176 
178  QColor backgroundColor() const;
179 
181  void setBackgroundColor( const QColor &color );
182 
184  QSize outputSize() const;
185 
187  void setOutputSize( const QSize &outputSize );
188 
190  double outputDpi() const;
191 
193  void setOutputDpi( double outputDpi );
194 
196  QgsCoordinateReferenceSystem destinationCrs() const;
197 
199  void setDestinationCrs( const QgsCoordinateReferenceSystem &destinationCrs );
200 
202  QList<QgsMapLayer *> layers() const;
203 
205  void setLayers( const QList<QgsMapLayer *> &layers );
206 
207  signals:
210 
213 
216 
219 
222 
225 
228 
231 
234 
237 
238  private slots:
239 
245  void onReadProject( const QDomDocument &doc );
246 
247  private:
248  QgsProject *mProject = nullptr;
249  QgsMapSettings mMapSettings;
250 
251 };
252 
253 #endif // QGSQUICKMAPSETTINGS_H
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:58
QgsQuickMapSettings::extentChanged
void extentChanged()
Geographical coordinates of the rectangle that should be rendered.
QgsQuickMapSettings::destinationCrsChanged
void destinationCrsChanged()
CRS of destination coordinate reference system.
qgsrectangle.h
qgsmapthemecollection.h
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
qgscoordinatetransformcontext.h
QgsQuickMapSettings::projectChanged
void projectChanged()
A project property should be used as a primary source of project all other components in the applicat...
qgspoint.h
qgsmapsettings.h
QgsQuickMapSettings::layersChanged
void layersChanged()
Set list of layers for map rendering.
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsQuickMapSettings
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
Definition: qgsquickmapsettings.h:47
QgsQuickMapSettings::~QgsQuickMapSettings
~QgsQuickMapSettings()=default
QgsQuickMapSettings::outputDpiChanged
void outputDpiChanged()
Output DPI used for conversion between real world units (e.g.
QgsQuickMapSettings::mapUnitsPerPixelChanged
void mapUnitsPerPixelChanged()
Returns the distance in geographical coordinates that equals to one pixel in the map.
QgsQuickMapSettings::rotationChanged
void rotationChanged()
The rotation of the resulting map image, in degrees clockwise.
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsQuickMapSettings::outputSizeChanged
void outputSizeChanged()
The size of the resulting map image.
QgsQuickMapSettings::backgroundColorChanged
void backgroundColorChanged()
The background color used to render the map.
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88
QgsQuickMapSettings::visibleExtentChanged
void visibleExtentChanged()
Returns the actual extent derived from requested extent that takes takes output image size into accou...
QgsQuickMapSettings::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...