From d9e518f0aefc0e0a1d9b2fc731e4d2aa40b3e135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Schmitt?= Date: Mon, 27 Jun 2016 19:01:47 +0200 Subject: [PATCH 1/3] updated uis for plugins Export and VMFS. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Étienne Schmitt --- schnapps/plugins/export/export_dialog.ui | 454 +++++----- .../volume_mesh_from_surface/CMakeLists.txt | 4 +- .../volume_mesh_from_surface/cgal_export.ui | 809 ++++++++++++++++++ .../volume_mesh_from_surface/export_dialog.ui | 87 ++ .../volume_mesh_from_surface/tetgen_export.ui | 98 +++ .../volume_mesh_from_surface.cpp | 46 +- .../volume_mesh_from_surface.h | 9 +- .../volume_mesh_from_surface.ui | 771 ----------------- .../volume_mesh_from_surface_dialog.cpp | 283 ++++++ ...ab.h => volume_mesh_from_surface_dialog.h} | 33 +- .../volume_mesh_from_surface_dock_tab.cpp | 245 ------ 11 files changed, 1584 insertions(+), 1255 deletions(-) create mode 100644 schnapps/plugins/volume_mesh_from_surface/cgal_export.ui create mode 100644 schnapps/plugins/volume_mesh_from_surface/export_dialog.ui create mode 100644 schnapps/plugins/volume_mesh_from_surface/tetgen_export.ui delete mode 100644 schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.ui create mode 100644 schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp rename schnapps/plugins/volume_mesh_from_surface/{volume_mesh_from_surface_dock_tab.h => volume_mesh_from_surface_dialog.h} (75%) delete mode 100644 schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.cpp diff --git a/schnapps/plugins/export/export_dialog.ui b/schnapps/plugins/export/export_dialog.ui index aa455f4..f3fb797 100644 --- a/schnapps/plugins/export/export_dialog.ui +++ b/schnapps/plugins/export/export_dialog.ui @@ -6,230 +6,254 @@ 0 0 - 550 - 550 + 353 + 446 Export Map - - - - 20 - 50 - 331 - 362 - - - - - - - - - map - - - - - - + + + + + + + + + + 150 + 0 + + + + map + + + + + + + + -select map- + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 150 + 0 + + + + position attribute + + + + + + + + -select attribute- + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 150 + 0 + + + + other vertex attributes + + + + + + + + + + + + + + + 150 + 0 + + - -select map- + other cell attributes + + + + + + + + + + + + + + + 150 + 0 + - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - position attribute - - - - - - - -select attribute- + output + + + + + + + -select output- + + + + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + ... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + binary + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + compress + + + + + + + Qt::Horizontal + + + + 40 + 20 + - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - other vertex attributes - - - - - - - - - - - - - - other cell attributes - - - - - - - - - - - - - - output - - - - - - - -select output- - - - - - - - - 32 - 0 - - - - - 32 - 16777215 - - - - ... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - binary - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - compress - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - true - - - - - + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + diff --git a/schnapps/plugins/volume_mesh_from_surface/CMakeLists.txt b/schnapps/plugins/volume_mesh_from_surface/CMakeLists.txt index c28a8f0..8d8da2e 100644 --- a/schnapps/plugins/volume_mesh_from_surface/CMakeLists.txt +++ b/schnapps/plugins/volume_mesh_from_surface/CMakeLists.txt @@ -19,13 +19,13 @@ set(HEADER_FILES dll.h tetgen_structure_io.h volume_mesh_from_surface.h - volume_mesh_from_surface_dock_tab.h + volume_mesh_from_surface_dialog.h ) set(SOURCE_FILES tetgen_structure_io.cpp volume_mesh_from_surface.cpp - volume_mesh_from_surface_dock_tab.cpp + volume_mesh_from_surface_dialog.cpp ) if(CGAL_FOUND) diff --git a/schnapps/plugins/volume_mesh_from_surface/cgal_export.ui b/schnapps/plugins/volume_mesh_from_surface/cgal_export.ui new file mode 100644 index 0000000..edfb580 --- /dev/null +++ b/schnapps/plugins/volume_mesh_from_surface/cgal_export.ui @@ -0,0 +1,809 @@ + + + Dialog_cgal + + + + 0 + 0 + 455 + 386 + + + + Export with cgal + + + + + + 0 + + + + general + + + + 0 + + + 9 + + + 9 + + + + + + + + 160 + 0 + + + + cell size + + + + + + + 4 + + + 999.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + cell radius edge ratio + + + + + + + 4 + + + 999.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + + 160 + 0 + + + + facet angle + + + + + + + 4 + + + 180.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + + 160 + 0 + + + + facet size + + + + + + + 4 + + + 999.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + facet distance + + + + + + + 4 + + + 999.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + odt + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Lloyd smoothing + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + perturber + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + exuder + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + odt + + + + 0 + + + + + freeze + + + + + + + + + + 160 + 0 + + + + max iteration + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + convergence + + + + + + + 3 + + + 0.010000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + Freeze bound + + + + + + + 3 + + + 0.010000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Lloyd + + + + 0 + + + + + freeze + + + + + + + + + + 160 + 0 + + + + freeze bound + + + + + + + 3 + + + 0.010000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + convergence + + + + + + + 3 + + + 0.010000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + max iteration + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + misc + + + + 0 + + + + + + + + 160 + 0 + + + + exuder sliver bound + + + + + + + 3 + + + 0.010000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 160 + 0 + + + + perturber sliver bound + + + + + + + 3 + + + 0.010000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + + + buttonBox + accepted() + Dialog_cgal + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog_cgal + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui b/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui new file mode 100644 index 0000000..b237bf4 --- /dev/null +++ b/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui @@ -0,0 +1,87 @@ + + + Dialog_export + + + + 0 + 0 + 270 + 124 + + + + Make Mesh + + + + + + + + + 40 + 0 + + + + boundary + + + + + + + + -select map- + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + generate with tetgen + + + + + + + generate with cgal + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/schnapps/plugins/volume_mesh_from_surface/tetgen_export.ui b/schnapps/plugins/volume_mesh_from_surface/tetgen_export.ui new file mode 100644 index 0000000..708ba6d --- /dev/null +++ b/schnapps/plugins/volume_mesh_from_surface/tetgen_export.ui @@ -0,0 +1,98 @@ + + + Dialog_tetgen + + + + 0 + 0 + 281 + 92 + + + + Export with tetgen + + + + + + + + command line + + + + + + + -pqY + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + buttonBox + accepted() + Dialog_tetgen + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog_tetgen + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp index 4d3a6c0..11ba87f 100644 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp @@ -65,27 +65,40 @@ MapParameters::MapParameters() : bool Plugin_VolumeMeshFromSurface::enable() { - dock_tab_ = cgogn::make_unique(this->schnapps_, this); - schnapps_->add_plugin_dock_tab(this, dock_tab_.get(), "Volume Mesh From Surface"); + if (!dialog_) + dialog_ = cgogn::make_unique(schnapps_, this); + + gen_mesh_action_ = schnapps_->add_menu_action("Export;Tetrahedralize", "Tetrahedralize"); + connect(gen_mesh_action_, SIGNAL(triggered()), dialog_.get(), SLOT(show_export_dialog())); + + schnapps_->foreach_map([&](MapHandlerGen* mhg) + { + dialog_->map_added(mhg); + }); + return true; } void Plugin_VolumeMeshFromSurface::disable() { - schnapps_->remove_plugin_dock_tab(this, dock_tab_.get()); - dock_tab_.reset(); + schnapps_->remove_menu_action(gen_mesh_action_); } void Plugin_VolumeMeshFromSurface::selected_map_changed(MapHandlerGen*, MapHandlerGen* curr) { - const MapParameters& p = parameter_set_[curr]; - dock_tab_->update_map_parameters(curr, p); + if (curr) + { + const MapParameters& p = parameter_set_[curr]; + dialog_->update_map_parameters(curr, p); + selected_map_ = curr->get_name(); + } else + selected_map_ = QString(); } void Plugin_VolumeMeshFromSurface::generate_button_tetgen_pressed() { - using namespace CGAL::parameters; - MapHandler2* handler_map2 = dynamic_cast(schnapps_->get_selected_map()); + MapHandlerGen* mhg = schnapps_->get_map(selected_map_); + MapHandler2* handler_map2 = dynamic_cast(mhg); if (handler_map2) { Map2* map = handler_map2->get_map(); @@ -105,10 +118,14 @@ void Plugin_VolumeMeshFromSurface::generate_button_tetgen_pressed() void Plugin_VolumeMeshFromSurface::generate_button_cgal_pressed() { #ifdef PLUGIN_VMFS_WITH_CGAL - const MapParameters& param = this->parameter_set_[schnapps_->get_selected_map()]; - MapHandler2* mh2 = dynamic_cast(schnapps_->get_selected_map()); - MapHandler3* mh3 = dynamic_cast(schnapps_->add_map("cgal_export", 3)); - tetrahedralize(param, mh2, "position", mh3); + MapHandlerGen* mhg = schnapps_->get_map(selected_map_); + if (mhg) + { + const MapParameters& param = this->parameter_set_[mhg]; + MapHandler2* mh2 = dynamic_cast(mhg); + MapHandler3* mh3 = dynamic_cast(schnapps_->add_map("cgal_export", 3)); + tetrahedralize(param, mh2, "position", mh3); + } #endif // PLUGIN_VMFS_WITH_CGAL } @@ -117,5 +134,10 @@ void Plugin_VolumeMeshFromSurface::tetgen_args_updated(QString str) this->tetgen_args = std::move(str); } +void Plugin_VolumeMeshFromSurface::remove_map(MapHandlerGen* mhg) +{ + this->parameter_set_.erase(mhg); +} + } // namespace plugin_vmfs } // namespace schnapps diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h index 35da4de..ec85b6f 100644 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h @@ -26,7 +26,7 @@ #define SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_H_ #include "dll.h" -#include +#include #include #include @@ -76,7 +76,7 @@ class SCHNAPPS_PLUGIN_VMFS_API Plugin_VolumeMeshFromSurface : public PluginProce Q_PLUGIN_METADATA(IID "SCHNApps.Plugin") Q_INTERFACES(schnapps::Plugin) - friend class VolumeMeshFromSurface_DockTab; + friend class VolumeMeshFromSurfaceDialog; public: using Map2 = schnapps::CMap2; using Map3 = schnapps::CMap3; @@ -87,9 +87,11 @@ class SCHNAPPS_PLUGIN_VMFS_API Plugin_VolumeMeshFromSurface : public PluginProce virtual bool enable() override; virtual void disable() override; + QAction* gen_mesh_action_; std::map parameter_set_; - std::unique_ptr dock_tab_; + std::unique_ptr dialog_; QString tetgen_args; + QString selected_map_; private slots: void selected_map_changed(MapHandlerGen*, MapHandlerGen*); @@ -98,6 +100,7 @@ public slots: void generate_button_tetgen_pressed(); void generate_button_cgal_pressed(); void tetgen_args_updated(QString str); + void remove_map(MapHandlerGen*); }; } // namespace plugin_vmfs diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.ui b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.ui deleted file mode 100644 index 3db5506..0000000 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.ui +++ /dev/null @@ -1,771 +0,0 @@ - - - VolumeMeshFromSurface_TabWidget - - - - 0 - 0 - 323 - 860 - - - - Form - - - - - - Qt::Vertical - - - - 156 - 161 - - - - - - - - 0 - - - - - tetgen - - - Qt::AlignCenter - - - - - - - - - command line - - - - - - - -pqY - - - - - - - - - generate mesh (tetgen) - - - - - - - - - 6 - - - - - cgal - - - Qt::AlignCenter - - - - - - - generate mesh (cgal) - - - - - - - - - cell size - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 4 - - - 999.000000000000000 - - - 0.100000000000000 - - - - - - - - - - - cell radius edge ratio - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 4 - - - 999.000000000000000 - - - 0.100000000000000 - - - - - - - - - 0 - - - - - facet angle - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 4 - - - 180.000000000000000 - - - 0.100000000000000 - - - - - - - - - 0 - - - - - facet size - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 4 - - - 999.000000000000000 - - - 0.100000000000000 - - - - - - - - - - - facet distance - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 4 - - - 999.000000000000000 - - - 0.100000000000000 - - - - - - - - - Qt::Horizontal - - - - - - - - - Qt::Vertical - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - odt - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - freeze - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - max -iteration - - - - - - - - - - - - - - Convergence - - - - - - - 3 - - - 0.010000000000000 - - - - - - - - - - - Freeze -Bound - - - - - - - 3 - - - 0.010000000000000 - - - - - - - - - - - Qt::Vertical - - - - - - - - - Qt::Horizontal - - - - - - - - - Qt::Vertical - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Lloyd -smoothing - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - freeze - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - max -iteration - - - - - - - - - - - - - - Convergence - - - - - - - 3 - - - 0.010000000000000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Freeze -Bound - - - - - - - 3 - - - 0.010000000000000 - - - - - - - - - - - Qt::Vertical - - - - - - - - - Qt::Horizontal - - - - - - - - - Qt::Vertical - - - - - - - - - perturber - - - - - - - Qt::Horizontal - - - - - - - exuder - - - - - - - - - - - - - Sliver Bound - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 3 - - - 0.010000000000000 - - - - - - - - - Qt::Horizontal - - - - - - - - - Sliver bound - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 3 - - - 0.010000000000000 - - - - - - - - - - - Qt::Vertical - - - - - - - - - Qt::Horizontal - - - - - - - - - - diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp new file mode 100644 index 0000000..0266f50 --- /dev/null +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp @@ -0,0 +1,283 @@ +/******************************************************************************* +* SCHNApps * +* Copyright (C) 2016, IGG Group, ICube, University of Strasbourg, France * +* Plugin Volume Mesh From Surface * +* Author Etienne Schmitt (etienne.schmitt@inria.fr) Inria/Mimesis * +* This library is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by the * +* Free Software Foundation; either version 2.1 of the License, or (at your * +* option) any later version. * +* * +* This library is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this library; if not, write to the Free Software Foundation, * +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * +* * +* Web site: http://cgogn.unistra.fr/ * +* Contact information: cgogn@unistra.fr * +* * +*******************************************************************************/ + +#define SCHNAPPS_PLUGIN_VMFS_DLL_EXPORT + +#include +#include +#include +#include + +namespace schnapps +{ + +namespace plugin_vmfs +{ + +VolumeMeshFromSurfaceDialog::VolumeMeshFromSurfaceDialog(SCHNApps* s, Plugin_VolumeMeshFromSurface* p) : + schnapps_(s), + plugin_(p), + updating_ui_(false) +{ + export_dialog_ = cgogn::make_unique(); + cgal_dialog_ = cgogn::make_unique(); + tetgen_dialog_ = cgogn::make_unique(); + + this->export_dialog_->setupUi(export_dialog_.get()); + this->cgal_dialog_->setupUi(cgal_dialog_.get()); + this->tetgen_dialog_->setupUi(tetgen_dialog_.get()); + + connect(this->export_dialog_->comboBoxMapSelection, SIGNAL(currentIndexChanged(QString)), this, SLOT(selected_map_changed(QString))); + connect(this->export_dialog_->pushButton_gen_volume_meshTetgen, SIGNAL(pressed()), this->tetgen_dialog_.get(), SLOT(show())); + connect(this->export_dialog_->pushButtonGenMeshCGAL, SIGNAL(pressed()), this->cgal_dialog_.get(), SLOT(show())); + + connect(this->export_dialog_->pushButton_gen_volume_meshTetgen, SIGNAL(pressed()), this->export_dialog_.get(), SLOT(hide())); + connect(this->export_dialog_->pushButtonGenMeshCGAL, SIGNAL(pressed()), this->export_dialog_.get(), SLOT(hide())); + + connect(this->tetgen_dialog_->buttonBox,SIGNAL(accepted()), plugin_, SLOT(generate_button_tetgen_pressed())); + connect(this->cgal_dialog_->buttonBox, SIGNAL(accepted()), plugin_, SLOT(generate_button_cgal_pressed())); + connect(this->tetgen_dialog_->lineEdit_tetgen_args, SIGNAL(textChanged(QString)), plugin_, SLOT(tetgen_args_updated(QString))); + + connect(this->cgal_dialog_->doubleSpinBox_CellSize, SIGNAL(valueChanged(double)), this, SLOT(cell_size_changed(double))); + connect(this->cgal_dialog_->doubleSpinBox_Radius, SIGNAL(valueChanged(double)), this, SLOT(cell_radius_edge_ratio_changed(double))); + connect(this->cgal_dialog_->doubleSpinBoxFacetAngle, SIGNAL(valueChanged(double)), this, SLOT(facet_angle_changed(double))); + connect(this->cgal_dialog_->doubleSpinBox_FacetSize, SIGNAL(valueChanged(double)), this, SLOT(facet_size_changed(double))); + connect(this->cgal_dialog_->doubleSpinBox_3FacetDistance, SIGNAL(valueChanged(double)), this, SLOT(facet_distance_changed(double))); + + connect(this->cgal_dialog_->checkBox_ODT, SIGNAL(toggled(bool)), this, SLOT(odt_changed(bool))); + connect(this->cgal_dialog_->checkBox_FreezeODT, SIGNAL(toggled(bool)), this, SLOT(odt_freeze_changed(bool))); + connect(this->cgal_dialog_->spinBox_ODTMaxIter, SIGNAL(valueChanged(int)), this, SLOT(odt_max_iter_changed(int))); + connect(this->cgal_dialog_->doubleSpinBox_OdtConvergence, SIGNAL(valueChanged(double)), this, SLOT(odt_convergence_changed(double))); + connect(this->cgal_dialog_->doubleSpinBox_8OdtFreeze, SIGNAL(valueChanged(double)), this, SLOT(odt_freeze_bound_changed(double))); + + connect(this->cgal_dialog_->checkBoxLloyd, SIGNAL(toggled(bool)), this, SLOT(lloyd_changed(bool))); + connect(this->cgal_dialog_->checkBox_FreezeLloyd, SIGNAL(toggled(bool)), this, SLOT(lloyd_freeze_changed(bool))); + connect(this->cgal_dialog_->spinBoxMaxITLloyd, SIGNAL(valueChanged(int)), this, SLOT(lloyd_max_iter_changed(int))); + connect(this->cgal_dialog_->doubleSpinBox_ConvergenceLloyd, SIGNAL(valueChanged(double)), this, SLOT(lloyd_convergence_changed(double))); + connect(this->cgal_dialog_->doubleSpinBox_FreezeBoundLLoyd, SIGNAL(valueChanged(double)), this, SLOT(lloyd_freeze_bound_changed(double))); + + connect(this->cgal_dialog_->checkBox_Perturber, SIGNAL(toggled(bool)), this, SLOT(perturber_changed(bool))); + connect(this->cgal_dialog_->doubleSpinBox_PerturberSliver, SIGNAL(valueChanged(double)), this, SLOT(perturber_sliver_changed(double))); + + connect(this->cgal_dialog_->checkBox_5Exuder, SIGNAL(toggled(bool)), this, SLOT(exuder_changed(bool))); + connect(this->cgal_dialog_->doubleSpinBox_ExuderSliver, SIGNAL(valueChanged(double)), this, SLOT(exuder_sliver_changed(double))); + + connect(schnapps_, SIGNAL(map_added(MapHandlerGen*)), this, SLOT(map_added(MapHandlerGen*))); + connect(schnapps_, SIGNAL(map_removed(MapHandlerGen*)), this, SLOT(map_removed(MapHandlerGen*))); + + this->export_dialog_->pushButton_gen_volume_meshTetgen->setDisabled(true); + this->export_dialog_->pushButtonGenMeshCGAL->setDisabled(true); + +} + +void VolumeMeshFromSurfaceDialog::show_export_dialog() +{ + this->export_dialog_->show(); +} + +void VolumeMeshFromSurfaceDialog::map_added(MapHandlerGen* mhg) +{ + if (mhg) + this->export_dialog_->comboBoxMapSelection->addItem(mhg->get_name()); +} + +void VolumeMeshFromSurfaceDialog::map_removed(MapHandlerGen* mhg) +{ + if (mhg) + { + this->export_dialog_->comboBoxMapSelection->removeItem(this->export_dialog_->comboBoxMapSelection->findText(mhg->get_name())); + plugin_->remove_map(mhg); + } + +} + +void VolumeMeshFromSurfaceDialog::selected_map_changed(QString map_name) +{ + MapHandlerGen* mhg = schnapps_->get_map(map_name); + plugin_->selected_map_changed(nullptr, mhg); + if (mhg && dynamic_cast*>(mhg)) + { + this->export_dialog_->pushButton_gen_volume_meshTetgen->setDisabled(false); + this->export_dialog_->pushButtonGenMeshCGAL->setDisabled(false); + } else { + this->export_dialog_->pushButton_gen_volume_meshTetgen->setDisabled(true); + this->export_dialog_->pushButtonGenMeshCGAL->setDisabled(true); + } + update_map_parameters(mhg, plugin_->parameter_set_[mhg]); +} + +void VolumeMeshFromSurfaceDialog::cell_size_changed(double cs) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].cell_size_ = cs; +} + +void VolumeMeshFromSurfaceDialog::cell_radius_edge_ratio_changed(double ratio) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].cell_radius_edge_ratio_ = ratio; +} + +void VolumeMeshFromSurfaceDialog::facet_angle_changed(double fa) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].facet_angle_ = fa; +} + +void VolumeMeshFromSurfaceDialog::facet_size_changed(double fs) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].facet_size_ = fs; +} + +void VolumeMeshFromSurfaceDialog::facet_distance_changed(double fd) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].facet_distance_ = fd; +} + +void VolumeMeshFromSurfaceDialog::odt_changed(bool b) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].do_odt_ = b; + this->cgal_dialog_->doubleSpinBox_OdtConvergence->setDisabled(!b); + this->cgal_dialog_->spinBox_ODTMaxIter->setDisabled(!b); + this->cgal_dialog_->checkBox_FreezeODT->setDisabled(!b); + this->cgal_dialog_->doubleSpinBox_8OdtFreeze->setDisabled(!b); + +} + +void VolumeMeshFromSurfaceDialog::odt_freeze_changed(bool b) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].do_odt_freeze_ = b; + this->cgal_dialog_->doubleSpinBox_8OdtFreeze->setDisabled(!b); +} + +void VolumeMeshFromSurfaceDialog::odt_max_iter_changed(int nb_it) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].odt_max_iter_ = nb_it; +} + +void VolumeMeshFromSurfaceDialog::odt_convergence_changed(double cv) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].odt_convergence_ = cv; +} + +void VolumeMeshFromSurfaceDialog::odt_freeze_bound_changed(double fb) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].odt_freeze_bound_ = fb; +} + +void VolumeMeshFromSurfaceDialog::lloyd_changed(bool b) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].do_lloyd_ = b; + this->cgal_dialog_->doubleSpinBox_FreezeBoundLLoyd->setDisabled(!b); + this->cgal_dialog_->doubleSpinBox_ConvergenceLloyd->setDisabled(!b); + this->cgal_dialog_->spinBoxMaxITLloyd->setDisabled(!b); + this->cgal_dialog_->checkBox_FreezeLloyd->setDisabled(!b); +} + +void VolumeMeshFromSurfaceDialog::lloyd_freeze_changed(bool b) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].do_lloyd_freeze_ = b; + this->cgal_dialog_->doubleSpinBox_FreezeBoundLLoyd->setDisabled(!b); +} + +void VolumeMeshFromSurfaceDialog::lloyd_max_iter_changed(int nb_it) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].lloyd_max_iter_ = nb_it; +} + +void VolumeMeshFromSurfaceDialog::lloyd_convergence_changed(double cv) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].lloyd_convergence_ = cv; +} + +void VolumeMeshFromSurfaceDialog::lloyd_freeze_bound_changed(double fb) +{ + plugin_->parameter_set_[schnapps_->get_selected_map()].lloyd_freeze_bound_ = fb; +} + +void VolumeMeshFromSurfaceDialog::perturber_changed(bool b) +{ + this->cgal_dialog_->doubleSpinBox_PerturberSliver->setDisabled(!b); + plugin_->parameter_set_[schnapps_->get_selected_map()].do_perturber_ = b; +} + +void VolumeMeshFromSurfaceDialog::perturber_sliver_changed(double sb) +{ + this->cgal_dialog_->doubleSpinBox_PerturberSliver->setValue(sb); +} + +void VolumeMeshFromSurfaceDialog::exuder_changed(bool b) +{ + this->cgal_dialog_->doubleSpinBox_ExuderSliver->setDisabled(!b); + plugin_->parameter_set_[schnapps_->get_selected_map()].do_exuder_ = b; +} + +void VolumeMeshFromSurfaceDialog::exuder_sliver_changed(double sb) +{ + this->cgal_dialog_->doubleSpinBox_ExuderSliver->setValue(sb); +} + +void VolumeMeshFromSurfaceDialog::update_map_parameters(MapHandlerGen* map, const MapParameters& p) +{ + updating_ui_ = true; + if (map && dynamic_cast*>(map)) + { + plugin_->tetgen_args_updated(QString::fromStdString(p.tetgen_command_line)); + + this->cgal_dialog_->doubleSpinBox_CellSize->setValue(p.cell_size_); + this->cgal_dialog_->doubleSpinBox_Radius->setValue(p.cell_radius_edge_ratio_); + this->cgal_dialog_->doubleSpinBoxFacetAngle->setValue(p.facet_angle_); + this->cgal_dialog_->doubleSpinBox_FacetSize->setValue(p.facet_size_); + this->cgal_dialog_->doubleSpinBox_3FacetDistance->setValue(p.facet_distance_); + + this->cgal_dialog_->checkBox_ODT->setChecked(p.do_odt_); + this->cgal_dialog_->checkBox_FreezeODT->setChecked(p.do_odt_freeze_); + this->cgal_dialog_->spinBox_ODTMaxIter->setValue(p.odt_max_iter_); + this->cgal_dialog_->doubleSpinBox_OdtConvergence->setValue(p.odt_convergence_); + this->cgal_dialog_->doubleSpinBox_8OdtFreeze->setValue(p.odt_freeze_bound_); + this->cgal_dialog_->doubleSpinBox_OdtConvergence->setDisabled(!p.do_odt_); + this->cgal_dialog_->spinBox_ODTMaxIter->setDisabled(!p.do_odt_); + this->cgal_dialog_->checkBox_FreezeODT->setDisabled(!p.do_odt_); + this->cgal_dialog_->checkBox_ODT->setDisabled(!p.do_odt_); + + this->cgal_dialog_->checkBoxLloyd->setChecked(p.do_lloyd_); + this->cgal_dialog_->checkBox_FreezeLloyd->setChecked(p.do_lloyd_freeze_); + this->cgal_dialog_->spinBoxMaxITLloyd->setValue(p.lloyd_max_iter_); + this->cgal_dialog_->doubleSpinBox_ConvergenceLloyd->setValue(p.lloyd_convergence_); + this->cgal_dialog_->doubleSpinBox_FreezeBoundLLoyd->setValue(p.lloyd_freeze_bound_); + this->cgal_dialog_->doubleSpinBox_FreezeBoundLLoyd->setDisabled(!p.do_lloyd_); + this->cgal_dialog_->doubleSpinBox_ConvergenceLloyd->setDisabled(!p.do_lloyd_); + this->cgal_dialog_->spinBoxMaxITLloyd->setDisabled(!p.do_lloyd_); + this->cgal_dialog_->checkBox_FreezeLloyd->setDisabled(!p.do_lloyd_); + + this->cgal_dialog_->checkBox_Perturber->setChecked(p.do_perturber_); + this->cgal_dialog_->doubleSpinBox_PerturberSliver->setValue(p.perturber_sliver_bound_); + this->cgal_dialog_->doubleSpinBox_PerturberSliver->setDisabled(!p.do_perturber_); + + this->cgal_dialog_->checkBox_5Exuder->setChecked(p.do_exuder_); + this->cgal_dialog_->doubleSpinBox_ExuderSliver->setValue(p.exuder_sliver_bound_); + this->cgal_dialog_->doubleSpinBox_ExuderSliver->setDisabled(!p.do_exuder_); + } + updating_ui_ = false; +} + +} // namespace plugin_vmfs +} // namespace schnapps diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.h b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.h similarity index 75% rename from schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.h rename to schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.h index e85e624..d0ce464 100644 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.h +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.h @@ -21,12 +21,14 @@ * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ -#ifndef SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_VECTOR_DOCK_TAB_H_ -#define SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_VECTOR_DOCK_TAB_H_ +#ifndef SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_VECTOR_DIALOG_H_ +#define SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_VECTOR_DIALOG_H_ #include "dll.h" #include -#include +#include +#include +#include namespace schnapps { @@ -40,7 +42,16 @@ namespace plugin_vmfs class Plugin_VolumeMeshFromSurface; struct MapParameters; -class SCHNAPPS_PLUGIN_VMFS_API VolumeMeshFromSurface_DockTab : public QWidget, public Ui::VolumeMeshFromSurface_TabWidget +class SCHNAPPS_PLUGIN_VMFS_API ExportDialog : public QDialog, public Ui::Dialog_export +{}; + +class SCHNAPPS_PLUGIN_VMFS_API ExportTetgenDialog : public QDialog, public Ui::Dialog_tetgen +{}; + +class SCHNAPPS_PLUGIN_VMFS_API ExportCGALDialog : public QDialog, public Ui::Dialog_cgal +{}; + +class SCHNAPPS_PLUGIN_VMFS_API VolumeMeshFromSurfaceDialog : QObject { Q_OBJECT @@ -48,7 +59,7 @@ class SCHNAPPS_PLUGIN_VMFS_API VolumeMeshFromSurface_DockTab : public QWidget, p public: - VolumeMeshFromSurface_DockTab(SCHNApps* s, Plugin_VolumeMeshFromSurface* p); + VolumeMeshFromSurfaceDialog(SCHNApps* s, Plugin_VolumeMeshFromSurface* p); private: @@ -56,9 +67,11 @@ class SCHNAPPS_PLUGIN_VMFS_API VolumeMeshFromSurface_DockTab : public QWidget, p Plugin_VolumeMeshFromSurface* plugin_; bool updating_ui_; +public slots: + void show_export_dialog(); private slots: - void selected_map_changed(MapHandlerGen*, MapHandlerGen*); + void selected_map_changed(QString map_name); void cell_size_changed(double cs); void cell_radius_edge_ratio_changed(double ratio); @@ -83,11 +96,17 @@ private slots: void exuder_changed(bool b); void exuder_sliver_changed(double sb); + void map_added(MapHandlerGen* mhg); + void map_removed(MapHandlerGen* mhg); private: void update_map_parameters(MapHandlerGen* map, const MapParameters& p); + + std::unique_ptr cgal_dialog_; + std::unique_ptr tetgen_dialog_; + std::unique_ptr export_dialog_; }; } // namespace plugin_vmfs } // namespace schnapps -#endif // SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_VECTOR_DOCK_TAB_H_ +#endif // SCHNAPPS_PLUGIN_VOLUME_MESH_FROM_SURFACE_VECTOR_DIALOG_H_ diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.cpp b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.cpp deleted file mode 100644 index a13158a..0000000 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dock_tab.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* -* SCHNApps * -* Copyright (C) 2016, IGG Group, ICube, University of Strasbourg, France * -* Plugin Volume Mesh From Surface * -* Author Etienne Schmitt (etienne.schmitt@inria.fr) Inria/Mimesis * -* This library is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by the * -* Free Software Foundation; either version 2.1 of the License, or (at your * -* option) any later version. * -* * -* This library is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this library; if not, write to the Free Software Foundation, * -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * -* * -* Web site: http://cgogn.unistra.fr/ * -* Contact information: cgogn@unistra.fr * -* * -*******************************************************************************/ - -#define SCHNAPPS_PLUGIN_VMFS_DLL_EXPORT - -#include -#include -#include -#include - -namespace schnapps -{ - -namespace plugin_vmfs -{ - -VolumeMeshFromSurface_DockTab::VolumeMeshFromSurface_DockTab(SCHNApps* s, Plugin_VolumeMeshFromSurface* p) : - schnapps_(s), - plugin_(p), - updating_ui_(false) -{ - setupUi(this); - connect(schnapps_, SIGNAL(selected_map_changed(MapHandlerGen*, MapHandlerGen*)), this, SLOT(selected_map_changed(MapHandlerGen*, MapHandlerGen*))); - connect(this->pushButton_gen_volume_meshTetgen,SIGNAL(pressed()), plugin_, SLOT(generate_button_tetgen_pressed())); - connect(this->pushButtonGenMeshCGAL, SIGNAL(pressed()), plugin_, SLOT(generate_button_cgal_pressed())); - connect(this->lineEdit_tetgen_args, SIGNAL(textChanged(QString)), plugin_, SLOT(tetgen_args_updated(QString))); - - - connect(this->doubleSpinBox_CellSize, SIGNAL(valueChanged(double)), this, SLOT(cell_size_changed(double))); - connect(this->doubleSpinBox_Radius, SIGNAL(valueChanged(double)), this, SLOT(cell_radius_edge_ratio_changed(double))); - connect(this->doubleSpinBoxFacetAngle, SIGNAL(valueChanged(double)), this, SLOT(facet_angle_changed(double))); - connect(this->doubleSpinBox_FacetSize, SIGNAL(valueChanged(double)), this, SLOT(facet_size_changed(double))); - connect(this->doubleSpinBox_3FacetDistance, SIGNAL(valueChanged(double)), this, SLOT(facet_distance_changed(double))); - - connect(this->checkBox_ODT, SIGNAL(toggled(bool)), this, SLOT(odt_changed(bool))); - connect(this->checkBox_FreezeODT, SIGNAL(toggled(bool)), this, SLOT(odt_freeze_changed(bool))); - connect(this->spinBox_ODTMaxIter, SIGNAL(valueChanged(int)), this, SLOT(odt_max_iter_changed(int))); - connect(this->doubleSpinBox_OdtConvergence, SIGNAL(valueChanged(double)), this, SLOT(odt_convergence_changed(double))); - connect(this->doubleSpinBox_8OdtFreeze, SIGNAL(valueChanged(double)), this, SLOT(odt_freeze_bound_changed(double))); - - connect(this->checkBoxLloyd, SIGNAL(toggled(bool)), this, SLOT(lloyd_changed(bool))); - connect(this->checkBox_FreezeLloyd, SIGNAL(toggled(bool)), this, SLOT(lloyd_freeze_changed(bool))); - connect(this->spinBoxMaxITLloyd, SIGNAL(valueChanged(int)), this, SLOT(lloyd_max_iter_changed(int))); - connect(this->doubleSpinBox_ConvergenceLloyd, SIGNAL(valueChanged(double)), this, SLOT(lloyd_convergence_changed(double))); - connect(this->doubleSpinBox_FreezeBoundLLoyd, SIGNAL(valueChanged(double)), this, SLOT(lloyd_freeze_bound_changed(double))); - - connect(this->checkBox_Perturber, SIGNAL(toggled(bool)), this, SLOT(perturber_changed(bool))); - connect(this->doubleSpinBox_PerturberSliver, SIGNAL(valueChanged(double)), this, SLOT(perturber_sliver_changed(double))); - - connect(this->checkBox_5Exuder, SIGNAL(toggled(bool)), this, SLOT(exuder_changed(bool))); - connect(this->doubleSpinBox_ExuderSliver, SIGNAL(valueChanged(double)), this, SLOT(exuder_sliver_changed(double))); - - this->selected_map_changed(nullptr, schnapps_->get_selected_map()); -} - -void VolumeMeshFromSurface_DockTab::selected_map_changed(MapHandlerGen*, MapHandlerGen* curr) -{ - if (curr && dynamic_cast(curr->get_map())) - { - this->pushButton_gen_volume_meshTetgen->setDisabled(false); - this->pushButtonGenMeshCGAL->setDisabled(false); - this->lineEdit_tetgen_args->setDisabled(false); - } else { - this->pushButton_gen_volume_meshTetgen->setDisabled(true); - this->pushButtonGenMeshCGAL->setDisabled(true); - this->lineEdit_tetgen_args->setDisabled(true); - } - update_map_parameters(curr, plugin_->parameter_set_[curr]); -} - -void VolumeMeshFromSurface_DockTab::cell_size_changed(double cs) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].cell_size_ = cs; -} - -void VolumeMeshFromSurface_DockTab::cell_radius_edge_ratio_changed(double ratio) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].cell_radius_edge_ratio_ = ratio; -} - -void VolumeMeshFromSurface_DockTab::facet_angle_changed(double fa) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].facet_angle_ = fa; -} - -void VolumeMeshFromSurface_DockTab::facet_size_changed(double fs) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].facet_size_ = fs; -} - -void VolumeMeshFromSurface_DockTab::facet_distance_changed(double fd) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].facet_distance_ = fd; -} - -void VolumeMeshFromSurface_DockTab::odt_changed(bool b) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].do_odt_ = b; - this->doubleSpinBox_OdtConvergence->setDisabled(!b); - this->spinBox_ODTMaxIter->setDisabled(!b); - this->checkBox_FreezeODT->setDisabled(!b); - this->doubleSpinBox_8OdtFreeze->setDisabled(!b); - -} - -void VolumeMeshFromSurface_DockTab::odt_freeze_changed(bool b) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].do_odt_freeze_ = b; - this->doubleSpinBox_8OdtFreeze->setDisabled(!b); -} - -void VolumeMeshFromSurface_DockTab::odt_max_iter_changed(int nb_it) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].odt_max_iter_ = nb_it; -} - -void VolumeMeshFromSurface_DockTab::odt_convergence_changed(double cv) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].odt_convergence_ = cv; -} - -void VolumeMeshFromSurface_DockTab::odt_freeze_bound_changed(double fb) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].odt_freeze_bound_ = fb; -} - -void VolumeMeshFromSurface_DockTab::lloyd_changed(bool b) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].do_lloyd_ = b; - this->doubleSpinBox_FreezeBoundLLoyd->setDisabled(!b); - this->doubleSpinBox_ConvergenceLloyd->setDisabled(!b); - this->spinBoxMaxITLloyd->setDisabled(!b); - this->checkBox_FreezeLloyd->setDisabled(!b); -} - -void VolumeMeshFromSurface_DockTab::lloyd_freeze_changed(bool b) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].do_lloyd_freeze_ = b; - this->doubleSpinBox_FreezeBoundLLoyd->setDisabled(!b); -} - -void VolumeMeshFromSurface_DockTab::lloyd_max_iter_changed(int nb_it) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].lloyd_max_iter_ = nb_it; -} - -void VolumeMeshFromSurface_DockTab::lloyd_convergence_changed(double cv) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].lloyd_convergence_ = cv; -} - -void VolumeMeshFromSurface_DockTab::lloyd_freeze_bound_changed(double fb) -{ - plugin_->parameter_set_[schnapps_->get_selected_map()].lloyd_freeze_bound_ = fb; -} - -void VolumeMeshFromSurface_DockTab::perturber_changed(bool b) -{ - this->doubleSpinBox_PerturberSliver->setDisabled(!b); - plugin_->parameter_set_[schnapps_->get_selected_map()].do_perturber_ = b; -} - -void VolumeMeshFromSurface_DockTab::perturber_sliver_changed(double sb) -{ - this->doubleSpinBox_PerturberSliver->setValue(sb); -} - -void VolumeMeshFromSurface_DockTab::exuder_changed(bool b) -{ - this->doubleSpinBox_ExuderSliver->setDisabled(!b); - plugin_->parameter_set_[schnapps_->get_selected_map()].do_exuder_ = b; -} - -void VolumeMeshFromSurface_DockTab::exuder_sliver_changed(double sb) -{ - this->doubleSpinBox_ExuderSliver->setValue(sb); -} - -void VolumeMeshFromSurface_DockTab::update_map_parameters(MapHandlerGen* map, const MapParameters& p) -{ - updating_ui_ = true; - if (map && dynamic_cast*>(map)) - { - plugin_->tetgen_args_updated(QString::fromStdString(p.tetgen_command_line)); - - this->doubleSpinBox_CellSize->setValue(p.cell_size_); - this->doubleSpinBox_Radius->setValue(p.cell_radius_edge_ratio_); - this->doubleSpinBoxFacetAngle->setValue(p.facet_angle_); - this->doubleSpinBox_FacetSize->setValue(p.facet_size_); - this->doubleSpinBox_3FacetDistance->setValue(p.facet_distance_); - - this->checkBox_ODT->setChecked(p.do_odt_); - this->checkBox_FreezeODT->setChecked(p.do_odt_freeze_); - this->spinBox_ODTMaxIter->setValue(p.odt_max_iter_); - this->doubleSpinBox_OdtConvergence->setValue(p.odt_convergence_); - this->doubleSpinBox_8OdtFreeze->setValue(p.odt_freeze_bound_); - this->doubleSpinBox_OdtConvergence->setDisabled(!p.do_odt_); - this->spinBox_ODTMaxIter->setDisabled(!p.do_odt_); - this->checkBox_FreezeODT->setDisabled(!p.do_odt_); - this->checkBox_ODT->setDisabled(!p.do_odt_); - - this->checkBoxLloyd->setChecked(p.do_lloyd_); - this->checkBox_FreezeLloyd->setChecked(p.do_lloyd_freeze_); - this->spinBoxMaxITLloyd->setValue(p.lloyd_max_iter_); - this->doubleSpinBox_ConvergenceLloyd->setValue(p.lloyd_convergence_); - this->doubleSpinBox_FreezeBoundLLoyd->setValue(p.lloyd_freeze_bound_); - this->doubleSpinBox_FreezeBoundLLoyd->setDisabled(!p.do_lloyd_); - this->doubleSpinBox_ConvergenceLloyd->setDisabled(!p.do_lloyd_); - this->spinBoxMaxITLloyd->setDisabled(!p.do_lloyd_); - this->checkBox_FreezeLloyd->setDisabled(!p.do_lloyd_); - - this->checkBox_Perturber->setChecked(p.do_perturber_); - this->doubleSpinBox_PerturberSliver->setValue(p.perturber_sliver_bound_); - this->doubleSpinBox_PerturberSliver->setDisabled(!p.do_perturber_); - - this->checkBox_5Exuder->setChecked(p.do_exuder_); - this->doubleSpinBox_ExuderSliver->setValue(p.exuder_sliver_bound_); - this->doubleSpinBox_ExuderSliver->setDisabled(!p.do_exuder_); - } - updating_ui_ = false; -} - -} // namespace plugin_vmfs -} // namespace schnapps From 9d5d247a23377765fb5a4236426f2d8815be4679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Schmitt?= Date: Tue, 28 Jun 2016 15:36:54 +0200 Subject: [PATCH 2/3] fixed crash when checking "draw" or "draw path" and no camera selected. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Étienne Schmitt --- schnapps/core/control_dock_camera_tab.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/schnapps/core/control_dock_camera_tab.cpp b/schnapps/core/control_dock_camera_tab.cpp index d006b20..7ea3ce5 100644 --- a/schnapps/core/control_dock_camera_tab.cpp +++ b/schnapps/core/control_dock_camera_tab.cpp @@ -49,6 +49,9 @@ ControlDock_CameraTab::ControlDock_CameraTab(SCHNApps* s) : // connect SCHNApps signals connect(schnapps_, SIGNAL(camera_added(Camera*)), this, SLOT(camera_added(Camera*))); connect(schnapps_, SIGNAL(camera_removed(Camera*)), this, SLOT(camera_removed(Camera*))); + + check_drawCamera->setDisabled(true); + check_drawCameraPath->setDisabled(true); } void ControlDock_CameraTab::add_camera_button_clicked() @@ -83,6 +86,9 @@ void ControlDock_CameraTab::selected_camera_changed() else selected_camera_ = nullptr; + check_drawCamera->setDisabled(selected_camera_ == nullptr); + check_drawCameraPath->setDisabled(selected_camera_ == nullptr); + update_selected_camera_info(); } } @@ -100,13 +106,13 @@ void ControlDock_CameraTab::camera_projection_changed(QAbstractButton* b) void ControlDock_CameraTab::camera_draw_clicked(bool b) { - if (!updating_ui_) + if (!updating_ui_ && selected_camera_) selected_camera_->set_draw(b); } void ControlDock_CameraTab::camera_draw_path_clicked(bool b) { - if (!updating_ui_) + if (!updating_ui_&& selected_camera_) selected_camera_->set_draw_path(b); } @@ -173,6 +179,9 @@ void ControlDock_CameraTab::selected_camera_draw_path_changed(bool b) void ControlDock_CameraTab::update_selected_camera_info() { + if (!selected_camera_) + return; + updating_ui_ = true; if (selected_camera_->get_projection_type() == qoglviewer::Camera::PERSPECTIVE) From feea180ad18f94c81950b6961d7c18d3cb6a37a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Schmitt?= Date: Tue, 28 Jun 2016 18:00:52 +0200 Subject: [PATCH 3/3] plugin vmfs : asking for position attribute. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Étienne Schmitt --- .../cgal/cgogn_surface_to_cgal_polyhedron.cpp | 4 ++ .../volume_mesh_from_surface/export_dialog.ui | 43 ++++++++++++++++++- .../volume_mesh_from_surface.cpp | 24 +++++------ .../volume_mesh_from_surface.h | 3 -- .../volume_mesh_from_surface_dialog.cpp | 19 +++++--- 5 files changed, 70 insertions(+), 23 deletions(-) diff --git a/schnapps/plugins/volume_mesh_from_surface/cgal/cgogn_surface_to_cgal_polyhedron.cpp b/schnapps/plugins/volume_mesh_from_surface/cgal/cgogn_surface_to_cgal_polyhedron.cpp index 2a256b6..ad8c82e 100644 --- a/schnapps/plugins/volume_mesh_from_surface/cgal/cgogn_surface_to_cgal_polyhedron.cpp +++ b/schnapps/plugins/volume_mesh_from_surface/cgal/cgogn_surface_to_cgal_polyhedron.cpp @@ -47,7 +47,11 @@ void PolyhedronBuilder::operator()(HalfedgeDS& hds) const auto pos_att = map_->get_attribute(QString::fromStdString(pos_att_name_)); if (!pos_att.is_valid()) + { + cgogn_log_info("PolyhedronBuilder") << "The position attribute has to be of type VEC3."; return; + } + uint32 id{0u}; auto id_attribute = map_->add_attribute("ids_polyhedron_builder"); diff --git a/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui b/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui index b237bf4..500dbde 100644 --- a/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui +++ b/schnapps/plugins/volume_mesh_from_surface/export_dialog.ui @@ -7,7 +7,7 @@ 0 0 270 - 124 + 162 @@ -20,7 +20,7 @@ - 40 + 64 0 @@ -53,6 +53,45 @@ + + + + + + + 64 + 0 + + + + position + + + + + + + + -select attribute- + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp index 11ba87f..196a550 100644 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.cpp @@ -84,17 +84,6 @@ void Plugin_VolumeMeshFromSurface::disable() schnapps_->remove_menu_action(gen_mesh_action_); } -void Plugin_VolumeMeshFromSurface::selected_map_changed(MapHandlerGen*, MapHandlerGen* curr) -{ - if (curr) - { - const MapParameters& p = parameter_set_[curr]; - dialog_->update_map_parameters(curr, p); - selected_map_ = curr->get_name(); - } else - selected_map_ = QString(); -} - void Plugin_VolumeMeshFromSurface::generate_button_tetgen_pressed() { MapHandlerGen* mhg = schnapps_->get_map(selected_map_); @@ -102,7 +91,15 @@ void Plugin_VolumeMeshFromSurface::generate_button_tetgen_pressed() if (handler_map2) { Map2* map = handler_map2->get_map(); - auto tetgen_input = export_tetgen(*map, map->template get_attribute("position")); + const std::string& position_att_name = dialog_->export_dialog_->comboBoxPositionSelection->currentText().toStdString(); + auto position_att = map->template get_attribute(position_att_name); + + if (!position_att.is_valid()) + { + cgogn_log_info("Plugin_VolumeMeshFromSurface") << "The position attribute has to be of type VEC3."; + return; + } + auto tetgen_input = export_tetgen(*map, position_att); tetgenio tetgen_output; tetrahedralize(this->tetgen_args.toStdString().c_str(), tetgen_input.get(), &tetgen_output); @@ -124,7 +121,8 @@ void Plugin_VolumeMeshFromSurface::generate_button_cgal_pressed() const MapParameters& param = this->parameter_set_[mhg]; MapHandler2* mh2 = dynamic_cast(mhg); MapHandler3* mh3 = dynamic_cast(schnapps_->add_map("cgal_export", 3)); - tetrahedralize(param, mh2, "position", mh3); + const std::string& position_att_name = dialog_->export_dialog_->comboBoxPositionSelection->currentText().toStdString(); + tetrahedralize(param, mh2, position_att_name, mh3); } #endif // PLUGIN_VMFS_WITH_CGAL } diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h index ec85b6f..bea9016 100644 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface.h @@ -93,9 +93,6 @@ class SCHNAPPS_PLUGIN_VMFS_API Plugin_VolumeMeshFromSurface : public PluginProce QString tetgen_args; QString selected_map_; -private slots: - void selected_map_changed(MapHandlerGen*, MapHandlerGen*); - public slots: void generate_button_tetgen_pressed(); void generate_button_cgal_pressed(); diff --git a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp index 0266f50..21300fd 100644 --- a/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp +++ b/schnapps/plugins/volume_mesh_from_surface/volume_mesh_from_surface_dialog.cpp @@ -98,13 +98,13 @@ void VolumeMeshFromSurfaceDialog::show_export_dialog() void VolumeMeshFromSurfaceDialog::map_added(MapHandlerGen* mhg) { - if (mhg) + if (mhg && dynamic_cast*>(mhg)) this->export_dialog_->comboBoxMapSelection->addItem(mhg->get_name()); } void VolumeMeshFromSurfaceDialog::map_removed(MapHandlerGen* mhg) { - if (mhg) + if (mhg && dynamic_cast*>(mhg)) { this->export_dialog_->comboBoxMapSelection->removeItem(this->export_dialog_->comboBoxMapSelection->findText(mhg->get_name())); plugin_->remove_map(mhg); @@ -115,16 +115,26 @@ void VolumeMeshFromSurfaceDialog::map_removed(MapHandlerGen* mhg) void VolumeMeshFromSurfaceDialog::selected_map_changed(QString map_name) { MapHandlerGen* mhg = schnapps_->get_map(map_name); - plugin_->selected_map_changed(nullptr, mhg); + if (mhg && dynamic_cast*>(mhg)) { + const MapParameters& p = plugin_->parameter_set_[mhg]; + update_map_parameters(mhg, p); + plugin_->selected_map_ = mhg->get_name(); this->export_dialog_->pushButton_gen_volume_meshTetgen->setDisabled(false); this->export_dialog_->pushButtonGenMeshCGAL->setDisabled(false); + + this->export_dialog_->comboBoxPositionSelection->clear(); + const auto& vert_att_cont = mhg->const_attribute_container(CellType::Vertex_Cell); + for (const auto& att_name : vert_att_cont.names()) + this->export_dialog_->comboBoxPositionSelection->addItem(QString::fromStdString(att_name)); + } else { + plugin_->selected_map_ = QString(); this->export_dialog_->pushButton_gen_volume_meshTetgen->setDisabled(true); this->export_dialog_->pushButtonGenMeshCGAL->setDisabled(true); } - update_map_parameters(mhg, plugin_->parameter_set_[mhg]); + } void VolumeMeshFromSurfaceDialog::cell_size_changed(double cs) @@ -159,7 +169,6 @@ void VolumeMeshFromSurfaceDialog::odt_changed(bool b) this->cgal_dialog_->spinBox_ODTMaxIter->setDisabled(!b); this->cgal_dialog_->checkBox_FreezeODT->setDisabled(!b); this->cgal_dialog_->doubleSpinBox_8OdtFreeze->setDisabled(!b); - } void VolumeMeshFromSurfaceDialog::odt_freeze_changed(bool b)