Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QGraphicsSceneIndexPrivate Class Reference

#include <qgraphicssceneindex_p.h>

Inheritance diagram for QGraphicsSceneIndexPrivate:
QObjectPrivate QObjectData QGraphicsSceneBspTreeIndexPrivate

Public Functions

void init ()
 
void items_helper (const QRectF &rect, QGraphicsSceneIndexIntersector *intersector, QList< QGraphicsItem *> *items, const QTransform &viewTransform, Qt::ItemSelectionMode mode, Qt::SortOrder order) const
 
 QGraphicsSceneIndexPrivate (QGraphicsScene *scene)
 Constructs a private scene index. More...
 
void recursive_items_helper (QGraphicsItem *item, QRectF exposeRect, QGraphicsSceneIndexIntersector *intersector, QList< QGraphicsItem *> *items, const QTransform &viewTransform, Qt::ItemSelectionMode mode, qreal parentOpacity=1.0) const
 This function returns the items in ascending order. More...
 
 ~QGraphicsSceneIndexPrivate ()
 Destructor of private scene index. More...
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static bool itemCollidesWithPath (const QGraphicsItem *item, const QPainterPath &path, Qt::ItemSelectionMode mode)
 Checks if item collides with the path and mode, but also checks that if it doesn't collide, maybe its frame rect will. More...
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

QGraphicsSceneIndexPathIntersectorpathIntersector
 
QGraphicsSceneIndexPointIntersectorpointIntersector
 
QGraphicsSceneIndexRectIntersectorrectIntersector
 
QGraphicsScenescene
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 128 of file qgraphicssceneindex_p.h.

Constructors and Destructors

◆ QGraphicsSceneIndexPrivate()

QGraphicsSceneIndexPrivate::QGraphicsSceneIndexPrivate ( QGraphicsScene scene)

◆ ~QGraphicsSceneIndexPrivate()

QGraphicsSceneIndexPrivate::~QGraphicsSceneIndexPrivate ( )

Destructor of private scene index.

Definition at line 233 of file qgraphicssceneindex.cpp.

234 {
235  delete pointIntersector;
236  delete rectIntersector;
237  delete pathIntersector;
238 }
QGraphicsSceneIndexPointIntersector * pointIntersector
QGraphicsSceneIndexPathIntersector * pathIntersector
QGraphicsSceneIndexRectIntersector * rectIntersector

Functions

◆ init()

void QGraphicsSceneIndexPrivate::init ( )

Definition at line 361 of file qgraphicssceneindex.cpp.

362 {
363  if (!scene)
364  return;
365 
366  QObject::connect(scene, SIGNAL(sceneRectChanged(QRectF)),
367  q_func(), SLOT(updateSceneRect(QRectF)));
368 }
#define SLOT(a)
Definition: qobjectdefs.h:226
#define SIGNAL(a)
Definition: qobjectdefs.h:227
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580

◆ itemCollidesWithPath()

bool QGraphicsSceneIndexPrivate::itemCollidesWithPath ( const QGraphicsItem item,
const QPainterPath path,
Qt::ItemSelectionMode  mode 
)
static

Checks if item collides with the path and mode, but also checks that if it doesn't collide, maybe its frame rect will.

Warning
This function is not part of the public interface.

Definition at line 249 of file qgraphicssceneindex.cpp.

Referenced by QGraphicsSceneIndexRectIntersector::intersect(), QGraphicsSceneIndexPointIntersector::intersect(), and QGraphicsSceneIndexPathIntersector::intersect().

