QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsquickmapcanvasmap.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsquickmapcanvasmap.h
3  --------------------------------------
4  Date : 10.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 QGSQUICKMAPCANVASMAP_H
17 #define QGSQUICKMAPCANVASMAP_H
18 
19 #include <memory>
20 
21 #include <QtQuick/QQuickItem>
22 #include <QFutureSynchronizer>
23 #include <QTimer>
24 
25 #include "qgsmapsettings.h"
26 #include "qgspoint.h"
27 
28 #include "qgis_quick.h"
29 #include "qgsquickmapsettings.h"
30 
33 class QgsLabelingResults;
34 
52 class QUICK_EXPORT QgsQuickMapCanvasMap : public QQuickItem
53 {
54  Q_OBJECT
55 
64  Q_PROPERTY( QgsQuickMapSettings *mapSettings READ mapSettings )
65 
66 
70  Q_PROPERTY( bool freeze READ freeze WRITE setFreeze NOTIFY freezeChanged )
71 
72 
77  Q_PROPERTY( bool isRendering READ isRendering NOTIFY isRenderingChanged )
78 
79 
84  Q_PROPERTY( int mapUpdateInterval READ mapUpdateInterval WRITE setMapUpdateInterval NOTIFY mapUpdateIntervalChanged )
85 
86 
89  Q_PROPERTY( bool incrementalRendering READ incrementalRendering WRITE setIncrementalRendering NOTIFY incrementalRenderingChanged )
90 
91  public:
93  QgsQuickMapCanvasMap( QQuickItem *parent = nullptr );
94  ~QgsQuickMapCanvasMap() = default;
95 
96  QSGNode *updatePaintNode( QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * ) override;
97 
99  QgsQuickMapSettings *mapSettings() const;
100 
102  bool freeze() const;
103 
105  void setFreeze( bool freeze );
106 
108  bool isRendering() const;
109 
111  int mapUpdateInterval() const;
112 
114  void setMapUpdateInterval( int mapUpdateInterval );
115 
117  bool incrementalRendering() const;
118 
120  void setIncrementalRendering( bool incrementalRendering );
121 
122  signals:
123 
128 
133 
136 
139 
142 
145 
146  protected:
147  void geometryChanged( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
148 
149  public slots:
151  void stopRendering();
152 
156  void zoom( QPointF center, qreal scale );
157 
161  void pan( QPointF oldPos, QPointF newPos );
162 
167  void refresh();
168 
169  private slots:
170  void refreshMap();
171  void renderJobUpdated();
172  void renderJobFinished();
173  void onWindowChanged( QQuickWindow *window );
174  void onScreenChanged( QScreen *screen );
175  void onExtentChanged();
176  void onLayersChanged();
177 
178  private:
179 
183  void destroyJob( QgsMapRendererJob *job );
184  QgsMapSettings prepareMapSettings() const;
185  void updateTransform();
186  void zoomToFullExtent();
187 
188  std::unique_ptr<QgsQuickMapSettings> mMapSettings;
189  bool mPinching = false;
190  QPoint mPinchStartPoint;
191  QgsMapRendererParallelJob *mJob = nullptr;
192  QgsMapRendererCache *mCache = nullptr;
193  QgsLabelingResults *mLabelingResults = nullptr;
194  QImage mImage;
195  QgsMapSettings mImageMapSettings;
196  QTimer mRefreshTimer;
197  bool mDirty = false;
198  bool mFreeze = false;
199  bool mNeedsRefresh = false;
200  QList<QMetaObject::Connection> mLayerConnections;
201  QTimer mMapUpdateTimer;
202  bool mIncrementalRendering = false;
203 };
204 
205 #endif // QGSQUICKMAPCANVASMAP_H
QgsQuickMapCanvasMap::isRenderingChanged
void isRenderingChanged()
The isRendering property is set to true while a rendering job is pending for this map canvas map.
QgsQuickMapCanvasMap::~QgsQuickMapCanvasMap
~QgsQuickMapCanvasMap()=default
QgsLabelingResults
Class that stores computed placement from labeling engine.
Definition: qgspallabeling.h:1224
QgsQuickMapCanvasMap::mapUpdateIntervalChanged
void mapUpdateIntervalChanged()
Interval in milliseconds after which the map canvas will be updated while a rendering job is ongoing.
qgspoint.h
QgsQuickMapCanvasMap::mapCanvasRefreshed
void mapCanvasRefreshed()
Emitted when the canvas is refreshed.
qgsmapsettings.h
QgsMapRendererCache
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
Definition: qgsmaprenderercache.h:43
QgsQuickMapSettings
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
Definition: qgsquickmapsettings.h:47
QgsMapRendererParallelJob
Job implementation that renders all layers in parallel.
Definition: qgsmaprendererparalleljob.h:33
QgsQuickMapCanvasMap
This class implements a visual Qt Quick Item that does map rendering according to the current map set...
Definition: qgsquickmapcanvasmap.h:53
QgsQuickMapCanvasMap::renderStarting
void renderStarting()
Emitted when a rendering is starting.
QgsQuickMapCanvasMap::incrementalRenderingChanged
void incrementalRenderingChanged()
When the incrementalRendering property is set to true, the automatic refresh of map canvas during ren...
QgsQuickMapCanvasMap::freezeChanged
void freezeChanged()
When freeze property is set to true, the map canvas does not refresh.
QgsMapRendererJob
Abstract base class for map rendering implementations.
Definition: qgsmaprendererjob.h:187
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88
qgsquickmapsettings.h