QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgis_quick.h"
20 #include "qgsquickmapsettings.h"
21 
22 #include <QFutureSynchronizer>
23 #include <QTimer>
24 #include <QtQuick/QQuickItem>
25 #include <qgsmapsettings.h>
26 #include <qgspoint.h>
27 
28 #include <memory>
29 
32 class QgsLabelingResults;
33 
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 
77  Q_PROPERTY( bool isRendering READ isRendering NOTIFY isRenderingChanged )
78 
84  Q_PROPERTY( int mapUpdateInterval READ mapUpdateInterval WRITE setMapUpdateInterval NOTIFY mapUpdateIntervalChanged )
85 
89  Q_PROPERTY( bool incrementalRendering READ incrementalRendering WRITE setIncrementalRendering NOTIFY incrementalRenderingChanged )
90 
91  public:
93  explicit QgsQuickMapCanvasMap( QQuickItem *parent = nullptr );
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 
127  void renderStarting();
128 
132  void mapCanvasRefreshed();
133 
135  void freezeChanged();
136 
138  void isRenderingChanged();
139 
141  void mapUpdateIntervalChanged();
142 
144  void incrementalRenderingChanged();
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 
172  void clearCache();
173 
174  private slots:
175  void refreshMap();
176  void renderJobUpdated();
177  void renderJobFinished();
178  void layerRepaintRequested( bool deferred );
179  void onWindowChanged( QQuickWindow *window );
180  void onScreenChanged( QScreen *screen );
181  void onExtentChanged();
182  void onLayersChanged();
183 
184  private:
185 
189  void destroyJob( QgsMapRendererJob *job );
190  QgsMapSettings prepareMapSettings() const;
191  void updateTransform();
192  void zoomToFullExtent();
193 
194  std::unique_ptr<QgsQuickMapSettings> mMapSettings;
195  bool mPinching = false;
196  QPoint mPinchStartPoint;
197  QgsMapRendererParallelJob *mJob = nullptr;
198  std::unique_ptr<QgsMapRendererCache> mCache;
199  QgsLabelingResults *mLabelingResults = nullptr;
200  QImage mImage;
201  QgsMapSettings mImageMapSettings;
202  QTimer mRefreshTimer;
203  bool mDirty = false;
204  bool mFreeze = false;
205  QList<QMetaObject::Connection> mLayerConnections;
206  QTimer mMapUpdateTimer;
207  bool mIncrementalRendering = false;
208  bool mSilentRefresh = false;
209  bool mDeferredRefreshPending = false;
210 
211  QQuickWindow *mWindow = nullptr;
212 };
213 
214 #endif // QGSQUICKMAPCANVASMAP_H
QgsLabelingResults
Class that stores computed placement from labeling engine.
Definition: qgslabelingresults.h:32
qgspoint.h
qgsmapsettings.h
QgsMapRendererCache
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
Definition: qgsmaprenderercache.h:47
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
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:32
QgsQuickMapCanvasMap
This class implements a visual Qt Quick Item that does map rendering according to the current map set...
Definition: qgsquickmapcanvasmap.h:52
QgsMapRendererJob
Abstract base class for map rendering implementations.
Definition: qgsmaprendererjob.h:269
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
Definition: qgsmapsettings.h:88
qgsquickmapsettings.h