1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qpicktriangleevent.h" |
41 | #include "qpicktriangleevent_p.h" |
42 | #include "qpickevent_p.h" |
43 | #include <private/qobject_p.h> |
44 | |
45 | QT_BEGIN_NAMESPACE |
46 | |
47 | namespace Qt3DRender { |
48 | |
49 | |
50 | Qt3DRender::QPickTriangleEventPrivate::QPickTriangleEventPrivate() |
51 | : QPickEventPrivate() |
52 | , m_triangleIndex(0) |
53 | , m_vertex1Index(0) |
54 | , m_vertex2Index(0) |
55 | , m_vertex3Index(0) |
56 | { |
57 | } |
58 | |
59 | const QPickTriangleEventPrivate *QPickTriangleEventPrivate::get(const QPickTriangleEvent *ev) |
60 | { |
61 | return ev->d_func(); |
62 | } |
63 | |
64 | QPickTriangleEvent *QPickTriangleEventPrivate::clone() const |
65 | { |
66 | auto res = new QPickTriangleEvent(); |
67 | res->d_func()->m_accepted = m_accepted; |
68 | res->d_func()->m_position = m_position; |
69 | res->d_func()->m_worldIntersection = m_worldIntersection; |
70 | res->d_func()->m_localIntersection = m_localIntersection; |
71 | res->d_func()->m_distance = m_distance; |
72 | res->d_func()->m_button = m_button; |
73 | res->d_func()->m_buttons = m_buttons; |
74 | res->d_func()->m_modifiers = m_modifiers; |
75 | res->d_func()->m_entity = m_entity; |
76 | res->d_func()->m_entityPtr = m_entityPtr; |
77 | res->d_func()->m_viewport = m_viewport; |
78 | res->d_func()->m_triangleIndex = m_triangleIndex; |
79 | res->d_func()->m_vertex1Index = m_vertex1Index; |
80 | res->d_func()->m_vertex2Index = m_vertex2Index; |
81 | res->d_func()->m_vertex3Index = m_vertex3Index; |
82 | return res; |
83 | } |
84 | |
85 | |
86 | /*! |
87 | \class Qt3DRender::QPickTriangleEvent |
88 | \inmodule Qt3DRender |
89 | |
90 | \brief The QPickTriangleEvent class holds information when a triangle is picked. |
91 | |
92 | When QPickingSettings::pickMode() is set to QPickingSettings::TrianglePicking, the signals |
93 | on QObjectPicker will carry an instance of QPickTriangleEvent. |
94 | |
95 | This contains the details of the triangle that was picked. |
96 | |
97 | \note In the case of indexed rendering, the point indices are relative to the |
98 | array of coordinates, not the array of indices. |
99 | |
100 | \sa QPickingSettings, QPickEvent, QObjectPicker, QAttribute |
101 | \since 5.7 |
102 | */ |
103 | |
104 | /*! |
105 | * \qmltype PickTriangleEvent |
106 | * \instantiates Qt3DRender::QPickTriangleEvent |
107 | * \inqmlmodule Qt3D.Render |
108 | * \brief PickTriangleEvent holds information when a triangle is picked. |
109 | * |
110 | * When QPickingSettings::pickMode() is set to QPickingSettings::TrianglePicking, the signals |
111 | * on QObjectPicker will carry an instance of QPickTriangleEvent. |
112 | * |
113 | * This contains the details of the triangle that was picked. |
114 | * |
115 | * \note In case of indexed rendering, the point indices are relative to the |
116 | * array of indices, not the array of coordinates. |
117 | * |
118 | * \sa PickingSettings, PickEvent, ObjectPicker, Attribute |
119 | */ |
120 | |
121 | |
122 | /*! |
123 | \fn Qt3DRender::QPickTriangleEvent::QPickTriangleEvent() |
124 | Constructs a new QPickEvent. |
125 | */ |
126 | QPickTriangleEvent::QPickTriangleEvent() |
127 | : QPickEvent(*new QPickTriangleEventPrivate()) |
128 | { |
129 | } |
130 | |
131 | /*! |
132 | * \brief QPickTriangleEvent::QPickTriangleEvent Constructs a new QPickEvent with the given parameters |
133 | * \a position, |
134 | * \a worldIntersection, |
135 | * \a localIntersection, |
136 | * \a distance, |
137 | * \a triangleIndex, |
138 | * \a vertex1Index, |
139 | * \a vertex2Index and |
140 | * \a vertex3Index |
141 | |
142 | //! NOTE: remove in Qt6 |
143 | */ |
144 | QPickTriangleEvent::QPickTriangleEvent(const QPointF &position, const QVector3D &worldIntersection, const QVector3D &localIntersection, float distance, |
145 | uint triangleIndex, uint vertex1Index, uint vertex2Index, |
146 | uint vertex3Index) |
147 | : QPickEvent(*new QPickTriangleEventPrivate()) |
148 | { |
149 | Q_D(QPickTriangleEvent); |
150 | d->m_position = position; |
151 | d->m_distance = distance; |
152 | d->m_worldIntersection = worldIntersection; |
153 | d->m_localIntersection = localIntersection; |
154 | d->m_triangleIndex = triangleIndex; |
155 | d->m_vertex1Index = vertex1Index; |
156 | d->m_vertex2Index = vertex2Index; |
157 | d->m_vertex3Index = vertex3Index; |
158 | } |
159 | |
160 | QPickTriangleEvent::QPickTriangleEvent(const QPointF &position, const QVector3D &worldIntersection, |
161 | const QVector3D &localIntersection, float distance, |
162 | uint triangleIndex, uint vertex1Index, uint vertex2Index, |
163 | uint vertex3Index, QPickEvent::Buttons button, int buttons, |
164 | int modifiers, const QVector3D &uvw) |
165 | : QPickEvent(*new QPickTriangleEventPrivate()) |
166 | { |
167 | Q_D(QPickTriangleEvent); |
168 | d->m_position = position; |
169 | d->m_distance = distance; |
170 | d->m_worldIntersection = worldIntersection; |
171 | d->m_localIntersection = localIntersection; |
172 | d->m_triangleIndex = triangleIndex; |
173 | d->m_vertex1Index = vertex1Index; |
174 | d->m_vertex2Index = vertex2Index; |
175 | d->m_vertex3Index = vertex3Index; |
176 | d->m_button = button; |
177 | d->m_buttons = buttons; |
178 | d->m_modifiers = modifiers; |
179 | d->m_uvw = uvw; |
180 | } |
181 | |
182 | /*! \internal */ |
183 | QPickTriangleEvent::~QPickTriangleEvent() |
184 | { |
185 | } |
186 | |
187 | /*! |
188 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::triangleIndex |
189 | Specifies the triangle index of the event |
190 | */ |
191 | /*! |
192 | \property Qt3DRender::QPickTriangleEvent::triangleIndex |
193 | Specifies the triangle index of the event |
194 | */ |
195 | /*! |
196 | * \brief QPickTriangleEvent::triangleIndex |
197 | * Returns the index of the picked triangle |
198 | */ |
199 | uint QPickTriangleEvent::triangleIndex() const |
200 | { |
201 | Q_D(const QPickTriangleEvent); |
202 | return d->m_triangleIndex; |
203 | } |
204 | |
205 | /*! |
206 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::vertex1Index |
207 | Specifies the index of the first vertex in the triangle |
208 | */ |
209 | /*! |
210 | \property Qt3DRender::QPickTriangleEvent::vertex1Index |
211 | Specifies the index of the first vertex in the triangle |
212 | */ |
213 | /*! |
214 | * \brief QPickTriangleEvent::vertex1Index |
215 | * Returns the index of the first point of the picked triangle |
216 | */ |
217 | uint QPickTriangleEvent::vertex1Index() const |
218 | { |
219 | Q_D(const QPickTriangleEvent); |
220 | return d->m_vertex1Index; |
221 | } |
222 | |
223 | /*! |
224 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::vertex2Index |
225 | Specifies the index of the second vertex in the triangle |
226 | */ |
227 | /*! |
228 | \property Qt3DRender::QPickTriangleEvent::vertex2Index |
229 | Specifies the index of the second vertex in the triangle |
230 | */ |
231 | /*! |
232 | * \brief QPickTriangleEvent::vertex2Index |
233 | * Returns the index of the second point of the picked triangle |
234 | */ |
235 | uint QPickTriangleEvent::vertex2Index() const |
236 | { |
237 | Q_D(const QPickTriangleEvent); |
238 | return d->m_vertex2Index; |
239 | } |
240 | |
241 | /*! |
242 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::vertex3Index |
243 | Specifies the index of the third vertex in the triangle |
244 | */ |
245 | /*! |
246 | \property Qt3DRender::QPickTriangleEvent::vertex3Index |
247 | Specifies the index of the third vertex in the triangle |
248 | */ |
249 | /*! |
250 | * \brief QPickTriangleEvent::vertex3Index |
251 | * Returns index of third point of picked triangle |
252 | */ |
253 | uint QPickTriangleEvent::vertex3Index() const |
254 | { |
255 | Q_D(const QPickTriangleEvent); |
256 | return d->m_vertex3Index; |
257 | } |
258 | |
259 | /*! |
260 | \property Qt3DRender::QPickTriangleEvent::uvw |
261 | |
262 | */ |
263 | /*! |
264 | Returns the 3D coordinates u,v, and w. |
265 | */ |
266 | QVector3D QPickTriangleEvent::uvw() const |
267 | { |
268 | Q_D(const QPickTriangleEvent); |
269 | return d->m_uvw; |
270 | } |
271 | |
272 | } // Qt3DRender |
273 | |
274 | QT_END_NAMESPACE |
275 | |
276 | |