QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgschunknode.h
Go to the documentation of this file.
1/***************************************************************************
2 qgschunknode.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 QGSCHUNKNODE_H
17#define QGSCHUNKNODE_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 "qgsaabb.h"
31#include "qgsbox3d.h"
32
33#include "qgis.h"
34#include <QTime>
35
36#define SIP_NO_FILE
37
38namespace Qt3DCore
39{
40 class QEntity;
41}
42
43struct QgsChunkListEntry;
44class QgsChunkLoader;
45class QgsChunkQueueJob;
46class QgsChunkQueueJobFactory;
47
48
61struct QgsChunkNodeId
62{
63
67 QgsChunkNodeId( int _d = -1, int _x = -1, int _y = -1, int _z = -1 )
68 : d( _d ), x( _x ), y( _y ), z( _z ) {}
69
75 QgsChunkNodeId( long long id )
76 : uniqueId( id )
77 {}
78
79 int d = 0;
80 int x = 0;
81 int y = 0;
82 int z = 0;
83 long long uniqueId = -1;
84
86 QString text() const
87 {
88 if ( uniqueId != -1 )
89 return QString::number( uniqueId );
90 else if ( z == -1 )
91 return QStringLiteral( "%1/%2/%3" ).arg( d ).arg( x ).arg( y ); // quadtree
92 else
93 return QStringLiteral( "%1/%2/%3/%4" ).arg( d ).arg( x ).arg( y ).arg( z ); // octree
94 }
95
96 bool operator==( const QgsChunkNodeId &other ) const
97 {
98 return ( uniqueId == -1 && other.uniqueId == -1 && d == other.d && x == other.x && y == other.y && z == other.z )
99 || ( uniqueId != -1 && uniqueId == other.uniqueId );
100 }
101
102 bool operator!=( const QgsChunkNodeId &other ) const
103 {
104 return !( *this == other );
105 }
106};
107
124class QgsChunkNode
125{
126 public:
127
129 QgsChunkNode( const QgsChunkNodeId &nodeId, const QgsBox3D &box3D, float error, QgsChunkNode *parent = nullptr );
130
131 ~QgsChunkNode();
132
151 enum State
152 {
153 Skeleton,
154 QueuedForLoad,
155 Loading,
156 Loaded,
157 QueuedForUpdate,
158 Updating,
159 };
160
162 QgsBox3D box3D() const { return mBox3D; }
164 float error() const { return mError; }
166 QgsChunkNodeId tileId() const { return mNodeId; }
168 QgsChunkNode *parent() const { return mParent; }
170 int childCount() const { return mChildren.count(); }
172 QgsChunkNode *const *children() const { return mChildren.constData(); }
174 Qgis::TileRefinementProcess refinementProcess() const { return mRefinementProcess; }
176 State state() const { return mState; }
177
179 QgsChunkListEntry *loaderQueueEntry() const { return mLoaderQueueEntry; }
181 QgsChunkListEntry *replacementQueueEntry() const { return mReplacementQueueEntry; }
183 QgsChunkLoader *loader() const { return mLoader; }
185 Qt3DCore::QEntity *entity() const { return mEntity; }
187 QgsChunkQueueJob *updater() const { return mUpdater; }
188
190 bool allChildChunksResident( QTime currentTime ) const;
191
193 bool hasChildrenPopulated() const { return mChildrenPopulated; }
194
196 void populateChildren( const QVector<QgsChunkNode *> &children );
197
199 void setRefinementProcess( Qgis::TileRefinementProcess refinementProcess ) { mRefinementProcess = refinementProcess; }
200
202 int level() const;
203
205 QList<QgsChunkNode *> descendants();
206
207 //
208 // changes of states in the state machine (see State enum)
209 //
210
212 void setQueuedForLoad( QgsChunkListEntry *entry );
213
215 void cancelQueuedForLoad();
216
218 void setLoading( QgsChunkLoader *chunkLoader );
219
221 void cancelLoading();
222
224 void setLoaded( Qt3DCore::QEntity *mEntity );
225
227 void unloadChunk();
228
230 void setQueuedForUpdate( QgsChunkListEntry *entry, QgsChunkQueueJobFactory *updateJobFactory );
231
233 void cancelQueuedForUpdate();
234
236 void setUpdating();
237
239 void cancelUpdating();
240
242 void setUpdated();
243
245 void setExactBox3D( const QgsBox3D &box3D );
246
254 void updateParentBoundingBoxesRecursively() const;
255
257 void setHasData( bool hasData ) { mHasData = hasData; }
259 bool hasData() const { return mHasData; }
260
261 private:
262 QgsBox3D mBox3D;
263 float mError;
264
265 QgsChunkNodeId mNodeId;
266
267 QgsChunkNode *mParent;
268 QVector<QgsChunkNode *> mChildren;
269 bool mChildrenPopulated = false;
270
271 State mState;
272
274
275 QgsChunkListEntry *mLoaderQueueEntry;
276 QgsChunkListEntry *mReplacementQueueEntry;
277
278 QgsChunkLoader *mLoader;
279 Qt3DCore::QEntity *mEntity;
280
281 QgsChunkQueueJobFactory *mUpdaterFactory;
282 QgsChunkQueueJob *mUpdater;
283
284 QTime mEntityCreatedTime;
285 bool mHasData = true;
286};
287
289
290#endif // CHUNKNODE_H
TileRefinementProcess
Tiled scene tile refinement processes.
Definition qgis.h:5254
@ Replacement
When tile is refined then its children should be used in place of itself.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:43
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)