1 | // Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB). |
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 QT3DCORE_QGEOMETRYVIEW_H |
5 | #define QT3DCORE_QGEOMETRYVIEW_H |
6 | |
7 | #include <Qt3DCore/qnode.h> |
8 | #include <Qt3DCore/qgeometry.h> |
9 | #include <Qt3DCore/qt3dcore_global.h> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | namespace Qt3DCore { |
14 | |
15 | class QGeometryViewPrivate; |
16 | class QGeometryFactory; |
17 | |
18 | typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr; |
19 | |
20 | class Q_3DCORESHARED_EXPORT QGeometryView : public Qt3DCore::QNode |
21 | { |
22 | Q_OBJECT |
23 | Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged) |
24 | Q_PROPERTY(int vertexCount READ vertexCount WRITE setVertexCount NOTIFY vertexCountChanged) |
25 | Q_PROPERTY(int indexOffset READ indexOffset WRITE setIndexOffset NOTIFY indexOffsetChanged) |
26 | Q_PROPERTY(int firstInstance READ firstInstance WRITE setFirstInstance NOTIFY firstInstanceChanged) |
27 | Q_PROPERTY(int firstVertex READ firstVertex WRITE setFirstVertex NOTIFY firstVertexChanged) |
28 | Q_PROPERTY(int indexBufferByteOffset READ indexBufferByteOffset WRITE setIndexBufferByteOffset NOTIFY indexBufferByteOffsetChanged) |
29 | Q_PROPERTY(int restartIndexValue READ restartIndexValue WRITE setRestartIndexValue NOTIFY restartIndexValueChanged) |
30 | Q_PROPERTY(int verticesPerPatch READ verticesPerPatch WRITE setVerticesPerPatch NOTIFY verticesPerPatchChanged) |
31 | Q_PROPERTY(bool primitiveRestartEnabled READ primitiveRestartEnabled WRITE setPrimitiveRestartEnabled NOTIFY primitiveRestartEnabledChanged) |
32 | Q_PROPERTY(Qt3DCore::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) |
33 | Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged) |
34 | |
35 | public: |
36 | explicit QGeometryView(Qt3DCore::QNode *parent = nullptr); |
37 | ~QGeometryView(); |
38 | |
39 | enum PrimitiveType { |
40 | Points = 0x0000, |
41 | Lines = 0x0001, |
42 | LineLoop = 0x0002, |
43 | LineStrip = 0x0003, |
44 | Triangles = 0x0004, |
45 | TriangleStrip = 0x0005, |
46 | TriangleFan = 0x0006, |
47 | LinesAdjacency = 0x000A, |
48 | TrianglesAdjacency = 0x000C, |
49 | LineStripAdjacency = 0x000B, |
50 | TriangleStripAdjacency = 0x000D, |
51 | Patches = 0x000E |
52 | }; |
53 | Q_ENUM(PrimitiveType) // LCOV_EXCL_LINE |
54 | |
55 | // how to figure out index count and all the fancy stuff that QMeshData provides for us? |
56 | // also how to figure out which attribute(s?) hold the indices? |
57 | |
58 | int instanceCount() const; |
59 | int vertexCount() const; |
60 | int indexOffset() const; |
61 | int firstInstance() const; |
62 | int firstVertex() const; |
63 | int indexBufferByteOffset() const; |
64 | int restartIndexValue() const; |
65 | int verticesPerPatch() const; |
66 | bool primitiveRestartEnabled() const; |
67 | QGeometry *geometry() const; |
68 | PrimitiveType primitiveType() const; |
69 | |
70 | QGeometryFactoryPtr geometryFactory() const; |
71 | void setGeometryFactory(const QGeometryFactoryPtr &factory); |
72 | |
73 | public Q_SLOTS: |
74 | void setInstanceCount(int instanceCount); |
75 | void setVertexCount(int vertexCount); |
76 | void setIndexOffset(int indexOffset); |
77 | void setFirstInstance(int firstInstance); |
78 | void setFirstVertex(int firstVertex); |
79 | void setIndexBufferByteOffset(int offset); |
80 | void setRestartIndexValue(int index); |
81 | void setVerticesPerPatch(int verticesPerPatch); |
82 | void setPrimitiveRestartEnabled(bool enabled); |
83 | void setGeometry(QGeometry *geometry); |
84 | void setPrimitiveType(PrimitiveType primitiveType); |
85 | |
86 | Q_SIGNALS: |
87 | void instanceCountChanged(int instanceCount); |
88 | void vertexCountChanged(int vertexCount); |
89 | void indexOffsetChanged(int indexOffset); |
90 | void firstInstanceChanged(int firstInstance); |
91 | void firstVertexChanged(int firstVertex); |
92 | void indexBufferByteOffsetChanged(int offset); |
93 | void restartIndexValueChanged(int restartIndexValue); |
94 | void verticesPerPatchChanged(int verticesPerPatch); |
95 | void primitiveRestartEnabledChanged(bool primitiveRestartEnabled); |
96 | void geometryChanged(QGeometry *geometry); |
97 | void primitiveTypeChanged(PrimitiveType primitiveType); |
98 | |
99 | protected: |
100 | explicit QGeometryView(QGeometryViewPrivate &dd, Qt3DCore::QNode *parent = nullptr); |
101 | |
102 | private: |
103 | Q_DECLARE_PRIVATE(QGeometryView) |
104 | }; |
105 | |
106 | } // namespace Qt3DCore |
107 | |
108 | QT_END_NAMESPACE |
109 | |
110 | #endif // QT3DCORE_QGEOMETRYVIEW_H |
111 | |