KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
quickprimitiveitem_p.h
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2015 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#ifndef KDSME_QUICK_QUICKPRIMITIVEITEM_P_H
17#define KDSME_QUICK_QUICKPRIMITIVEITEM_P_H
18
19#include <QScopedPointer>
20#include <QtQuick/QSGGeometry>
21#include <QtQuick/QQuickItem>
22
23QT_BEGIN_NAMESPACE
24class QRectF;
25QT_END_NAMESPACE
26
27namespace GeometryUtils {
28
29QRectF boundingRect(QSGGeometry *geometry);
30
31}
32
33class QuickGeometryItem : public QObject
34{
35 Q_OBJECT
36 Q_PROPERTY(QList<qreal> data READ vertexData WRITE setVertexData NOTIFY vertexDataChanged)
38 Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged)
39
41
42public:
49 Q_ENUM(VertexDataType)
50
52 {
53 Points = QSGGeometry::DrawPoints,
54 Lines = QSGGeometry::DrawLines,
55 LineLoop = QSGGeometry::DrawLineLoop,
56 LineStrip = QSGGeometry::DrawLineStrip,
57 Triangles = QSGGeometry::DrawTriangles,
58 TriangleStrip = QSGGeometry::DrawTriangleStrip,
59 TriangleFan = QSGGeometry::DrawTriangleFan
60 };
61 Q_ENUM(DrawingMode)
62
63 explicit QuickGeometryItem(QObject *parent = nullptr);
64
65 QList<qreal> vertexData() const;
66 void setVertexData(const QList<qreal> &vertexData);
67
70
73
74 float lineWidth() const;
75 void setLineWidth(float lineWidth);
76
77 QSGGeometry *createGeometry() const;
78
79Q_SIGNALS:
80 void vertexDataChanged(const QList<qreal> &vertexData);
85 void changed();
86
87private:
88 QList<qreal> m_vertexData;
89 VertexDataType m_vertexDataType;
90 DrawingMode m_drawingMode;
91 float m_lineWidth;
92};
93
94Q_DECLARE_METATYPE(QuickGeometryItem::VertexDataType)
95Q_DECLARE_METATYPE(QuickGeometryItem::DrawingMode)
96
97class QuickPrimitiveItem : public QQuickItem
98{
99 Q_OBJECT
100 Q_PROPERTY(QuickGeometryItem *geometry READ geometryItem WRITE setGeometryItem NOTIFY geometryItemChanged)
101 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
102
103public:
104 explicit QuickPrimitiveItem(QQuickItem *parent = nullptr);
105
106 QuickGeometryItem *geometryItem() const;
107 void setGeometryItem(QuickGeometryItem *item);
108
109 QColor color() const;
110 void setColor(const QColor &color);
111
112Q_SIGNALS:
113 void geometryItemChanged(QuickGeometryItem *geometry);
114 void colorChanged(const QColor &color);
115
116protected:
117 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
118
119private Q_SLOTS:
120 void updateGeometry();
121
122private:
123 void updateImplicitSize(QSGGeometry *geometry);
124
125 QuickGeometryItem *m_geometryItem;
126 bool m_geometryDirty;
127 QColor m_color;
128};
129
130#endif // QUICKPRIMITIVEITEM_P_H
void setLineWidth(float lineWidth)
void lineWidthChanged(float lineWidth)
VertexDataType vertexDataType() const
void vertexDataChanged(const QList< qreal > &vertexData)
void setVertexData(const QList< qreal > &vertexData)
QSGGeometry * createGeometry() const
void setDrawingMode(DrawingMode drawingMode)
QList< qreal > vertexData() const
void vertexDataTypeChanged(QuickGeometryItem::VertexDataType type)
void drawingModeChanged(QuickGeometryItem::DrawingMode drawingMode)
QuickGeometryItem::VertexDataType type
void setVertexDataType(VertexDataType type)
void changed()
Emitted in case any of this object properties changes.
QRectF boundingRect(QSGGeometry *geometry)

© 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