properties_dialog.cpp
Go to the documentation of this file.
2 
3 #include <QFileDialog>
4 
5 namespace pal
6 {
7 MotionProperties::MotionProperties(QWidget *parent) : QDialog(parent)
8 {
9  ui_.setupUi(this);
10  QLabel *out_label = new QLabel();
11  out_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
12  QVBoxLayout *layout = new QVBoxLayout();
13  out_label->setLayout(layout);
14  ui_.scrollArea->setWidget(out_label);
15  ui_.scrollArea->setWidgetResizable(true);
16 
17  connect(ui_.cancel_btn_, SIGNAL(pressed()), this, SLOT(onCancel()));
18  connect(ui_.build_yaml_btn_, SIGNAL(pressed()), this, SLOT(onSaveYAML()));
19  connect(ui_.yaml_name_, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString)));
20 }
21 
23 {
24  store_client_ = nh.serviceClient<play_motion_builder_msgs::StoreMotion>(
25  "/play_motion_builder_node/store_motion");
26 }
27 
29 {
30  ui_.yaml_name_->setText("");
31  ui_.name_->setText("");
32  ui_.usage_->setText("");
33  ui_.description_->setText("");
34 }
35 
36 void MotionProperties::loadYamlName(const std::string &yaml_name)
37 {
38  ui_.yaml_name_->setText(QString::fromStdString(yaml_name));
39 }
40 
41 void MotionProperties::loadMeta(const std::string &name, const std::string &usage,
42  const std::string &description)
43 {
44  ui_.name_->setText(QString::fromStdString(name));
45  ui_.usage_->setText(QString::fromStdString(usage));
46  ui_.description_->setText(QString::fromStdString(description));
47 }
48 
50 {
51  this->close();
52 }
53 
54 void MotionProperties::onTextChanged(const QString &text)
55 {
56  ui_.build_yaml_btn_->setEnabled(!text.isEmpty());
57 }
58 
60 {
61  QString file = QFileDialog::getSaveFileName(this);
62  ROS_INFO_STREAM("Directory: " << file.toStdString());
63 
64  play_motion_builder_msgs::StoreMotion sm;
65  sm.request.file_path = file.toStdString();
66  sm.request.ros_name = ui_.yaml_name_->text().toStdString();
67  sm.request.meta.name = ui_.name_->text().toStdString();
68  sm.request.meta.usage = ui_.usage_->text().toStdString();
69  sm.request.meta.description = ui_.description_->text().toStdString();
70 
71  if (store_client_.call(sm))
72  {
73  if (sm.response.ok)
74  {
75  emit motionStored(ui_.yaml_name_->text());
76  }
77  else
78  {
79  ROS_ERROR_STREAM("Error on storing: " << sm.response.message);
80  }
81  }
82  else
83  {
84  ROS_ERROR_STREAM("Couldn't connect with the store service");
85  }
86 }
87 
88 } // namespace pal
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
MotionProperties(QWidget *parent=0)
void init(ros::NodeHandle &nh)
bool call(MReq &req, MRes &res)
void motionStored(QString motion_name)
ros::ServiceClient store_client_
void loadYamlName(const std::string &yaml_name)
#define ROS_INFO_STREAM(args)
Ui::MotionProperties ui_
#define ROS_ERROR_STREAM(args)
void onTextChanged(const QString &text)
void loadMeta(const std::string &name, const std::string &usage, const std::string &description)


rqt_play_motion_builder
Author(s):
autogenerated on Mon Feb 28 2022 23:13:41