Qt 4.8
Classes | Macros | Functions
qpainterpath_p.h File Reference
#include "QtGui/qpainterpath.h"
#include "QtGui/qregion.h"
#include "QtCore/qlist.h"
#include "QtCore/qvarlengtharray.h"
#include <qdebug.h>
#include <private/qvectorpath_p.h>
#include <private/qstroker_p.h>

Go to the source code of this file.

Classes

class  QPainterPathData
 
class  QPainterPathStrokerPrivate
 
class  QVectorPathConverter
 
struct  QVectorPathConverter::QVectorPathData
 

Macros

#define KAPPA   qreal(0.5522847498)
 

Functions

void Q_GUI_EXPORT qt_find_ellipse_coords (const QRectF &r, qreal angle, qreal length, QPointF *startPoint, QPointF *endPoint)
 

Macro Definition Documentation

◆ KAPPA

#define KAPPA   qreal(0.5522847498)

Definition at line 273 of file qpainterpath_p.h.

Function Documentation

◆ qt_find_ellipse_coords()

void Q_GUI_EXPORT qt_find_ellipse_coords ( const QRectF r,
qreal  angle,
qreal  length,
QPointF startPoint,
QPointF endPoint 
)

Definition at line 97 of file qpainterpath.cpp.

Referenced by QVectorPath::convertToPainterPath().

99 {
100  if (r.isNull()) {
101  if (startPoint)
102  *startPoint = QPointF();
103  if (endPoint)
104  *endPoint = QPointF();
105  return;
106  }
107 
108  qreal w2 = r.width() / 2;
109  qreal h2 = r.height() / 2;
110 
111  qreal angles[2] = { angle, angle + length };
112  QPointF *points[2] = { startPoint, endPoint };
113 
114  for (int i = 0; i < 2; ++i) {
115  if (!points[i])
116  continue;
117 
118  qreal theta = angles[i] - 360 * qFloor(angles[i] / 360);
119  qreal t = theta / 90;
120  // truncate
121  int quadrant = int(t);
122  t -= quadrant;
123 
124  t = qt_t_for_arc_angle(90 * t);
125 
126  // swap x and y?
127  if (quadrant & 1)
128  t = 1 - t;
129 
130  qreal a, b, c, d;
131  QBezier::coefficients(t, a, b, c, d);
132  QPointF p(a + b + c*QT_PATH_KAPPA, d + c + b*QT_PATH_KAPPA);
133 
134  // left quadrants
135  if (quadrant == 1 || quadrant == 2)
136  p.rx() = -p.x();
137 
138  // top quadrants
139  if (quadrant == 0 || quadrant == 1)
140  p.ry() = -p.y();
141 
142  *points[i] = r.center() + QPointF(w2 * p.x(), h2 * p.y());
143  }
144 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
int qFloor(qreal v)
Definition: qmath.h:73
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static void coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal &d)
Definition: qbezier_p.h:152
#define QT_PATH_KAPPA
Definition: qstroker_p.h:113
long ASN1_INTEGER_get ASN1_INTEGER * a
qreal qt_t_for_arc_angle(qreal angle)
Definition: qstroker.cpp:796
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
qreal angle(const QPointF &p1, const QPointF &p2)
QPointF center() const
Returns the center point of the rectangle.
Definition: qrect.h:686
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:655