Qt 4.8
Functions
qpolygon.cpp File Reference
#include "qpolygon.h"
#include "qrect.h"
#include "qdatastream.h"
#include "qmatrix.h"
#include "qdebug.h"
#include "qpainterpath.h"
#include "qvariant.h"
#include "qpainterpath_p.h"
#include "qbezier_p.h"
#include <stdarg.h>

Go to the source code of this file.

Functions

QDebug operator<< (QDebug dbg, const QPolygon &a)
 
QDataStreamoperator<< (QDataStream &s, const QPolygon &a)
 
QDataStreamoperator<< (QDataStream &s, const QPolygonF &a)
 
QDebug operator<< (QDebug dbg, const QPolygonF &a)
 
QDataStreamoperator>> (QDataStream &s, QPolygon &a)
 
QDataStreamoperator>> (QDataStream &s, QPolygonF &a)
 
static void qt_polygon_isect_line (const QPointF &p1, const QPointF &p2, const QPointF &pos, int *winding)
 

Function Documentation

◆ operator<<() [1/4]

QDebug operator<< ( QDebug  dbg,
const QPolygon a 
)

Definition at line 516 of file qpolygon.cpp.

517 {
518 #ifndef Q_BROKEN_DEBUG_STREAM
519  dbg.nospace() << "QPolygon(";
520  for (int i = 0; i < a.count(); ++i)
521  dbg.nospace() << a.at(i);
522  dbg.nospace() << ')';
523  return dbg.space();
524 #else
525  qWarning("This compiler doesn't support streaming QPolygon to QDebug");
526  return dbg;
527  Q_UNUSED(a);
528 #endif
529 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
Q_CORE_EXPORT void qWarning(const char *,...)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
#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

◆ operator<<() [2/4]

QDataStream& operator<< ( QDataStream s,
const QPolygon a 
)
related

Definition at line 828 of file qpolygon.cpp.

829 {
830  const QVector<QPoint> &v = a;
831  return s << v;
832 }
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ operator<<() [3/4]

QDataStream& operator<< ( QDataStream s,
const QPolygonF a 
)
related

Definition at line 871 of file qpolygon.cpp.

872 {
873  quint32 len = a.size();
874  uint i;
875 
876  s << len;
877  for (i = 0; i < len; ++i)
878  s << a.at(i);
879  return s;
880 }
unsigned int uint
Definition: qglobal.h:996
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ operator<<() [4/4]

QDebug operator<< ( QDebug  dbg,
const QPolygonF a 
)

Definition at line 912 of file qpolygon.cpp.

913 {
914 #ifndef Q_BROKEN_DEBUG_STREAM
915  dbg.nospace() << "QPolygonF(";
916  for (int i = 0; i < a.count(); ++i)
917  dbg.nospace() << a.at(i);
918  dbg.nospace() << ')';
919  return dbg.space();
920 #else
921  qWarning("This compiler doesn't support streaming QPolygonF to QDebug");
922  return dbg;
923  Q_UNUSED(a);
924 #endif
925 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
Q_CORE_EXPORT void qWarning(const char *,...)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
#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

◆ operator>>() [1/2]

QDataStream& operator>> ( QDataStream s,
QPolygon a 
)
related

Definition at line 847 of file qpolygon.cpp.

848 {
849  QVector<QPoint> &v = a;
850  return s >> v;
851 }
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ operator>>() [2/2]

QDataStream& operator>> ( QDataStream s,
QPolygonF a 
)
related

Definition at line 895 of file qpolygon.cpp.

896 {
897  quint32 len;
898  uint i;
899 
900  s >> len;
901  a.reserve(a.size() + (int)len);
902  QPointF p;
903  for (i = 0; i < len; ++i) {
904  s >> p;
905  a.insert(i, p);
906  }
907  return s;
908 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
unsigned int uint
Definition: qglobal.h:996
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
unsigned int quint32
Definition: qglobal.h:938
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ qt_polygon_isect_line()

static void qt_polygon_isect_line ( const QPointF p1,
const QPointF p2,
const QPointF pos,
int *  winding 
)
static

Definition at line 57 of file qpolygon.cpp.

Referenced by QPolygon::containsPoint(), and QPolygonF::containsPoint().

59 {
60  qreal x1 = p1.x();
61  qreal y1 = p1.y();
62  qreal x2 = p2.x();
63  qreal y2 = p2.y();
64  qreal y = pos.y();
65 
66  int dir = 1;
67 
68  if (qFuzzyCompare(y1, y2)) {
69  // ignore horizontal lines according to scan conversion rule
70  return;
71  } else if (y2 < y1) {
72  qreal x_tmp = x2; x2 = x1; x1 = x_tmp;
73  qreal y_tmp = y2; y2 = y1; y1 = y_tmp;
74  dir = -1;
75  }
76 
77  if (y >= y1 && y < y2) {
78  qreal x = x1 + ((x2 - x1) / (y2 - y1)) * (y - y1);
79 
80  // count up the winding number if we're
81  if (x<=pos.x()) {
82  (*winding) += dir;
83  }
84  }
85 }
double qreal
Definition: qglobal.h:1193
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.
Definition: qmatrix.h:172