KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
quickpainterpath.cpp
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2014 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: Kevin Funk <kevin.funk@kdab.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8
9 Licensees holding valid commercial KDAB State Machine Editor Library
10 licenses may use this file in accordance with the KDAB State Machine Editor
11 Library License Agreement provided with the Software.
12
13 Contact info@kdab.com if any conditions of this licensing are not clear to you.
14*/
15
16#include "quickpainterpath_p.h"
17
19 : QObject(parent)
20{
21}
22
24{
25 return m_stroker.width();
26}
27
29{
30 if (qFuzzyCompare(m_stroker.width(), width))
31 return;
32
33 m_stroker.setWidth(width);
34 Q_EMIT widthChanged(width);
35}
36
37QPainterPath QuickPainterPathStroker::createStroke(const QPainterPath &path) const
38{
39 return m_stroker.createStroke(path);
40}
41
43 : QObject(parent)
44 , m_isEmpty(true)
45{
46}
47
48QPainterPath QuickPainterPath::path() const
49{
50 return m_path;
51}
52
53void QuickPainterPath::setPath(const QPainterPath &path)
54{
55 if (m_path == path)
56 return;
57
58 m_path = path;
59 Q_EMIT pathChanged(path);
60
61 updateState(path);
62}
63
65{
66 return m_startPoint;
67}
68
70{
71 return m_endPoint;
72}
73
75{
76 return m_isEmpty;
77}
78
79void QuickPainterPath::moveTo(QPointF point)
80{
81 m_path.moveTo(point);
82 updateState(m_path);
83}
84
85void QuickPainterPath::lineTo(QPointF endPoint)
86{
87 m_path.lineTo(endPoint);
88 updateState(m_path);
89}
90
92{
93 setPath(QPainterPath());
94}
95
96bool QuickPainterPath::contains(QPointF point) const
97{
98 return m_path.contains(point);
99}
100
102{
103 return m_path.angleAtPercent(t);
104}
105
106void QuickPainterPath::updateState(const QPainterPath &path)
107{
108 const QPointF newStartPoint = path.pointAtPercent(0.0);
109 if (newStartPoint != m_startPoint) {
110 m_startPoint = newStartPoint;
111 Q_EMIT startPointChanged(m_startPoint);
112 }
113 const QPointF newEndPoint = path.pointAtPercent(1.0);
114 if (newEndPoint != m_endPoint) {
115 m_endPoint = newEndPoint;
116 Q_EMIT endPointChanged(m_endPoint);
117 }
118 const bool newIsEmpty = path.isEmpty();
119 if (newIsEmpty != m_isEmpty) {
120 m_isEmpty = newIsEmpty;
121 Q_EMIT isEmptyChanged(m_isEmpty);
122 }
123}
124
130
131
133{
134 return m_path;
135}
136
137void QuickPainterPathGeometryItem::setPath(const QPainterPath &path)
138{
139 if (m_path == path)
140 return;
141
142 m_path = path;
143 updateData();
144 Q_EMIT pathChanged(m_path);
145 Q_EMIT changed();
146}
147
148void QuickPainterPathGeometryItem::updateData()
149{
150 // update data
151 m_vertexCoordinates.clear();
152 if (!m_path.isEmpty()) {
153 m_vertexCoordinates.addPath(qtVectorPathForPath(m_path), 1.);
154 }
155 QOpenGLPoint *points = m_vertexCoordinates.data();
156 const int vertexCount = m_vertexCoordinates.vertexCount();
157 QList<qreal> vertexData;
158 vertexData.reserve(vertexCount * 2);
159 for (int i = 0; i < vertexCount; ++i) {
160 vertexData << points[i].x;
161 vertexData << points[i].y;
162 }
164}
void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline=true)
void setVertexData(const QList< qreal > &vertexData)
void setDrawingMode(DrawingMode drawingMode)
QList< qreal > vertexData() const
void changed()
Emitted in case any of this object properties changes.
void setPath(const QPainterPath &path)
QuickPainterPathGeometryItem(QQuickItem *parent=nullptr)
void pathChanged(const QPainterPath &path)
QuickPainterPathStroker(QObject *parent=nullptr)
Q_INVOKABLE QPainterPath createStroke(const QPainterPath &path) const
void widthChanged(qreal width)
Q_INVOKABLE qreal angleAtPercent(qreal t) const
Q_INVOKABLE void lineTo(QPointF endPoint)
Q_INVOKABLE void clear()
void pathChanged(const QPainterPath &path)
void startPointChanged(const QPointF &startPoint)
void endPointChanged(const QPointF &endPoint)
void isEmptyChanged(bool isEmpty)
Q_INVOKABLE void moveTo(QPointF point)
QuickPainterPath(QObject *parent=nullptr)
Q_INVOKABLE bool contains(QPointF point) const
void setPath(const QPainterPath &path)

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8