Qt 4.8
Classes | Public Functions | Protected Functions | Protected Variables | List of all members
QStrokerOps Class Referenceabstract

#include <qstroker_p.h>

Inheritance diagram for QStrokerOps:
QDashStroker QStroker

Classes

struct  Element
 

Public Functions

virtual void begin (void *customData)
 Prepares the stroker. More...
 
QRectF clipRect () const
 
void cubicTo (qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey)
 
qfixed curveThreshold () const
 
virtual void end ()
 Finishes the stroke. More...
 
void lineTo (qfixed x, qfixed y)
 
void moveTo (qfixed x, qfixed y)
 
 QStrokerOps ()
 
void setClipRect (const QRectF &clip)
 
void setCubicToHook (qStrokerCubicToHook cubicToHook)
 
void setCurveThreshold (qfixed threshold)
 
void setCurveThresholdFromTransform (const QTransform &transform)
 
void setLineToHook (qStrokerLineToHook lineToHook)
 
void setMoveToHook (qStrokerMoveToHook moveToHook)
 
void strokeEllipse (const QRectF &ellipse, void *data, const QTransform &matrix)
 Convenience function for stroking an ellipse with bounding rect rect. More...
 
void strokePath (const QPainterPath &path, void *data, const QTransform &matrix)
 Convenience function that decomposes path into begin(), moveTo(), lineTo(), curevTo() and end() calls. More...
 
void strokePolygon (const QPointF *points, int pointCount, bool implicit_close, void *data, const QTransform &matrix)
 Convenience function for stroking a polygon of the pointCount first points in points. More...
 
virtual ~QStrokerOps ()
 

Protected Functions

void emitCubicTo (qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey)
 
void emitLineTo (qfixed x, qfixed y)
 
void emitMoveTo (qfixed x, qfixed y)
 
virtual void processCurrentSubpath ()=0
 

Protected Variables

QRectF m_clip_rect
 
qStrokerCubicToHook m_cubicTo
 
qfixed m_curveThreshold
 
void * m_customData
 
qfixed m_dashThreshold
 
QDataBuffer< Elementm_elements
 
qStrokerLineToHook m_lineTo
 
qStrokerMoveToHook m_moveTo
 

Detailed Description

Definition at line 130 of file qstroker_p.h.

Constructors and Destructors

◆ QStrokerOps()

QStrokerOps::QStrokerOps ( )

Definition at line 190 of file qstroker.cpp.

191  : m_elements(0)
194  , m_customData(0)
195  , m_moveTo(0)
196  , m_lineTo(0)
197  , m_cubicTo(0)
198 {
199 }
qStrokerLineToHook m_lineTo
Definition: qstroker_p.h:191
QDataBuffer< Element > m_elements
Definition: qstroker_p.h:183
#define qt_real_to_fixed(real)
Definition: qstroker_p.h:101
qStrokerMoveToHook m_moveTo
Definition: qstroker_p.h:190
qStrokerCubicToHook m_cubicTo
Definition: qstroker_p.h:192
qfixed m_curveThreshold
Definition: qstroker_p.h:186
void * m_customData
Definition: qstroker_p.h:189
qfixed m_dashThreshold
Definition: qstroker_p.h:187

◆ ~QStrokerOps()

QStrokerOps::~QStrokerOps ( )
virtual

Definition at line 201 of file qstroker.cpp.

202 {
203 }

Functions

◆ begin()

void QStrokerOps::begin ( void *  customData)
virtual

Prepares the stroker.

Call this function once before starting a stroke by calling moveTo, lineTo or cubicTo.

The customData is passed back through that callback functions and can be used by the user to for instance maintain state information.

Reimplemented in QDashStroker.

Definition at line 213 of file qstroker.cpp.

Referenced by QDashStroker::begin(), strokeEllipse(), strokePath(), and strokePolygon().

