Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtriangulatingstroker_p.h
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QTRIANGULATINGSTROKER_P_H
6
#
define
QTRIANGULATINGSTROKER_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
qmath
.
h
>
20
#
include
<
QtGui
/
private
/
qtguiglobal_p
.
h
>
21
#
include
<
private
/
qdatabuffer_p
.
h
>
22
#
include
<
qvarlengtharray
.
h
>
23
#
include
<
private
/
qvectorpath_p
.
h
>
24
#
include
<
private
/
qbezier_p
.
h
>
25
#
include
<
private
/
qnumeric_p
.
h
>
26
#
include
<
private
/
qmath_p
.
h
>
27
28
QT_BEGIN_NAMESPACE
29
30
class
Q_GUI_EXPORT
QTriangulatingStroker
31
{
32
public
:
33
QTriangulatingStroker() : m_vertices(0), m_cx(0), m_cy(0), m_nvx(0), m_nvy(0), m_width(1), m_miter_limit(2),
34
m_roundness(0), m_sin_theta(0), m_cos_theta(0), m_inv_scale(1), m_curvyness_mul(1), m_curvyness_add(0),
35
m_join_style(Qt::BevelJoin), m_cap_style(Qt::SquareCap) {}
36
37
void
process(
const
QVectorPath &path,
const
QPen &pen,
const
QRectF &clip, QPainter::RenderHints hints);
38
39
inline
int
vertexCount()
const
{
return
m_vertices.size(); }
40
inline
const
float
*vertices()
const
{
return
m_vertices.data(); }
41
42
inline
void
setInvScale(qreal invScale) { m_inv_scale = invScale; }
43
44
private
:
45
inline
void
emitLineSegment(
float
x,
float
y,
float
nx,
float
ny);
46
void
moveTo(
const
qreal *pts);
47
inline
void
lineTo(
const
qreal *pts);
48
void
cubicTo(
const
qreal *pts);
49
void
join(
const
qreal *pts);
50
inline
void
normalVector(
float
x1,
float
y1,
float
x2,
float
y2,
float
*nx,
float
*ny);
51
void
endCap(
const
qreal *pts);
52
void
arcPoints(
float
cx,
float
cy,
float
fromX,
float
fromY,
float
toX,
float
toY, QVarLengthArray<
float
> &points);
53
void
endCapOrJoinClosed(
const
qreal *start,
const
qreal *cur,
bool
implicitClose,
bool
endsAtStart);
54
55
56
QDataBuffer<
float
> m_vertices;
57
58
float
m_cx, m_cy;
// current points
59
float
m_nvx, m_nvy;
// normal vector...
60
float
m_width;
61
qreal m_miter_limit;
62
63
int
m_roundness;
// Number of line segments in a round join
64
qreal m_sin_theta;
// sin(m_roundness / 360);
65
qreal m_cos_theta;
// cos(m_roundness / 360);
66
qreal m_inv_scale;
67
float
m_curvyness_mul;
68
float
m_curvyness_add;
69
70
Qt::PenJoinStyle m_join_style;
71
Qt::PenCapStyle m_cap_style;
72
};
73
74
class
Q_GUI_EXPORT
QDashedStrokeProcessor
75
{
76
public
:
77
QDashedStrokeProcessor();
78
79
void
process(
const
QVectorPath &path,
const
QPen &pen,
const
QRectF &clip, QPainter::RenderHints hints);
80
81
inline
void
addElement(QPainterPath::ElementType type, qreal x, qreal y) {
82
m_points.add(x);
83
m_points.add(y);
84
m_types.add(type);
85
}
86
87
inline
int
elementCount()
const
{
return
m_types.size(); }
88
inline
qreal *points()
const
{
return
m_points.data(); }
89
inline
QPainterPath::ElementType *elementTypes()
const
{
return
m_types.data(); }
90
91
inline
void
setInvScale(qreal invScale) { m_inv_scale = invScale; }
92
93
private
:
94
QDataBuffer<qreal> m_points;
95
QDataBuffer<QPainterPath::ElementType> m_types;
96
QDashStroker m_dash_stroker;
97
qreal m_inv_scale;
98
};
99
100
inline
void
QTriangulatingStroker::normalVector(
float
x1,
float
y1,
float
x2,
float
y2,
101
float
*nx,
float
*ny)
102
{
103
const
float
dx = x2 - x1;
104
const
float
dy = y2 - y1;
105
const
float
pw = m_width / qHypot(dx, dy);
106
107
*nx = -dy * pw;
108
*ny = dx * pw;
109
}
110
111
inline
void
QTriangulatingStroker::emitLineSegment(
float
x,
float
y,
float
vx,
float
vy)
112
{
113
m_vertices.add(x + vx);
114
m_vertices.add(y + vy);
115
m_vertices.add(x - vx);
116
m_vertices.add(y - vy);
117
}
118
119
void
QTriangulatingStroker::lineTo(
const
qreal *pts)
120
{
121
emitLineSegment(pts[0], pts[1], m_nvx, m_nvy);
122
m_cx = pts[0];
123
m_cy = pts[1];
124
}
125
126
QT_END_NAMESPACE
127
128
#
endif
QDashedStrokeProcessor
Definition
qtriangulatingstroker_p.h:75
QTriangulatingStroker
Definition
qtriangulatingstroker_p.h:31
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
CURVE_FLATNESS
#define CURVE_FLATNESS
Definition
qtriangulatingstroker.cpp:10
qdashprocessor_moveTo
static void qdashprocessor_moveTo(qreal x, qreal y, void *data)
Definition
qtriangulatingstroker.cpp:482
qdashprocessor_cubicTo
static void qdashprocessor_cubicTo(qreal, qreal, qreal, qreal, qreal, qreal, void *)
Definition
qtriangulatingstroker.cpp:492
skipDuplicatePoints
static void skipDuplicatePoints(const qreal **pts, const qreal *endPts)
Definition
qtriangulatingstroker.cpp:39
qdashprocessor_lineTo
static void qdashprocessor_lineTo(qreal x, qreal y, void *data)
Definition
qtriangulatingstroker.cpp:487
qtbase
src
gui
painting
qtriangulatingstroker_p.h
Generated on
for Qt by
1.18.0