QGIS API Documentation 4.3.0-Master (8c22baaae17)
Loading...
Searching...
No Matches
qgscategorizedchunkloader_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscategorizedchunkloader_p.h
3 --------------------------------------
4 Date : November 2025
5 Copyright : (C) 2025 by Jean Felder
6 Email : jean dot felder at oslandia 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 QGSCATEGORIZEDCHUNKLOADER_H
17#define QGSCATEGORIZEDCHUNKLOADER_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"
33#include "qgschunkloader.h"
34
35#include <QFutureWatcher>
36#include <QMutex>
37
38#define SIP_NO_FILE
39
41class QgsVectorLayer;
44class QgsFeature3DHandler;
45
46namespace Qt3DCore
47{
48 class QTransform;
49}
50
58class QgsCategorizedChunkLoader : public QgsQuadtreeChunkLoader
59{
60 Q_OBJECT
61
62 public:
64 QgsCategorizedChunkLoader( const Qgs3DRenderContext &context, QgsVectorLayer *vectorLayer, const QgsCategorized3DRenderer *renderer, double zMin, double zMax, int maxFeatures );
65 ~QgsCategorizedChunkLoader() override;
66
67 QFuture<QgsChunkLoaderResult> loadChunk( QgsChunkNode *node ) override;
68 QFuture<QVector<QgsChunkNode *>> createChildren( QgsChunkNode *node ) override;
69
70 private:
72 struct NodeIsLeafMap
73 {
74 QHash< QString, bool > map;
75 QMutex mutex;
76 };
77
79 struct ChunkLoadingContext
80 {
81 // We need shared_ptr, because we capture this in std::function. We could
82 // get around this with std::move_only_function (C++23 feature) or by
83 // returning a custom allocated object with virtual methods.
84 QgsChunkNode *node;
85 std::shared_ptr<QgsVectorLayerFeatureSource> source;
86 Qgs3DRenderContext renderCtx;
87 std::vector<std::shared_ptr<QgsFeature3DHandler>> handlers;
89 QHash<QString, QgsFeature3DHandler *> featuresHandlerHash;
90 std::shared_ptr<QgsExpression> expression;
91 int attributeIdx = -1;
92 int maxFeatures;
93 std::shared_ptr<NodeIsLeafMap> nodesAreLeafs;
94 };
95
96 static void loadChunkInWorker( QPromise<ChunkLoadingContext> &promise, ChunkLoadingContext ctx, QgsFeatureRequest request );
97 Qt3DCore::QEntity *createEntity( ChunkLoadingContext ctx, Qt3DCore::QEntity *parent );
98 static void processFeature( ChunkLoadingContext &ctx, const QgsFeature &feature );
99
100 Qgs3DRenderContext mRenderContext;
101 const QgsVectorLayer *mLayer = nullptr;
102 const Qgs3DCategoryList *mCategories = nullptr;
103 QString mAttributeName;
104 std::shared_ptr<NodeIsLeafMap> mNodesAreLeafs;
105 int mMaxFeatures = 0;
106
107 friend class QgsCategorizedChunkedEntity;
108};
109
121class QgsCategorizedChunkedEntity : public QgsAbstractFeatureBasedChunkedEntity
122{
123 Q_OBJECT
124 public:
126 explicit QgsCategorizedChunkedEntity(
127 Qgs3DMapSettings *mapSettings, QgsVectorLayer *vectorLayer, double zMin, double zMax, const QgsVectorLayer3DTilingSettings &tilingSettings, const QgsCategorized3DRenderer *renderer
128 );
129
130 ~QgsCategorizedChunkedEntity() override;
131
132 private:
133 bool applyTerrainOffset() const override;
134};
135
137
138#endif // QGSCATEGORIZEDCHUNKLOADER_H
Definition of the world.
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Partial snapshot of vector layer's state (only the members necessary for access to features).
Represents a vector layer which manages a vector based dataset.
QList< Qgs3DRendererCategory > Qgs3DCategoryList