Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgraphicsscenebsptreeindex_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//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists for the convenience
10// of other Qt classes. This header file may change from version to
11// version without notice, or even be removed.
12//
13// We mean it.
14//
15
16#ifndef QGRAPHICSBSPTREEINDEX_H
17#define QGRAPHICSBSPTREEINDEX_H
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20
24
25#include <QtCore/qbasictimer.h>
26#include <QtCore/qrect.h>
27#include <QtCore/qlist.h>
28
30
32
33static const int QGRAPHICSSCENE_INDEXTIMER_TIMEOUT = 2000;
34
35class QGraphicsScene;
37
38class Q_AUTOTEST_EXPORT QGraphicsSceneBspTreeIndex : public QGraphicsSceneIndex
39{
40 Q_OBJECT
41 Q_PROPERTY(int bspTreeDepth READ bspTreeDepth WRITE setBspTreeDepth)
42public:
43 QGraphicsSceneBspTreeIndex(QGraphicsScene *scene = nullptr);
44 ~QGraphicsSceneBspTreeIndex();
45
46 QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const override;
47 QList<QGraphicsItem *> estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const override;
48 QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const override;
49
50 int bspTreeDepth() const;
51 void setBspTreeDepth(int depth);
52
53protected Q_SLOTS:
54 void updateSceneRect(const QRectF &rect) override;
55
56protected:
57 bool event(QEvent *event) override;
58 void clear() override;
59
60 void addItem(QGraphicsItem *item) override;
61 void removeItem(QGraphicsItem *item) override;
62 void prepareBoundingRectChange(const QGraphicsItem *item) override;
63
64 void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) override;
65
66private :
67 Q_DECLARE_PRIVATE(QGraphicsSceneBspTreeIndex)
68 Q_DISABLE_COPY_MOVE(QGraphicsSceneBspTreeIndex)
69 Q_PRIVATE_SLOT(d_func(), void _q_updateSortCache())
70 Q_PRIVATE_SLOT(d_func(), void _q_updateIndex())
71
72 friend class QGraphicsScene;
73 friend class QGraphicsScenePrivate;
74};
75
77{
78 Q_DECLARE_PUBLIC(QGraphicsSceneBspTreeIndex)
79public:
81
83 QRectF sceneRect;
89
94
97 void purgeRemovedItems();
98
99 void _q_updateIndex();
100 void startIndexTimer(int interval = QGRAPHICSSCENE_INDEXTIMER_TIMEOUT);
101 void resetIndex();
102
103 void _q_updateSortCache();
106 void invalidateSortCache();
107 void addItem(QGraphicsItem *item, bool recursive = false);
108 void removeItem(QGraphicsItem *item, bool recursive = false, bool moveToUnindexedItems = false);
109 QList<QGraphicsItem *> estimateItems(const QRectF &, Qt::SortOrder, bool b = false);
110
111 static void climbTree(QGraphicsItem *item, int *stackingOrder);
112
113 static inline bool closestItemFirst_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
114 {
115 return item1->d_ptr->globalStackingOrder < item2->d_ptr->globalStackingOrder;
116 }
117 static inline bool closestItemLast_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
118 {
119 return item1->d_ptr->globalStackingOrder >= item2->d_ptr->globalStackingOrder;
120 }
121
122 static void sortItems(QList<QGraphicsItem *> *itemList, Qt::SortOrder order,
123 bool cached, bool onlyTopLevelItems = false);
124};
125
126static inline bool QRectF_intersects(const QRectF &s, const QRectF &r)
127{
128 qreal xp = s.left();
129 qreal yp = s.top();
130 qreal w = s.width();
131 qreal h = s.height();
132 qreal l1 = xp;
133 qreal r1 = xp;
134 if (w < 0)
135 l1 += w;
136 else
137 r1 += w;
138
139 qreal l2 = r.left();
140 qreal r2 = r.left();
141 if (w < 0)
142 l2 += r.width();
143 else
144 r2 += r.width();
145
146 if (l1 >= r2 || l2 >= r1)
147 return false;
148
149 qreal t1 = yp;
150 qreal b1 = yp;
151 if (h < 0)
152 t1 += h;
153 else
154 b1 += h;
155
156 qreal t2 = r.top();
157 qreal b2 = r.top();
158 if (r.height() < 0)
159 t2 += r.height();
160 else
161 b2 += r.height();
162
163 return !(t1 >= b2 || t2 >= b1);
164}
165
166QT_END_NAMESPACE
167
168#endif // QGRAPHICSBSPTREEINDEX_H
The QAbstractGraphicsShapeItem class provides a common base for all path items.
The QGraphicsEllipseItem class provides an ellipse item that you can add to a QGraphicsScene.
QList< QRectF > exposed
QHash< QPaintDevice *, DeviceData > deviceData
QHash< const QGraphicsItem *, QMap< int, QVariant > > data
The QGraphicsItemGroup class provides a container that treats a group of items as a single item.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene.
The QGraphicsObject class provides a base class for all graphics items that require signals,...
QGraphicsPixmapItem::ShapeMode shapeMode
Qt::TransformationMode transformationMode
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.
The QGraphicsPolygonItem class provides a polygon item that you can add to a QGraphicsScene.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
The QGraphicsRotation class provides a rotation transformation around a given axis.
The QGraphicsScale class provides a scale transformation.
void removeItem(QGraphicsItem *item, bool recursive=false, bool moveToUnindexedItems=false)
void addItem(QGraphicsItem *item, bool recursive=false)
void startIndexTimer(int interval=QGRAPHICSSCENE_INDEXTIMER_TIMEOUT)
QList< QGraphicsItem * > estimateItems(const QRectF &, Qt::SortOrder, bool b=false)
void _q_updateIndex()
This method will update the BSP index by removing the items from the temporary unindexed list and add...
static void sortItems(QList< QGraphicsItem * > *itemList, Qt::SortOrder order, bool cached, bool onlyTopLevelItems=false)
Sort a list of itemList in a specific order and use the cache if requested.
static bool closestItemFirst_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
static bool closestItemLast_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
static void climbTree(QGraphicsItem *item, int *stackingOrder)
The QGraphicsSceneBspTreeIndex class provides an implementation of a BSP indexing algorithm for disco...
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework.
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
The QGraphicsSceneEvent class provides a base class for all graphics view related events.
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
The QGraphicsSceneMoveEvent class provides events for widget moving in the graphics view framework.
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
The QGraphicsSimpleTextItem class provides a simple text item that you can add to a QGraphicsScene.
void _q_updateBoundingRect(const QSizeF &)
bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *)
QWidgetTextControl * control
QWidgetTextControl * textControl() const
void sendControlEvent(QEvent *e)
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display form...
The QGraphicsTransform class is an abstract base class for building advanced transformations on QGrap...
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
friend class QPainter
\inmodule QtGui
friend class QWidget
Definition qpainter.h:431
\inmodule QtCore\reentrant
Definition qpoint.h:231
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
QT_REQUIRE_CONFIG(animation)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
static void formatGraphicsItemHelper(QDebug debug, const QGraphicsItem *item)
bool _qt_movableAncestorIsSelected(const QGraphicsItem *item)
static QRectF setupTextLayout(QTextLayout *layout)
QDebug operator<<(QDebug debug, const QGraphicsObject *item)
static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen)
QDebug operator<<(QDebug debug, const QGraphicsItem *item)
static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item, const QGraphicsItem *other, const QRectF &rect)
bool qt_closestItemLast(const QGraphicsItem *item1, const QGraphicsItem *item2)
Returns true if item2 is on top of item1.
bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)
bool qt_notclosestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)
bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem *item2)
Returns true if item1 is on top of item2.
QT_REQUIRE_CONFIG(graphicsview)
static QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
static QRectF adjustedItemEffectiveBoundingRect(const QGraphicsItem *item)
static void _q_adjustRect(QRectF *rect)
static bool QRectF_intersects(const QRectF &s, const QRectF &r)
static QT_BEGIN_NAMESPACE const int QGRAPHICSSCENE_INDEXTIMER_TIMEOUT
QDebug operator<<(QDebug debug, QIODevice::OpenMode modes)
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
const QTransform * transformPtr
const QTransform * effectTransform
QStyleOptionGraphicsItem * option
const QTransform * viewTransform