39#include <QtCore/qglobal.h>
41#include <private/qgraphicsscene_p.h>
42#include <private/qgraphicsscenebsptreeindex_p.h>
43#include <private/qgraphicssceneindex_p.h>
45#include <QtCore/qmath.h>
46#include <QtCore/qdebug.h>
64 restartIndexTimer(
false),
65 regenerateIndex(true),
68 sortCacheEnabled(
false),
69 updatingSortCache(
false)
99 item->d_func()->index = freeIndex;
112 static const int slack = 100;
210 for (
int i = 0;
i < childList.
size(); ++
i) {
216 for (
int i = 0;
i < childList.
size(); ++
i) {
238 int stackingOrder = 0;
249 for (
int i = 0;
i < topLevels.
size(); ++
i)
288 qWarning(
"QGraphicsSceneBspTreeIndex::addItem: item has already been added to this BSP");
298 bool moveToUnindexedItems)
331 if (moveToUnindexedItems)
341 bool onlyTopLevelItems)
344 if (onlyTopLevelItems &&
rect.isNull())
345 return q->QGraphicsSceneIndex::estimateTopLevelItems(
rect,
order);
352 if (onlyTopLevelItems) {
377 bool sortCacheEnabled,
bool onlyTopLevelItems)
382 if (onlyTopLevelItems) {
417 for (
int i = 0;
i <
d->indexedItems.size(); ++
i) {
434 d->lastItemCount = 0;
435 d->freeItemIndexes.clear();
436 for (
int i = 0;
i <
d->indexedItems.size(); ++
i) {
443 d->indexedItems.clear();
444 d->unindexedItems.clear();
445 d->untransformableItems.clear();
446 d->regenerateIndex =
true;
484 d->removeItem(thatItem,
false,
true);
518 itemList.
reserve(
d->indexedItems.size() +
d->unindexedItems.size());
525 std::remove_copy(
d->indexedItems.cbegin(),
d->indexedItems.cend(),
526 std::back_inserter(itemList), null);
527 std::remove_copy(
d->unindexedItems.cbegin(),
d->unindexedItems.cend(),
528 std::back_inserter(itemList), null);
530 d->sortItems(&itemList,
order,
d->sortCacheEnabled);
564 return d->bspTreeDepth;
570 if (
d->bspTreeDepth ==
depth)
601 QGraphicsItem::GraphicsItemFlags newFlags = *
static_cast<const QGraphicsItem::GraphicsItemFlags *
>(
value);
608 if ((ignoredTransform != willIgnoreTransform) || (clipsChildren != willClipChildren)) {
614 d->removeItem(thatItem,
true,
true);
619 d->invalidateSortCache();
622 d->invalidateSortCache();
630 bool ancestorWillClipChildren = newParent
635 if ((ignoredTransform != willIgnoreTransform) || (ancestorClippedChildren != ancestorWillClipChildren)) {
641 d->removeItem(thatItem,
true,
true);
661 if (
d->restartIndexTimer) {
662 d->restartIndexTimer =
false;
674#include "moc_qgraphicsscenebsptreeindex_p.cpp"
bool itemIsUntransformable() const
QList< QGraphicsItem * > children
@ AncestorContainsChildren
QRectF sceneEffectiveBoundingRect() const
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
QScopedPointer< QGraphicsItemPrivate > d_ptr
@ ItemIgnoresTransformations
@ ItemClipsChildrenToShape
@ ItemContainsChildrenInShape
QGraphicsItem * topLevelItem() const
Returns this item's top-level item.
GraphicsItemFlags flags() const
Returns this item's flags.
void removeItem(QGraphicsItem *item, bool recursive=false, bool moveToUnindexedItems=false)
QGraphicsSceneBspTreeIndexPrivate(QGraphicsScene *scene)
Constructs a private scene bsp index.
void invalidateSortCache()
void addItem(QGraphicsItem *item, bool recursive=false)
void startIndexTimer(int interval=QGRAPHICSSCENE_INDEXTIMER_TIMEOUT)
QList< QGraphicsItem * > estimateItems(const QRectF &, Qt::SortOrder, bool b=false)
QSet< QGraphicsItem * > removedItems
void _q_updateIndex()
This method will update the BSP index by removing the items from the temporary unindexed list and add...
void _q_updateSortCache()
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.
QList< QGraphicsItem * > unindexedItems
static bool closestItemFirst_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
QList< int > freeItemIndexes
QList< QGraphicsItem * > untransformableItems
QList< QGraphicsItem * > indexedItems
QGraphicsSceneBspTree bsp
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...
void removeItem(QGraphicsItem *item) override
Remove the item from the BSP index.
void setBspTreeDepth(int depth)
void updateSceneRect(const QRectF &rect) override
void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) override
QList< QGraphicsItem * > estimateItems(const QRectF &rect, Qt::SortOrder order) const override
Returns an estimation visible items that are either inside or intersect with the specified rect and r...
~QGraphicsSceneBspTreeIndex()
int bspTreeDepth
the depth of the BSP index tree
QList< QGraphicsItem * > estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const override
QList< QGraphicsItem * > items(Qt::SortOrder order=Qt::DescendingOrder) const override
Return all items in the BSP index and sort them using order.
void prepareBoundingRectChange(const QGraphicsItem *item) override
void addItem(QGraphicsItem *item) override
Add the item into the BSP index.
bool event(QEvent *event) override
\reimp
void removeItem(QGraphicsItem *item, const QRectF &rect)
void removeItems(const QSet< QGraphicsItem * > &items)
void initialize(const QRectF &rect, int depth)
QList< QGraphicsItem * > items(const QRectF &rect, bool onlyTopLevelItems=false) const
void insertItem(QGraphicsItem *item, const QRectF &rect)
The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for disc...
friend class QGraphicsSceneBspTreeIndex
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
qsizetype size() const noexcept
bool isEmpty() const noexcept
bool removeOne(const AT &t)
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
\inmodule QtCore\reentrant
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
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.
static QT_BEGIN_NAMESPACE int intmaxlog(int n)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLint GLenum GLsizei GLsizei GLsizei depth
GLdouble GLdouble GLdouble GLdouble q
GLfixed GLfixed GLint GLint order
bool contains(const AT &t) const noexcept