Qt 4.8
Classes | Functions | Variables
qpaintengineex.cpp File Reference
#include "qpaintengineex_p.h"
#include "qpainter_p.h"
#include "qstroker_p.h"
#include "qbezier_p.h"
#include <private/qpainterpath_p.h>
#include <private/qfontengine_p.h>
#include <private/qstatictext_p.h>
#include <qvarlengtharray.h>
#include <qdebug.h>

Go to the source code of this file.

Classes

struct  StrokeHandler
 

Functions

QDebug Q_GUI_EXPORToperator<< (QDebug &s, const QVectorPath &path)
 
static void qpaintengineex_cubicTo (qreal c1x, qreal c1y, qreal c2x, qreal c2y, qreal ex, qreal ey, void *data)
 
static void qpaintengineex_lineTo (qreal x, qreal y, void *data)
 
static void qpaintengineex_moveTo (qreal x, qreal y, void *data)
 
Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath (const QVectorPath &path)
 
Q_GUI_EXPORT bool qt_scaleForTransform (const QTransform &transform, qreal *scale)
 
const QVectorPathqtVectorPathForPath (const QPainterPath &path)
 

Variables

static QPainterPath::ElementType qpaintengineex_ellipse_types []
 
static QPainterPath::ElementType qpaintengineex_line_types_16 []
 
static QPainterPath::ElementType qpaintengineex_rect4_types_32 []
 
static QPainterPath::ElementType qpaintengineex_roundedrect_types []
 

Function Documentation

◆ operator<<()

QDebug Q_GUI_EXPORT& operator<< ( QDebug s,
const QVectorPath path 
)

Definition at line 136 of file qpaintengineex.cpp.

137 {
138  QRectF rf = path.controlPointRect();
139  s << "QVectorPath(size:" << path.elementCount()
140  << " hints:" << hex << path.hints()
141  << rf << ')';
142  return s;
143 }
int elementCount() const
QRectF controlPointRect() const
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
uint hints() const
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.

◆ qpaintengineex_cubicTo()

static void qpaintengineex_cubicTo ( qreal  c1x,
qreal  c1y,
qreal  c2x,
qreal  c2y,
qreal  ex,
qreal  ey,
void *  data 
)
static

Definition at line 353 of file qpaintengineex.cpp.

Referenced by QPaintEngineEx::stroke().

353  {
354  ((StrokeHandler *) data)->pts.add(c1x);
355  ((StrokeHandler *) data)->pts.add(c1y);
356  ((StrokeHandler *) data)->types.add(QPainterPath::CurveToElement);
357 
358  ((StrokeHandler *) data)->pts.add(c2x);
359  ((StrokeHandler *) data)->pts.add(c2y);
360  ((StrokeHandler *) data)->types.add(QPainterPath::CurveToDataElement);
361 
362  ((StrokeHandler *) data)->pts.add(ex);
363  ((StrokeHandler *) data)->pts.add(ey);
364  ((StrokeHandler *) data)->types.add(QPainterPath::CurveToDataElement);
365 }
static const char * data(const QByteArray &arr)

◆ qpaintengineex_lineTo()

static void qpaintengineex_lineTo ( qreal  x,
qreal  y,
void *  data 
)
static

Definition at line 347 of file qpaintengineex.cpp.

Referenced by QPaintEngineEx::stroke().

347  {
348  ((StrokeHandler *) data)->pts.add(x);
349  ((StrokeHandler *) data)->pts.add(y);
350  ((StrokeHandler *) data)->types.add(QPainterPath::LineToElement);
351 }
static const char * data(const QByteArray &arr)

◆ qpaintengineex_moveTo()

static void qpaintengineex_moveTo ( qreal  x,
qreal  y,
void *  data 
)
static

Definition at line 341 of file qpaintengineex.cpp.

Referenced by QPaintEngineEx::stroke().

341  {
342  ((StrokeHandler *) data)->pts.add(x);
343  ((StrokeHandler *) data)->pts.add(y);
344  ((StrokeHandler *) data)->types.add(QPainterPath::MoveToElement);
345 }
static const char * data(const QByteArray &arr)

◆ qt_painterPathFromVectorPath()

Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath ( const QVectorPath path)

Definition at line 1033 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::draw(), QVGPaintEngine::fill(), QOpenGLPaintEngine::fill(), and QOpenGLPaintEngine::transformChanged().

1034 {
1035  const qreal *points = path.points();
1036  const QPainterPath::ElementType *types = path.elements();
1037 
1038  QPainterPath p;
1039  if (types) {
1040  int id = 0;
1041  for (int i=0; i<path.elementCount(); ++i) {
1042  switch(types[i]) {
1044  p.moveTo(QPointF(points[id], points[id+1]));
1045  id+=2;
1046  break;
1048  p.lineTo(QPointF(points[id], points[id+1]));
1049  id+=2;
1050  break;
1052  QPointF p1(points[id], points[id+1]);
1053  QPointF p2(points[id+2], points[id+3]);
1054  QPointF p3(points[id+4], points[id+5]);
1055  p.cubicTo(p1, p2, p3);
1056  id+=6;
1057  break;
1058  }
1060  ;
1061  break;
1062  }
1063  }
1064  } else {
1065  p.moveTo(QPointF(points[0], points[1]));
1066  int id = 2;
1067  for (int i=1; i<path.elementCount(); ++i) {
1068  p.lineTo(QPointF(points[id], points[id+1]));
1069  id+=2;
1070  }
1071  }
1072  if (path.hints() & QVectorPath::WindingFill)
1074 
1075  return p;
1076 }
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
Definition: qpainterpath.h:70
double qreal
Definition: qglobal.h:1193
int elementCount() const
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
const QPainterPath::ElementType * elements() const
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
uint hints() const
static const struct @32 types[]
const qreal * points() const
void cubicTo(const QPointF &ctrlPt1, const QPointF &ctrlPt2, const QPointF &endPt)
Adds a cubic Bezier curve between the current position and the given endPoint using the control point...

◆ qt_scaleForTransform()

Q_GUI_EXPORT bool qt_scaleForTransform ( const QTransform transform,
qreal scale 
)

Definition at line 2407 of file qtransform.cpp.

Referenced by QPaintEngineEx::createState().

2408 {
2409  const QTransform::TransformationType type = transform.type();
2410  if (type <= QTransform::TxTranslate) {
2411  if (scale)
2412  *scale = 1;
2413  return true;
2414  } else if (type == QTransform::TxScale) {
2415  const qreal xScale = qAbs(transform.m11());
2416  const qreal yScale = qAbs(transform.m22());
2417  if (scale)
2418  *scale = qMax(xScale, yScale);
2419  return qFuzzyCompare(xScale, yScale);
2420  }
2421 
2422  const qreal xScale = transform.m11() * transform.m11()
2423  + transform.m21() * transform.m21();
2424  const qreal yScale = transform.m12() * transform.m12()
2425  + transform.m22() * transform.m22();
2426  if (scale)
2427  *scale = qSqrt(qMax(xScale, yScale));
2428  return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale);
2429 }
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
qreal m21() const
Returns the horizontal shearing factor.
Definition: qtransform.h:249
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
TransformationType type() const
Returns the transformation type of this matrix.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal m12() const
Returns the vertical shearing factor.
Definition: qtransform.h:241
TransformationType
Definition: qtransform.h:68
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.
Definition: qmatrix.h:172
qreal qSqrt(qreal v)
Definition: qmath.h:205
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237

◆ qtVectorPathForPath()

const QVectorPath& qtVectorPathForPath ( const QPainterPath path)

Variable Documentation

◆ qpaintengineex_ellipse_types

QPainterPath::ElementType qpaintengineex_ellipse_types[]
static

◆ qpaintengineex_line_types_16

QPainterPath::ElementType qpaintengineex_line_types_16[]
static

◆ qpaintengineex_rect4_types_32

QPainterPath::ElementType qpaintengineex_rect4_types_32[]
static

Definition at line 283 of file qpaintengineex.cpp.

Referenced by QPaintEngineEx::clip().

◆ qpaintengineex_roundedrect_types

QPainterPath::ElementType qpaintengineex_roundedrect_types[]
static