1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
2 | // Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #ifndef _USE_MATH_DEFINES |
6 | # define _USE_MATH_DEFINES // For MSVC |
7 | #endif |
8 | |
9 | #include "qcylindermesh.h" |
10 | #include "qcylindergeometryview.h" |
11 | |
12 | #include <Qt3DCore/qbuffer.h> |
13 | #include <Qt3DCore/qattribute.h> |
14 | #include <QtGui/QVector3D> |
15 | |
16 | #include <qmath.h> |
17 | |
18 | QT_BEGIN_NAMESPACE |
19 | |
20 | using namespace Qt3DCore; |
21 | |
22 | namespace Qt3DExtras { |
23 | |
24 | /*! |
25 | * \qmltype CylinderMesh |
26 | * \instantiates Qt3DExtras::QCylinderMesh |
27 | * \inqmlmodule Qt3D.Extras |
28 | * \brief A cylindrical mesh. |
29 | */ |
30 | |
31 | /*! |
32 | * \qmlproperty int CylinderMesh::rings |
33 | * |
34 | * Holds the number of rings in the mesh. |
35 | */ |
36 | |
37 | /*! |
38 | * \qmlproperty int CylinderMesh::slices |
39 | * |
40 | * Holds the number of slices in the mesh. |
41 | */ |
42 | |
43 | /*! |
44 | * \qmlproperty real CylinderMesh::radius |
45 | * |
46 | * Holds the radius of the cylinder. |
47 | */ |
48 | |
49 | /*! |
50 | * \qmlproperty real CylinderMesh::length |
51 | * |
52 | * Holds the length of the cylinder. |
53 | */ |
54 | |
55 | /*! |
56 | * \class Qt3DExtras::QCylinderMesh |
57 | * \ingroup qt3d-extras-geometries |
58 | * \inheaderfile Qt3DExtras/QCylinderMesh |
59 | * \inmodule Qt3DExtras |
60 | * |
61 | * \inherits Qt3DRender::QGeometryRenderer |
62 | * |
63 | * \brief A cylindrical mesh. |
64 | */ |
65 | |
66 | /*! |
67 | * Constructs a new QCylinderMesh with \a parent. |
68 | */ |
69 | QCylinderMesh::(QNode *parent) |
70 | : Qt3DRender::QGeometryRenderer(parent) |
71 | { |
72 | QCylinderGeometryView *geometry = new QCylinderGeometryView(this); |
73 | QObject::connect(sender: geometry, signal: &QCylinderGeometryView::radiusChanged, context: this, slot: &QCylinderMesh::radiusChanged); |
74 | QObject::connect(sender: geometry, signal: &QCylinderGeometryView::ringsChanged, context: this, slot: &QCylinderMesh::ringsChanged); |
75 | QObject::connect(sender: geometry, signal: &QCylinderGeometryView::slicesChanged, context: this, slot: &QCylinderMesh::slicesChanged); |
76 | QObject::connect(sender: geometry, signal: &QCylinderGeometryView::lengthChanged, context: this, slot: &QCylinderMesh::lengthChanged); |
77 | |
78 | setView(geometry); |
79 | } |
80 | |
81 | /*! \internal */ |
82 | QCylinderMesh::() |
83 | { |
84 | } |
85 | |
86 | void QCylinderMesh::(int rings) |
87 | { |
88 | static_cast<QCylinderGeometryView *>(view())->setRings(rings); |
89 | } |
90 | |
91 | void QCylinderMesh::(int slices) |
92 | { |
93 | static_cast<QCylinderGeometryView *>(view())->setSlices(slices); |
94 | } |
95 | |
96 | void QCylinderMesh::(float radius) |
97 | { |
98 | static_cast<QCylinderGeometryView *>(view())->setRadius(radius); |
99 | } |
100 | |
101 | void QCylinderMesh::(float length) |
102 | { |
103 | static_cast<QCylinderGeometryView *>(view())->setLength(length); |
104 | } |
105 | |
106 | /*! |
107 | * \property QCylinderMesh::rings |
108 | * |
109 | * Holds the number of rings in the mesh. |
110 | */ |
111 | int QCylinderMesh::() const |
112 | { |
113 | return static_cast<QCylinderGeometryView *>(view())->rings(); |
114 | } |
115 | |
116 | /*! |
117 | * \property QCylinderMesh::slices |
118 | * |
119 | * Holds the number of slices in the mesh. |
120 | */ |
121 | int QCylinderMesh::() const |
122 | { |
123 | return static_cast<QCylinderGeometryView *>(view())->slices(); |
124 | } |
125 | |
126 | /*! |
127 | * \property QCylinderMesh::radius |
128 | * |
129 | * Holds the radius of the cylinder. |
130 | */ |
131 | float QCylinderMesh::() const |
132 | { |
133 | return static_cast<QCylinderGeometryView *>(view())->radius(); |
134 | } |
135 | |
136 | /*! |
137 | * \property QCylinderMesh::length |
138 | * |
139 | * Holds the length of the cylinder. |
140 | */ |
141 | float QCylinderMesh::() const |
142 | { |
143 | return static_cast<QCylinderGeometryView *>(view())->length(); |
144 | } |
145 | |
146 | } // namespace Qt3DExtras |
147 | |
148 | QT_END_NAMESPACE |
149 | |
150 | #include "moc_qcylindermesh.cpp" |
151 | |