1// Copyright (C) 2018 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#ifndef QT3DRENDER_RENDER_ABSTRACTPICKINGJOB_P_H
5#define QT3DRENDER_RENDER_ABSTRACTPICKINGJOB_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <Qt3DCore/qaspectjob.h>
19#include <Qt3DRender/private/qray3d_p.h>
20#include <Qt3DRender/private/handle_types_p.h>
21#include <Qt3DRender/private/qboundingvolumeprovider_p.h>
22#include <Qt3DRender/private/qcollisionqueryresult_p.h>
23#include <Qt3DRender/private/pickboundingvolumeutils_p.h>
24#include <Qt3DRender/private/qt3drender_global_p.h>
25
26QT_BEGIN_NAMESPACE
27
28namespace Qt3DCore {
29class QNodeId;
30}
31
32namespace Qt3DRender {
33namespace Render {
34
35class Entity;
36class Renderer;
37class NodeManagers;
38class RenderSettings;
39
40class Q_3DRENDERSHARED_PRIVATE_EXPORT AbstractPickingJob : public Qt3DCore::QAspectJob
41{
42public:
43 AbstractPickingJob();
44
45 void setRoot(Entity *root);
46 void setFrameGraphRoot(FrameGraphNode *frameGraphRoot);
47 void setRenderSettings(RenderSettings *settings);
48 void setManagers(NodeManagers *manager);
49
50 // public for unit tests
51 virtual bool runHelper() = 0;
52 static RayCasting::QRay3D intersectionRay(const QPoint &pos,
53 const Matrix4x4 &viewMatrix,
54 const Matrix4x4 &projectionMatrix,
55 const QRect &viewport);
56
57protected:
58 AbstractPickingJob(Qt3DCore::QAspectJobPrivate &dd);
59
60 void run() final;
61
62 NodeManagers *m_manager;
63 Entity *m_node;
64 FrameGraphNode *m_frameGraphRoot;
65 RenderSettings *m_renderSettings;
66
67 bool m_oneEnabledAtLeast;
68
69 QRect windowViewport(const QSize &area, const QRectF &relativeViewport) const;
70 RayCasting::QRay3D rayForViewportAndCamera(const PickingUtils::ViewportCameraAreaDetails &vca,
71 QObject *eventSource,
72 const QPoint &pos) const;
73};
74
75} // namespace Render
76
77} // namespace Qt3DRender
78
79QT_END_NAMESPACE
80
81#endif // QT3DRENDER_RENDER_ABSTRACTPICKINGJOB_P_H
82

source code of qt3d/src/render/jobs/abstractpickingjob_p.h