214 {
215  m_customData = customData;
216  m_elements.reset();
217 }
QDataBuffer< Element > m_elements
Definition: qstroker_p.h:183
void * m_customData
Definition: qstroker_p.h:189

◆ clipRect()

QRectF QStrokerOps::clipRect ( ) const
inline

Definition at line 164 of file qstroker_p.h.

Referenced by QPainterPathStroker::createStroke().

164 { return m_clip_rect; }
QRectF m_clip_rect
Definition: qstroker_p.h:185

◆ cubicTo()

void QStrokerOps::cubicTo ( qfixed  x1,
qfixed  y1,
qfixed  x2,
qfixed  y2,
qfixed  ex,
qfixed  ey 
)
inline

Definition at line 323 of file qstroker_p.h.

Referenced by strokeEllipse(), and strokePath().

324 {
325  Element c1 = { QPainterPath::CurveToElement, x1, y1 };
326  Element c2 = { QPainterPath::CurveToDataElement, x2, y2 };
328  m_elements.add(c1);
329  m_elements.add(c2);
330  m_elements.add(e);
331 }
QDataBuffer< Element > m_elements
Definition: qstroker_p.h:183

◆ curveThreshold()

qfixed QStrokerOps::curveThreshold ( ) const
inline

Definition at line 175 of file qstroker_p.h.

Referenced by qt_stroke_side().

175 { return m_curveThreshold; }
qfixed m_curveThreshold
Definition: qstroker_p.h:186

◆ emitCubicTo()

void QStrokerOps::emitCubicTo ( qfixed  c1x,
qfixed  c1y,
qfixed  c2x,
qfixed  c2y,
qfixed  ex,
qfixed  ey 
)
inlineprotected

Definition at line 302 of file qstroker_p.h.

Referenced by QStroker::emitCubicTo().

303 {
305  m_cubicTo(c1x, c1y, c2x, c2y, ex, ey, m_customData);
306 }
qStrokerCubicToHook m_cubicTo
Definition: qstroker_p.h:192
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void * m_customData
Definition: qstroker_p.h:189

◆ emitLineTo()

void QStrokerOps::emitLineTo ( qfixed  x,
qfixed  y 
)
inlineprotected

Definition at line 296 of file qstroker_p.h.

Referenced by QStroker::emitLineTo(), and QDashStroker::processCurrentSubpath().

297 {
299  m_lineTo(x, y, m_customData);
300 }
qStrokerLineToHook m_lineTo
Definition: qstroker_p.h:191
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void * m_customData
Definition: qstroker_p.h:189

◆ emitMoveTo()

void QStrokerOps::emitMoveTo ( qfixed  x,
qfixed  y 
)
inlineprotected

Definition at line 290 of file qstroker_p.h.

Referenced by QStroker::emitMoveTo(), and QDashStroker::processCurrentSubpath().

291 {
293  m_moveTo(x, y, m_customData);
294 }
qStrokerMoveToHook m_moveTo
Definition: qstroker_p.h:190
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void * m_customData
Definition: qstroker_p.h:189

◆ end()

void QStrokerOps::end ( )
virtual

Finishes the stroke.

Call this function once when an entire primitive has been stroked.

Reimplemented in QDashStroker.

Definition at line 224 of file qstroker.cpp.

Referenced by QDashStroker::end(), qt_curves_for_arc(), strokeEllipse(), strokePath(), and strokePolygon().

225 {
226  if (m_elements.size() > 1)
228  m_customData = 0;
229 }
QDataBuffer< Element > m_elements
Definition: qstroker_p.h:183
virtual void processCurrentSubpath()=0
void * m_customData
Definition: qstroker_p.h:189

◆ lineTo()

void QStrokerOps::lineTo ( qfixed  x,
qfixed  y 
)
inline

Definition at line 317 of file qstroker_p.h.

Referenced by QDashedStrokeProcessor::process(), strokePath(), and strokePolygon().

318 {
319  Element e = { QPainterPath::LineToElement, x, y };
320  m_elements.add(e);
321 }
QDataBuffer< Element > m_elements
Definition: qstroker_p.h:183

◆ moveTo()

void QStrokerOps::moveTo ( qfixed  x,
qfixed  y 
)
inline

Definition at line 308 of file qstroker_p.h.

Referenced by QDashedStrokeProcessor::process(), strokeEllipse(), strokePath(), and strokePolygon().

309 {
310  if (m_elements.size()>1)
312  m_elements.reset();
313  Element e = { QPainterPath::MoveToElement, x, y };
314  m_elements.add(e);
315 }
QDataBuffer< Element > m_elements
Definition: qstroker_p.h:183
virtual void processCurrentSubpath()=0

◆ processCurrentSubpath()

virtual void QStrokerOps::processCurrentSubpath ( )
protectedpure virtual

Implemented in QDashStroker, and QStroker.

Referenced by end().

◆ setClipRect()

void QStrokerOps::setClipRect ( const QRectF clip)
inline

◆ setCubicToHook()

void QStrokerOps::setCubicToHook ( qStrokerCubicToHook  cubicToHook)
inline

Definition at line 150 of file qstroker_p.h.

Referenced by QDashedStrokeProcessor::QDashedStrokeProcessor(), QDashStroker::QDashStroker(), QPainterPathStrokerPrivate::QPainterPathStrokerPrivate(), and QPdf::Stroker::Stroker().

150 { m_cubicTo = cubicToHook; }
qStrokerCubicToHook m_cubicTo
Definition: qstroker_p.h:192
static void cubicToHook(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey, void *data)
Definition: qpdf.cpp:735

◆ setCurveThreshold()

void QStrokerOps::setCurveThreshold ( qfixed  threshold)
inline

Definition at line 174 of file qstroker_p.h.

174 { m_curveThreshold = threshold; }
qfixed m_curveThreshold
Definition: qstroker_p.h:186

◆ setCurveThresholdFromTransform()

void QStrokerOps::setCurveThresholdFromTransform ( const QTransform transform)
inline

Definition at line 167 of file qstroker_p.h.

Referenced by strokeEllipse(), strokePath(), and strokePolygon().

168  {
169  qreal scale;
170  qt_scaleForTransform(transform, &scale);
171  m_dashThreshold = scale == 0 ? qreal(0.5) : (qreal(0.5) / scale);
172  }
double qreal
Definition: qglobal.h:1193
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
qfixed m_dashThreshold
Definition: qstroker_p.h:187

◆ setLineToHook()

void QStrokerOps::setLineToHook ( qStrokerLineToHook  lineToHook)
inline

Definition at line 149 of file qstroker_p.h.

Referenced by QDashedStrokeProcessor::QDashedStrokeProcessor(), QDashStroker::QDashStroker(), QPainterPathStrokerPrivate::QPainterPathStrokerPrivate(), and QPdf::Stroker::Stroker().

149 { m_lineTo = lineToHook; }
qStrokerLineToHook m_lineTo
Definition: qstroker_p.h:191
static void lineToHook(qfixed x, qfixed y, void *data)
Definition: qpdf.cpp:727

◆ setMoveToHook()

void QStrokerOps::setMoveToHook ( qStrokerMoveToHook  moveToHook)
inline

Definition at line 148 of file qstroker_p.h.

Referenced by QDashedStrokeProcessor::QDashedStrokeProcessor(), QDashStroker::QDashStroker(), QPainterPathStrokerPrivate::QPainterPathStrokerPrivate(), and QPdf::Stroker::Stroker().

148 { m_moveTo = moveToHook; }
qStrokerMoveToHook m_moveTo
Definition: qstroker_p.h:190
static void moveToHook(qfixed x, qfixed y, void *data)
Definition: qpdf.cpp:716

◆ strokeEllipse()

void QStrokerOps::strokeEllipse ( const QRectF rect,
void *  data,
const QTransform matrix 
)

