From 5465d6fb0995d5c7e062ba286f62032e32eb4083 Mon Sep 17 00:00:00 2001 From: Michael Ripperger Date: Thu, 28 Dec 2023 09:25:27 -0600 Subject: [PATCH 1/6] Added configurable TPP pipeline widget --- noether_gui/CMakeLists.txt | 3 + .../configurable_tpp_pipeline_widget.h | 31 +++++++ .../configurable_tpp_pipeline_widget.cpp | 92 +++++++++++++++++++ .../ui/configurable_tpp_pipeline_widget.ui | 49 ++++++++++ 4 files changed, 175 insertions(+) create mode 100644 noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h create mode 100644 noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp create mode 100644 noether_gui/ui/configurable_tpp_pipeline_widget.ui diff --git a/noether_gui/CMakeLists.txt b/noether_gui/CMakeLists.txt index 954a1023..eea10c7e 100644 --- a/noether_gui/CMakeLists.txt +++ b/noether_gui/CMakeLists.txt @@ -20,6 +20,7 @@ option(NOETHER_ENABLE_TESTING "Enables compilation of unit tests" OFF) qt5_wrap_cpp(${PROJECT_NAME}_widget_mocs include/${PROJECT_NAME}/widgets/collapsible_area_widget.h include/${PROJECT_NAME}/widgets/tpp_pipeline_widget.h + include/${PROJECT_NAME}/widgets/configurable_tpp_pipeline_widget.h include/${PROJECT_NAME}/widgets/tpp_widget.h # Tool Path Planners # Raster @@ -52,6 +53,7 @@ qt5_wrap_ui(${PROJECT_NAME}_widget_ui_mocs ui/linear_approach_modifier_widget.ui ui/raster_planner_widget.ui ui/tpp_pipeline_widget.ui + ui/configurable_tpp_pipeline_widget.ui ui/tpp_widget.ui) include_directories(include ${CMAKE_CURRENT_BINARY_DIR}) @@ -63,6 +65,7 @@ add_library(${PROJECT_NAME} SHARED src/widgets/collapsible_area_widget.cpp src/widgets/plugin_loader_widget.cpp src/widgets/tpp_pipeline_widget.cpp + src/widgets/configurable_tpp_pipeline_widget.cpp src/widgets/tpp_widget.cpp # Tool Path Planners # Raster Planner diff --git a/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h b/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h new file mode 100644 index 00000000..dd6a9f0e --- /dev/null +++ b/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +namespace Ui +{ +class ConfigurableTPPPipeline; +} + +namespace noether +{ +class TPPPipelineWidget; + +class ConfigurableTPPPipelineWidget : public QWidget +{ + Q_OBJECT +public: + ConfigurableTPPPipelineWidget(boost_plugin_loader::PluginLoader loader, QWidget* parent = nullptr); + + TPPPipelineWidget* pipeline_widget; + void setConfigurationFile(const QString& file); + +private: + void onLoadConfiguration(const bool /*checked*/); + void onSaveConfiguration(const bool /*checked*/); + + Ui::ConfigurableTPPPipeline* ui_; +}; + +} // namespace noether diff --git a/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp b/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp new file mode 100644 index 00000000..291ddb22 --- /dev/null +++ b/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include "ui_configurable_tpp_pipeline_widget.h" + +#include +#include +#include +#include +#include +#include + +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()) +{ + ui_->setupUi(this); + 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); +} + +void ConfigurableTPPPipelineWidget::setConfigurationFile(const QString& file) +{ + ui_->line_edit->setText(file); + + try + { + pipeline_widget->configure(YAML::LoadFile(file.toStdString())); + } + catch (const YAML::BadFile&) + { + QString message; + QTextStream ss; + ss << "Failed to open YAML file at '" << file << "'"; + QMessageBox::warning(this, "Configuration Error", message); + } + catch (const std::exception& ex) + { + std::stringstream ss; + printException(ex, ss); + QMessageBox::warning(this, "Configuration Error", QString::fromStdString(ss.str())); + } +} + +void ConfigurableTPPPipelineWidget::onLoadConfiguration(const bool /*checked*/) +{ + QString file = ui_->line_edit->text(); + if (file.isEmpty()) + file = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0); + + file = QFileDialog::getOpenFileName(this, "Load configuration file", file, "YAML files (*.yaml)"); + if (!file.isEmpty()) + setConfigurationFile(file); +} + +void ConfigurableTPPPipelineWidget::onSaveConfiguration(const bool /*checked*/) +{ + try + { + QString file = ui_->line_edit->text(); + if (file.isEmpty()) + file = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0); + + file = QFileDialog::getSaveFileName(this, "Save configuration file", file, "YAML files (*.yaml)"); + if (file.isEmpty()) + return; + + YAML::Node config; + pipeline_widget->save(config); + + std::ofstream ofh(file.toStdString()); + if (!ofh) + throw std::runtime_error("Failed to open output file at '" + file.toStdString() + "'"); + + ofh << config; + QMessageBox::information(this, "Configuration", "Successfully saved tool path planning pipeline configuration"); + } + catch (const std::exception& ex) + { + std::stringstream ss; + printException(ex, ss); + QMessageBox::warning(this, "Save Error", QString::fromStdString(ss.str())); + } +} + +} // namespace noether diff --git a/noether_gui/ui/configurable_tpp_pipeline_widget.ui b/noether_gui/ui/configurable_tpp_pipeline_widget.ui new file mode 100644 index 00000000..734ed46a --- /dev/null +++ b/noether_gui/ui/configurable_tpp_pipeline_widget.ui @@ -0,0 +1,49 @@ + + + ConfigurableTPPPipeline + + + + 0 + 0 + 400 + 79 + + + + Form + + + + + + + + + + + Load + + + + + + + + + Save + + + + + + + Qt::Horizontal + + + + + + + + From 652a4cd1a1164ce7257f48872fbfa0c7a515816e Mon Sep 17 00:00:00 2001 From: Michael Ripperger Date: Thu, 28 Dec 2023 09:28:05 -0600 Subject: [PATCH 2/6] Included configurable TPP pipeline widget in TPP widget --- .../include/noether_gui/widgets/tpp_widget.h | 6 +- noether_gui/src/widgets/tpp_widget.cpp | 71 ++----------------- noether_gui/ui/tpp_widget.ui | 30 +------- 3 files changed, 7 insertions(+), 100 deletions(-) diff --git a/noether_gui/include/noether_gui/widgets/tpp_widget.h b/noether_gui/include/noether_gui/widgets/tpp_widget.h index 613a91ab..a58cdd63 100644 --- a/noether_gui/include/noether_gui/widgets/tpp_widget.h +++ b/noether_gui/include/noether_gui/widgets/tpp_widget.h @@ -26,7 +26,7 @@ class TPP; namespace noether { -class TPPPipelineWidget; +class ConfigurableTPPPipelineWidget; /** * @brief Basic tool path planning widget @@ -51,8 +51,6 @@ class TPPWidget : public QWidget private: void onLoadMesh(const bool /*checked*/); - void onLoadConfiguration(const bool /*checked*/); - void onSaveConfiguration(const bool /*checked*/); void onPlan(const bool /*checked*/); void onShowOriginalMesh(const bool); void onShowModifiedMesh(const bool); @@ -60,7 +58,7 @@ class TPPWidget : public QWidget void onShowModifiedToolPath(const bool); Ui::TPP* ui_; - TPPPipelineWidget* pipeline_widget_; + ConfigurableTPPPipelineWidget* pipeline_widget_; // Viewer rendering QVTKWidget* render_widget_; diff --git a/noether_gui/src/widgets/tpp_widget.cpp b/noether_gui/src/widgets/tpp_widget.cpp index c2b12386..e39a0fa1 100644 --- a/noether_gui/src/widgets/tpp_widget.cpp +++ b/noether_gui/src/widgets/tpp_widget.cpp @@ -1,5 +1,6 @@ #include #include "ui_tpp_widget.h" +#include #include #include @@ -34,7 +35,7 @@ namespace noether TPPWidget::TPPWidget(boost_plugin_loader::PluginLoader loader, QWidget* parent) : QWidget(parent) , ui_(new Ui::TPP()) - , pipeline_widget_(new TPPPipelineWidget(std::move(loader), this)) + , pipeline_widget_(new ConfigurableTPPPipelineWidget(std::move(loader), this)) , render_widget_(new QVTKWidget(this)) , renderer_(vtkSmartPointer::New()) , mesh_mapper_(vtkSmartPointer::New()) @@ -80,8 +81,6 @@ TPPWidget::TPPWidget(boost_plugin_loader::PluginLoader loader, QWidget* parent) // Connect signals connect(ui_->push_button_load_mesh, &QPushButton::clicked, this, &TPPWidget::onLoadMesh); - connect(ui_->push_button_load_configuration, &QPushButton::clicked, this, &TPPWidget::onLoadConfiguration); - connect(ui_->push_button_save_configuration, &QPushButton::clicked, this, &TPPWidget::onSaveConfiguration); connect(ui_->check_box_show_original_mesh, &QCheckBox::clicked, this, &TPPWidget::onShowOriginalMesh); connect(ui_->check_box_show_modified_mesh, &QCheckBox::clicked, this, &TPPWidget::onShowModifiedMesh); connect(ui_->check_box_show_original_tool_path, &QCheckBox::clicked, this, &TPPWidget::onShowUnmodifiedToolPath); @@ -160,69 +159,7 @@ void TPPWidget::onLoadMesh(const bool /*checked*/) setMeshFile(file); } -void TPPWidget::setConfigurationFile(const QString& file) -{ - ui_->line_edit_configuration->setText(file); - - try - { - pipeline_widget_->configure(YAML::LoadFile(file.toStdString())); - } - catch (const YAML::BadFile&) - { - QString message; - QTextStream ss; - ss << "Failed to open YAML file at '" << file << "'"; - QMessageBox::warning(this, "Configuration Error", message); - } - catch (const std::exception& ex) - { - std::stringstream ss; - printException(ex, ss); - QMessageBox::warning(this, "Configuration Error", QString::fromStdString(ss.str())); - } -} - -void TPPWidget::onLoadConfiguration(const bool /*checked*/) -{ - QString file = ui_->line_edit_configuration->text(); - if (file.isEmpty()) - file = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0); - - file = QFileDialog::getOpenFileName(this, "Load configuration file", file, "YAML files (*.yaml)"); - if (!file.isEmpty()) - setConfigurationFile(file); -} - -void TPPWidget::onSaveConfiguration(const bool /*checked*/) -{ - try - { - QString file = ui_->line_edit_configuration->text(); - if (file.isEmpty()) - file = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0); - - file = QFileDialog::getSaveFileName(this, "Save configuration file", file, "YAML files (*.yaml)"); - if (file.isEmpty()) - return; - - YAML::Node config; - pipeline_widget_->save(config); - - std::ofstream ofh(file.toStdString()); - if (!ofh) - throw std::runtime_error("Failed to open output file at '" + file.toStdString() + "'"); - - ofh << config; - QMessageBox::information(this, "Configuration", "Successfully saved tool path planning pipeline configuration"); - } - catch (const std::exception& ex) - { - std::stringstream ss; - printException(ex, ss); - QMessageBox::warning(this, "Save Error", QString::fromStdString(ss.str())); - } -} +void TPPWidget::setConfigurationFile(const QString& file) { pipeline_widget_->setConfigurationFile(file); } vtkSmartPointer toVTK(const Eigen::Isometry3d& mat) { @@ -297,7 +234,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_->createPipeline(); + const ToolPathPlannerPipeline pipeline = pipeline_widget_->pipeline_widget->createPipeline(); QApplication::setOverrideCursor(Qt::WaitCursor); // Run the mesh modifier diff --git a/noether_gui/ui/tpp_widget.ui b/noether_gui/ui/tpp_widget.ui index c26caec0..f1447db0 100644 --- a/noether_gui/ui/tpp_widget.ui +++ b/noether_gui/ui/tpp_widget.ui @@ -62,31 +62,6 @@ Configuration - - - - - - true - - - - - - - Load - - - - - - - - - Save - - - @@ -113,7 +88,7 @@ 0 0 1024 - 220 + 278 @@ -211,9 +186,6 @@ line_edit_mesh push_button_load_mesh - line_edit_configuration - push_button_load_configuration - push_button_save_configuration scroll_area push_button_plan double_spin_box_axis_size From bbebbf4984fefb331b61aacd119c2c007a55f800 Mon Sep 17 00:00:00 2001 From: Michael Ripperger Date: Thu, 28 Dec 2023 11:06:42 -0600 Subject: [PATCH 3/6] Moved scroll widgets into TPP pipeline pages --- .../widgets/plugin_loader_widget.h | 3 ++ .../widgets/plugin_loader_widget.hpp | 20 ++++++----- .../src/widgets/collapsible_area_widget.cpp | 2 ++ .../src/widgets/tpp_pipeline_widget.cpp | 12 +++---- noether_gui/src/widgets/tpp_widget.cpp | 2 +- noether_gui/ui/plugin_loader_widget.ui | 33 ++++++++--------- noether_gui/ui/tpp_pipeline_widget.ui | 24 +++++++++++-- noether_gui/ui/tpp_widget.ui | 36 ++----------------- 8 files changed, 65 insertions(+), 67 deletions(-) diff --git a/noether_gui/include/noether_gui/widgets/plugin_loader_widget.h b/noether_gui/include/noether_gui/widgets/plugin_loader_widget.h index 0f8734be..e53e86a8 100644 --- a/noether_gui/include/noether_gui/widgets/plugin_loader_widget.h +++ b/noether_gui/include/noether_gui/widgets/plugin_loader_widget.h @@ -13,6 +13,8 @@ namespace YAML class Node; } +class QVBoxLayout; + namespace noether { /** @@ -35,6 +37,7 @@ class PluginLoaderWidget : public QWidget void addWidget(const QString& plugin_name, const YAML::Node& config); Ui::PluginLoader* ui_; + QVBoxLayout* widgets_layout_; const boost_plugin_loader::PluginLoader loader_; }; diff --git a/noether_gui/include/noether_gui/widgets/plugin_loader_widget.hpp b/noether_gui/include/noether_gui/widgets/plugin_loader_widget.hpp index 0cd86919..6b5f998f 100644 --- a/noether_gui/include/noether_gui/widgets/plugin_loader_widget.hpp +++ b/noether_gui/include/noether_gui/widgets/plugin_loader_widget.hpp @@ -13,10 +13,12 @@ template PluginLoaderWidget::PluginLoaderWidget(boost_plugin_loader::PluginLoader loader, const QString& title, QWidget* parent) - : QWidget(parent), ui_(new Ui::PluginLoader()), loader_(std::move(loader)) + : QWidget(parent), ui_(new Ui::PluginLoader()), widgets_layout_(new QVBoxLayout()), loader_(std::move(loader)) { ui_->setupUi(this); + ui_->contents->setLayout(widgets_layout_); + ui_->group_box->setTitle(title); ui_->combo_box->addItems(getAvailablePlugins(loader_)); @@ -45,7 +47,7 @@ void PluginLoaderWidget::addWidget(const QString& plugin_name, const YA collapsible_area->setWidget(plugin->create(this, config)); collapsible_area->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); - ui_->vertical_layout_plugins->addWidget(collapsible_area); + widgets_layout_->addWidget(collapsible_area); // Add a right click menu option for deleting this tool path modifier widget connect(collapsible_area, &QWidget::customContextMenuRequested, [this, collapsible_area](const QPoint& pos) { @@ -54,7 +56,7 @@ void PluginLoaderWidget::addWidget(const QString& plugin_name, const YA QAction* action = context_menu.exec(collapsible_area->mapToGlobal(pos)); if (action == remove_action) { - ui_->vertical_layout_plugins->removeWidget(collapsible_area); + widgets_layout_->removeWidget(collapsible_area); delete collapsible_area; } }); @@ -67,9 +69,9 @@ template QWidgetList PluginLoaderWidget::getWidgets() const { QWidgetList widgets; - for (int i = 0; i < ui_->vertical_layout_plugins->count(); ++i) + for (int i = 0; i < widgets_layout_->count(); ++i) { - QLayoutItem* item = ui_->vertical_layout_plugins->itemAt(i); + QLayoutItem* item = widgets_layout_->itemAt(i); if (item) { auto collapsible_area = dynamic_cast(item->widget()); @@ -96,9 +98,9 @@ void PluginLoaderWidget::configure(const YAML::Node& config) template void PluginLoaderWidget::save(YAML::Node& config) const { - for (int i = 0; i < ui_->vertical_layout_plugins->count(); ++i) + for (int i = 0; i < widgets_layout_->count(); ++i) { - QLayoutItem* item = ui_->vertical_layout_plugins->itemAt(i); + QLayoutItem* item = widgets_layout_->itemAt(i); if (item) { auto collapsible_area = dynamic_cast(item->widget()); @@ -121,9 +123,9 @@ void PluginLoaderWidget::save(YAML::Node& config) const template void PluginLoaderWidget::removeWidgets() { - for (int i = 0; i < ui_->vertical_layout_plugins->count(); ++i) + for (int i = 0; i < widgets_layout_->count(); ++i) { - ui_->vertical_layout_plugins->itemAt(i)->widget()->deleteLater(); + widgets_layout_->itemAt(i)->widget()->deleteLater(); } } diff --git a/noether_gui/src/widgets/collapsible_area_widget.cpp b/noether_gui/src/widgets/collapsible_area_widget.cpp index 6fb93d2e..44752bbd 100644 --- a/noether_gui/src/widgets/collapsible_area_widget.cpp +++ b/noether_gui/src/widgets/collapsible_area_widget.cpp @@ -44,6 +44,8 @@ CollapsibleArea::CollapsibleArea(const QString& label, QWidget* parent) content->setStyleSheet("QScrollArea { border: none; }"); content->setMaximumHeight(0); content->setMinimumHeight(0); + content->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + content->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); animation_->addAnimation(new QPropertyAnimation(this, "minimumHeight")); animation_->addAnimation(new QPropertyAnimation(this, "maximumHeight")); diff --git a/noether_gui/src/widgets/tpp_pipeline_widget.cpp b/noether_gui/src/widgets/tpp_pipeline_widget.cpp index d6ef56ba..60006b40 100644 --- a/noether_gui/src/widgets/tpp_pipeline_widget.cpp +++ b/noether_gui/src/widgets/tpp_pipeline_widget.cpp @@ -68,12 +68,12 @@ TPPPipelineWidget::TPPPipelineWidget(boost_plugin_loader::PluginLoader loader, Q ui_->group_box_tpp->setTitle(text); if (text.isEmpty()) { - overwriteWidget(ui_->group_box_tpp->layout(), ui_->widget_tpp, new QWidget(this)); + ui_->scroll_area->setWidget(new QWidget(this)); } else { auto plugin = loader_.createInstance(text.toStdString()); - overwriteWidget(ui_->group_box_tpp->layout(), ui_->widget_tpp, plugin->create(this)); + ui_->scroll_area->setWidget(plugin->create(this)); } } catch (const std::exception& ex) @@ -98,7 +98,7 @@ void TPPPipelineWidget::configure(const YAML::Node& config) auto tpp_config = config[TOOL_PATH_PLANNER_KEY]; auto name = getEntry(tpp_config, "name"); auto plugin = loader_.createInstance(name); - overwriteWidget(ui_->group_box_tpp->layout(), ui_->widget_tpp, plugin->create(this, tpp_config)); + ui_->scroll_area->setWidget(plugin->create(this, tpp_config)); ui_->group_box_tpp->setTitle(QString::fromStdString(name)); } catch (const std::exception&) @@ -112,7 +112,7 @@ void TPPPipelineWidget::configure(const YAML::Node& config) catch (const std::exception&) { // Clear the widgets - overwriteWidget(ui_->group_box_tpp->layout(), ui_->widget_tpp, new QWidget(this)); + ui_->scroll_area->setWidget(new QWidget(this)); mesh_modifier_loader_widget_->removeWidgets(); tool_path_modifier_loader_widget_->removeWidgets(); @@ -131,7 +131,7 @@ void TPPPipelineWidget::save(YAML::Node& config) const // Tool path planner { - auto tpp_widget = dynamic_cast(ui_->widget_tpp); + auto tpp_widget = dynamic_cast(ui_->scroll_area->widget()); if (tpp_widget) { YAML::Node tpp_config; @@ -151,7 +151,7 @@ void TPPPipelineWidget::save(YAML::Node& config) const ToolPathPlannerPipeline TPPPipelineWidget::createPipeline() const { - auto widget_tpp = dynamic_cast(ui_->widget_tpp); + auto widget_tpp = dynamic_cast(ui_->scroll_area->widget()); if (!widget_tpp) throw std::runtime_error("No tool path planner specified"); diff --git a/noether_gui/src/widgets/tpp_widget.cpp b/noether_gui/src/widgets/tpp_widget.cpp index e39a0fa1..afc2b09a 100644 --- a/noether_gui/src/widgets/tpp_widget.cpp +++ b/noether_gui/src/widgets/tpp_widget.cpp @@ -48,7 +48,7 @@ TPPWidget::TPPWidget(boost_plugin_loader::PluginLoader loader, QWidget* parent) { ui_->setupUi(this); - ui_->scroll_area->setWidget(pipeline_widget_); + overwriteWidget(ui_->group_box_configuration->layout(), ui_->widget, pipeline_widget_); ui_->splitter->addWidget(render_widget_); // Set up the VTK objects diff --git a/noether_gui/ui/plugin_loader_widget.ui b/noether_gui/ui/plugin_loader_widget.ui index 7a554bcd..7720f4fe 100644 --- a/noether_gui/ui/plugin_loader_widget.ui +++ b/noether_gui/ui/plugin_loader_widget.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 340 + 159 @@ -47,24 +47,25 @@ - + + + true + + + + + 0 + 0 + 296 + 68 + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/noether_gui/ui/tpp_pipeline_widget.ui b/noether_gui/ui/tpp_pipeline_widget.ui index 13420e3a..37caaf5e 100644 --- a/noether_gui/ui/tpp_pipeline_widget.ui +++ b/noether_gui/ui/tpp_pipeline_widget.ui @@ -61,9 +61,29 @@ - + - + + + Qt::ScrollBarAlwaysOff + + + true + + + Qt::AlignHCenter|Qt::AlignTop + + + + + 0 + 0 + 364 + 289 + + + + diff --git a/noether_gui/ui/tpp_widget.ui b/noether_gui/ui/tpp_widget.ui index f1447db0..b40e5d52 100644 --- a/noether_gui/ui/tpp_widget.ui +++ b/noether_gui/ui/tpp_widget.ui @@ -6,8 +6,8 @@ 0 0 - 1070 - 614 + 215 + 344 @@ -63,36 +63,7 @@ - - - - 0 - 0 - - - - - 16777215 - 1024 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 1024 - 278 - - - - + @@ -186,7 +157,6 @@ line_edit_mesh push_button_load_mesh - scroll_area push_button_plan double_spin_box_axis_size check_box_show_original_mesh From a1fb794982c215e51634e55ea777259c17cfec10 Mon Sep 17 00:00:00 2001 From: Michael Ripperger Date: Thu, 28 Dec 2023 11:26:53 -0600 Subject: [PATCH 4/6] Exposed TPP pipeline methods in configurable TPP widget --- .../widgets/configurable_tpp_pipeline_widget.h | 12 +++++++++++- .../configurable_tpp_pipeline_widget.cpp | 17 +++++++++++++---- noether_gui/src/widgets/tpp_widget.cpp | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h b/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h index dd6a9f0e..e1dc4504 100644 --- a/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h +++ b/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h @@ -2,12 +2,18 @@ #include #include +#include namespace Ui { class ConfigurableTPPPipeline; } +namespace YAML +{ +class Node; +} + namespace noether { class TPPPipelineWidget; @@ -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 diff --git a/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp b/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp index 291ddb22..c5fcced6 100644 --- a/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp +++ b/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp @@ -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&) { @@ -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) diff --git a/noether_gui/src/widgets/tpp_widget.cpp b/noether_gui/src/widgets/tpp_widget.cpp index afc2b09a..08ef5f73 100644 --- a/noether_gui/src/widgets/tpp_widget.cpp +++ b/noether_gui/src/widgets/tpp_widget.cpp @@ -234,7 +234,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 From ebf0f8fa7af133be1ab0c04fba64c98e19c724d7 Mon Sep 17 00:00:00 2001 From: Michael Ripperger Date: Thu, 28 Dec 2023 16:54:16 -0600 Subject: [PATCH 5/6] Added function to configure from file --- .../configurable_tpp_pipeline_widget.h | 1 + .../configurable_tpp_pipeline_widget.cpp | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h b/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h index e1dc4504..e389040e 100644 --- a/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h +++ b/noether_gui/include/noether_gui/widgets/configurable_tpp_pipeline_widget.h @@ -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: diff --git a/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp b/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp index c5fcced6..77805730 100644 --- a/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp +++ b/noether_gui/src/widgets/configurable_tpp_pipeline_widget.cpp @@ -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) From 9b119204ecc9637066b7442a651833a2fcf7d437 Mon Sep 17 00:00:00 2001 From: Michael Ripperger Date: Wed, 3 Jan 2024 10:28:45 -0600 Subject: [PATCH 6/6] Show app maximized --- noether_gui/src/tpp_app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noether_gui/src/tpp_app.cpp b/noether_gui/src/tpp_app.cpp index 0b787b13..33cb69b3 100644 --- a/noether_gui/src/tpp_app.cpp +++ b/noether_gui/src/tpp_app.cpp @@ -49,7 +49,7 @@ int main(int argc, char** argv) // Set the TPP widget as the central widget and show w.setCentralWidget(widget); - w.show(); + w.showMaximized(); return app.exec(); }