ViewManager.h 4.1 KB

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