9 setObjectName(
"DonghongDingAlgorithm");
13 QHBoxLayout *file =
new QHBoxLayout;
14 QPushButton *file_explorer =
new QPushButton;
15 file_explorer->setText(
"...");
16 file_explorer->setMaximumSize(30, 30);
17 file_ =
new QLineEdit;
19 file->addWidget(
file_);
20 file->addWidget(file_explorer);
21 connect(file_explorer, SIGNAL(released()),
this, SLOT(
browseFiles()));
25 QHBoxLayout *number_of_layers_layout =
new QHBoxLayout;
26 number_of_layers_layout->addWidget(
new QLabel(
"Number of layers:"));
37 QHBoxLayout *height_between_layers_layout =
new QHBoxLayout;
38 height_between_layers_layout->addWidget(
new QLabel(
"Height between layers:"));
47 QHBoxLayout *deposited_material_width_layout =
new QHBoxLayout;
48 deposited_material_width_layout->addWidget(
new QLabel(
"Deposited material width:"));
56 QHBoxLayout *contours_filtering_tolerance_layout =
new QHBoxLayout;
57 contours_filtering_tolerance_layout->addWidget(
new QLabel(
"Contours filtering tolerance:"));
83 QHBoxLayout* vector_layout =
new QHBoxLayout;
84 vector_layout->addWidget(
new QLabel(
"X"));
86 vector_layout->addStretch(1);
87 vector_layout->addWidget(
new QLabel(
"Y"));
89 vector_layout->addStretch(1);
90 vector_layout->addWidget(
new QLabel(
"Z"));
92 QVBoxLayout *slicing_direction_layout =
new QVBoxLayout;
93 slicing_direction_layout->addWidget(
new QLabel(
"Slicing direction:"));
94 slicing_direction_layout->addLayout(vector_layout);
99 main_layout_->addWidget(
new QLabel(
"YAML or mesh file:"));
103 main_layout_->addLayout(deposited_material_width_layout);
104 main_layout_->addLayout(contours_filtering_tolerance_layout);
125 QString file_dir(
"");
127 QFileInfo file(
file_->text());
128 if (!
file_->text().isEmpty() && file.dir().exists())
129 file_dir = file.dir().path();
133 file_dir = QString::fromStdString(path);
138 browser.setOption(QFileDialog::DontUseNativeDialog,
true);
139 QString file_path = browser.getOpenFileName(
140 this, tr(
"Choose YAML or mesh file"), file_dir,
141 tr(
"YAML and mesh files (*.yaml *.YAML *.yml *.YML *.ply *.PLY *.stl *.STL *.obj *.OBJ)"));
143 file_->setText(file_path);
149 if (!strcasecmp(file_extension.c_str(),
"yaml") || !strcasecmp(file_extension.c_str(),
"yml"))
155 else if (!strcasecmp(file_extension.c_str(),
"ply") || !strcasecmp(file_extension.c_str(),
"stl")
156 || !strcasecmp(file_extension.c_str(),
"obj"))
174 float tmp_float(0.01);
176 if (config.
mapGetString(objectName() +
"file", &tmp_str))
177 file_->setText(tmp_str);
179 if (config.
mapGetInt(objectName() +
"number_of_layers", &tmp_int))
182 if (config.
mapGetFloat(objectName() +
"height_between_layers", &tmp_float))
187 if (config.
mapGetFloat(objectName() +
"deposited_material_width", &tmp_float))
192 if (config.
mapGetFloat(objectName() +
"contours_filtering_tolerance", &tmp_float))
197 if (config.
mapGetFloat(objectName() +
"slicing_direction_x", &tmp_float))
202 if (config.
mapGetFloat(objectName() +
"slicing_direction_y", &tmp_float))
207 if (config.
mapGetFloat(objectName() +
"slicing_direction_z", &tmp_float))
227 if (
file_->text().isEmpty())
228 return "File name is not specified.";
230 goal.file =
file_->text().toStdString();
245 size_t last_index = full_path.find_last_of(
"/");
246 std::string file_name = full_path.substr(last_index + 1, full_path.size());
248 last_index = file_name.find_last_of(
"\\");
249 file_name = file_name.substr(last_index + 1, file_name.size());
251 last_index = file_name.find_last_of(
".");
252 if (last_index == std::string::npos)
255 return file_name.substr(last_index + 1, file_name.size());
bool mapGetFloat(const QString &key, float *value_out) const
bool mapGetString(const QString &key, QString *value_out) const
void mapSetValue(const QString &key, QVariant value)
bool mapGetInt(const QString &key, int *value_out) const
ROSLIB_DECL std::string getPath(const std::string &package_name)