QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 "qgs3drendercontext.h"
32#include "qgschunkedentity.h"
33#include "qgschunkloader.h"
34#include "qgstextformat.h"
35
36#include <QImage>
37
38#define SIP_NO_FILE
39
42
43namespace Qt3DCore
44{
45 class QTransform;
46}
47
48#include <QFutureWatcher>
49
50
57class QgsAnnotationLayerChunkLoaderFactory : public QgsQuadtreeChunkLoaderFactory
58{
59 Q_OBJECT
60
61 public:
63 QgsAnnotationLayerChunkLoaderFactory(
64 const Qgs3DRenderContext &context,
65 QgsAnnotationLayer *layer,
66 int leafLevel,
68 double zOffset,
69 bool showCallouts,
70 const QColor &calloutLineColor,
71 double calloutLineWidth,
72 const QgsTextFormat &textFormat,
73 double zMin,
74 double zMax
75 );
76
78 QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override;
79
80 Qgs3DRenderContext mRenderContext;
81 QgsAnnotationLayer *mLayer = nullptr;
82 int mLeafLevel = 0;
84 double mZOffset = 0;
85 bool mShowCallouts = false;
86 QColor mCalloutLineColor;
87 double mCalloutLineWidth = 2;
88 QgsTextFormat mTextFormat;
89};
90
91
99class QgsAnnotationLayerChunkLoader : public QgsChunkLoader
100{
101 Q_OBJECT
102
103 public:
105 QgsAnnotationLayerChunkLoader( const QgsAnnotationLayerChunkLoaderFactory *factory, QgsChunkNode *node );
106 ~QgsAnnotationLayerChunkLoader() override;
107
108 void start() override;
109 void cancel() override;
110 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
111
112 private:
113 const QgsAnnotationLayerChunkLoaderFactory *mFactory = nullptr;
114 Qgs3DRenderContext mRenderContext;
115 bool mCanceled = false;
116 QFutureWatcher<void> *mFutureWatcher = nullptr;
117 QString mLayerName;
118 QgsVector3D mChunkOrigin;
119
120 std::vector< std::unique_ptr< QgsAnnotationItem > > mItemsToRender;
121
122 QVector< QgsBillboardGeometry::BillboardAtlasData > mBillboardPositions;
123 QVector< QgsBillboardGeometry::BillboardAtlasData > mTextBillboardPositions;
124 QVector< QgsLineString > mCalloutLines;
125 QImage mBillboardAtlas;
126 QImage mTextBillboardAtlas;
127 double mZMin = std::numeric_limits< double >::max();
128 double mZMax = std::numeric_limits< double >::lowest();
129};
130
131
142class QgsAnnotationLayerChunkedEntity : public QgsChunkedEntity
143{
144 Q_OBJECT
145 public:
147 explicit QgsAnnotationLayerChunkedEntity(
148 Qgs3DMapSettings *map,
149 QgsAnnotationLayer *layer,
150 Qgis::AltitudeClamping clamping,
151 double zOffset,
152 bool showCallouts,
153 const QColor &calloutLineColor,
154 double calloutLineWidth,
155 const QgsTextFormat &textFormat,
156 double zMin,
157 double zMax
158 );
159 ~QgsAnnotationLayerChunkedEntity() override;
160
161 private slots:
162 void onTerrainElevationOffsetChanged();
163
164 private:
165 Qt3DCore::QTransform *mTransform = nullptr;
166
167 bool applyTerrainOffset() const;
168
169 friend class TestQgsChunkedEntity;
170};
171
173
174#endif // QGSANNOTATIONLAYERCHUNKLOADER_P_H
AltitudeClamping
Altitude clamping.
Definition qgis.h:4099
@ Relative
Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation).
Definition qgis.h:4101
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Represents a map layer containing a set of georeferenced annotations, e.g.