ViewManager.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : interface for the CViewManager class.
  9. #ifndef CRYINCLUDE_EDITOR_VIEWMANAGER_H
  10. #define CRYINCLUDE_EDITOR_VIEWMANAGER_H
  11. #pragma once
  12. #include "Cry_Geo.h"
  13. #include "Viewport.h"
  14. #include "QtViewPaneManager.h"
  15. // forward declaration.
  16. class CLayoutWnd;
  17. class CViewport;
  18. namespace AzToolsFramework
  19. {
  20. class ManipulatorManager;
  21. }
  22. AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  23. /** Manages set of viewports.
  24. */
  25. class SANDBOX_API CViewManager
  26. : public IEditorNotifyListener
  27. {
  28. AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  29. public:
  30. static bool IsMultiViewportEnabled();
  31. void ReleaseView(CViewport* pViewport);
  32. CViewport* GetViewport(EViewportType type) const;
  33. CViewport* GetViewport(const QString& name) const;
  34. //! Find viewport at Screen point.
  35. CViewport* GetViewportAtPoint(const QPoint& point) const;
  36. void SelectViewport(CViewport* pViewport);
  37. CViewport* GetSelectedViewport() const { return m_pSelectedView; }
  38. void SetAxisConstrain(int axis);
  39. void SetZoomFactor(float zoom);
  40. float GetZoomFactor() const { return m_zoomFactor; }
  41. //! Reset all views.
  42. void ResetViews();
  43. //! Update all views.
  44. void UpdateViews(int flags = 0xFFFFFFFF);
  45. void SetUpdateRegion(const AABB& updateRegion) { m_updateRegion = updateRegion; };
  46. const AABB& GetUpdateRegion() { return m_updateRegion; };
  47. /** Get 2D viewports origin.
  48. */
  49. Vec3 GetOrigin2D() const { return m_origin2D; }
  50. /** Assign 2D viewports origin.
  51. */
  52. void SetOrigin2D(const Vec3& org) { m_origin2D = org; };
  53. /** Assign zoom factor for 2d viewports.
  54. */
  55. void SetZoom2D(float zoom);
  56. /** Get zoom factor of 2d viewports.
  57. */
  58. float GetZoom2D() const { return m_zoom2D; };
  59. //////////////////////////////////////////////////////////////////////////
  60. //! Get currently active camera object id.
  61. REFGUID GetCameraObjectId() const { return m_cameraObjectId; };
  62. //! Sets currently active camera object id.
  63. void SetCameraObjectId(REFGUID cameraObjectId) { m_cameraObjectId = cameraObjectId; };
  64. //////////////////////////////////////////////////////////////////////////
  65. //! Get number of currently existing viewports.
  66. virtual int GetViewCount() { return static_cast<int>(m_viewports.size()); };
  67. //! Get viewport by index.
  68. //! @param index 0 <= index < GetViewportCount()
  69. virtual CViewport* GetView(int index) { return m_viewports[index]; }
  70. //////////////////////////////////////////////////////////////////////////
  71. //! Get current layout window.
  72. //! @return Pointer to the layout window, can be nullptr.
  73. virtual CLayoutWnd* GetLayout() const;
  74. //! Cycle between different 2D viewports type on same view pane.
  75. virtual void Cycle2DViewport();
  76. //////////////////////////////////////////////////////////////////////////
  77. // Retrieve main game viewport, where the full game is rendered in 3D.
  78. CViewport* GetGameViewport() const;
  79. //! Get number of Game Viewports
  80. int GetNumberOfGameViewports();
  81. virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
  82. AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> GetManipulatorManager();
  83. private:
  84. friend class CEditorImpl;
  85. friend class QtViewport;
  86. void IdleUpdate();
  87. void RegisterViewport(CViewport* vp);
  88. void UnregisterViewport(CViewport* vp);
  89. private:
  90. CViewManager();
  91. ~CViewManager();
  92. //////////////////////////////////////////////////////////////////////////
  93. //FIELDS.
  94. float m_zoomFactor;
  95. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  96. AABB m_updateRegion;
  97. //! Origin of 2d viewports.
  98. Vec3 m_origin2D;
  99. //! Zoom of 2d viewports.
  100. float m_zoom2D;
  101. //! Id of camera object.
  102. GUID m_cameraObjectId;
  103. int m_nGameViewports;
  104. bool m_bGameViewportsUpdated;
  105. //! Array of currently existing viewports.
  106. std::vector<CViewport*> m_viewports;
  107. CViewport* m_pSelectedView;
  108. AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> m_manipulatorManager;
  109. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  110. };
  111. #endif // CRYINCLUDE_EDITOR_VIEWMANAGER_H