QtBase  v6.3.1
Public Member Functions | Protected Slots | Protected Member Functions | Properties | Friends | List of all members
QGraphicsSceneBspTreeIndex Class Reference

The QGraphicsSceneBspTreeIndex class provides an implementation of a BSP indexing algorithm for discovering items in QGraphicsScene. More...

#include <qgraphicsscenebsptreeindex_p.h>

Inheritance diagram for QGraphicsSceneBspTreeIndex:
Inheritance graph
[legend]
Collaboration diagram for QGraphicsSceneBspTreeIndex:
Collaboration graph
[legend]

Public Member Functions

 QGraphicsSceneBspTreeIndex (QGraphicsScene *scene=nullptr)
 
 ~QGraphicsSceneBspTreeIndex ()
 
QList< QGraphicsItem * > estimateItems (const QRectF &rect, Qt::SortOrder order) const override
 
QList< QGraphicsItem * > estimateTopLevelItems (const QRectF &rect, Qt::SortOrder order) const override
 
QList< QGraphicsItem * > items (Qt::SortOrder order=Qt::DescendingOrder) const override
 
int bspTreeDepth () const
 
void setBspTreeDepth (int depth)
 
- Public Member Functions inherited from QGraphicsSceneIndex
 QGraphicsSceneIndex (QGraphicsScene *scene=nullptr)
 
virtual ~QGraphicsSceneIndex ()
 
QGraphicsScenescene () const
 
