1// Copyright (C) 2015 Paul Lemire paul.lemire350@gmail.com
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 "pickeventfilter_p.h"
5#include <Qt3DRender/private/qrenderaspect_p.h>
6
7#include <QtGui/QHoverEvent>
8
9QT_BEGIN_NAMESPACE
10
11namespace Qt3DRender {
12
13namespace Render {
14
15PickEventFilter::PickEventFilter(QRenderAspectPrivate *aspect, QObject *parent)
16 : QObject(parent)
17 , m_aspect(aspect)
18{
19}
20
21PickEventFilter::~PickEventFilter()
22{
23}
24
25/*!
26 \internal
27 Called from the main thread.
28*/
29bool PickEventFilter::eventFilter(QObject *obj, QEvent *e)
30{
31 switch (e->type()) {
32 case QEvent::MouseButtonPress:
33 case QEvent::MouseButtonRelease:
34 case QEvent::MouseMove:
35 return m_aspect->processMouseEvent(obj, event: static_cast<QMouseEvent *>(e));
36 case QEvent::HoverMove: {
37 QHoverEvent *he = static_cast<QHoverEvent *>(e);
38 auto mouseEvent = QMouseEvent(QEvent::MouseMove,
39 he->position(),
40 he->globalPosition(),
41 Qt::NoButton, Qt::NoButton,
42 he->modifiers());
43 return m_aspect->processMouseEvent(obj, event: &mouseEvent);
44 }
45 case QEvent::KeyPress:
46 case QEvent::KeyRelease:
47 return m_aspect->processKeyEvent(obj, event: static_cast<QKeyEvent *>(e));
48 default:
49 break;
50 }
51
52 return false;
53}
54
55} // Render
56
57} // Qt3DRender
58
59QT_END_NAMESPACE
60
61#include "moc_pickeventfilter_p.cpp"
62

source code of qt3d/src/render/picking/pickeventfilter.cpp