Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsgcurvestrokenode_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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
4#ifndef QSGCURVESTROKENODE_P_H
5#define QSGCURVESTROKENODE_P_H
6
7#include <QtQuick/qtquickexports.h>
8#include <QtQuick/qsgnode.h>
9
12
13//
14// W A R N I N G
15// -------------
16//
17// This file is not part of the Qt API. It exists for the convenience
18// of a number of Qt sources files. This header file may change from
19// version to version without notice, or even be removed.
20//
21// We mean it.
22//
23
25
26class Q_QUICK_EXPORT QSGCurveStrokeNode : public QSGCurveAbstractNode
27{
28public:
30
31 void setColor(QColor col) override
32 {
33 m_color = col;
34 }
35
36 QColor color() const
37 {
38 return m_color;
39 }
40
42 {
43 m_strokeWidth = width;
44 }
45
46 float strokeWidth() const
47 {
48 return m_strokeWidth;
49 }
50
51 void appendTriangle(const std::array<QVector2D, 3> &v, // triangle vertices
52 const std::array<QVector2D, 3> &p, // curve points
53 const std::array<QVector2D, 3> &n); // vertex normals
54 void appendTriangle(const std::array<QVector2D, 3> &v, // triangle vertices
55 const std::array<QVector2D, 2> &p, // line points
56 const std::array<QVector2D, 3> &n); // vertex normals
57
58 void cookGeometry() override;
59
60 static const QSGGeometry::AttributeSet &attributes();
61
62 QVector<quint32> uncookedIndexes() const
63 {
64 return m_uncookedIndexes;
65 }
66
67 float debug() const
68 {
69 return m_debug;
70 }
71
72 void setDebug(float newDebug)
73 {
74 m_debug = newDebug;
75 }
76
77 void setLocalScale(float scale)
78 {
79 m_localScale = scale;
80 }
81
82 float localScale() const
83 {
84 return m_localScale;
85 }
86
87private:
88
89 struct StrokeVertex
90 {
91 float x, y;
92 float ax, ay;
93 float bx, by;
94 float cx, cy;
95 float nx, ny; //normal vector: direction to move vertext to account for AA
96 };
97
98 void updateMaterial();
99
100 static std::array<QVector2D, 3> curveABC(const std::array<QVector2D, 3> &p);
101
102 QColor m_color;
103 float m_strokeWidth = 0.0f;
104 float m_debug = 0.0f;
105 float m_localScale = 1.0f;
106
107protected:
108 QScopedPointer<QSGCurveStrokeMaterial> m_material;
109
110 QVector<StrokeVertex> m_uncookedVertexes;
111 QVector<quint32> m_uncookedIndexes;
112};
113
115
116#endif // QSGCURVESTROKENODE_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
QVector< quint32 > m_uncookedIndexes
QScopedPointer< QSGCurveStrokeMaterial > m_material
QVector< StrokeVertex > m_uncookedVertexes
void setDebug(float newDebug)
void setStrokeWidth(float width)
QVector< quint32 > uncookedIndexes() const
void setColor(QColor col) override
void setLocalScale(float scale)
Combined button and popup list for selecting options.
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei width
GLfloat n
GLint y
GLbyte nx
GLfixed ny
GLfloat GLfloat p
[1]
GLenum GLenum GLenum GLenum GLenum scale
GLbyte by
The QSGGeometry::AttributeSet describes how the vertices in a QSGGeometry are built up.
Definition qsggeometry.h:73