virtual QList< QGraphicsItem * > items (const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > items (const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > items (const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > items (const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > estimateItems (const QPointF &point, Qt::SortOrder order) const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Protected Slots

void updateSceneRect (const QRectF &rect) override
 
- Protected Slots inherited from QGraphicsSceneIndex
virtual void updateSceneRect (const QRectF &rect)
 

Protected Member Functions

bool event (QEvent *event) override
 
void clear () override
 
void addItem (QGraphicsItem *item) override
 
void removeItem (QGraphicsItem *item) override
 
void prepareBoundingRectChange (const QGraphicsItem *item) override
 
void itemChange (const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) override
 
- Protected Member Functions inherited from QGraphicsSceneIndex
virtual void deleteItem (QGraphicsItem *item)
 
 QGraphicsSceneIndex (QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

int bspTreeDepth
 the depth of the BSP index tree More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QGraphicsScenePrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QGraphicsSceneBspTreeIndex class provides an implementation of a BSP indexing algorithm for discovering items in QGraphicsScene.

Since
4.6

Definition at line 72 of file qgraphicsscenebsptreeindex_p.h.

Constructor & Destructor Documentation

◆ QGraphicsSceneBspTreeIndex()

QGraphicsSceneBspTreeIndex::QGraphicsSceneBspTreeIndex ( QGraphicsScene scene = nullptr)

Constructs a BSP scene index for the given scene.

Definition at line 444 of file qgraphicsscenebsptreeindex.cpp.

◆ ~QGraphicsSceneBspTreeIndex()

QGraphicsSceneBspTreeIndex::~QGraphicsSceneBspTreeIndex ( )

Definition at line 450 of file qgraphicsscenebsptreeindex.cpp.

Member Function Documentation

◆ addItem()

void QGraphicsSceneBspTreeIndex::addItem ( QGraphicsItem item)
overrideprotectedvirtual

Add the item into the BSP index.

Implements QGraphicsSceneIndex.

Definition at line 488 of file qgraphicsscenebsptreeindex.cpp.

◆ bspTreeDepth()

int QGraphicsSceneBspTreeIndex::bspTreeDepth ( ) const

Definition at line 597 of file qgraphicsscenebsptreeindex.cpp.

◆ clear()

void QGraphicsSceneBspTreeIndex::clear ( )
overrideprotectedvirtual

This virtual function removes all items in the scene index.

Reimplemented from QGraphicsSceneIndex.

Definition at line 466 of file qgraphicsscenebsptreeindex.cpp.

◆ estimateItems()

QList< QGraphicsItem * > QGraphicsSceneBspTreeIndex::estimateItems ( const QRectF rect,
Qt::SortOrder  order 
) const
overridevirtual

Returns an estimation visible items that are either inside or intersect with the specified rect and return a list sorted using order.

deviceTransform is the transformation apply to the view.

Implements QGraphicsSceneIndex.

Definition at line 532 of file qgraphicsscenebsptreeindex.cpp.

Here is the caller graph for this function:

◆ estimateTopLevelItems()

QList< QGraphicsItem * > QGraphicsSceneBspTreeIndex::estimateTopLevelItems ( const QRectF rect,
Qt::SortOrder  order 
) const
overridevirtual

Reimplemented from QGraphicsSceneIndex.

Definition at line 538 of file qgraphicsscenebsptreeindex.cpp.

Here is the call graph for this function:

◆ event()

bool QGraphicsSceneBspTreeIndex::event ( QEvent event)
overrideprotectedvirtual

\reimp

Used to catch the timer event.

Reimplemented from QObject.

Definition at line 692 of file qgraphicsscenebsptreeindex.cpp.

Here is the call graph for this function:

◆ itemChange()

void QGraphicsSceneBspTreeIndex::itemChange ( const QGraphicsItem item,
QGraphicsItem::GraphicsItemChange  change,
const void *const  value 
)
overrideprotectedvirtual

This virtual function is called by QGraphicsItem to notify the index that some part of the item 's state changes. By reimplementing this function, your can react to a change, and in some cases, (depending on change,) adjustments in the index can be made.

change is the parameter of the item that is changing. value is the value that changed; the type of the value depends on change.

The default implementation does nothing.

See also
QGraphicsItem::GraphicsItemChange

Reimplemented from QGraphicsSceneIndex.

Definition at line 631 of file qgraphicsscenebsptreeindex.cpp.

Here is the call graph for this function:

◆ items()

QList< QGraphicsItem * > QGraphicsSceneBspTreeIndex::items ( Qt::SortOrder  order = Qt::DescendingOrder) const
overridevirtual

Return all items in the BSP index and sort them using order.

Implements QGraphicsSceneIndex.

Definition at line 549 of file qgraphicsscenebsptreeindex.cpp.

◆ prepareBoundingRectChange()

void QGraphicsSceneBspTreeIndex::prepareBoundingRectChange ( const QGraphicsItem item)
overrideprotectedvirtual

Notify the index for a geometry change of an item.

See also
QGraphicsItem::prepareGeometryChange()

Reimplemented from QGraphicsSceneIndex.

Definition at line 507 of file qgraphicsscenebsptreeindex.cpp.

Here is the call graph for this function:

◆ removeItem()

void QGraphicsSceneBspTreeIndex::removeItem ( QGraphicsItem item)
overrideprotectedvirtual

Remove the item from the BSP index.

Implements QGraphicsSceneIndex.

Definition at line 497 of file qgraphicsscenebsptreeindex.cpp.

◆ setBspTreeDepth()

void QGraphicsSceneBspTreeIndex::setBspTreeDepth ( int  depth)

Definition at line 603 of file qgraphicsscenebsptreeindex.cpp.

Here is the caller graph for this function:

◆ updateSceneRect

void QGraphicsSceneBspTreeIndex::updateSceneRect ( const QRectF rect)
overrideprotectedslot

Definition at line 618 of file qgraphicsscenebsptreeindex.cpp.

Friends And Related Function Documentation

◆ QGraphicsScenePrivate

friend class QGraphicsScenePrivate
friend

Definition at line 107 of file qgraphicsscenebsptreeindex_p.h.

Property Documentation

◆ bspTreeDepth

QGraphicsSceneBspTreeIndex::bspTreeDepth
readwrite

the depth of the BSP index tree

Since
4.6

This value determines the depth of BSP tree. The depth directly affects performance and memory usage; the latter growing exponentially with the depth of the tree. With an optimal tree depth, the index can instantly determine the locality of items, even for scenes with thousands or millions of items. This also greatly improves rendering performance.

By default, the value is 0, in which case Qt will guess a reasonable default depth based on the size, location and number of items in the scene. If these parameters change frequently, however, you may experience slowdowns as the index retunes the depth internally. You can avoid potential slowdowns by fixating the tree depth through setting this property.

The depth of the tree and the size of the scene rectangle decide the granularity of the scene's partitioning. The size of each scene segment is determined by the following algorithm:

The BSP tree has an optimal size when each segment contains between 0 and 10 items.

Definition at line 200 of file qgraphicsscenebsptreeindex_p.h.


The documentation for this class was generated from the following files: