Skip to content

Commit

Permalink
Added function to configure from file
Browse files Browse the repository at this point in the history
  • Loading branch information
marip8 committed Jan 4, 2024
1 parent dae6199 commit ea044a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ConfigurableTPPPipelineWidget : public QWidget

ToolPathPlannerPipeline createPipeline() const;
void configure(const YAML::Node& config);
void configure(const QString& file);
void save(YAML::Node& config) const;

private:
Expand Down
22 changes: 22 additions & 0 deletions noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ ToolPathPlannerPipeline ConfigurableTPPPipelineWidget::createPipeline() const

void ConfigurableTPPPipelineWidget::configure(const YAML::Node& config) { return pipeline_widget_->configure(config); }

void ConfigurableTPPPipelineWidget::configure(const QString& file)
{
try
{
configure(YAML::LoadFile(file.toStdString()));
ui_->line_edit->setText(file);
}
catch (const YAML::BadFile&)
{
QString message;
QTextStream ss(&message);
ss << "Failed to open YAML file at '" << file << "'";
QMessageBox::warning(this, "Configuration Error", message);
}
catch (const std::exception& ex)
{
std::stringstream ss;
noether::printException(ex, ss);
QMessageBox::warning(this, "Configuration Error", QString::fromStdString(ss.str()));
}
}

void ConfigurableTPPPipelineWidget::save(YAML::Node& config) const { return pipeline_widget_->save(config); }

void ConfigurableTPPPipelineWidget::setConfigurationFile(const QString& file)
Expand Down

0 comments on commit ea044a9

Please sign in to comment.