Plasma Engine  2.0
Loading...
Searching...
No Matches
EngineViewWidget.moc.h
1#pragma once
2
3#include <Core/Graphics/Camera.h>
4#include <EditorEngineProcessFramework/EngineProcess/ViewRenderSettings.h>
5#include <EditorFramework/EditorFrameworkDLL.h>
6#include <EditorFramework/IPC/EngineProcessConnection.h>
7#include <Foundation/Containers/HybridArray.h>
8#include <Foundation/Math/Size.h>
9#include <QWidget>
10
13class QHBoxLayout;
14class QPushButton;
15class QVBoxLayout;
17
18struct PL_EDITORFRAMEWORK_DLL plObjectPickingResult
19{
20 plObjectPickingResult() { Reset(); }
21 void Reset();
22
23 plUuid m_PickedObject;
24 plUuid m_PickedComponent;
25 plUuid m_PickedOther;
26 plUInt32 m_uiPartIndex;
27 plVec3 m_vPickedPosition;
28 plVec3 m_vPickedNormal;
29 plVec3 m_vPickingRayStart;
30};
31
33class PL_EDITORFRAMEWORK_DLL plQtEngineViewWidget : public QWidget
34{
35 Q_OBJECT
36
37public:
38 plQtEngineViewWidget(QWidget* pParent, plQtEngineDocumentWindow* pDocumentWindow, plEngineViewConfig* pViewConfig);
40
43
45 plUInt32 GetViewID() const { return m_uiViewID; }
46 plQtEngineDocumentWindow* GetDocumentWindow() const { return m_pDocumentWindow; }
47
49 virtual void SyncToEngine();
50
51 void GetCameraMatrices(plMat4& out_mViewMatrix, plMat4& out_mProjectionMatrix) const;
52
53 plEngineViewConfig* m_pViewConfig;
54
56 void UpdateCameraInterpolation();
57
59 void InterpolateCameraTo(
60 const plVec3& vPosition, const plVec3& vDirection, float fFovOrDim, const plVec3* pNewUpDirection = nullptr, bool bImmediate = false);
61
66 void SetEnablePicking(bool bEnable);
67
68 void SetPickTransparent(bool bEnable);
69
71 virtual bool IsPickingAgainstSelectionAllowed() const { return !m_bInDragAndDropOperation; }
72
75 {
76 plQtEngineViewWidget* m_pLastHoveredViewWidget = nullptr;
77 const plObjectPickingResult* m_pLastPickingResult = nullptr;
78 };
79
81 static const InteractionContext& GetInteractionContext() { return s_InteractionContext; }
82
84 static void SetInteractionContext(const InteractionContext& ctxt) { s_InteractionContext = ctxt; }
85
87 void OpenContextMenu(QPoint globalPos);
88
90 const plObjectPickingResult& PickObject(plUInt16 uiScreenPosX, plUInt16 uiScreenPosY) const;
91
93 plResult PickPlane(plUInt16 uiScreenPosX, plUInt16 uiScreenPosY, const plPlane& plane, plVec3& out_vPosition) const;
94
96 void HandleViewMessage(const plEditorEngineViewMsg* pMsg);
97
100 virtual plPlane GetFallbackPickingPlane(plVec3 vPointOnPlane = plVec3(0)) const;
101
105
106 void TakeScreenshot(const char* szOutputPath) const;
107
108protected:
110 virtual bool eventFilter(QObject* object, QEvent* event) override;
111
112 virtual void paintEvent(QPaintEvent* event) override;
113 virtual QPaintEngine* paintEngine() const override { return nullptr; }
114
115 virtual void resizeEvent(QResizeEvent* event) override;
116
117 virtual void keyPressEvent(QKeyEvent* e) override;
118 virtual void keyReleaseEvent(QKeyEvent* e) override;
119 virtual void mousePressEvent(QMouseEvent* e) override;
120 virtual void mouseReleaseEvent(QMouseEvent* e) override;
121 virtual void mouseMoveEvent(QMouseEvent* e) override;
122 virtual void wheelEvent(QWheelEvent* e) override;
123 virtual void focusOutEvent(QFocusEvent* e) override;
124 virtual void dragEnterEvent(QDragEnterEvent* e) override;
125 virtual void dragLeaveEvent(QDragLeaveEvent* e) override;
126 virtual void dropEvent(QDropEvent* e) override;
127
128protected:
129 void EngineViewProcessEventHandler(const plEditorEngineProcessConnection::Event& e);
130 void ShowRestartButton(bool bShow);
131 virtual void OnOpenContextMenu(QPoint globalPos) {}
132 virtual void HandleMarqueePickingResult(const plViewMarqueePickingResultMsgToEditor* pMsg) {}
133
134private Q_SLOTS:
135 void SlotRestartEngineProcess();
136
137protected:
138 bool m_bUpdatePickingData;
139 bool m_bPickTransparent = true;
140 bool m_bInDragAndDropOperation;
141 plUInt32 m_uiViewID;
142 plQtEngineDocumentWindow* m_pDocumentWindow;
143
144 static plUInt32 s_uiNextViewID;
145
146 // Camera Interpolation
147 float m_fCameraLerp;
148 float m_fCameraStartFovOrDim;
149 float m_fCameraTargetFovOrDim;
150 plVec3 m_vCameraStartPosition;
151 plVec3 m_vCameraTargetPosition;
152 plVec3 m_vCameraStartDirection;
153 plVec3 m_vCameraTargetDirection;
154 plVec3 m_vCameraUp;
155 plTime m_LastCameraUpdate;
156
157 QHBoxLayout* m_pRestartButtonLayout;
158 QPushButton* m_pRestartButton;
159
160 mutable plObjectPickingResult m_LastPickingResult;
161
162 static InteractionContext s_InteractionContext;
163};
164
166class PL_EDITORFRAMEWORK_DLL plQtViewWidgetContainer : public QWidget
167{
168 Q_OBJECT
169
170public:
171 plQtViewWidgetContainer(QWidget* pParent, plQtEngineViewWidget* pViewWidget, const char* szToolBarMapping);
173
174 plQtEngineViewWidget* GetViewWidget() const { return m_pViewWidget; }
175 QVBoxLayout* GetLayout() const { return m_pLayout; }
176
177private:
178 plQtEngineViewWidget* m_pViewWidget;
179 QVBoxLayout* m_pLayout;
180};
181
Definition EngineProcessMessages.h:196
Definition EditorInputContext.h:22
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Base class for all document windows that need a connection to the engine process, and might want to r...
Definition EngineDocumentWindow.moc.h:37
Base class for views that show engine output.
Definition EngineViewWidget.moc.h:34
plUInt32 GetViewID() const
Returns the ID of this view.
Definition EngineViewWidget.moc.h:45
static const InteractionContext & GetInteractionContext()
Returns the latest information about what viewport the user interacted with.
Definition EngineViewWidget.moc.h:81
static void SetInteractionContext(const InteractionContext &ctxt)
Overrides the InteractionContext with custom values. Mostly useful for injecting procedural user inte...
Definition EngineViewWidget.moc.h:84
plHybridArray< plEditorInputContext *, 8 > m_InputContexts
Add input contexts in the order in which they are supposed to be processed.
Definition EngineViewWidget.moc.h:42
static plSizeU32 s_FixedResolution
Definition EngineViewWidget.moc.h:104
virtual bool IsPickingAgainstSelectionAllowed() const
Disabled during drag&drop operations, to prevent picking against the dragged object.
Definition EngineViewWidget.moc.h:71
Wraps and decorates a view widget with a toolbar and layout.
Definition EngineViewWidget.moc.h:167
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
Definition EngineProcessMessages.h:388
Definition EngineProcessConnection.h:63
Definition ViewRenderSettings.h:26
Definition EngineViewWidget.moc.h:19
Holds information about the viewport that the user just now hovered over and what object was picked l...
Definition EngineViewWidget.moc.h:75
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12