QGIS API Documentation 3.99.0-Master (26c88405ac0)
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#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
149 void geometryChanged( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
150#else
151 void geometryChange( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
152#endif
153
154 public slots:
156 void stopRendering();
157
161 void zoom( QPointF center, qreal scale );
162
166 void pan( QPointF oldPos, QPointF newPos );
167
172 void refresh();
173
177 void clearCache();
178
179 private slots:
180 void refreshMap();
181 void renderJobUpdated();
182 void renderJobFinished();
183 void layerRepaintRequested( bool deferred );
184 void onWindowChanged( QQuickWindow *window );
185 void onScreenChanged( QScreen *screen );
186 void onExtentChanged();
187 void onLayersChanged();
188 void onTemporalStateChanged();
189 void onzRangeChanged();
190
191 private:
192 enum class CacheInvalidationType
193 {
194 Temporal = 1 << 0,
195 Elevation = 1 << 1,
196 };
197
201 void destroyJob( QgsMapRendererJob *job );
202 QgsMapSettings prepareMapSettings() const;
203 void updateTransform();
204 void zoomToFullExtent();
205
206 void clearTemporalCache();
207 void clearElevationCache();
208 QFlags<CacheInvalidationType> mCacheInvalidations;
209
210 std::unique_ptr<QgsQuickMapSettings> mMapSettings;
211 bool mPinching = false;
212 QPoint mPinchStartPoint;
213 QgsMapRendererParallelJob *mJob = nullptr;
214 std::unique_ptr<QgsMapRendererCache> mCache;
215 QgsLabelingResults *mLabelingResults = nullptr;
216 QImage mImage;
217 QgsMapSettings mImageMapSettings;
218 QTimer mRefreshTimer;
219 bool mDirty = false;
220 bool mFreeze = false;
221 QList<QMetaObject::Connection> mLayerConnections;
222 QTimer mMapUpdateTimer;
223 bool mIncrementalRendering = false;
224 bool mSilentRefresh = false;
225 bool mDeferredRefreshPending = false;
226
227 QQuickWindow *mWindow = nullptr;
228};
229
230#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...