1 | // Copyright (C) 2015 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 "qpicktriangleevent.h" |
5 | #include "qpicktriangleevent_p.h" |
6 | #include "qpickevent_p.h" |
7 | #include <private/qobject_p.h> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | namespace Qt3DRender { |
12 | |
13 | |
14 | Qt3DRender::QPickTriangleEventPrivate::QPickTriangleEventPrivate() |
15 | : QPickEventPrivate() |
16 | , m_triangleIndex(0) |
17 | , m_vertex1Index(0) |
18 | , m_vertex2Index(0) |
19 | , m_vertex3Index(0) |
20 | { |
21 | } |
22 | |
23 | const QPickTriangleEventPrivate *QPickTriangleEventPrivate::get(const QPickTriangleEvent *ev) |
24 | { |
25 | return ev->d_func(); |
26 | } |
27 | |
28 | QPickTriangleEvent *QPickTriangleEventPrivate::clone() const |
29 | { |
30 | auto res = new QPickTriangleEvent(); |
31 | res->d_func()->m_accepted = m_accepted; |
32 | res->d_func()->m_position = m_position; |
33 | res->d_func()->m_worldIntersection = m_worldIntersection; |
34 | res->d_func()->m_localIntersection = m_localIntersection; |
35 | res->d_func()->m_distance = m_distance; |
36 | res->d_func()->m_button = m_button; |
37 | res->d_func()->m_buttons = m_buttons; |
38 | res->d_func()->m_modifiers = m_modifiers; |
39 | res->d_func()->m_entity = m_entity; |
40 | res->d_func()->m_entityPtr = m_entityPtr; |
41 | res->d_func()->m_viewport = m_viewport; |
42 | res->d_func()->m_triangleIndex = m_triangleIndex; |
43 | res->d_func()->m_vertex1Index = m_vertex1Index; |
44 | res->d_func()->m_vertex2Index = m_vertex2Index; |
45 | res->d_func()->m_vertex3Index = m_vertex3Index; |
46 | return res; |
47 | } |
48 | |
49 | |
50 | /*! |
51 | \class Qt3DRender::QPickTriangleEvent |
52 | \inmodule Qt3DRender |
53 | |
54 | \brief The QPickTriangleEvent class holds information when a triangle is picked. |
55 | |
56 | When QPickingSettings::pickMode() is set to QPickingSettings::TrianglePicking, the signals |
57 | on QObjectPicker will carry an instance of QPickTriangleEvent. |
58 | |
59 | This contains the details of the triangle that was picked. |
60 | |
61 | \note In the case of indexed rendering, the point indices are relative to the |
62 | array of coordinates, not the array of indices. |
63 | |
64 | \sa QPickingSettings, QPickEvent, QObjectPicker |
65 | \since 5.7 |
66 | */ |
67 | |
68 | /*! |
69 | * \qmltype PickTriangleEvent |
70 | * \instantiates Qt3DRender::QPickTriangleEvent |
71 | * \inqmlmodule Qt3D.Render |
72 | * \brief PickTriangleEvent holds information when a triangle is picked. |
73 | * |
74 | * When QPickingSettings::pickMode() is set to QPickingSettings::TrianglePicking, the signals |
75 | * on QObjectPicker will carry an instance of QPickTriangleEvent. |
76 | * |
77 | * This contains the details of the triangle that was picked. |
78 | * |
79 | * \note In case of indexed rendering, the point indices are relative to the |
80 | * array of indices, not the array of coordinates. |
81 | * |
82 | * \sa PickingSettings, PickEvent, ObjectPicker, Attribute |
83 | */ |
84 | |
85 | |
86 | /*! |
87 | \fn Qt3DRender::QPickTriangleEvent::QPickTriangleEvent() |
88 | Constructs a new QPickEvent. |
89 | */ |
90 | QPickTriangleEvent::QPickTriangleEvent() |
91 | : QPickEvent(*new QPickTriangleEventPrivate()) |
92 | { |
93 | } |
94 | |
95 | /*! |
96 | * \brief QPickTriangleEvent::QPickTriangleEvent Constructs a new QPickEvent with the given parameters |
97 | * \a position, |
98 | * \a worldIntersection, |
99 | * \a localIntersection, |
100 | * \a distance, |
101 | * \a triangleIndex, |
102 | * \a vertex1Index, |
103 | * \a vertex2Index and |
104 | * \a vertex3Index |
105 | |
106 | //! NOTE: remove in Qt6 |
107 | */ |
108 | QPickTriangleEvent::QPickTriangleEvent(const QPointF &position, const QVector3D &worldIntersection, const QVector3D &localIntersection, float distance, |
109 | uint triangleIndex, uint vertex1Index, uint vertex2Index, |
110 | uint vertex3Index) |
111 | : QPickEvent(*new QPickTriangleEventPrivate()) |
112 | { |
113 | Q_D(QPickTriangleEvent); |
114 | d->m_position = position; |
115 | d->m_distance = distance; |
116 | d->m_worldIntersection = worldIntersection; |
117 | d->m_localIntersection = localIntersection; |
118 | d->m_triangleIndex = triangleIndex; |
119 | d->m_vertex1Index = vertex1Index; |
120 | d->m_vertex2Index = vertex2Index; |
121 | d->m_vertex3Index = vertex3Index; |
122 | } |
123 | |
124 | QPickTriangleEvent::QPickTriangleEvent(const QPointF &position, const QVector3D &worldIntersection, |
125 | const QVector3D &localIntersection, float distance, |
126 | uint triangleIndex, uint vertex1Index, uint vertex2Index, |
127 | uint vertex3Index, QPickEvent::Buttons button, int buttons, |
128 | int modifiers, const QVector3D &uvw) |
129 | : QPickEvent(*new QPickTriangleEventPrivate()) |
130 | { |
131 | Q_D(QPickTriangleEvent); |
132 | d->m_position = position; |
133 | d->m_distance = distance; |
134 | d->m_worldIntersection = worldIntersection; |
135 | d->m_localIntersection = localIntersection; |
136 | d->m_triangleIndex = triangleIndex; |
137 | d->m_vertex1Index = vertex1Index; |
138 | d->m_vertex2Index = vertex2Index; |
139 | d->m_vertex3Index = vertex3Index; |
140 | d->m_button = button; |
141 | d->m_buttons = buttons; |
142 | d->m_modifiers = modifiers; |
143 | d->m_uvw = uvw; |
144 | } |
145 | |
146 | /*! \internal */ |
147 | QPickTriangleEvent::~QPickTriangleEvent() |
148 | { |
149 | } |
150 | |
151 | /*! |
152 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::triangleIndex |
153 | Specifies the triangle index of the event |
154 | */ |
155 | /*! |
156 | \property Qt3DRender::QPickTriangleEvent::triangleIndex |
157 | Specifies the triangle index of the event |
158 | */ |
159 | /*! |
160 | * \brief QPickTriangleEvent::triangleIndex |
161 | * Returns the index of the picked triangle |
162 | */ |
163 | uint QPickTriangleEvent::triangleIndex() const |
164 | { |
165 | Q_D(const QPickTriangleEvent); |
166 | return d->m_triangleIndex; |
167 | } |
168 | |
169 | /*! |
170 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::vertex1Index |
171 | Specifies the index of the first vertex in the triangle |
172 | */ |
173 | /*! |
174 | \property Qt3DRender::QPickTriangleEvent::vertex1Index |
175 | Specifies the index of the first vertex in the triangle |
176 | */ |
177 | /*! |
178 | * \brief QPickTriangleEvent::vertex1Index |
179 | * Returns the index of the first point of the picked triangle |
180 | */ |
181 | uint QPickTriangleEvent::vertex1Index() const |
182 | { |
183 | Q_D(const QPickTriangleEvent); |
184 | return d->m_vertex1Index; |
185 | } |
186 | |
187 | /*! |
188 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::vertex2Index |
189 | Specifies the index of the second vertex in the triangle |
190 | */ |
191 | /*! |
192 | \property Qt3DRender::QPickTriangleEvent::vertex2Index |
193 | Specifies the index of the second vertex in the triangle |
194 | */ |
195 | /*! |
196 | * \brief QPickTriangleEvent::vertex2Index |
197 | * Returns the index of the second point of the picked triangle |
198 | */ |
199 | uint QPickTriangleEvent::vertex2Index() const |
200 | { |
201 | Q_D(const QPickTriangleEvent); |
202 | return d->m_vertex2Index; |
203 | } |
204 | |
205 | /*! |
206 | \qmlproperty uint Qt3D.Render::PickTriangleEvent::vertex3Index |
207 | Specifies the index of the third vertex in the triangle |
208 | */ |
209 | /*! |
210 | \property Qt3DRender::QPickTriangleEvent::vertex3Index |
211 | Specifies the index of the third vertex in the triangle |
212 | */ |
213 | /*! |
214 | * \brief QPickTriangleEvent::vertex3Index |
215 | * Returns index of third point of picked triangle |
216 | */ |
217 | uint QPickTriangleEvent::vertex3Index() const |
218 | { |
219 | Q_D(const QPickTriangleEvent); |
220 | return d->m_vertex3Index; |
221 | } |
222 | |
223 | /*! |
224 | \property Qt3DRender::QPickTriangleEvent::uvw |
225 | |
226 | */ |
227 | /*! |
228 | Returns the 3D coordinates u,v, and w. |
229 | */ |
230 | QVector3D QPickTriangleEvent::uvw() const |
231 | { |
232 | Q_D(const QPickTriangleEvent); |
233 | return d->m_uvw; |
234 | } |
235 | |
236 | } // Qt3DRender |
237 | |
238 | QT_END_NAMESPACE |
239 | |
240 | #include "moc_qpicktriangleevent.cpp" |
241 | |
242 | |