| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qbsptree.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | QBspTree::QBspTree() : depth(6), visited(0) {} never executed: end of block | 0 | ||||||||||||
| 5 | - | |||||||||||||
| 6 | void QBspTree::create(int n, int d) | - | ||||||||||||
| 7 | { | - | ||||||||||||
| 8 | - | |||||||||||||
| 9 | if (d == -1
| 0 | ||||||||||||
| 10 | int c; | - | ||||||||||||
| 11 | for (c = 0; n
| 0 | ||||||||||||
| 12 | n = n / 10; never executed: n = n / 10; | 0 | ||||||||||||
| 13 | depth = c << 1; | - | ||||||||||||
| 14 | } never executed: else {end of block | 0 | ||||||||||||
| 15 | depth = d; | - | ||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||
| 17 | depth = qMax(depth, uint(1)); | - | ||||||||||||
| 18 | - | |||||||||||||
| 19 | nodes.resize((1 << depth) - 1); | - | ||||||||||||
| 20 | leaves.resize(1 << depth); | - | ||||||||||||
| 21 | } never executed: end of block | 0 | ||||||||||||
| 22 | - | |||||||||||||
| 23 | void QBspTree::destroy() | - | ||||||||||||
| 24 | { | - | ||||||||||||
| 25 | leaves.clear(); | - | ||||||||||||
| 26 | nodes.clear(); | - | ||||||||||||
| 27 | } never executed: end of block | 0 | ||||||||||||
| 28 | - | |||||||||||||
| 29 | void QBspTree::climbTree(const QRect &rect, callback *function, QBspTreeData data) | - | ||||||||||||
| 30 | { | - | ||||||||||||
| 31 | if (nodes.isEmpty()
| 0 | ||||||||||||
| 32 | return; never executed: return; | 0 | ||||||||||||
| 33 | ++visited; | - | ||||||||||||
| 34 | climbTree(rect, function, data, 0); | - | ||||||||||||
| 35 | } never executed: end of block | 0 | ||||||||||||
| 36 | - | |||||||||||||
| 37 | void QBspTree::climbTree(const QRect &area, callback *function, QBspTreeData data, int index) | - | ||||||||||||
| 38 | { | - | ||||||||||||
| 39 | if (index >= nodes.count()
| 0 | ||||||||||||
| 40 | ((!(!nodes.isEmpty())) ? qt_assert("!nodes.isEmpty()",__FILE__,80) : qt_noop()); | - | ||||||||||||
| 41 | function(leaf(index - nodes.count()), area, visited, data); | - | ||||||||||||
| 42 | return; never executed: return; | 0 | ||||||||||||
| 43 | } | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | Node::Type t = (Node::Type) nodes.at(index).type; | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | int pos = nodes.at(index).pos; | - | ||||||||||||
| 48 | int idx = firstChildIndex(index); | - | ||||||||||||
| 49 | if (t == Node::VerticalPlane
| 0 | ||||||||||||
| 50 | if (area.left() < pos
| 0 | ||||||||||||
| 51 | climbTree(area, function, data, idx); never executed: climbTree(area, function, data, idx); | 0 | ||||||||||||
| 52 | if (area.right() >= pos
| 0 | ||||||||||||
| 53 | climbTree(area, function, data, idx + 1); never executed: climbTree(area, function, data, idx + 1); | 0 | ||||||||||||
| 54 | } never executed: else {end of block | 0 | ||||||||||||
| 55 | if (area.top() < pos
| 0 | ||||||||||||
| 56 | climbTree(area, function, data, idx); never executed: climbTree(area, function, data, idx); | 0 | ||||||||||||
| 57 | if (area.bottom() >= pos
| 0 | ||||||||||||
| 58 | climbTree(area, function, data, idx + 1); never executed: climbTree(area, function, data, idx + 1); | 0 | ||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | void QBspTree::init(const QRect &area, int depth, NodeType type, int index) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | Node::Type t = Node::None; | - | ||||||||||||
| 65 | if (type == Node::Both
| 0 | ||||||||||||
| 66 | t = (
never executed: t = (depth & 1) ? Node::HorizontalPlane : Node::VerticalPlane; | 0 | ||||||||||||
| 67 | else | - | ||||||||||||
| 68 | t = type; never executed: t = type; | 0 | ||||||||||||
| 69 | QPoint center = area.center(); | - | ||||||||||||
| 70 | nodes[index].pos = (t == Node::VerticalPlane
| 0 | ||||||||||||
| 71 | nodes[index].type = t; | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | QRect front = area; | - | ||||||||||||
| 74 | QRect back = area; | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | if (t == Node::VerticalPlane
| 0 | ||||||||||||
| 77 | front.setLeft(center.x()); | - | ||||||||||||
| 78 | back.setRight(center.x() - 1); | - | ||||||||||||
| 79 | } never executed: else {end of block | 0 | ||||||||||||
| 80 | front.setTop(center.y()); | - | ||||||||||||
| 81 | back.setBottom(center.y() - 1); | - | ||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | int idx = firstChildIndex(index); | - | ||||||||||||
| 85 | if (--
| 0 | ||||||||||||
| 86 | init(back, depth, type, idx); | - | ||||||||||||
| 87 | init(front, depth, type, idx + 1); | - | ||||||||||||
| 88 | } never executed: end of block | 0 | ||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||
| 90 | - | |||||||||||||
| 91 | void QBspTree::insert(QVector<int> &leaf, const QRect &, uint, QBspTreeData data) | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | leaf.append(data.i); | - | ||||||||||||
| 94 | } never executed: end of block | 0 | ||||||||||||
| 95 | - | |||||||||||||
| 96 | void QBspTree::remove(QVector<int> &leaf, const QRect &, uint, QBspTreeData data) | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | int i = leaf.indexOf(data.i); | - | ||||||||||||
| 99 | if (i != -1
| 0 | ||||||||||||
| 100 | leaf.remove(i); never executed: leaf.remove(i); | 0 | ||||||||||||
| 101 | } never executed: end of block | 0 | ||||||||||||
| 102 | - | |||||||||||||
| 103 | - | |||||||||||||
| Switch to Source code | Preprocessed file |