Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qbsptree_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QBSPTREE_P_H
5#define QBSPTREE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <qlist.h>
20#include <qrect.h>
21
23
25{
26public:
27
28 struct Node
29 {
30 enum Type { None = 0, VerticalPlane = 1, HorizontalPlane = 2, Both = 3 };
31 inline Node() : pos(0), type(None) {}
32 int pos;
34 };
36
37 struct Data
38 {
39 Data(void *p) : ptr(p) {}
40 Data(int n) : i(n) {}
41 union {
42 void *ptr;
43 int i;
44 };
45 };
47 typedef void callback(QList<int> &leaf, const QRect &area, uint visited, QBspTreeData data);
48
49 QBspTree();
50
51 void create(int n, int d = -1);
52 void destroy();
53
54 inline void init(const QRect &area, NodeType type) { init(area, depth, type, 0); }
55
56 void climbTree(const QRect &rect, callback *function, QBspTreeData data);
57
58 inline int leafCount() const { return leaves.size(); }
59 inline QList<int> &leaf(int i) { return leaves[i]; }
60 inline void insertLeaf(const QRect &r, int i) { climbTree(r, &insert, i, 0); }
61 inline void removeLeaf(const QRect &r, int i) { climbTree(r, &remove, i, 0); }
62
63protected:
64 void init(const QRect &area, int depth, NodeType type, int index);
65 void climbTree(const QRect &rect, callback *function, QBspTreeData data, int index);
66
67 inline int parentIndex(int i) const { return (i & 1) ? ((i - 1) / 2) : ((i - 2) / 2); }
68 inline int firstChildIndex(int i) const { return ((i * 2) + 1); }
69
70 static void insert(QList<int> &leaf, const QRect &area, uint visited, QBspTreeData data);
71 static void remove(QList<int> &leaf, const QRect &area, uint visited, QBspTreeData data);
72
73private:
74 uint depth;
75 mutable uint visited;
76 QList<Node> nodes;
77 mutable QList<QList<int>> leaves; // the leaves are just indices into the items
78};
79
81
82#endif // QBSPTREE_P_H
static void remove(QList< int > &leaf, const QRect &area, uint visited, QBspTreeData data)
Definition qbsptree.cpp:100
Node::Type NodeType
Definition qbsptree_p.h:35
void insertLeaf(const QRect &r, int i)
Definition qbsptree_p.h:60
QBspTree::Data QBspTreeData
Definition qbsptree_p.h:46
int parentIndex(int i) const
Definition qbsptree_p.h:67
void callback(QList< int > &leaf, const QRect &area, uint visited, QBspTreeData data)
Definition qbsptree_p.h:47
void destroy()
Definition qbsptree.cpp:27
int firstChildIndex(int i) const
Definition qbsptree_p.h:68
void climbTree(const QRect &rect, callback *function, QBspTreeData data)
Definition qbsptree.cpp:33
void init(const QRect &area, NodeType type)
Definition qbsptree_p.h:54
void removeLeaf(const QRect &r, int i)
Definition qbsptree_p.h:61
int leafCount() const
Definition qbsptree_p.h:58
static void insert(QList< int > &leaf, const QRect &area, uint visited, QBspTreeData data)
Definition qbsptree.cpp:95
QList< int > & leaf(int i)
Definition qbsptree_p.h:59
qsizetype size() const noexcept
Definition qlist.h:397
\inmodule QtCore\reentrant
Definition qrect.h:30
rect
[4]
Combined button and popup list for selecting options.
static int area(const QSize &s)
Definition qicon.cpp:153
GLint GLenum GLsizei GLsizei GLsizei depth
GLuint index
[2]
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLfloat n
GLfloat GLfloat p
[1]
unsigned int uint
Definition qtypes.h:34
view create()
Data(void *p)
Definition qbsptree_p.h:39
Definition moc.h:23