WhiteBoxPolygonTranslationModifier.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #pragma once
  9. #include "Viewport/WhiteBoxManipulatorBounds.h"
  10. #include "Viewport/WhiteBoxViewportConstants.h"
  11. #include <AzCore/Component/ComponentBus.h>
  12. #include <AzToolsFramework/Viewport/ViewportTypes.h>
  13. #include <WhiteBox/WhiteBoxToolApi.h>
  14. namespace AzToolsFramework
  15. {
  16. class LinearManipulator;
  17. }
  18. namespace WhiteBox
  19. {
  20. class ManipulatorViewPolygon;
  21. //! Provides manipulators for translating a polygon on a white box mesh.
  22. class PolygonTranslationModifier
  23. {
  24. public:
  25. AZ_CLASS_ALLOCATOR_DECL
  26. using HandleType = Api::PolygonHandle;
  27. PolygonTranslationModifier(
  28. const AZ::EntityComponentIdPair& entityComponentIdPair, const Api::PolygonHandle& polygonHandle,
  29. const AZ::Vector3& intersectionPoint);
  30. ~PolygonTranslationModifier();
  31. bool MouseOver() const;
  32. void ForwardMouseOverEvent(const AzToolsFramework::ViewportInteraction::MouseInteraction& interaction);
  33. Api::PolygonHandle GetHandle() const; // Generic context version
  34. Api::PolygonHandle GetPolygonHandle() const;
  35. void SetPolygonHandle(const Api::PolygonHandle& polygonHandle);
  36. void SetColors(const AZ::Color& fillColor, const AZ::Color& outlineColor);
  37. void Refresh();
  38. void CreateView();
  39. bool PerformingAction() const;
  40. private:
  41. void CreateManipulator();
  42. void DestroyManipulator();
  43. AZ::EntityComponentIdPair
  44. m_entityComponentIdPair; //!< The entity and component id this modifier is associated with.
  45. AZStd::shared_ptr<AzToolsFramework::LinearManipulator>
  46. m_translationManipulator; //!< The manipulator used to modify the position of the polygon (triangles).
  47. AZStd::vector<Api::VertexHandle> m_vertexHandles; //!< The vertex handles associated with this polygon.
  48. Api::PolygonHandle m_polygonHandle; //!< The polygon handle this modifier is associated with.
  49. AZStd::shared_ptr<ManipulatorViewPolygon>
  50. m_polygonView; //!< Manipulator view used to represent a mesh polygon for translation.
  51. AZ::Color m_fillColor =
  52. ed_whiteBoxPolygonHover; //!< The color to use for the highlighted filled section of the polygon.
  53. AZ::Color m_outlineColor =
  54. ed_whiteBoxOutlineHover; //!< The color to use for the outline of the polygon.
  55. };
  56. inline Api::PolygonHandle PolygonTranslationModifier::GetHandle() const
  57. {
  58. return GetPolygonHandle();
  59. }
  60. inline Api::PolygonHandle PolygonTranslationModifier::GetPolygonHandle() const
  61. {
  62. return m_polygonHandle;
  63. }
  64. inline void PolygonTranslationModifier::SetColors(const AZ::Color& fillColor, const AZ::Color& outlineColor)
  65. {
  66. m_fillColor = fillColor;
  67. m_outlineColor = outlineColor;
  68. }
  69. } // namespace WhiteBox