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

QPointF scenePoint
 

Detailed Description

Definition at line 126 of file qgraphicssceneindex.cpp.

Functions

◆ intersect()

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

Implements QGraphicsSceneIndexIntersector.

Definition at line 129 of file qgraphicssceneindex.cpp.

131  {
132  QRectF brect = item->boundingRect();
133  _q_adjustRect(&brect);
134 
135  // ### Add test for this (without making things slower?)
136  Q_UNUSED(exposeRect);
137 
138  bool keep = false;
139  const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);
140  if (itemd->itemIsUntransformable()) {
141  // Untransformable items; map the scene point to item coordinates.
142  const QTransform transform = item->deviceTransform(deviceTransform);
143  QPointF itemPoint = (deviceTransform * transform.inverted()).map(scenePoint);
144  keep = brect.contains(itemPoint);
145  if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
146  QPainterPath pointPath;
147  pointPath.addRect(QRectF(itemPoint, QSizeF(1, 1)));
148  keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, pointPath, mode);
149  }
150  } else {
151  Q_ASSERT(!itemd->dirtySceneTransform);
152  QRectF sceneBoundingRect = itemd->sceneTransformTranslateOnly
153  ? brect.translated(itemd->sceneTransform.dx(),
154  itemd->sceneTransform.dy())
155  : itemd->sceneTransform.mapRect(brect);
156  keep = sceneBoundingRect.intersects(QRectF(scenePoint, QSizeF(1, 1)));
157  if (keep) {
159  ? QPointF(scenePoint.x() - itemd->sceneTransform.dx(),
160  scenePoint.y() - itemd->sceneTransform.dy())
162  keep = item->contains(p);
163  }
164  }
165 
166  return keep;
167  }
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 ...
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
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)
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...
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&#39;s device transformation matrix, using viewportTransform to map from scene to device...
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
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&#39;t collide...

Properties

◆ scenePoint

QPointF QGraphicsSceneIndexPointIntersector::scenePoint

Definition at line 169 of file qgraphicssceneindex.cpp.


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