QGIS API Documentation 4.1.0-Master (01362494303)
Loading...
Searching...
No Matches
qgspointcloudlayerchunkloader_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudlayerchunkloader_p.h
3 --------------------------------------
4 Date : October 2020
5 Copyright : (C) 2020 by Peter Petrik
6 Email : zilolv 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 QGSPOINTCLOUDLAYERCHUNKLOADER_P_H
17#define QGSPOINTCLOUDLAYERCHUNKLOADER_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 <memory>
31
32#include "qgschunkedentity.h"
33#include "qgschunkloader.h"
36#include "qgspointcloudindex.h"
38
39#include <QFutureWatcher>
40#include <QVector3D>
41#include <Qt3DCore/QBuffer>
42#include <Qt3DCore/QGeometry>
43
44#define SIP_NO_FILE
45
53class QgsPointCloudLayerChunkLoaderFactory : public QgsChunkLoaderFactory
54{
55 Q_OBJECT
56
57 public:
62 QgsPointCloudLayerChunkLoaderFactory(
63 const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, QgsPointCloudIndex pc, QgsPointCloud3DSymbol *symbol, double zValueScale, double zValueOffset, int pointBudget
64 );
65
67 QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override;
68 QgsChunkNode *createRootNode() const override;
69 QVector<QgsChunkNode *> createChildren( QgsChunkNode *node ) const override;
70 int primitivesCount( QgsChunkNode *node ) const override;
71
72 bool canCreateChildren( QgsChunkNode *node ) override;
73 void prepareChildren( QgsChunkNode *node ) override;
74
76 void fetchHierarchyForNode( const QgsPointCloudNodeId &nodeId, QgsChunkNode *origNode );
77
78 Qgs3DRenderContext mRenderContext;
79 QgsCoordinateTransform mCoordinateTransform;
80 QgsPointCloudIndex mPointCloudIndex;
81 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
82 double mZValueScale = 1.0;
83 double mZValueOffset = 0;
84 int mPointBudget = 1000000;
85 bool mTriangulate = false;
86 QgsRectangle mExtent;
87 QSet<QgsPointCloudNodeId> mPendingHierarchyFetches;
88 QSet<QgsPointCloudNodeId> mFutureHierarchyFetches;
89};
90
91
100class QgsPointCloudLayerChunkLoader : public QgsChunkLoader
101{
102 Q_OBJECT
103
104 public:
109 QgsPointCloudLayerChunkLoader(
110 const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr<QgsPointCloud3DSymbol> symbol, const QgsCoordinateTransform &coordinateTransform, double zValueScale, double zValueOffset
111 );
112 ~QgsPointCloudLayerChunkLoader() override;
113
114 void start() override;
115 void cancel() override;
116 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
117
118 private:
119 const QgsPointCloudLayerChunkLoaderFactory *mFactory;
120 std::unique_ptr<QgsPointCloud3DSymbolHandler> mHandler;
121 QgsPointCloud3DRenderContext mContext;
122 QFutureWatcher<void> *mFutureWatcher = nullptr;
123};
124
125
136class QgsPointCloudLayerChunkedEntity : public QgsChunkedEntity
137{
138 Q_OBJECT
139 public:
140 explicit QgsPointCloudLayerChunkedEntity(
141 Qgs3DMapSettings *map,
142 QgsPointCloudLayer *pcl,
143 const int indexPosition,
144 const QgsCoordinateTransform &coordinateTransform,
145 QgsPointCloud3DSymbol *symbol,
146 float maxScreenError,
147 bool showBoundingBoxes,
148 double zValueScale,
149 double zValueOffset,
150 int pointBudget
151 );
152
153 QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const override;
154
155 ~QgsPointCloudLayerChunkedEntity() override;
156
157 private slots:
158 void updateIndex();
159
160 private:
168 static QgsPointCloudIndex resolveIndex( const QgsPointCloudLayer *pcl, int indexPosition );
169
170 QgsPointCloudLayer *mLayer = nullptr;
171 std::unique_ptr<QgsChunkUpdaterFactory> mChunkUpdaterFactory;
172 int mIndexPosition;
173};
174
176
177#endif // QGSPOINTCLOUDLAYERCHUNKLOADER_P_H