QGIS API Documentation 4.3.0-Master (16eddb2670e)
Loading...
Searching...
No Matches
qgsannotationlayerchunkloader_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationlayerchunkloader_p.h
3 --------------------------------------
4 Date : September 2025
5 Copyright : (C) 2025 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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 QGSANNOTATIONLAYERCHUNKLOADER_P_H
17#define QGSANNOTATIONLAYERCHUNKLOADER_P_H
18
20
21//
22// W A R N I N G
23// -------------
24//
25// This file is not part of the QGIS API. It exists purely as an
26// implementation detail. This header file may change from version to
27// version without notice, or even be removed.
28//
29
30#include <functional>
31#include <limits>
32#include <memory>
33#include <vector>
34
35#include "qgs3drendercontext.h"
38#include "qgschunkloader.h"
40#include "qgslinestring.h"
41#include "qgstextformat.h"
42#include "qgsvector3d.h"
43
44#include <QImage>
45#include <QPromise>
46#include <QSize>
47#include <QVector3D>
48
49#define SIP_NO_FILE
50
53
54namespace Qt3DCore
55{
56 class QTransform;
57}
58
59#include <QFutureWatcher>
60
61
68class QgsAnnotationLayerChunkLoader : public QgsQuadtreeChunkLoader
69{
70 Q_OBJECT
71
72 public:
74 QgsAnnotationLayerChunkLoader(
75 const Qgs3DRenderContext &context,
76 QgsAnnotationLayer *layer,
77 int leafLevel,
79 double zOffset,
80 bool showCallouts,
81 const QColor &calloutLineColor,
82 double calloutLineWidth,
83 const QgsTextFormat &textFormat,
84 double zMin,
85 double zMax
86 );
87
88 QFuture<QgsChunkLoaderResult> loadChunk( QgsChunkNode *node ) override;
89
90 Qgs3DRenderContext mRenderContext;
91 QgsAnnotationLayer *mLayer = nullptr;
92 int mLeafLevel = 0;
93
95 struct LoaderData
96 {
98 double mZOffset = 0;
99 bool mShowCallouts = false;
100 QColor mCalloutLineColor;
101 double mCalloutLineWidth = 2;
102 QgsTextFormat mTextFormat;
103 };
104
105 // Each worker thread loading a chunk copies this data.
106 LoaderData mData;
107
108 private:
110 struct PictureBillboards
111 {
112 QImage image;
113 QVector< QVector3D > positions;
114 QVector< QSizeF > sizes;
116 };
117
119 struct ChunkData
120 {
121 QgsChunkNode *node = nullptr;
122 QString layerName;
123 QgsVector3D chunkOrigin;
124 Qgs3DRenderContext renderContext;
125 QVector< QgsBillboardGeometry::BillboardAtlasData > billboardPositions;
126 QVector< QgsBillboardGeometry::BillboardAtlasData > textBillboardPositions;
127 QImage billboardAtlas;
128 QImage textBillboardAtlas;
129 QVector< PictureBillboards > pictureBillboards;
130 QVector< QgsLineString > calloutLines;
131 double zMin = std::numeric_limits< double >::max();
132 double zMax = std::numeric_limits< double >::lowest();
133 };
134
135 static void loadChunkInWorker(
136 QPromise<ChunkData> &promise,
137 QgsChunkNode *node,
138 const QgsRectangle &rect,
139 const QgsCoordinateTransform &layerToMapTransform,
140 const QString &layerName,
141 const std::vector< std::unique_ptr< QgsAnnotationItem > > &itemsToRender,
142 const QgsVector3D &chunkOrigin,
143 const Qgs3DRenderContext &renderCtx,
144 const LoaderData &data
145 );
146
147 Qt3DCore::QEntity *createEntity( const ChunkData &chunkData, Qt3DCore::QEntity *parent );
148};
149
160class QgsAnnotationLayerChunkedEntity : public QgsAbstractFeatureBasedChunkedEntity
161{
162 Q_OBJECT
163 public:
165 explicit QgsAnnotationLayerChunkedEntity(
166 Qgs3DMapSettings *map,
167 QgsAnnotationLayer *layer,
168 Qgis::AltitudeClamping clamping,
169 double zOffset,
170 bool showCallouts,
171 const QColor &calloutLineColor,
172 double calloutLineWidth,
173 const QgsTextFormat &textFormat,
174 double zMin,
175 double zMax
176 );
177 ~QgsAnnotationLayerChunkedEntity() override;
178
179 QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const override;
180
181 private:
182 bool applyTerrainOffset() const override;
183};
184
186
187#endif // QGSANNOTATIONLAYERCHUNKLOADER_P_H
AltitudeClamping
Altitude clamping.
Definition qgis.h:4245
@ Relative
Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation).
Definition qgis.h:4247
BillboardScaleMode
3D billboard scaling modes.
Definition qgis.h:4497
@ ViewIndependent
Billboard has a fixed pixel size on the screen, regardless of the camera distance.
Definition qgis.h:4498
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Represents a map layer containing a set of georeferenced annotations, e.g.