QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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 "qgis_quick.h"
22#include "qgsmapsettings.h"
23#include "qgspoint.h"
24#include "qgsquickmapsettings.h"
25
26#include <QFutureSynchronizer>
27#include <QTimer>
28#include <QtQuick/QQuickItem>
29
33
53class QUICK_EXPORT QgsQuickMapCanvasMap : public QQuickItem
54{
55 Q_OBJECT
56
66
67
71 Q_PROPERTY( bool freeze READ freeze WRITE setFreeze NOTIFY freezeChanged )
72
78 Q_PROPERTY( bool isRendering READ isRendering NOTIFY isRenderingChanged )
79
86
91
92 public:
94 explicit QgsQuickMapCanvasMap( QQuickItem *parent = nullptr );
96
97 QSGNode *updatePaintNode( QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * ) override;
98
101
103 bool freeze() const;
104
106 void setFreeze( bool freeze );
107
109 bool isRendering() const;
110
112 int mapUpdateInterval() const;
113
116
118 bool incrementalRendering() const;
119
122
123 signals:
124
129
134
137
140
143
146
147 protected:
148 void geometryChange( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
149
150 public slots:
152 void stopRendering();
153
157 void zoom( QPointF center, qreal scale );
158
162 void pan( QPointF oldPos, QPointF newPos );
163
168 void refresh();
169
173 void clearCache();
174
175 private slots:
176 void refreshMap();
177 void renderJobUpdated();
178 void renderJobFinished();
179 void layerRepaintRequested( bool deferred );
180 void onWindowChanged( QQuickWindow *window );
181 void onScreenChanged( QScreen *screen );
182 void onExtentChanged();
183 void onLayersChanged();
184 void onTemporalStateChanged();
185 void onzRangeChanged();
186
187 private:
188 enum class CacheInvalidationType
189 {
190 Temporal = 1 << 0,
191 Elevation = 1 << 1,
192 };
193
197 void destroyJob( QgsMapRendererJob *job );
198 QgsMapSettings prepareMapSettings() const;
199 void updateTransform();
200 void zoomToFullExtent();
201
202 void clearTemporalCache();
203 void clearElevationCache();
204 QFlags<CacheInvalidationType> mCacheInvalidations;
205
206 std::unique_ptr<QgsQuickMapSettings> mMapSettings;
207 bool mPinching = false;
208 QPoint mPinchStartPoint;
209 QgsMapRendererParallelJob *mJob = nullptr;
210 std::unique_ptr<QgsMapRendererCache> mCache;
211 QgsLabelingResults *mLabelingResults = nullptr;
212 QImage mImage;
213 QgsMapSettings mImageMapSettings;
214 QTimer mRefreshTimer;
215 bool mDirty = false;
216 bool mFreeze = false;
217 QList<QMetaObject::Connection> mLayerConnections;
218 QTimer mMapUpdateTimer;
219 bool mIncrementalRendering = false;
220 bool mSilentRefresh = false;
221 bool mDeferredRefreshPending = false;
222
223 QQuickWindow *mWindow = nullptr;
224};
225
226#endif // QGSQUICKMAPCANVASMAP_H
Stores computed placement from labeling engine.
Responsible for keeping a cache of rendered images resulting from a map rendering job.
Abstract base class for map rendering implementations.
Job implementation that renders all layers in parallel.
Contains configuration for rendering maps.
void freezeChanged()
When freeze property is set to true, the map canvas does not refresh.
bool isRendering
The isRendering property is set to true while a rendering job is pending for this map canvas map.
void mapCanvasRefreshed()
Signal is emitted when a canvas is refreshed.
void incrementalRenderingChanged()
When the incrementalRendering property is set to true, the automatic refresh of map canvas during ren...
int mapUpdateInterval
Interval in milliseconds after which the map canvas will be updated while a rendering job is ongoing.
void setMapUpdateInterval(int mapUpdateInterval)
Interval in milliseconds after which the map canvas will be updated while a rendering job is ongoing.
void pan(QPointF oldPos, QPointF newPos)
Set map setting's extent (pan the map) based on the difference of positions.
void renderStarting()
Signal is emitted when a rendering is starting.
void stopRendering()
Stop map rendering.
void zoom(QPointF center, qreal scale)
Set map setting's extent (zoom the map) on the center by given scale.
void setIncrementalRendering(bool incrementalRendering)
When the incrementalRendering property is set to true, the automatic refresh of map canvas during ren...
void clearCache()
Clears rendering cache.
void setFreeze(bool freeze)
When freeze property is set to true, the map canvas does not refresh.
QgsQuickMapSettings * mapSettings
The mapSettings property contains configuration for rendering of the map.
void refresh()
Refresh the map canvas.
QSGNode * updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) override
void mapUpdateIntervalChanged()
Interval in milliseconds after which the map canvas will be updated while a rendering job is ongoing.
bool incrementalRendering
When the incrementalRendering property is set to true, the automatic refresh of map canvas during ren...
bool freeze
When freeze property is set to true, the map canvas does not refresh.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
QgsQuickMapCanvasMap(QQuickItem *parent=nullptr)
Create map canvas map.
void isRenderingChanged()
The isRendering property is set to true while a rendering job is pending for this map canvas map.
Encapsulates QgsMapSettings class to offer settings of configuration of map rendering via QML propert...