QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsvectorlayerchunkloader_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerchunkloader_p.h
3 --------------------------------------
4 Date : July 2019
5 Copyright : (C) 2019 by Martin Dobias
6 Email : wonder dot sk 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 QGSVECTORLAYERCHUNKLOADER_P_H
17#define QGSVECTORLAYERCHUNKLOADER_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"
31#include "qgschunkedentity.h"
32#include "qgschunkloader.h"
33
34#define SIP_NO_FILE
35
36class QgsVectorLayer;
40class QgsFeature3DHandler;
41
42namespace Qt3DCore
43{
44 class QTransform;
45}
46
47#include <QFutureWatcher>
48
49
57class QgsVectorLayerChunkLoaderFactory : public QgsQuadtreeChunkLoaderFactory
58{
59 Q_OBJECT
60
61 public:
63 QgsVectorLayerChunkLoaderFactory( const Qgs3DRenderContext &context, QgsVectorLayer *vl, QgsAbstract3DSymbol *symbol, double zMin, double zMax, int maxFeatures );
64
66 QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override;
67 bool canCreateChildren( QgsChunkNode *node ) override;
68 QVector<QgsChunkNode *> createChildren( QgsChunkNode *node ) const override;
69
70 Qgs3DRenderContext mRenderContext;
71 QgsVectorLayer *mLayer;
72 std::unique_ptr<QgsAbstract3DSymbol> mSymbol;
74 mutable QHash< QString, bool > mNodesAreLeafs;
75 int mMaxFeatures;
76};
77
78
87class QgsVectorLayerChunkLoader : public QgsChunkLoader
88{
89 Q_OBJECT
90
91 public:
93 QgsVectorLayerChunkLoader( const QgsVectorLayerChunkLoaderFactory *factory, QgsChunkNode *node );
94 ~QgsVectorLayerChunkLoader() override;
95
96 void start() override;
97 void cancel() override;
98 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
99
100 private:
101 const QgsVectorLayerChunkLoaderFactory *mFactory;
102 std::unique_ptr<QgsFeature3DHandler> mHandler;
103 Qgs3DRenderContext mRenderContext;
104 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
105 bool mCanceled = false;
106 QFutureWatcher<void> *mFutureWatcher = nullptr;
107 QString mLayerName;
108 bool mNodeIsLeaf = false;
109};
110
111
122class QgsVectorLayerChunkedEntity : public QgsChunkedEntity
123{
124 Q_OBJECT
125 public:
127 explicit QgsVectorLayerChunkedEntity( Qgs3DMapSettings *map, QgsVectorLayer *vl, double zMin, double zMax, const QgsVectorLayer3DTilingSettings &tilingSettings, QgsAbstract3DSymbol *symbol );
128
129 QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const override;
130
131 ~QgsVectorLayerChunkedEntity() override;
132 private slots:
133 void onTerrainElevationOffsetChanged();
134
135 private:
136 friend class QgsRuleBasedChunkedEntity;
138 static QList<QgsRayCastHit> rayIntersection( const QList<QgsChunkNode *> &activeNodes, const QMatrix4x4 &transformMatrix, const QgsRay3D &ray, const QgsRayCastContext &context, const QgsVector3D &origin );
139
140 Qt3DCore::QTransform *mTransform = nullptr;
141
142 bool applyTerrainOffset() const;
143
144 friend class TestQgsChunkedEntity;
145};
146
148
149#endif // QGSVECTORLAYERCHUNKLOADER_P_H
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Defines configuration of how a vector layer gets tiled for 3D rendering.
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.