1// Copyright (C) 2016 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 "qconegeometryview.h"
5
6#include <Qt3DExtras/qconegeometry.h>
7#include <Qt3DCore/qbuffer.h>
8#include <Qt3DCore/qattribute.h>
9#include <QtGui/QVector3D>
10
11#include <qmath.h>
12
13QT_BEGIN_NAMESPACE
14
15namespace Qt3DExtras {
16
17/*!
18 * \qmltype ConeGeometryView
19 * \instantiates Qt3DExtras::QConeGeometryView
20 * \inqmlmodule Qt3D.Extras
21 * \brief A conical mesh.
22 */
23
24/*!
25 * \qmlproperty int ConeGeometryView::rings
26 *
27 * Holds the number of rings in the mesh.
28 */
29
30/*!
31 * \qmlproperty int ConeGeometryView::slices
32 *
33 * Holds the number of slices in the mesh.
34 */
35
36/*!
37 * \qmlproperty bool ConeGeometryView::hasTopEndcap
38 *
39 * Determines if the cone top is capped or open.
40 */
41
42/*!
43 * \qmlproperty bool ConeGeometryView::hasBottomEndcap
44 *
45 * Determines if the cone bottom is capped or open.
46 */
47
48/*!
49 * \qmlproperty real ConeGeometryView::topRadius
50 *
51 * Holds the top radius of the cone.
52 */
53
54/*!
55 * \qmlproperty real ConeGeometryView::bottomRadius
56 *
57 * Holds the bottom radius of the cone.
58 */
59
60/*!
61 * \qmlproperty real ConeGeometryView::length
62 *
63 * Holds the length of the cone.
64 */
65
66/*!
67 * \class Qt3DExtras::QConeGeometryView
68 \ingroup qt3d-extras-geometries
69 * \inheaderfile Qt3DExtras/QConeGeometryView
70 * \inmodule Qt3DExtras
71 *
72 * \inherits Qt3DRender::QGeometryRenderer
73 *
74 * \brief A conical mesh.
75 */
76
77QConeGeometryView::QConeGeometryView(QNode *parent)
78 : Qt3DCore::QGeometryView(parent)
79{
80 QConeGeometry *geometry = new QConeGeometry(this);
81 QObject::connect(sender: geometry, signal: &QConeGeometry::hasTopEndcapChanged, context: this, slot: &QConeGeometryView::hasTopEndcapChanged);
82 QObject::connect(sender: geometry, signal: &QConeGeometry::hasBottomEndcapChanged, context: this, slot: &QConeGeometryView::hasBottomEndcapChanged);
83 QObject::connect(sender: geometry, signal: &QConeGeometry::topRadiusChanged, context: this, slot: &QConeGeometryView::topRadiusChanged);
84 QObject::connect(sender: geometry, signal: &QConeGeometry::bottomRadiusChanged, context: this, slot: &QConeGeometryView::bottomRadiusChanged);
85 QObject::connect(sender: geometry, signal: &QConeGeometry::ringsChanged, context: this, slot: &QConeGeometryView::ringsChanged);
86 QObject::connect(sender: geometry, signal: &QConeGeometry::slicesChanged, context: this, slot: &QConeGeometryView::slicesChanged);
87 QObject::connect(sender: geometry, signal: &QConeGeometry::lengthChanged, context: this, slot: &QConeGeometryView::lengthChanged);
88
89 QGeometryView::setGeometry(geometry);
90}
91
92/*! \internal */
93QConeGeometryView::~QConeGeometryView()
94{
95}
96
97void QConeGeometryView::setHasTopEndcap(bool hasTopEndcap)
98{
99 static_cast<QConeGeometry *>(geometry())->setHasTopEndcap(hasTopEndcap);
100}
101
102void QConeGeometryView::setHasBottomEndcap(bool hasBottomEndcap)
103{
104 static_cast<QConeGeometry *>(geometry())->setHasBottomEndcap(hasBottomEndcap);
105}
106
107void QConeGeometryView::setTopRadius(float topRadius)
108{
109 static_cast<QConeGeometry *>(geometry())->setTopRadius(topRadius);
110}
111
112void QConeGeometryView::setBottomRadius(float bottomRadius)
113{
114 static_cast<QConeGeometry *>(geometry())->setBottomRadius(bottomRadius);
115}
116
117void QConeGeometryView::setRings(int rings)
118{
119 static_cast<QConeGeometry *>(geometry())->setRings(rings);
120}
121
122void QConeGeometryView::setSlices(int slices)
123{
124 static_cast<QConeGeometry *>(geometry())->setSlices(slices);
125}
126
127void QConeGeometryView::setLength(float length)
128{
129 static_cast<QConeGeometry *>(geometry())->setLength(length);
130}
131
132/*!
133 * \property QConeGeometryView::hasTopEndcap
134 *
135 * Determines if the cone top is capped or open.
136 */
137bool QConeGeometryView::hasTopEndcap() const
138{
139 return static_cast<QConeGeometry *>(geometry())->hasTopEndcap();
140}
141
142/*!
143 * \property QConeGeometryView::hasBottomEndcap
144 *
145 * Determines if the cone bottom is capped or open.
146 */
147bool QConeGeometryView::hasBottomEndcap() const
148{
149 return static_cast<QConeGeometry *>(geometry())->hasBottomEndcap();
150}
151
152/*!
153 * \property QConeGeometryView::topRadius
154 *
155 * Holds the top radius of the cone.
156 */
157float QConeGeometryView::topRadius() const
158{
159 return static_cast<QConeGeometry *>(geometry())->topRadius();
160}
161
162/*!
163 * \property QConeGeometryView::bottomRadius
164 *
165 * Holds the bottom radius of the cone.
166 */
167float QConeGeometryView::bottomRadius() const
168{
169 return static_cast<QConeGeometry *>(geometry())->bottomRadius();
170}
171
172/*!
173 * \property QConeGeometryView::rings
174 *
175 * Holds the number of rings in the mesh.
176 */
177int QConeGeometryView::rings() const
178{
179 return static_cast<QConeGeometry *>(geometry())->rings();
180}
181
182/*!
183 * \property QConeGeometryView::slices
184 *
185 * Holds the number of slices in the mesh.
186 */
187int QConeGeometryView::slices() const
188{
189 return static_cast<QConeGeometry *>(geometry())->slices();
190}
191
192/*!
193 * \property QConeGeometryView::length
194 *
195 * Holds the length of the cone.
196 */
197float QConeGeometryView::length() const
198{
199 return static_cast<QConeGeometry *>(geometry())->length();
200}
201
202} // namespace Qt3DExtras
203
204QT_END_NAMESPACE
205
206#include "moc_qconegeometryview.cpp"
207

source code of qt3d/src/extras/geometries/qconegeometryview.cpp