Qt 4.8
Functions | Variables
qgraphicsview.cpp File Reference
#include "qgraphicsview.h"
#include "qgraphicsview_p.h"
#include "qgraphicsitem.h"
#include "qgraphicsitem_p.h"
#include "qgraphicsscene.h"
#include "qgraphicsscene_p.h"
#include "qgraphicssceneevent.h"
#include "qgraphicswidget.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmath.h>
#include <QtGui/qapplication.h>
#include <QtGui/qdesktopwidget.h>
#include <QtGui/qevent.h>
#include <QtGui/qlayout.h>
#include <QtGui/qtransform.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qpainter.h>
#include <QtGui/qscrollbar.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qinputcontext.h>
#include <QtGui/qpaintengine.h>
#include <private/qt_x11_p.h>
#include <private/qevent_p.h>
#include "moc_qgraphicsview.cpp"

Go to the source code of this file.

Functions

static bool containsViewport (const QRect &r, int width, int height)
 
static bool intersectsViewport (const QRect &r, int width, int height)
 
int q_round_bound (qreal d)
 
static void QRect_unite (QRect *rect, const QRect &other)
 
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath (const QRegion &region)
 
bool qt_sendSpontaneousEvent (QObject *receiver, QEvent *event)
 

Variables

static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503
 
static const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD = 50
 

Function Documentation

◆ containsViewport()

static bool containsViewport ( const QRect r,
int  width,
int  height 
)
inlinestatic

Definition at line 894 of file qgraphicsview.cpp.

Referenced by QGraphicsViewPrivate::updateRect().

895 { return r.left() <= 0 && r.top() <= 0 && r.right() >= width - 1 && r.bottom() >= height - 1; }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246

◆ intersectsViewport()

static bool intersectsViewport ( const QRect r,
int  width,
int  height 
)
inlinestatic

Definition at line 891 of file qgraphicsview.cpp.

Referenced by QGraphicsViewPrivate::updateRect(), and QGraphicsViewPrivate::updateRegion().

892 { return !(r.left() > width) && !(r.right() < 0) && !(r.top() >= height) && !(r.bottom() < 0); }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246

◆ q_round_bound()

int q_round_bound ( qreal  d)
inline

Definition at line 313 of file qgraphicsview.cpp.

Referenced by QGraphicsViewPrivate::recalculateContentSize().

314 {
315  if (d <= (qreal) INT_MIN)
316  return INT_MIN;
317  else if (d >= (qreal) INT_MAX)
318  return INT_MAX;
319  return d >= 0.0 ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1);
320 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
#define INT_MAX

◆ QRect_unite()

static void QRect_unite ( QRect rect,
const QRect other 
)
inlinestatic

Definition at line 897 of file qgraphicsview.cpp.

Referenced by QGraphicsViewPrivate::updateRect().

898 {
899  if (rect->isEmpty()) {
900  *rect = other;
901  } else {
902  rect->setCoords(qMin(rect->left(), other.left()), qMin(rect->top(), other.top()),
903  qMax(rect->right(), other.right()), qMax(rect->bottom(), other.bottom()));
904  }
905 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246

◆ qt_regionToPath()

Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath ( const QRegion region)

Definition at line 1160 of file qregion.cpp.

Referenced by QGraphicsViewPrivate::findItems(), and QGraphicsViewPrivate::freeStyleOptionsArray().

1161 {
1162  QPainterPath result;
1163  if (region.rectCount() == 1) {
1164  result.addRect(region.boundingRect());
1165  return result;
1166  }
1167 
1168  const QVector<QRect> rects = region.rects();
1169 
1170  QVarLengthArray<Segment> segments;
1171  segments.resize(4 * rects.size());
1172 
1173  const QRect *rect = rects.constData();
1174  const QRect *end = rect + rects.size();
1175 
1176  int lastRowSegmentCount = 0;
1177  Segment *lastRowSegments = 0;
1178 
1179  int lastSegment = 0;
1180  int lastY = 0;
1181  while (rect != end) {
1182  const int y = rect[0].y();
1183  int count = 0;
1184  while (&rect[count] != end && rect[count].y() == y)
1185  ++count;
1186 
1187  for (int i = 0; i < count; ++i) {
1188  int offset = lastSegment + i;
1189  segments[offset] = Segment(rect[i].topLeft());
1190  segments[offset += count] = Segment(rect[i].topRight() + QPoint(1, 0));
1191  segments[offset += count] = Segment(rect[i].bottomRight() + QPoint(1, 1));
1192  segments[offset += count] = Segment(rect[i].bottomLeft() + QPoint(0, 1));
1193 
1194  offset = lastSegment + i;
1195  for (int j = 0; j < 4; ++j)
1196  segments[offset + j * count].connect(segments[offset + ((j + 1) % 4) * count]);
1197  }
1198 
1199  if (lastRowSegments && lastY == y)
1200  mergeSegments(lastRowSegments, lastRowSegmentCount, &segments[lastSegment], count);
1201 
1202  lastRowSegments = &segments[lastSegment + 2 * count];
1203  lastRowSegmentCount = count;
1204  lastSegment += 4 * count;
1205  lastY = y + rect[0].height();
1206  rect += count;
1207  }
1208 
1209  for (int i = 0; i < lastSegment; ++i) {
1210  Segment *segment = &segments[i];
1211  if (!segment->added)
1212  addSegmentsToPath(segment, result);
1213  }
1214 
1215  return result;
1216 }
void resize(int size)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
static const KeyPair *const end
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ qt_sendSpontaneousEvent()

bool qt_sendSpontaneousEvent ( QObject receiver,
QEvent event 
)

Definition at line 5779 of file qapplication.cpp.

Referenced by QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), and QGraphicsView::mouseReleaseEvent().

5780 {
5781  return QCoreApplication::sendSpontaneousEvent(receiver, event);
5782 }
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)

Variable Documentation

◆ QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS

const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503
static

Definition at line 44 of file qgraphicsview.cpp.

Referenced by QGraphicsViewPrivate::QGraphicsViewPrivate().

◆ QGRAPHICSVIEW_REGION_RECT_THRESHOLD

const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD = 50
static

Definition at line 42 of file qgraphicsview.cpp.

Referenced by QGraphicsView::updateScene().