Skip to content

Commit

Permalink
Exposed TPP pipeline methods in configurable TPP widget
Browse files Browse the repository at this point in the history
  • Loading branch information
marip8 committed Jan 4, 2024
1 parent 3ff33aa commit dae6199
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

#include <QWidget>
#include <boost_plugin_loader/plugin_loader.h>
#include <noether_tpp/core/tool_path_planner_pipeline.h>

namespace Ui
{
class ConfigurableTPPPipeline;
}

namespace YAML
{
class Node;
}

namespace noether
{
class TPPPipelineWidget;
Expand All @@ -18,14 +24,18 @@ class ConfigurableTPPPipelineWidget : public QWidget
public:
ConfigurableTPPPipelineWidget(boost_plugin_loader::PluginLoader loader, QWidget* parent = nullptr);

TPPPipelineWidget* pipeline_widget;
void setConfigurationFile(const QString& file);

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

private:
void onLoadConfiguration(const bool /*checked*/);
void onSaveConfiguration(const bool /*checked*/);

Ui::ConfigurableTPPPipeline* ui_;
TPPPipelineWidget* pipeline_widget_;
};

} // namespace noether
17 changes: 13 additions & 4 deletions noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,33 @@ namespace noether
{
ConfigurableTPPPipelineWidget::ConfigurableTPPPipelineWidget(boost_plugin_loader::PluginLoader loader, QWidget* parent)
: QWidget(parent)
, pipeline_widget(new TPPPipelineWidget(std::move(loader), this))
, ui_(new Ui::ConfigurableTPPPipeline())
, pipeline_widget_(new TPPPipelineWidget(std::move(loader), this))
{
ui_->setupUi(this);
layout()->addWidget(pipeline_widget);
layout()->addWidget(pipeline_widget_);

// Connect
connect(ui_->push_button_load, &QPushButton::clicked, this, &ConfigurableTPPPipelineWidget::onLoadConfiguration);
connect(ui_->push_button_save, &QPushButton::clicked, this, &ConfigurableTPPPipelineWidget::onSaveConfiguration);
}

ToolPathPlannerPipeline ConfigurableTPPPipelineWidget::createPipeline() const
{
return pipeline_widget_->createPipeline();
}

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

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

void ConfigurableTPPPipelineWidget::setConfigurationFile(const QString& file)
{
ui_->line_edit->setText(file);

try
{
pipeline_widget->configure(YAML::LoadFile(file.toStdString()));
configure(YAML::LoadFile(file.toStdString()));
}
catch (const YAML::BadFile&)
{
Expand Down Expand Up @@ -72,7 +81,7 @@ void ConfigurableTPPPipelineWidget::onSaveConfiguration(const bool /*checked*/)
return;

YAML::Node config;
pipeline_widget->save(config);
save(config);

std::ofstream ofh(file.toStdString());
if (!ofh)
Expand Down
2 changes: 1 addition & 1 deletion noether_gui/src/widgets/tpp_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void TPPWidget::onPlan(const bool /*checked*/)
if (pcl::io::loadPolygonFile(mesh_file, full_mesh) < 1)
throw std::runtime_error("Failed to load mesh from file");

const ToolPathPlannerPipeline pipeline = pipeline_widget_->pipeline_widget->createPipeline();
const ToolPathPlannerPipeline pipeline = pipeline_widget_->createPipeline();
QApplication::setOverrideCursor(Qt::WaitCursor);

// Run the mesh modifier
Expand Down

0 comments on commit dae6199

Please sign in to comment.