Qt 4.8
Public Functions | Public Variables | List of all members
QGraphicsSceneIndexRectIntersector Class Reference
Inheritance diagram for QGraphicsSceneIndexRectIntersector:
QGraphicsSceneIndexIntersector

Public Functions

bool intersect (const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode, const QTransform &deviceTransform) const
 
- Public Functions inherited from QGraphicsSceneIndexIntersector
 QGraphicsSceneIndexIntersector ()
 
virtual ~QGraphicsSceneIndexIntersector ()
 

Public Variables

QRectF sceneRect
 

Detailed Description

Definition at line 73 of file qgraphicssceneindex.cpp.

Functions

◆ intersect()

bool QGraphicsSceneIndexRectIntersector::intersect ( const QGraphicsItem item,
const QRectF exposeRect,
Qt::ItemSelectionMode  mode,
const QTransform deviceTransform 
) const
inlinevirtual

Implements QGraphicsSceneIndexIntersector.

Definition at line 76 of file qgraphicssceneindex.cpp.

78  {
79  QRectF brect = item->boundingRect();
80  _q_adjustRect(&brect);
81 
82  // ### Add test for this (without making things slower?)
83  Q_UNUSED(exposeRect);
84 
85  bool keep = true;
87  if (itemd->itemIsUntransformable()) {
88  // Untransformable items; map the scene rect to item coordinates.
89  const QTransform transform = item->deviceTransform(deviceTransform);
90  QRectF itemRect = (deviceTransform * transform.inverted()).mapRect(sceneRect);
92  keep = itemRect.contains(brect) && itemRect != brect;
93  else
94  keep = itemRect.intersects(brect);
95  if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
96  QPainterPath itemPath;
97  itemPath.addRect(itemRect);
98  keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
99  }
100  } else {
101  Q_ASSERT(!itemd->dirtySceneTransform);
102  const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
103  ? brect.translated(itemd->sceneTransform.dx(),
104  itemd->sceneTransform.dy())
105  : itemd->sceneTransform.mapRect(brect);
107  keep = sceneRect != brect && sceneRect.contains(itemSceneBoundingRect);
108  else
109  keep = sceneRect.intersects(itemSceneBoundingRect);
110  if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
111  QPainterPath rectPath;
112  rectPath.addRect(sceneRect);
113  if (itemd->sceneTransformTranslateOnly)
114  rectPath.translate(-itemd->sceneTransform.dx(), -itemd->sceneTransform.dy());
115  else
116  rectPath = itemd->sceneTransform.inverted().map(rectPath);
117  keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, rectPath, mode);
118  }
119  }
120  return keep;
121  }
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
void translate(qreal dx, qreal dy)
Translates all elements in the path by ({dx}, {dy}).
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
bool intersects(const QRectF &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:2744
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
static void _q_adjustRect(QRect *rect)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool itemIsUntransformable() const
quint32 sceneTransformTranslateOnly
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...
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
QTransform deviceTransform(const QTransform &viewportTransform) const
Returns this item's device transformation matrix, using viewportTransform to map from scene to device...
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:740
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
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...

Properties

◆ sceneRect

QRectF QGraphicsSceneIndexRectIntersector::sceneRect

Definition at line 123 of file qgraphicssceneindex.cpp.

Referenced by intersect().


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