Qt 4.8
Public Functions | Public Variables | List of all members
QGraphicsSceneIndexPathIntersector Class Reference
Inheritance diagram for QGraphicsSceneIndexPathIntersector:
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

QPainterPath scenePath
 

Detailed Description

Definition at line 172 of file qgraphicssceneindex.cpp.

Functions

◆ intersect()

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

Implements QGraphicsSceneIndexIntersector.

Definition at line 175 of file qgraphicssceneindex.cpp.

177  {
178  QRectF brect = item->boundingRect();
179  _q_adjustRect(&brect);
180 
181  // ### Add test for this (without making things slower?)
182  Q_UNUSED(exposeRect);
183 
184  bool keep = true;
185  const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);
186  if (itemd->itemIsUntransformable()) {
187  // Untransformable items; map the scene rect to item coordinates.
188  const QTransform transform = item->deviceTransform(deviceTransform);
189  QPainterPath itemPath = (deviceTransform * transform.inverted()).map(scenePath);
191  keep = itemPath.contains(brect);
192  else
193  keep = itemPath.intersects(brect);
194  if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape))
195  keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
196  } else {
197  Q_ASSERT(!itemd->dirtySceneTransform);
198  const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
199  ? brect.translated(itemd->sceneTransform.dx(),
200  itemd->sceneTransform.dy())
201  : itemd->sceneTransform.mapRect(brect);
203  keep = scenePath.contains(itemSceneBoundingRect);
204  else
205  keep = scenePath.intersects(itemSceneBoundingRect);
206  if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
207  QPainterPath itemPath = itemd->sceneTransformTranslateOnly
209  -itemd->sceneTransform.dy())
210  : itemd->sceneTransform.inverted().map(scenePath);
211  keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
212  }
213  }
214  return keep;
215  }
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
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 &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.
#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
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)
QFuture< void > map(Sequence &sequence, MapFunction function)
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...
QTransform deviceTransform(const QTransform &viewportTransform) const
Returns this item&#39;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
QPainterPath translated(qreal dx, qreal dy) const
Returns a copy of the path that is translated by ({dx}, {dy}).
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&#39;t collide...

Properties

◆ scenePath

QPainterPath QGraphicsSceneIndexPathIntersector::scenePath

Definition at line 217 of file qgraphicssceneindex.cpp.


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