ROS2FrameConfiguration.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include <AzCore/Serialization/EditContext.h>
  9. #include <AzCore/Serialization/EditContextConstants.inl>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <ROS2/Frame/NamespaceConfiguration.h>
  12. #include <ROS2/Frame/ROS2FrameConfiguration.h>
  13. #include <ROS2/ROS2GemUtilities.h>
  14. #include <ROS2/Utilities/ROS2Names.h>
  15. namespace ROS2
  16. {
  17. void ROS2FrameConfiguration::Reflect(AZ::ReflectContext* context)
  18. {
  19. NamespaceConfiguration::Reflect(context);
  20. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  21. {
  22. serialize->Class<ROS2FrameConfiguration>()
  23. ->Version(1)
  24. ->Field("Namespace Configuration", &ROS2FrameConfiguration::m_namespaceConfiguration)
  25. ->Field("Frame Name", &ROS2FrameConfiguration::m_frameName)
  26. ->Field("Joint Name", &ROS2FrameConfiguration::m_jointName)
  27. ->Field("Publish Transform", &ROS2FrameConfiguration::m_publishTransform);
  28. if (AZ::EditContext* ec = serialize->GetEditContext())
  29. {
  30. ec->Class<ROS2FrameConfiguration>("ROS2 Frame configuration", "[ROS2 Frame component configuration]")
  31. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  32. ->DataElement(
  33. AZ::Edit::UIHandlers::Default,
  34. &ROS2FrameConfiguration::m_namespaceConfiguration,
  35. "Namespace Configuration",
  36. "Namespace Configuration")
  37. ->DataElement(AZ::Edit::UIHandlers::Default, &ROS2FrameConfiguration::m_frameName, "Frame Name", "Frame Name")
  38. ->DataElement(AZ::Edit::UIHandlers::Default, &ROS2FrameConfiguration::m_jointName, "Joint Name", "Joint Name")
  39. ->DataElement(
  40. AZ::Edit::UIHandlers::Default,
  41. &ROS2FrameConfiguration::m_publishTransform,
  42. "Publish Transform",
  43. "Publish Transform")
  44. ->ClassElement(AZ::Edit::ClassElements::Group, "Info")
  45. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  46. ->UIElement(AZ::Edit::UIHandlers::Label, "Effective namespace", "")
  47. ->Attribute(AZ::Edit::Attributes::ValueText, &ROS2FrameConfiguration::m_effectiveNamespace)
  48. ->UIElement(AZ::Edit::UIHandlers::Label, "Full name", "")
  49. ->Attribute(AZ::Edit::Attributes::ValueText, &ROS2FrameConfiguration::m_fullName);
  50. }
  51. }
  52. }
  53. void ROS2FrameConfiguration::SetEffectiveNamespace(const AZStd::string& effectiveNamespace)
  54. {
  55. m_effectiveNamespace = effectiveNamespace;
  56. m_fullName = effectiveNamespace + '/' + m_frameName;
  57. }
  58. } // namespace ROS2