QGIS API Documentation 3.41.0-Master (af5edcb665c)
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{
66 QgsChunkNodeId( int _d = -1, int _x = -1, int _y = -1, int _z = -1 )
67 : d( _d ), x( _x ), y( _y ), z( _z ) {}
68
74 QgsChunkNodeId( long long id )
75 : uniqueId( id )
76 {}
77
78 int d = 0;
79 int x = 0;
80 int y = 0;
81 int z = 0;
82 long long uniqueId = -1;
83
85 QString text() const
86 {
87 if ( uniqueId != -1 )
88 return QString::number( uniqueId );
89 else if ( z == -1 )
90 return QStringLiteral( "%1/%2/%3" ).arg( d ).arg( x ).arg( y ); // quadtree
91 else
92 return QStringLiteral( "%1/%2/%3/%4" ).arg( d ).arg( x ).arg( y ).arg( z ); // octree
93 }
94
95 bool operator==( const QgsChunkNodeId &other ) const
96 {
97 return ( uniqueId == -1 && other.uniqueId == -1 && d == other.d && x == other.x && y == other.y && z == other.z )
98 || ( uniqueId != -1 && uniqueId == other.uniqueId );
99 }
100
101 bool operator!=( const QgsChunkNodeId &other ) const
102 {
103 return !( *this == other );
104 }
105};
106
123class QgsChunkNode
124{
125 public:
127 QgsChunkNode( const QgsChunkNodeId &nodeId, const QgsBox3D &box3D, float error, QgsChunkNode *parent = nullptr );
128
129 ~QgsChunkNode();
130
149 enum State
150 {
151 Skeleton,
152 QueuedForLoad,
153 Loading,
154 Loaded,
155 QueuedForUpdate,
156 Updating,
157 };
158
160 QgsBox3D box3D() const { return mBox3D; }
162 float error() const { return mError; }
164 QgsChunkNodeId tileId() const { return mNodeId; }
166 QgsChunkNode *parent() const { return mParent; }
168 int childCount() const { return mChildren.count(); }
170 QgsChunkNode *const *children() const { return mChildren.constData(); }
172 Qgis::TileRefinementProcess refinementProcess() const { return mRefinementProcess; }
174 State state() const { return mState; }
175
177 QgsChunkListEntry *loaderQueueEntry() const { return mLoaderQueueEntry; }
179 QgsChunkListEntry *replacementQueueEntry() const { return mReplacementQueueEntry; }
181 QgsChunkLoader *loader() const { return mLoader; }
183 Qt3DCore::QEntity *entity() const { return mEntity; }
185 QgsChunkQueueJob *updater() const { return mUpdater; }
186
188 bool allChildChunksResident( QTime currentTime ) const;
189
191 bool hasChildrenPopulated() const { return mChildrenPopulated; }
192
194 void populateChildren( const QVector<QgsChunkNode *> &children );
195
197 void setRefinementProcess( Qgis::TileRefinementProcess refinementProcess ) { mRefinementProcess = refinementProcess; }
198
200 int level() const;
201
203 QList<QgsChunkNode *> descendants();
204
205 //
206 // changes of states in the state machine (see State enum)
207 //
208
210 void setQueuedForLoad( QgsChunkListEntry *entry );
211
213 void cancelQueuedForLoad();
214
216 void setLoading( QgsChunkLoader *chunkLoader );
217
219 void cancelLoading();
220
222 void setLoaded( Qt3DCore::QEntity *mEntity );
223
225 void unloadChunk();
226
228 void setQueuedForUpdate( QgsChunkListEntry *entry, QgsChunkQueueJobFactory *updateJobFactory );
229
231 void cancelQueuedForUpdate();
232
234 void setUpdating();
235
237 void cancelUpdating();
238
240 void setUpdated();
241
243 void setExactBox3D( const QgsBox3D &box3D );
244
252 void updateParentBoundingBoxesRecursively() const;
253
255 void setHasData( bool hasData ) { mHasData = hasData; }
257 bool hasData() const { return mHasData; }
258
259 private:
260 QgsBox3D mBox3D;
261 float mError;
262
263 QgsChunkNodeId mNodeId;
264
265 QgsChunkNode *mParent;
266 QVector<QgsChunkNode *> mChildren;
267 bool mChildrenPopulated = false;
268
269 State mState;
270
272
273 QgsChunkListEntry *mLoaderQueueEntry;
274 QgsChunkListEntry *mReplacementQueueEntry;
275
276 QgsChunkLoader *mLoader;
277 Qt3DCore::QEntity *mEntity;
278
279 QgsChunkQueueJobFactory *mUpdaterFactory;
280 QgsChunkQueueJob *mUpdater;
281
282 QTime mEntityCreatedTime;
283 bool mHasData = true;
284};
285
287
288#endif // CHUNKNODE_H
TileRefinementProcess
Tiled scene tile refinement processes.
Definition qgis.h:5317
@ 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)