QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 Qgs3DRenderContext mRenderContext;
72 QgsCoordinateTransform mCoordinateTransform;
73 QgsPointCloudIndex mPointCloudIndex;
74 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
75 double mZValueScale = 1.0;
76 double mZValueOffset = 0;
77 int mPointBudget = 1000000;
78 bool mTriangulate = false;
79 QgsRectangle mExtent;
80};
81
82
91class QgsPointCloudLayerChunkLoader : public QgsChunkLoader
92{
93 Q_OBJECT
94
95 public:
100 QgsPointCloudLayerChunkLoader(
101 const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr<QgsPointCloud3DSymbol> symbol, const QgsCoordinateTransform &coordinateTransform, double zValueScale, double zValueOffset
102 );
103 ~QgsPointCloudLayerChunkLoader() override;
104
105 void start() override;
106 void cancel() override;
107 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
108
109 private:
110 const QgsPointCloudLayerChunkLoaderFactory *mFactory;
111 std::unique_ptr<QgsPointCloud3DSymbolHandler> mHandler;
112 QgsPointCloud3DRenderContext mContext;
113 QFutureWatcher<void> *mFutureWatcher = nullptr;
114};
115
116
127class QgsPointCloudLayerChunkedEntity : public QgsChunkedEntity
128{
129 Q_OBJECT
130 public:
131 explicit QgsPointCloudLayerChunkedEntity(
132 Qgs3DMapSettings *map,
133 QgsPointCloudLayer *pcl,
134 const int indexPosition,
135 const QgsCoordinateTransform &coordinateTransform,
136 QgsPointCloud3DSymbol *symbol,
137 float maxScreenError,
138 bool showBoundingBoxes,
139 double zValueScale,
140 double zValueOffset,
141 int pointBudget
142 );
143
144 QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const override;
145
146 ~QgsPointCloudLayerChunkedEntity() override;
147
148 private slots:
149 void updateIndex();
150
151 private:
152 static QgsPointCloudIndex resolveIndex( const QgsPointCloudLayer *pcl, int indexPosition );
153
154 QgsPointCloudLayer *mLayer = nullptr;
155 std::unique_ptr<QgsChunkUpdaterFactory> mChunkUpdaterFactory;
156 int mIndexPosition;
157};
158
160
161#endif // QGSPOINTCLOUDLAYERCHUNKLOADER_P_H