RobotDescriptionPage.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "RobotDescriptionPage.h"
  9. #include <QVBoxLayout>
  10. namespace ROS2RobotImporter
  11. {
  12. RobotDescriptionPage::RobotDescriptionPage(QWizard* parent)
  13. : QWizardPage(parent)
  14. , m_success(false)
  15. , m_warning(false)
  16. {
  17. m_urdfName = new QLineEdit(this);
  18. m_saveButton = new QPushButton(tr("Save URDF"), this);
  19. m_showButton = new QPushButton(tr("Show URDF"), this);
  20. m_log = new QTextEdit(this);
  21. m_log->acceptRichText();
  22. m_log->setReadOnly(true);
  23. QVBoxLayout* layout = new QVBoxLayout;
  24. QHBoxLayout* layoutInner = new QHBoxLayout;
  25. layoutInner->addWidget(m_urdfName);
  26. layoutInner->addWidget(m_saveButton);
  27. layoutInner->addWidget(m_showButton);
  28. layout->addWidget(m_log);
  29. layout->addLayout(layoutInner);
  30. setTitle(tr("URDF/SDF opening results:"));
  31. setLayout(layout);
  32. connect(m_saveButton, &QPushButton::pressed, this, &RobotDescriptionPage::onSaveModifiedUrdfPressed);
  33. connect(m_showButton, &QPushButton::pressed, this, &RobotDescriptionPage::onShowModifiedUrdfPressed);
  34. }
  35. void RobotDescriptionPage::ReportParsingResult(const QString& status, bool isSuccess, bool isWarning)
  36. {
  37. m_log->setMarkdown(status);
  38. m_success = isSuccess;
  39. m_warning = isWarning;
  40. if ((isSuccess && isWarning == false) || isSuccess == false)
  41. {
  42. m_urdfName->setDisabled(true);
  43. m_saveButton->setDisabled(true);
  44. m_showButton->setDisabled(true);
  45. }
  46. else
  47. {
  48. m_urdfName->setDisabled(false);
  49. m_saveButton->setDisabled(false);
  50. m_showButton->setDisabled(false);
  51. }
  52. emit completeChanged();
  53. }
  54. void RobotDescriptionPage::SetModifiedUrdfName(const AZStd::string prefabName)
  55. {
  56. m_urdfName->setText(QString::fromUtf8(prefabName.data(), int(prefabName.size())));
  57. }
  58. AZStd::string RobotDescriptionPage::GetModifiedUrdfName() const
  59. {
  60. return AZStd::string(m_urdfName->text().toUtf8().constData());
  61. }
  62. bool RobotDescriptionPage::isComplete() const
  63. {
  64. return m_success;
  65. }
  66. bool RobotDescriptionPage::isWarning() const
  67. {
  68. return m_warning;
  69. }
  70. } // namespace ROS2RobotImporter