Convenience function for stroking an ellipse with bounding rect rect.

The matrix is used to transform the coordinates before they enter the stroker.

Definition at line 346 of file qstroker.cpp.

347 {
348  int count = 0;
349  QPointF pts[12];
350  QPointF start = qt_curves_for_arc(rect, 0, -360, pts, &count);
351  Q_ASSERT(count == 12); // a perfect circle..
352 
353  if (!matrix.isIdentity()) {
354  start = start * matrix;
355  for (int i=0; i<12; ++i) {
356  pts[i] = pts[i] * matrix;
357  }
358  }
359 
361  begin(data);
362  moveTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y()));
363  for (int i=0; i<12; i+=3) {
364  cubicTo(qt_real_to_fixed(pts[i].x()), qt_real_to_fixed(pts[i].y()),
365  qt_real_to_fixed(pts[i+1].x()), qt_real_to_fixed(pts[i+1].y()),
366  qt_real_to_fixed(pts[i+2].x()), qt_real_to_fixed(pts[i+2].y()));
367  }
368  end();
369 }
#define qt_real_to_fixed(real)
Definition: qstroker_p.h:101
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void setCurveThresholdFromTransform(const QTransform &transform)
Definition: qstroker_p.h:167
void cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey)
Definition: qstroker_p.h:323
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qtransform.h:204
static const char * data(const QByteArray &arr)
virtual void end()
Finishes the stroke.
Definition: qstroker.cpp:224
virtual void begin(void *customData)
Prepares the stroker.
Definition: qstroker.cpp:213
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void moveTo(qfixed x, qfixed y)
Definition: qstroker_p.h:308
QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, QPointF *curves, int *point_count)
Creates a number of curves for a given arc definition.
Definition: qstroker.cpp:859
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ strokePath()

void QStrokerOps::strokePath ( const QPainterPath path,
void *  customData,
const QTransform matrix 
)

Convenience function that decomposes path into begin(), moveTo(), lineTo(), curevTo() and end() calls.

The customData parameter is used in the callback functions

The matrix is used to transform the points before input to the stroker.

See also
begin()

Definition at line 242 of file qstroker.cpp.

Referenced by QPainterPathStroker::createStroke(), and QPdf::Stroker::strokePath().

243 {
244  if (path.isEmpty())
245  return;
246 
248  begin(customData);
249  int count = path.elementCount();
250  if (matrix.isIdentity()) {
251  for (int i=0; i<count; ++i) {
252  const QPainterPath::Element &e = path.elementAt(i);
253  switch (e.type) {
256  break;
259  break;
261  {
262  const QPainterPath::Element &cp2 = path.elementAt(++i);
263  const QPainterPath::Element &ep = path.elementAt(++i);
267  }
268  break;
269  default:
270  break;
271  }
272  }
273  } else {
274  for (int i=0; i<count; ++i) {
275  const QPainterPath::Element &e = path.elementAt(i);
276  QPointF pt = QPointF(e.x, e.y) * matrix;
277  switch (e.type) {
280  break;
283  break;
285  {
286  QPointF cp2 = ((QPointF) path.elementAt(++i)) * matrix;
287  QPointF ep = ((QPointF) path.elementAt(++i)) * matrix;
289  qt_real_to_fixed(cp2.x()), qt_real_to_fixed(cp2.y()),
290  qt_real_to_fixed(ep.x()), qt_real_to_fixed(ep.y()));
291  }
292  break;
293  default:
294  break;
295  }
296  }
297  }
298  end();
299 }
ElementType type
the type of element
Definition: qpainterpath.h:81
The QPainterPath::Element class specifies the position and type of a subpath.
Definition: qpainterpath.h:77
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
#define qt_real_to_fixed(real)
Definition: qstroker_p.h:101
void lineTo(qfixed x, qfixed y)
Definition: qstroker_p.h:317
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal y
the y coordinate of the element&#39;s position.
Definition: qpainterpath.h:80
void setCurveThresholdFromTransform(const QTransform &transform)
Definition: qstroker_p.h:167
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Definition: qpainterpath.h:402
void cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey)
Definition: qstroker_p.h:323
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qtransform.h:204
virtual void end()
Finishes the stroke.
Definition: qstroker.cpp:224
virtual void begin(void *customData)
Prepares the stroker.
Definition: qstroker.cpp:213
qreal x
the x coordinate of the element&#39;s position.
Definition: qpainterpath.h:79
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void moveTo(qfixed x, qfixed y)
Definition: qstroker_p.h:308
int elementCount() const
Returns the number of path elements in the painter path.
Definition: qpainterpath.h:397
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ strokePolygon()

