8 setObjectName(
"ContoursAlgorithm");
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;
18 file->addWidget(
file_);
19 file->addWidget(file_explorer);
20 connect(file_explorer, SIGNAL(released()),
this, SLOT(
browseFiles()));
24 QHBoxLayout *number_of_layers_layout =
new QHBoxLayout;
25 number_of_layers_layout->addWidget(
new QLabel(
"Number of layers:"));
35 QHBoxLayout *height_between_layers_layout =
new QHBoxLayout;
36 height_between_layers_layout->addWidget(
new QLabel(
"Height between layers:"));
44 QHBoxLayout *deposited_material_width_layout =
new QHBoxLayout;
45 deposited_material_width_layout->addWidget(
new QLabel(
"Deposited material width:"));
71 QHBoxLayout* vector_layout =
new QHBoxLayout;
72 vector_layout->addWidget(
new QLabel(
"X"));
74 vector_layout->addStretch(1);
75 vector_layout->addWidget(
new QLabel(
"Y"));
77 vector_layout->addStretch(1);
78 vector_layout->addWidget(
new QLabel(
"Z"));
80 QVBoxLayout *slicing_direction_layout =
new QVBoxLayout;
81 slicing_direction_layout->addWidget(
new QLabel(
"Slicing direction:"));
82 slicing_direction_layout->addLayout(vector_layout);
87 main_layout_->addWidget(
new QLabel(
"YAML or mesh file:"));
91 main_layout_->addLayout(deposited_material_width_layout);
109 QString file_dir(
"");
111 QFileInfo file(
file_->text());
112 if (!
file_->text().isEmpty() && file.dir().exists())
113 file_dir = file.dir().path();
117 file_dir = QString::fromStdString(path);
122 browser.setOption(QFileDialog::DontUseNativeDialog,
true);
123 QString file_path = browser.getOpenFileName(
124 this, tr(
"Choose YAML or mesh file"), file_dir,
125 tr(
"YAML and mesh files (*.yaml *.YAML *.yml *.YML *.ply *.PLY *.stl *.STL *.obj *.OBJ)"));
127 file_->setText(file_path);
133 if (!strcasecmp(file_extension.c_str(),
"yaml") || !strcasecmp(file_extension.c_str(),
"yml"))
139 else if (!strcasecmp(file_extension.c_str(),
"ply") || !strcasecmp(file_extension.c_str(),
"stl")
140 || !strcasecmp(file_extension.c_str(),
"obj"))
158 float tmp_float(0.01);
160 if (config.
mapGetString(objectName() +
"file", &tmp_str))
161 file_->setText(tmp_str);
163 if (config.
mapGetInt(objectName() +
"number_of_layers", &tmp_int))
166 if (config.
mapGetFloat(objectName() +
"height_between_layers", &tmp_float))
171 if (config.
mapGetFloat(objectName() +
"deposited_material_width", &tmp_float))
176 if (config.
mapGetFloat(objectName() +
"slicing_direction_x", &tmp_float))
181 if (config.
mapGetFloat(objectName() +
"slicing_direction_y", &tmp_float))
186 if (config.
mapGetFloat(objectName() +
"slicing_direction_z", &tmp_float))
205 if (
file_->text().isEmpty())
206 return "File name is not specified.";
208 goal.file =
file_->text().toStdString();
222 size_t last_index = full_path.find_last_of(
"/");
223 std::string file_name = full_path.substr(last_index + 1, full_path.size());
225 last_index = file_name.find_last_of(
"\\");
226 file_name = file_name.substr(last_index + 1, file_name.size());
228 last_index = file_name.find_last_of(
".");
229 if (last_index == std::string::npos)
232 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)