252 {
253  if (item->collidesWithPath(path, mode))
254  return true;
255  if (item->isWidget()) {
256  // Check if this is a window, and if its frame rect collides.
257  const QGraphicsWidget *widget = static_cast<const QGraphicsWidget *>(item);
258  if (widget->isWindow()) {
259  QRectF frameRect = widget->windowFrameRect();
260  QPainterPath framePath;
261  framePath.addRect(frameRect);
262  bool intersects = path.intersects(frameRect);
264  return intersects || path.contains(frameRect.topLeft())
265  || framePath.contains(path.elementAt(0));
266  return !intersects && path.contains(frameRect.topLeft());
267  }
268  }
269  return false;
270 }
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
QPointer< QWidget > widget
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual bool collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
Returns true if this item collides with path.
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
bool intersects(const QRectF &rect) const
Returns true if any point in the given rectangle intersects the path; otherwise returns false...
bool contains(const QPointF &pt) const
Returns true if the given point is inside the path, otherwise returns false.
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Definition: qpainterpath.h:402
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
bool isWidget() const
Returns true if this item is a widget (i.
QRectF windowFrameRect() const
Returns the widget&#39;s local rect including any window frame.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ items_helper()

void QGraphicsSceneIndexPrivate::items_helper ( const QRectF rect,
QGraphicsSceneIndexIntersector intersector,
QList< QGraphicsItem *> *  items,
const QTransform viewTransform,
Qt::ItemSelectionMode  mode,
Qt::SortOrder  order 
) const
inline

Definition at line 152 of file qgraphicssceneindex_p.h.

155 {
156  Q_Q(const QGraphicsSceneIndex);
157  const QList<QGraphicsItem *> tli = q->estimateTopLevelItems(rect, Qt::AscendingOrder);
158  for (int i = 0; i < tli.size(); ++i)
159  recursive_items_helper(tli.at(i), rect, intersector, items, viewTransform, mode);
160  if (order == Qt::DescendingOrder) {
161  const int n = items->size();
162  for (int i = 0; i < n / 2; ++i)
163  items->swap(i, n - i - 1);
164  }
165 }
void recursive_items_helper(QGraphicsItem *item, QRectF exposeRect, QGraphicsSceneIndexIntersector *intersector, QList< QGraphicsItem *> *items, const QTransform &viewTransform, Qt::ItemSelectionMode mode, qreal parentOpacity=1.0) const
This function returns the items in ascending order.
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for disc...
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ recursive_items_helper()

void QGraphicsSceneIndexPrivate::recursive_items_helper ( QGraphicsItem item,
QRectF  exposeRect,
QGraphicsSceneIndexIntersector intersector,
QList< QGraphicsItem *> *  items,
const QTransform viewTransform,
Qt::ItemSelectionMode  mode,
qreal  parentOpacity = 1.0 
) const

This function returns the items in ascending order.

Warning
This function is not part of the public interface.

Definition at line 279 of file qgraphicssceneindex.cpp.

285 {
286  Q_ASSERT(item);
287  if (!item->d_ptr->visible)
288  return;
289 
290  const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
291  const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
292  const bool itemHasChildren = !item->d_ptr->children.isEmpty();
293  if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity()))
294  return;
295 
296  // Update the item's scene transform if dirty.
297  const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
298  const bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform && !itemIsUntransformable;
299  if (wasDirtyParentSceneTransform) {
302  }
303 
304  const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
305  bool processItem = !itemIsFullyTransparent;
306  if (processItem) {
307  processItem = intersector->intersect(item, exposeRect, mode, viewTransform);
308  if (!processItem && (!itemHasChildren || itemClipsChildrenToShape)) {
309  if (wasDirtyParentSceneTransform)
311  return;
312  }
313  } // else we know for sure this item has children we must process.
314 
315  int i = 0;
316  if (itemHasChildren) {
317  // Sort children.
318  item->d_ptr->ensureSortedChildren();
319 
320  // Clip to shape.
321  if (itemClipsChildrenToShape && !itemIsUntransformable) {
322  QPainterPath mappedShape = item->d_ptr->sceneTransformTranslateOnly
323  ? item->shape().translated(item->d_ptr->sceneTransform.dx(),
324  item->d_ptr->sceneTransform.dy())
325  : item->d_ptr->sceneTransform.map(item->shape());
326  exposeRect &= mappedShape.controlPointRect();
327  }
328 
329  // Process children behind
330  for (i = 0; i < item->d_ptr->children.size(); ++i) {
331  QGraphicsItem *child = item->d_ptr->children.at(i);
332  if (wasDirtyParentSceneTransform)
333  child->d_ptr->dirtySceneTransform = 1;
335  break;
336  if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
337  continue;
338  recursive_items_helper(child, exposeRect, intersector, items, viewTransform,
339  mode, opacity);
340  }
341  }
342 
343  // Process item
344  if (processItem)
345  items->append(item);
346 
347  // Process children in front
348  if (itemHasChildren) {
349  for (; i < item->d_ptr->children.size(); ++i) {
350  QGraphicsItem *child = item->d_ptr->children.at(i);
351  if (wasDirtyParentSceneTransform)
352  child->d_ptr->dirtySceneTransform = 1;
353  if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
354  continue;
355  recursive_items_helper(child, exposeRect, intersector, items, viewTransform,
356  mode, opacity);
357  }
358  }
359 }
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
qreal combineOpacityFromParent(qreal parentOpacity) const
double qreal
Definition: qglobal.h:1193
void recursive_items_helper(QGraphicsItem *item, QRectF exposeRect, QGraphicsSceneIndexIntersector *intersector, QList< QGraphicsItem *> *items, const QTransform &viewTransform, Qt::ItemSelectionMode mode, qreal parentOpacity=1.0) const
This function returns the items in ascending order.
QScopedPointer< QGraphicsItemPrivate > d_ptr
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual void updateSceneTransformFromParent()
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
bool isOpacityNull() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual QPainterPath shape() const
Returns the shape of this item as a QPainterPath in local coordinates.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void invalidateChildrenSceneTransform()
bool itemIsUntransformable() const
quint32 sceneTransformTranslateOnly
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
QRectF controlPointRect() const
Returns the rectangle containing all the points and control points in this path.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
virtual bool intersect(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode, const QTransform &deviceTransform) const =0
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
QList< QGraphicsItem * > children
bool childrenCombineOpacity() const
QPainterPath translated(qreal dx, qreal dy) const
Returns a copy of the path that is translated by ({dx}, {dy}).

Properties

◆ pathIntersector

QGraphicsSceneIndexPathIntersector* QGraphicsSceneIndexPrivate::pathIntersector

◆ pointIntersector

QGraphicsSceneIndexPointIntersector* QGraphicsSceneIndexPrivate::pointIntersector

◆ rectIntersector

QGraphicsSceneIndexRectIntersector* QGraphicsSceneIndexPrivate::rectIntersector

◆ scene

QGraphicsScene* QGraphicsSceneIndexPrivate::scene

Definition at line 146 of file qgraphicssceneindex_p.h.

Referenced by init().


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