ViewManager.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 <AzCore/Math/Aabb.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. /** Manages set of viewports.
  23. */
  24. class SANDBOX_API CViewManager
  25. : public IEditorNotifyListener
  26. {
  27. public:
  28. static bool IsMultiViewportEnabled();
  29. void ReleaseView(CViewport* pViewport);
  30. CViewport* GetViewport(EViewportType type) const;
  31. CViewport* GetViewport(const QString& name) const;
  32. //! Find viewport at Screen point.
  33. CViewport* GetViewportAtPoint(const QPoint& point) const;
  34. //! Retrieves the position in world space corresponding to the point clicked by the user.
  35. //! Will take context menus and cursor position into account as appropriate.
  36. AZ::Vector3 GetClickPositionInViewportSpace() const;
  37. void SelectViewport(CViewport* pViewport);
  38. CViewport* GetSelectedViewport() const { return m_pSelectedView; }
  39. void SetAxisConstrain(int axis);
  40. void SetZoomFactor(float zoom);
  41. float GetZoomFactor() const { return m_zoomFactor; }
  42. //! Reset all views.
  43. void ResetViews();
  44. //! Update all views.
  45. void UpdateViews(int flags = 0xFFFFFFFF);
  46. void SetUpdateRegion(const AZ::Aabb& updateRegion) { m_updateRegion = updateRegion; };
  47. const AZ::Aabb& GetUpdateRegion() { return m_updateRegion; };
  48. /** Get 2D viewports origin.
  49. */
  50. Vec3 GetOrigin2D() const { return m_origin2D; }
  51. /** Assign 2D viewports origin.
  52. */
  53. void SetOrigin2D(const Vec3& org) { m_origin2D = org; };
  54. /** Assign zoom factor for 2d viewports.
  55. */
  56. void SetZoom2D(float zoom);
  57. /** Get zoom factor of 2d viewports.
  58. */
  59. float GetZoom2D() const { return m_zoom2D; };
  60. //////////////////////////////////////////////////////////////////////////
  61. //! Get number of currently existing viewports.
  62. virtual int GetViewCount() { return static_cast<int>(m_viewports.size()); };
  63. //! Get viewport by index.
  64. //! @param index 0 <= index < GetViewportCount()
  65. virtual CViewport* GetView(int index) { return m_viewports[index]; }
  66. //////////////////////////////////////////////////////////////////////////
  67. //! Get current layout window.
  68. //! @return Pointer to the layout window, can be nullptr.
  69. virtual CLayoutWnd* GetLayout() const;
  70. //! Cycle between different 2D viewports type on same view pane.
  71. virtual void Cycle2DViewport();
  72. //////////////////////////////////////////////////////////////////////////
  73. // Retrieve main game viewport, where the full game is rendered in 3D.
  74. CViewport* GetGameViewport() const;
  75. //! Get number of Game Viewports
  76. int GetNumberOfGameViewports();
  77. virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
  78. AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> GetManipulatorManager();
  79. private:
  80. friend class CEditorImpl;
  81. friend class QtViewport;
  82. void IdleUpdate();
  83. void RegisterViewport(CViewport* vp);
  84. void UnregisterViewport(CViewport* vp);
  85. private:
  86. CViewManager();
  87. ~CViewManager();
  88. //////////////////////////////////////////////////////////////////////////
  89. //FIELDS.
  90. float m_zoomFactor;
  91. AZ::Aabb m_updateRegion;
  92. //! Origin of 2d viewports.
  93. Vec3 m_origin2D;
  94. //! Zoom of 2d viewports.
  95. float m_zoom2D;
  96. int m_nGameViewports;
  97. bool m_bGameViewportsUpdated;
  98. //! Array of currently existing viewports.
  99. std::vector<CViewport*> m_viewports;
  100. CViewport* m_pSelectedView;
  101. AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> m_manipulatorManager;
  102. };
  103. #endif // CRYINCLUDE_EDITOR_VIEWMANAGER_H