2
0

ROS2FrameConfiguration.cpp 2.9 KB

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