diff options
author | Paul Lemire <paul.lemire350@gmail.com> | 2015-10-14 17:49:29 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-10-24 14:05:08 +0000 |
commit | 39bab5ec63e8e11c44b97a8d693df108f16892fa (patch) | |
tree | 53753f743244a7b8c54d02ac37677b5be5e2e0a5 /src | |
parent | 4ac51657adb824819ad825a924ccb9836e0a2f43 (diff) |
PickEventFilter
Will take care of storing MouseEvents that will then be used by the renderer
for picking
Change-Id: I4d87f8a14975b7fb58484b8847bf07759b1262e0
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/backend/pickeventfilter.cpp | 81 | ||||
-rw-r--r-- | src/render/backend/pickeventfilter_p.h | 82 | ||||
-rw-r--r-- | src/render/backend/render-backend.pri | 6 |
3 files changed, 167 insertions, 2 deletions
diff --git a/src/render/backend/pickeventfilter.cpp b/src/render/backend/pickeventfilter.cpp new file mode 100644 index 000000000..deaa83d3d --- /dev/null +++ b/src/render/backend/pickeventfilter.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Paul Lemire paul.lemire350@gmail.com +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pickeventfilter_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +PickEventFilter::PickEventFilter(QObject *parent) + : QObject(parent) +{ +} + +PickEventFilter::~PickEventFilter() +{ +} + +// main thread (aspect->jobsToExecute) +QList<QMouseEvent> PickEventFilter::pendingEvents() +{ + QList<QMouseEvent> cpy(m_pendingEvents); + m_pendingEvents.clear(); + return cpy; +} + +// main thread +bool PickEventFilter::eventFilter(QObject *obj, QEvent *e) +{ + switch (e->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + m_pendingEvents.push_back(QMouseEvent(*static_cast<QMouseEvent *>(e))); + break; + default: + break; + } + return QObject::eventFilter(obj, e); +} + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/backend/pickeventfilter_p.h b/src/render/backend/pickeventfilter_p.h new file mode 100644 index 000000000..1c814dc88 --- /dev/null +++ b/src/render/backend/pickeventfilter_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Paul Lemire paul.lemire350@gmail.com +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DRENDER_RENDER_PICKEVENTFILTER_H +#define QT3DRENDER_RENDER_PICKEVENTFILTER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QObject> +#include <QMouseEvent> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +class PickEventFilter : public QObject +{ + Q_OBJECT +public: + explicit PickEventFilter(QObject *parent = Q_NULLPTR); + ~PickEventFilter(); + + QList<QMouseEvent> pendingEvents(); + +protected: + bool eventFilter(QObject *obj, QEvent *e) Q_DECL_FINAL; + +private: + QList<QMouseEvent> m_pendingEvents; +}; + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_PICKEVENTFILTER_H diff --git a/src/render/backend/render-backend.pri b/src/render/backend/render-backend.pri index 8066aa006..a2d0e8395 100644 --- a/src/render/backend/render-backend.pri +++ b/src/render/backend/render-backend.pri @@ -22,7 +22,8 @@ HEADERS += \ $$PWD/layer_p.h \ $$PWD/nodefunctor_p.h \ $$PWD/transform_p.h \ - $$PWD/objectpicker_p.h + $$PWD/objectpicker_p.h \ + $$PWD/pickeventfilter_p.h SOURCES += \ $$PWD/renderthread.cpp \ @@ -41,4 +42,5 @@ SOURCES += \ $$PWD/entity.cpp \ $$PWD/layer.cpp \ $$PWD/transform.cpp \ - $$PWD/objectpicker.cpp + $$PWD/objectpicker.cpp \ + $$PWD/pickeventfilter.cpp |