follow_poses.cpp
Go to the documentation of this file.
2 
3 namespace ram_qt_guis
4 {
6 
7 {
8  setObjectName("FollowPosesWidget");
9 
10  main_layout_ = new QVBoxLayout(this);
11 
12  QHBoxLayout *file = new QHBoxLayout;
13  QPushButton *file_explorer = new QPushButton;
14  file_explorer->setText("...");
15  file_explorer->setMaximumSize(30, 30);
16  file_ = new QLineEdit;
17  file->addWidget(file_);
18  file->addWidget(file_explorer);
19  connect(file_explorer, SIGNAL(released()), this, SLOT(browseFiles()));
20 
21  duplicate_layer_ = new QCheckBox;
22  duplicate_layer_->setText("Duplicate layers");
23  duplicate_layer_->setChecked(false);
24 
25  number_of_layers_ = new QSpinBox;
26  number_of_layers_->setRange(2, 10000);
27  number_of_layers_->setToolTip("The number of layers in the final trajectory");
28  QHBoxLayout *number_of_layers_layout = new QHBoxLayout;
29  number_of_layers_layout->addWidget(new QLabel("Number of layers:"));
30  number_of_layers_layout->addWidget(number_of_layers_);
31 
32  height_between_layers_ = new QDoubleSpinBox;
33  height_between_layers_->setRange(0.001, 1000);
34  height_between_layers_->setSuffix(" mm");
35  height_between_layers_->setSingleStep(0.1);
36  height_between_layers_->setDecimals(3);
37  QHBoxLayout *height_between_layers_layout = new QHBoxLayout;
38  height_between_layers_layout->addWidget(new QLabel("Height between layers:"));
39  height_between_layers_layout->addWidget(height_between_layers_);
40 
41  invert_one_of_two_layers_ = new QCheckBox("Invert one of two layers");
42 
43  duplicate_layer_widget_ = new QWidget;
44  QVBoxLayout *duplicate_layer_layout = new QVBoxLayout;
45  duplicate_layer_widget_->setLayout(duplicate_layer_layout);
46  duplicate_layer_layout->addLayout(number_of_layers_layout);
47  duplicate_layer_layout->addLayout(height_between_layers_layout);
48  duplicate_layer_layout->addWidget(invert_one_of_two_layers_);
49 
50  // Main layout
51  main_layout_->addWidget(new QLabel("YAML file:"));
52  main_layout_->addLayout(file);
53  main_layout_->addStretch(1);
54  main_layout_->addWidget(duplicate_layer_);
56  main_layout_->addStretch(1);
57 
58  connect(file_, SIGNAL(textChanged(QString)), this, SIGNAL(valueChanged()));
59  connect(duplicate_layer_, SIGNAL(clicked()), this, SIGNAL(valueChanged()));
60  connect(duplicate_layer_, SIGNAL(clicked()), this, SLOT(enableDisableDuplicateLayers()));
61  connect(number_of_layers_, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged()));
62  connect(invert_one_of_two_layers_, SIGNAL(stateChanged(int)), this, SIGNAL(valueChanged()));
63  connect(height_between_layers_, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged()));
64 }
65 
67 {
68 }
69 
71 {
72  QString file_dir("");
73  {
74  QFileInfo file(file_->text());
75  if (!file_->text().isEmpty() && file.dir().exists())
76  file_dir = file.dir().path();
77  else
78  {
79  std::string path = ros::package::getPath("ram_path_planning");
80  file_dir = QString::fromStdString(path);
81  }
82  }
83 
84  QFileDialog browser;
85  browser.setOption(QFileDialog::DontUseNativeDialog, true);
86  QString file_path = browser.getOpenFileName(this, "Choose YAML file", file_dir,
87  "YAML files (*.yaml *.YAML *.yml *.YML)");
88  if (file_path != "")
89  file_->setText(file_path);
90 }
91 
93 {
94  duplicate_layer_widget_->setEnabled(duplicate_layer_->isChecked());
95 }
96 
98 {
99  QString tmp_str("");
100  bool tmp_bool(false);
101  int tmp_int(0);
102  float tmp_float(0.01);
103 
104  if (config.mapGetString(objectName() + "file", &tmp_str))
105  file_->setText(tmp_str);
106 
107  if (config.mapGetBool(objectName() + "duplicate_layer", &tmp_bool))
108  duplicate_layer_->setChecked(tmp_bool);
109  else
110  duplicate_layer_->setChecked(false);
111 
112  if (config.mapGetInt(objectName() + "number_of_layers", &tmp_int))
113  number_of_layers_->setValue(tmp_int);
114 
115  if (config.mapGetFloat(objectName() + "height_between_layers", &tmp_float))
116  height_between_layers_->setValue(tmp_float);
117  else
119 
120  if (config.mapGetBool(objectName() + "invert_one_of_two_layers", &tmp_bool))
121  invert_one_of_two_layers_->setChecked(tmp_bool);
122  else
123  invert_one_of_two_layers_->setChecked(false);
124 
126 }
127 
129  {
130  config.mapSetValue(objectName() + "file", file_->text());
131  config.mapSetValue(objectName() + "duplicate_layer", duplicate_layer_->isChecked());
132  config.mapSetValue(objectName() + "number_of_layers", number_of_layers_->value());
133  config.mapSetValue(objectName() + "height_between_layers", height_between_layers_->value());
134  config.mapSetValue(objectName() + "invert_one_of_two_layers", invert_one_of_two_layers_->isChecked());
135 }
136 
137 std::string FollowPosesWidget::fillGoal(ram_path_planning::FollowPosesGoal &goal)
138 {
139  if (file_->text().isEmpty())
140  return "File name is not specified.";
141 
142  goal.file = file_->text().toStdString();
143  goal.duplicate_layer = duplicate_layer_->isChecked();
144  goal.number_of_layers = number_of_layers_->value();
145  goal.height_between_layers = height_between_layers_->value() / 1000.0;
146  goal.invert_one_of_two_layers = invert_one_of_two_layers_->isChecked();
147  return "";
148 }
149 
150 std::string FollowPosesWidget::fileExtension(const std::string full_path)
151 {
152  size_t last_index = full_path.find_last_of("/");
153  std::string file_name = full_path.substr(last_index + 1, full_path.size());
154 
155  last_index = file_name.find_last_of("\\");
156  file_name = file_name.substr(last_index + 1, file_name.size());
157 
158  last_index = file_name.find_last_of(".");
159  if (last_index == std::string::npos)
160  return "";
161 
162  return file_name.substr(last_index + 1, file_name.size());
163 }
164 
165 }
void save(rviz::Config config) const
bool mapGetFloat(const QString &key, float *value_out) const
QDoubleSpinBox * height_between_layers_
std::string fileExtension(const std::string full_path)
const double default_height_between_layers_
bool mapGetString(const QString &key, QString *value_out) const
void mapSetValue(const QString &key, QVariant value)
bool mapGetBool(const QString &key, bool *value_out) const
bool mapGetInt(const QString &key, int *value_out) const
ROSLIB_DECL std::string getPath(const std::string &package_name)
std::string fillGoal(ram_path_planning::FollowPosesGoal &goal)
void load(const rviz::Config &config)


ram_qt_guis
Author(s): Victor Lamoine - Institut Maupertuis
autogenerated on Mon Jun 10 2019 14:50:11