Skip to content

Commit

Permalink
Mesh: replace stacked widget of meshing panel with tabbed widget
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 27, 2020
1 parent 8533527 commit ea53563
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 67 deletions.
39 changes: 11 additions & 28 deletions src/Mod/MeshPart/Gui/Tessellation.cpp
Expand Up @@ -25,7 +25,6 @@
#ifndef _PreComp_
# include <TopExp_Explorer.hxx>
# include <QMessageBox>
# include <QButtonGroup>
#endif

#include "Tessellation.h"
Expand Down Expand Up @@ -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();
Expand All @@ -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()
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<double>(devAngle);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand All @@ -394,6 +376,7 @@ bool Tessellation::accept()
activeDoc->commitTransaction();
}
catch (const Base::Exception& e) {
activeDoc->abortTransaction();
Base::Console().Error(e.what());
}

Expand Down
9 changes: 6 additions & 3 deletions src/Mod/MeshPart/Gui/Tessellation.h
Expand Up @@ -30,15 +30,19 @@
#include <App/DocumentObserver.h>
#include <memory>

class QButtonGroup;

namespace MeshPartGui {

class Ui_Tessellation;
class Tessellation : public QWidget
{
Q_OBJECT

enum {
Standard,
Mefisto,
Netgen
};

public:
Tessellation(QWidget* parent = 0);
~Tessellation();
Expand All @@ -56,7 +60,6 @@ private Q_SLOTS:

private:
QString document;
QButtonGroup* buttonGroup;
std::unique_ptr<Ui_Tessellation> ui;
};

Expand Down
60 changes: 24 additions & 36 deletions src/Mod/MeshPart/Gui/Tessellation.ui
Expand Up @@ -20,42 +20,18 @@
<string>Meshing options</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButtonStandard">
<property name="toolTip">
<string>Use the standard mesher</string>
</property>
<property name="text">
<string>Standard</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioButtonMefisto">
<property name="toolTip">
<string>Use the Mefisto mesher</string>
</property>
<property name="text">
<string>Mefisto</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="radioButtonNetgen">
<property name="toolTip">
<string>Use the Netgen mesher</string>
</property>
<property name="text">
<string>Netgen</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QStackedWidget" name="stackedWidget">
<item row="0" column="0" colspan="3">
<widget class="QTabWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageStandard">
<attribute name="title">
<string>Standard</string>
</attribute>
<attribute name="toolTip">
<string>Use the standard mesher</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
Expand Down Expand Up @@ -165,10 +141,12 @@ this feature (e.g. the format OBJ).</string>
</layout>
</widget>
<widget class="QWidget" name="pageMefisto">
<property name="toolTip">
<string>If this number is smaller the mesh becomes finer.
The smallest value is 0.</string>
</property>
<attribute name="title">
<string>Mefisto</string>
</attribute>
<attribute name="toolTip">
<string>Use the Mefisto mesher</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
Expand All @@ -180,6 +158,10 @@ The smallest value is 0.</string>
<property name="checked">
<bool>true</bool>
</property>
<property name="toolTip">
<string>If this number is smaller the mesh becomes finer.
The smallest value is 0.</string>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -220,6 +202,12 @@ The smallest value is 0.</string>
</layout>
</widget>
<widget class="QWidget" name="pageNetgen">
<attribute name="title">
<string>Netgen</string>
</attribute>
<attribute name="toolTip">
<string>Use the Netgen mesher</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
Expand Down

0 comments on commit ea53563

Please sign in to comment.