Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QBSPTREE_P_H
6
#
define
QBSPTREE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists for the convenience
13
// of other Qt classes. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtWidgets
/
private
/
qtwidgetsglobal_p
.
h
>
20
#
include
<
qlist
.
h
>
21
#
include
<
qrect
.
h
>
22
23
QT_BEGIN_NAMESPACE
24
25
class
QBspTree
26
{
27
public
:
28
29
struct
Node
30
{
31
enum
Type
{
None
= 0,
VerticalPlane
= 1,
HorizontalPlane
= 2,
Both
= 3 };
32
inline
Node
() :
pos
(0),
type
(
None
) {}
33
int
pos
;
34
Type
type
;
35
};
36
typedef
Node
::
Type
NodeType
;
37
38
struct
Data
39
{
40
Data
(
void
*p) : ptr(p) {}
41
Data
(
int
n) : i(n) {}
42
union
{
43
void
*ptr;
44
int
i;
45
};
46
};
47
typedef
QBspTree
::
Data
QBspTreeData
;
48
typedef
void
callback
(
QList
<
int
> &leaf,
const
QRect &area, uint visited,
QBspTreeData
data);
49
50
QBspTree
();
51
52
void
create
(
int
n,
int
d = -1);
53
void
destroy
();
54
55
inline
void
init
(
const
QRect &area,
NodeType
type) { init(area, depth, type, 0); }
56
57
void
climbTree
(
const
QRect &rect,
callback
*function,
QBspTreeData
data);
58
59
inline
int
leafCount
()
const
{
return
leaves.size(); }
60
inline
QList
<
int
> &
leaf
(
int
i) {
return
leaves[i]; }
61
inline
void
insertLeaf
(
const
QRect &r,
int
i) { climbTree(r, &insert, i, 0); }
62
inline
void
removeLeaf
(
const
QRect &r,
int
i) { climbTree(r, &remove, i, 0); }
63
64
protected
:
65
void
init
(
const
QRect &area,
int
depth,
NodeType
type,
int
index);
66
void
climbTree
(
const
QRect &rect,
callback
*function,
QBspTreeData
data,
int
index);
67
68
inline
int
parentIndex
(
int
i)
const
{
return
(i & 1) ? ((i - 1) / 2) : ((i - 2) / 2); }
69
inline
int
firstChildIndex
(
int
i)
const
{
return
((i * 2) + 1); }
70
71
static
void
insert
(
QList
<
int
> &leaf,
const
QRect &area, uint visited,
QBspTreeData
data);
72
static
void
remove
(
QList
<
int
> &leaf,
const
QRect &area, uint visited,
QBspTreeData
data);
73
74
private
:
75
uint depth;
76
mutable
uint visited;
77
QList
<
Node
> nodes;
78
mutable
QList
<
QList
<
int
>> leaves;
// the leaves are just indices into the items
79
};
80
81
QT_END_NAMESPACE
82
83
#
endif
// QBSPTREE_P_H
QBspTree
Definition
qbsptree_p.h:26
QBspTree::remove
static void remove(QList< int > &leaf, const QRect &area, uint visited, QBspTreeData data)
Definition
qbsptree.cpp:101
QBspTree::NodeType
Node::Type NodeType
Definition
qbsptree_p.h:36
QBspTree::insertLeaf
void insertLeaf(const QRect &r, int i)
Definition
qbsptree_p.h:61
QBspTree::QBspTreeData
QBspTree::Data QBspTreeData
Definition
qbsptree_p.h:47
QBspTree::create
void create(int n, int d=-1)
Definition
qbsptree.cpp:11
QBspTree::parentIndex
int parentIndex(int i) const
Definition
qbsptree_p.h:68
QBspTree::callback
void callback(QList< int > &leaf, const QRect &area, uint visited, QBspTreeData data)
Definition
qbsptree_p.h:48
QBspTree::climbTree
void climbTree(const QRect &rect, callback *function, QBspTreeData data, int index)
Definition
qbsptree.cpp:42
QBspTree::destroy
void destroy()
Definition
qbsptree.cpp:28
QBspTree::firstChildIndex
int firstChildIndex(int i) const
Definition
qbsptree_p.h:69
QBspTree::QBspTree
QBspTree()
Definition
qbsptree.cpp:9
QBspTree::climbTree
void climbTree(const QRect &rect, callback *function, QBspTreeData data)
Definition
qbsptree.cpp:34
QBspTree::init
void init(const QRect &area, NodeType type)
Definition
qbsptree_p.h:55
QBspTree::removeLeaf
void removeLeaf(const QRect &r, int i)
Definition
qbsptree_p.h:62
QBspTree::leafCount
int leafCount() const
Definition
qbsptree_p.h:59
QBspTree::insert
static void insert(QList< int > &leaf, const QRect &area, uint visited, QBspTreeData data)
Definition
qbsptree.cpp:96
QBspTree::init
void init(const QRect &area, int depth, NodeType type, int index)
Definition
qbsptree.cpp:67
QBspTree::leaf
QList< int > & leaf(int i)
Definition
qbsptree_p.h:60
QList
Definition
qlist.h:82
QRect
\inmodule QtCore\reentrant
Definition
qrect.h:32
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QBspTree::Data
Definition
qbsptree_p.h:39
QBspTree::Data::Data
Data(void *p)
Definition
qbsptree_p.h:40
QBspTree::Data::Data
Data(int n)
Definition
qbsptree_p.h:41
QBspTree::Node
Definition
qbsptree_p.h:30
QBspTree::Node::pos
int pos
Definition
qbsptree_p.h:33
QBspTree::Node::Type
Type
Definition
qbsptree_p.h:31
QBspTree::Node::None
@ None
Definition
qbsptree_p.h:31
QBspTree::Node::HorizontalPlane
@ HorizontalPlane
Definition
qbsptree_p.h:31
QBspTree::Node::Both
@ Both
Definition
qbsptree_p.h:31
QBspTree::Node::VerticalPlane
@ VerticalPlane
Definition
qbsptree_p.h:31
QBspTree::Node::Node
Node()
Definition
qbsptree_p.h:32
QBspTree::Node::type
Type type
Definition
qbsptree_p.h:34
qtbase
src
widgets
itemviews
qbsptree_p.h
Generated on
for Qt by
1.18.0