QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgschunkedentity_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgschunkedentity_p.h
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 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 QGSCHUNKEDENTITY_P_H
17 #define QGSCHUNKEDENTITY_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 <Qt3DCore/QEntity>
31 
32 #define SIP_NO_FILE
33 
34 class QgsAABB;
35 class QgsChunkNode;
36 class QgsChunkList;
37 class QgsChunkQueueJob;
38 class QgsChunkLoaderFactory;
39 class QgsChunkBoundsEntity;
40 class QgsChunkQueueJobFactory;
41 
42 #include <QVector3D>
43 #include <QMatrix4x4>
44 
45 #include <QTime>
46 
47 #include "qgsfeatureid.h"
48 
49 namespace Qt3DRender
50 {
51  class QPickEvent;
52 }
53 
60 class QgsChunkedEntity : public Qt3DCore::QEntity
61 {
62  Q_OBJECT
63  public:
65  QgsChunkedEntity( const QgsAABB &rootBbox, float rootError, float mTau, int mMaxLevel, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, Qt3DCore::QNode *parent = nullptr );
66  ~QgsChunkedEntity() override;
67 
69  struct SceneState
70  {
71  QVector3D cameraPos;
72  float cameraFov;
73  int screenSizePx;
74  QMatrix4x4 viewProjectionMatrix;
75  };
76 
78  void update( const SceneState &state );
79 
81  bool needsUpdate() const { return mNeedsUpdate; }
82 
84  void setShowBoundingBoxes( bool enabled );
85 
87  void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
88 
90  QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
92  QgsChunkNode *rootNode() const { return mRootNode; }
93 
95  int pendingJobsCount() const;
96 
98  void setPickingEnabled( bool enabled );
100  bool hasPickingEnabled() const { return mPickingEnabled; }
101 
102  protected:
104  void cancelActiveJob( QgsChunkQueueJob *job );
105  void cancelActiveJobs();
107  void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
108 
109  private:
110  void update( QgsChunkNode *node, const SceneState &state );
111 
113  void requestResidency( QgsChunkNode *node );
114 
115  void startJobs();
116  QgsChunkQueueJob *startJob( QgsChunkNode *node );
117 
118  private slots:
119  void onActiveJobFinished();
120 
121  void onPickEvent( Qt3DRender::QPickEvent *event );
122 
123  signals:
125  void pendingJobsCountChanged();
126 
128  void newEntityCreated( Qt3DCore::QEntity *entity );
129 
131  void pickedObject( Qt3DRender::QPickEvent *pickEvent, QgsFeatureId fid );
132 
133  protected:
135  QgsChunkNode *mRootNode = nullptr;
137  bool mNeedsUpdate = false;
138 
146  float mTau;
148  int mMaxLevel;
150  QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
152  bool mOwnsFactory = true;
154  QgsChunkList *mChunkLoaderQueue = nullptr;
156  QgsChunkList *mReplacementQueue = nullptr;
158  QList<QgsChunkNode *> mActiveNodes;
160  int mFrustumCulled = 0;
161 
162  // TODO: max. length for loading queue
163 
164  QTime mCurrentTime;
165 
167  int mMaxLoadedChunks = 512;
168 
170  QgsChunkBoundsEntity *mBboxesEntity = nullptr;
171 
173  QList<QgsChunkQueueJob *> mActiveJobs;
174 
176  bool mPickingEnabled = false;
177 
178  bool mIsValid = true;
179 };
180 
182 
183 #endif // QGSCHUNKEDENTITY_P_H
qgsfeatureid.h
Qt3DRender
Definition: qgs3dmapscene.h:27
QgsAABB
3 Axis-aligned bounding box - in world coords.
Definition: qgsaabb.h:34
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28