From 0450dc07bbba53cc727d8e8e9304ed58cdaf1bfb Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Feb 2020 23:41:21 +0100 Subject: [PATCH] Mesh: replace stacked widget of meshing panel with tabbed widget --- src/Mod/MeshPart/Gui/Tessellation.cpp | 39 +++++------------ src/Mod/MeshPart/Gui/Tessellation.h | 9 ++-- src/Mod/MeshPart/Gui/Tessellation.ui | 60 +++++++++++---------------- 3 files changed, 41 insertions(+), 67 deletions(-) diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 68259a8882..4e3fa0fc53 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -25,7 +25,6 @@ #ifndef _PreComp_ # include # include -# include #endif #include "Tessellation.h" @@ -55,13 +54,6 @@ Tessellation::Tessellation(QWidget* parent) { ui->setupUi(this); - buttonGroup = new QButtonGroup(this); - buttonGroup->addButton(ui->radioButtonStandard, 0); - buttonGroup->addButton(ui->radioButtonMefisto, 1); - buttonGroup->addButton(ui->radioButtonNetgen, 2); - connect(buttonGroup, SIGNAL(buttonClicked(int)), - this, SLOT(meshingMethod(int))); - ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Mod/Mesh/Meshing/Standard"); double value = ui->spinSurfaceDeviation->value().getValue(); @@ -78,33 +70,23 @@ Tessellation::Tessellation(QWidget* parent) ui->spinMaximumEdgeLength->setRange(0, INT_MAX); - // set the standard method - ui->radioButtonStandard->setChecked(true); ui->comboFineness->setCurrentIndex(2); on_comboFineness_currentIndexChanged(2); #if !defined (HAVE_MEFISTO) - ui->radioButtonMefisto->setDisabled(true); -#else - ui->radioButtonMefisto->setChecked(true); + ui->stackedWidget->setTabEnabled(Mefisto, false); #endif #if !defined (HAVE_NETGEN) - ui->radioButtonNetgen->setDisabled(true); -#else - ui->radioButtonNetgen->setChecked(true); + ui->stackedWidget->setTabEnabled(Netgen, false); #endif Gui::Command::doCommand(Gui::Command::Doc, "import Mesh, Part, PartGui"); try { Gui::Command::doCommand(Gui::Command::Doc, "import MeshPart"); } - catch(...) { - ui->radioButtonNetgen->setDisabled(true); - ui->radioButtonMefisto->setDisabled(true); - ui->radioButtonStandard->setChecked(true); + catch (...) { + ui->stackedWidget->setDisabled(true); } - - meshingMethod(buttonGroup->checkedId()); } Tessellation::~Tessellation() @@ -255,10 +237,10 @@ bool Tessellation::accept() QString objname, label, subname; Gui::WaitCursor wc; - int method = buttonGroup->checkedId(); + int method = ui->stackedWidget->currentIndex(); // Save parameters - if (method == 0) { + if (method == Standard) { ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Mod/Mesh/Meshing/Standard"); double value = ui->spinSurfaceDeviation->value().getValue(); @@ -288,7 +270,7 @@ bool Tessellation::accept() Gui::Application::Instance->getViewProvider(sobj)); QString param; - if (method == 0) { // Standard + if (method == Standard) { // Standard double devFace = ui->spinSurfaceDeviation->value().getValue(); double devAngle = ui->spinAngularDeviation->value().getValue(); devAngle = Base::toRadians(devAngle); @@ -319,13 +301,13 @@ bool Tessellation::accept() QString::fromLatin1(sobj->getNameInDocument())); } } - else if (method == 1) { // Mefisto + else if (method == Mefisto) { // Mefisto double maxEdge = ui->spinMaximumEdgeLength->value().getValue(); if (!ui->spinMaximumEdgeLength->isEnabled()) maxEdge = 0; param = QString::fromLatin1("Shape=__shape__,MaxLength=%1").arg(maxEdge); } - else if (method == 2) { // Netgen + else if (method == Netgen) { // Netgen int fineness = ui->comboFineness->currentIndex(); double growthRate = ui->doubleGrading->value(); double nbSegPerEdge = ui->spinEdgeElements->value(); @@ -370,7 +352,7 @@ bool Tessellation::accept() Gui::Command::runCommand(Gui::Command::Doc, cmd.toUtf8()); // if Standard mesher is used and face colors should be applied - if (method == 0) { // Standard + if (method == Standard) { // Standard if (ui->meshShapeColors->isChecked()) { Gui::ViewProvider* vpm = Gui::Application::Instance->getViewProvider (activeDoc->getActiveObject()); @@ -394,6 +376,7 @@ bool Tessellation::accept() activeDoc->commitTransaction(); } catch (const Base::Exception& e) { + activeDoc->abortTransaction(); Base::Console().Error(e.what()); } diff --git a/src/Mod/MeshPart/Gui/Tessellation.h b/src/Mod/MeshPart/Gui/Tessellation.h index 6b9bdc1f88..17c07b59d5 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.h +++ b/src/Mod/MeshPart/Gui/Tessellation.h @@ -30,8 +30,6 @@ #include #include -class QButtonGroup; - namespace MeshPartGui { class Ui_Tessellation; @@ -39,6 +37,12 @@ class Tessellation : public QWidget { Q_OBJECT + enum { + Standard, + Mefisto, + Netgen + }; + public: Tessellation(QWidget* parent = 0); ~Tessellation(); @@ -56,7 +60,6 @@ private Q_SLOTS: private: QString document; - QButtonGroup* buttonGroup; std::unique_ptr ui; }; diff --git a/src/Mod/MeshPart/Gui/Tessellation.ui b/src/Mod/MeshPart/Gui/Tessellation.ui index 2a95fcbacc..4971bc48e8 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.ui +++ b/src/Mod/MeshPart/Gui/Tessellation.ui @@ -20,42 +20,18 @@ Meshing options - - - - Use the standard mesher - - - Standard - - - - - - - Use the Mefisto mesher - - - Mefisto - - - - - - - Use the Netgen mesher - - - Netgen - - - - - + + 0 + + Standard + + + Use the standard mesher + @@ -165,10 +141,12 @@ this feature (e.g. the format OBJ). - - If this number is smaller the mesh becomes finer. -The smallest value is 0. - + + Mefisto + + + Use the Mefisto mesher + @@ -180,6 +158,10 @@ The smallest value is 0. true + + If this number is smaller the mesh becomes finer. +The smallest value is 0. + @@ -220,6 +202,12 @@ The smallest value is 0. + + Netgen + + + Use the Netgen mesher +