PrimeWorldEditor/src/Editor/CSceneViewport.h

109 lines
3.2 KiB
C
Raw Normal View History

#ifndef CSCENEVIEWPORT_H
#define CSCENEVIEWPORT_H
#include "CBasicViewport.h"
#include "CGridRenderable.h"
#include "CLineRenderable.h"
#include "INodeEditor.h"
class CSceneViewport : public CBasicViewport
{
Q_OBJECT
INodeEditor *mpEditor = nullptr;
CScene *mpScene = nullptr;
std::unique_ptr<CRenderer> mpRenderer;
bool mRenderingMergedWorld = true;
// Scene interaction
bool mGizmoHovering = false;
bool mGizmoTransforming = false;
SRayIntersection mRayIntersection;
CSceneNode *mpHoverNode = nullptr;
CVector3f mHoverPoint{CVector3f::Zero()};
2016-01-05 14:54:16 +00:00
// Context Menu
QMenu *mpContextMenu = nullptr;
QAction *mpToggleSelectAction;
QAction *mpHideSelectionSeparator;
QAction *mpHideSelectionAction;
QAction *mpHideUnselectedAction;
QAction *mpHideHoverSeparator;
QAction *mpHideHoverNodeAction;
QAction *mpHideHoverTypeAction;
QAction *mpHideHoverLayerAction;
QAction *mpUnhideSeparator;
2016-01-05 14:54:16 +00:00
QAction *mpUnhideAllAction;
2019-04-06 22:53:05 +00:00
QAction *mpPlayFromHereSeparator;
QAction *mpPlayFromHereAction;
CSceneNode *mpMenuNode = nullptr;
2019-04-06 22:53:05 +00:00
CVector3f mMenuPoint;
2016-01-05 14:54:16 +00:00
QMenu *mpSelectConnectedMenu;
QAction *mpSelectConnectedOutgoingAction;
QAction *mpSelectConnectedIncomingAction;
QAction *mpSelectConnectedAllAction;
// Grid
CGridRenderable mGrid;
// Link Line
bool mLinkLineEnabled;
CLineRenderable mLinkLine;
public:
explicit CSceneViewport(QWidget *pParent = nullptr);
~CSceneViewport() override;
2016-01-06 10:19:06 +00:00
void SetScene(INodeEditor *pEditor, CScene *pScene);
void SetShowWorld(bool Visible);
2016-03-27 19:09:38 +00:00
void SetRenderMergedWorld(bool RenderMerged);
FShowFlags ShowFlags() const;
CRenderer* Renderer();
CSceneNode* HoverNode();
CVector3f HoverPoint();
2016-03-27 19:09:38 +00:00
void CheckGizmoInput(const CRay& rkRay);
SRayIntersection SceneRayCast(const CRay& rkRay);
void ResetHover();
bool IsHoveringGizmo();
void keyPressEvent(QKeyEvent* pEvent) override;
void keyReleaseEvent(QKeyEvent* pEvent) override;
void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB) { mLinkLine.SetPoints(rkPointA, rkPointB); }
2016-01-05 14:54:16 +00:00
protected:
void CreateContextMenu();
QMouseEvent CreateMouseEvent();
void FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList<uint32>& rIDList);
2016-01-05 14:54:16 +00:00
signals:
void InputProcessed(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
void ViewportClick(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
void GizmoMoved();
2015-11-27 21:18:22 +00:00
void CameraOrbit();
protected slots:
void CheckUserInput() override;
void Paint() override;
void ContextMenu(QContextMenuEvent *pEvent) override;
void OnResize() override;
void OnMouseClick(QMouseEvent *pEvent) override;
void OnMouseRelease(QMouseEvent *pEvent) override;
2016-01-05 14:54:16 +00:00
// Menu Actions
void OnToggleSelect();
void OnSelectConnected();
void OnHideSelection();
void OnHideUnselected();
2016-01-05 14:54:16 +00:00
void OnHideNode();
void OnHideType();
void OnHideLayer();
void OnUnhideAll();
2019-04-06 22:53:05 +00:00
void OnPlayFromHere();
2016-01-05 14:54:16 +00:00
void OnContextMenuClose();
};
#endif // CSCENEVIEWPORT_H