1 | // Copyright (C) 2014 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 | #include "qplanemesh.h" |
5 | |
6 | #include <Qt3DExtras/qplanegeometryview.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DExtras { |
11 | |
12 | /*! |
13 | * \qmltype PlaneMesh |
14 | * \instantiates Qt3DExtras::QPlaneMesh |
15 | * \inqmlmodule Qt3D.Extras |
16 | * \brief A square planar mesh. |
17 | */ |
18 | |
19 | /*! |
20 | * \qmlproperty real PlaneMesh::width |
21 | * |
22 | * Holds the plane width. |
23 | */ |
24 | |
25 | /*! |
26 | * \qmlproperty real PlaneMesh::height |
27 | * |
28 | * Holds the plane height. |
29 | */ |
30 | |
31 | /*! |
32 | * \qmlproperty size PlaneMesh::meshResolution |
33 | * |
34 | * Holds the plane resolution. |
35 | * The width and height values of this property specify the number of vertices generated for |
36 | * the mesh in the respective dimensions. |
37 | */ |
38 | |
39 | /*! |
40 | * \qmlproperty bool PlaneMesh::mirrored |
41 | * \since 5.9 |
42 | * |
43 | * Controls if the UV coordinates of the plane should be flipped vertically. |
44 | */ |
45 | |
46 | /*! |
47 | * \class Qt3DExtras::QPlaneMesh |
48 | * \ingroup qt3d-extras-geometries |
49 | * \inheaderfile Qt3DExtras/QPlaneMesh |
50 | * \inmodule Qt3DExtras |
51 | * |
52 | * \inherits Qt3DRender::QGeometryRenderer |
53 | * |
54 | * \brief A square planar mesh. |
55 | */ |
56 | |
57 | /*! |
58 | * Constructs a new QPlaneMesh with \a parent. |
59 | */ |
60 | QPlaneMesh::(QNode *parent) |
61 | : Qt3DRender::QGeometryRenderer(parent) |
62 | { |
63 | QPlaneGeometryView *geometry = new QPlaneGeometryView(this); |
64 | QObject::connect(sender: geometry, signal: &QPlaneGeometryView::widthChanged, context: this, slot: &QPlaneMesh::widthChanged); |
65 | QObject::connect(sender: geometry, signal: &QPlaneGeometryView::heightChanged, context: this, slot: &QPlaneMesh::heightChanged); |
66 | QObject::connect(sender: geometry, signal: &QPlaneGeometryView::meshResolutionChanged, context: this, slot: &QPlaneMesh::meshResolutionChanged); |
67 | QObject::connect(sender: geometry, signal: &QPlaneGeometryView::mirroredChanged, context: this, slot: &QPlaneMesh::mirroredChanged); |
68 | setView(geometry); |
69 | } |
70 | |
71 | /*! \internal */ |
72 | QPlaneMesh::() |
73 | { |
74 | } |
75 | |
76 | void QPlaneMesh::(float width) |
77 | { |
78 | static_cast<QPlaneGeometryView *>(view())->setWidth(width); |
79 | } |
80 | |
81 | /*! |
82 | * \property QPlaneMesh::width |
83 | * |
84 | * Holds the plane width. |
85 | */ |
86 | float QPlaneMesh::() const |
87 | { |
88 | return static_cast<QPlaneGeometryView *>(view())->width(); |
89 | } |
90 | |
91 | void QPlaneMesh::(float height) |
92 | { |
93 | static_cast<QPlaneGeometryView *>(view())->setHeight(height); |
94 | } |
95 | |
96 | /*! |
97 | * \property QPlaneMesh::height |
98 | * |
99 | * Holds the plane height. |
100 | */ |
101 | float QPlaneMesh::() const |
102 | { |
103 | return static_cast<QPlaneGeometryView *>(view())->height(); |
104 | } |
105 | |
106 | void QPlaneMesh::(const QSize &resolution) |
107 | { |
108 | static_cast<QPlaneGeometryView *>(view())->setMeshResolution(resolution); |
109 | } |
110 | |
111 | /*! |
112 | * \property QPlaneMesh::meshResolution |
113 | * |
114 | * Holds the plane resolution. |
115 | * The width and height values of this property specify the number of vertices generated for |
116 | * the mesh in the respective dimensions. |
117 | */ |
118 | QSize QPlaneMesh::() const |
119 | { |
120 | return static_cast<QPlaneGeometryView *>(view())->meshResolution(); |
121 | } |
122 | |
123 | void QPlaneMesh::(bool mirrored) |
124 | { |
125 | static_cast<QPlaneGeometryView *>(view())->setMirrored(mirrored); |
126 | } |
127 | |
128 | /*! |
129 | * \property QPlaneMesh::mirrored |
130 | * \since 5.9 |
131 | * |
132 | * Controls if the UV coordinates of the plane should be flipped vertically. |
133 | */ |
134 | bool QPlaneMesh::() const |
135 | { |
136 | return static_cast<QPlaneGeometryView *>(view())->mirrored(); |
137 | } |
138 | |
139 | } // namespace Qt3DExtras |
140 | |
141 | QT_END_NAMESPACE |
142 | |
143 | #include "moc_qplanemesh.cpp" |
144 | |