void QStrokerOps::strokePolygon ( const QPointF points,
int  pointCount,
bool  implicit_close,
void *  data,
const QTransform matrix 
)

Convenience function for stroking a polygon of the pointCount first points in points.

If implicit_close is set to true a line is implictly drawn between the first and last point in the polygon. Typically true for polygons and false for polylines.

The matrix is used to transform the points before they enter the stroker.

See also
begin()

Definition at line 313 of file qstroker.cpp.

315 {
316  if (!pointCount)
317  return;
318 
320  begin(data);
321  if (matrix.isIdentity()) {
322  moveTo(qt_real_to_fixed(points[0].x()), qt_real_to_fixed(points[0].y()));
323  for (int i=1; i<pointCount; ++i)
324  lineTo(qt_real_to_fixed(points[i].x()),
325  qt_real_to_fixed(points[i].y()));
326  if (implicit_close)
327  lineTo(qt_real_to_fixed(points[0].x()), qt_real_to_fixed(points[0].y()));
328  } else {
329  QPointF start = points[0] * matrix;
330  moveTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y()));
331  for (int i=1; i<pointCount; ++i) {
332  QPointF pt = points[i] * matrix;
334  }
335  if (implicit_close)
336  lineTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y()));
337  }
338  end();
339 }
#define qt_real_to_fixed(real)
Definition: qstroker_p.h:101
void lineTo(qfixed x, qfixed y)
Definition: qstroker_p.h:317
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void setCurveThresholdFromTransform(const QTransform &transform)
Definition: qstroker_p.h:167
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qtransform.h:204
static const char * data(const QByteArray &arr)
virtual void end()
Finishes the stroke.
Definition: qstroker.cpp:224
virtual void begin(void *customData)
Prepares the stroker.
Definition: qstroker.cpp:213
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void moveTo(qfixed x, qfixed y)
Definition: qstroker_p.h:308
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

Properties

◆ m_clip_rect

QRectF QStrokerOps::m_clip_rect
protected

Definition at line 185 of file qstroker_p.h.

Referenced by QDashStroker::processCurrentSubpath().

◆ m_cubicTo

qStrokerCubicToHook QStrokerOps::m_cubicTo
protected

Definition at line 192 of file qstroker_p.h.

◆ m_curveThreshold

qfixed QStrokerOps::m_curveThreshold
protected

Definition at line 186 of file qstroker_p.h.

◆ m_customData

void* QStrokerOps::m_customData
protected

Definition at line 189 of file qstroker_p.h.

Referenced by begin(), end(), and QDashStroker::processCurrentSubpath().

◆ m_dashThreshold

qfixed QStrokerOps::m_dashThreshold
protected

Definition at line 187 of file qstroker_p.h.

Referenced by QDashStroker::processCurrentSubpath().

◆ m_elements

QDataBuffer<Element> QStrokerOps::m_elements
protected

◆ m_lineTo

qStrokerLineToHook QStrokerOps::m_lineTo
protected

Definition at line 191 of file qstroker_p.h.

◆ m_moveTo

qStrokerMoveToHook QStrokerOps::m_moveTo
protected

Definition at line 190 of file qstroker_p.h.


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