diff --git a/src/Mod/MeshPart/Gui/CrossSections.cpp b/src/Mod/MeshPart/Gui/CrossSections.cpp index 94c9dec0ab..4fdc946351 100644 --- a/src/Mod/MeshPart/Gui/CrossSections.cpp +++ b/src/Mod/MeshPart/Gui/CrossSections.cpp @@ -172,6 +172,8 @@ CrossSections::CrossSections(const Base::BoundBox3d& bb, QWidget* parent, Qt::Wi { ui = new Ui_CrossSections(); ui->setupUi(this); + setupConnections(); + ui->position->setRange(-DBL_MAX, DBL_MAX); ui->position->setUnit(Base::Unit::Length); ui->distance->setRange(0, DBL_MAX); @@ -203,6 +205,27 @@ CrossSections::~CrossSections() delete vp; } +void CrossSections::setupConnections() +{ + connect(ui->xyPlane, &QRadioButton::clicked, + this, &CrossSections::xyPlaneClicked); + connect(ui->xzPlane, &QRadioButton::clicked, + this, &CrossSections::xzPlaneClicked); + connect(ui->yzPlane, &QRadioButton::clicked, + this, &CrossSections::yzPlaneClicked); + connect(ui->position, qOverload(&Gui::QuantitySpinBox::valueChanged), + this, &CrossSections::positionValueChanged); + connect(ui->distance, qOverload(&Gui::QuantitySpinBox::valueChanged), + this, &CrossSections::distanceValueChanged); + connect(ui->countSections, qOverload(&QSpinBox::valueChanged), + this, &CrossSections::countSectionsValueChanged); + connect(ui->checkBothSides, &QCheckBox::toggled, + this, &CrossSections::checkBothSidesToggled); + connect(ui->sectionsBox, &QGroupBox::toggled, + this, &CrossSections::sectionsBoxToggled); + +} + CrossSections::Plane CrossSections::plane() const { if (ui->xyPlane->isChecked()) @@ -345,7 +368,7 @@ void CrossSections::apply() #endif } -void CrossSections::on_xyPlane_clicked() +void CrossSections::xyPlaneClicked() { Base::Vector3d c = bbox.GetCenter(); ui->position->setValue(c.z); @@ -361,7 +384,7 @@ void CrossSections::on_xyPlane_clicked() } } -void CrossSections::on_xzPlane_clicked() +void CrossSections::xzPlaneClicked() { Base::Vector3d c = bbox.GetCenter(); ui->position->setValue(c.y); @@ -377,7 +400,7 @@ void CrossSections::on_xzPlane_clicked() } } -void CrossSections::on_yzPlane_clicked() +void CrossSections::yzPlaneClicked() { Base::Vector3d c = bbox.GetCenter(); ui->position->setValue(c.x); @@ -393,7 +416,7 @@ void CrossSections::on_yzPlane_clicked() } } -void CrossSections::on_position_valueChanged(double v) +void CrossSections::positionValueChanged(double v) { if (!ui->sectionsBox->isChecked()) { calcPlane(plane(), v); @@ -403,10 +426,10 @@ void CrossSections::on_position_valueChanged(double v) } } -void CrossSections::on_sectionsBox_toggled(bool b) +void CrossSections::sectionsBoxToggled(bool ok) { - if (b) { - on_countSections_valueChanged(ui->countSections->value()); + if (ok) { + countSectionsValueChanged(ui->countSections->value()); } else { CrossSections::Plane type = plane(); @@ -429,7 +452,7 @@ void CrossSections::on_sectionsBox_toggled(bool b) } } -void CrossSections::on_checkBothSides_toggled(bool b) +void CrossSections::checkBothSidesToggled(bool b) { double d = ui->distance->value().getValue(); d = b ? 2.0 * d : 0.5 * d; @@ -437,7 +460,7 @@ void CrossSections::on_checkBothSides_toggled(bool b) calcPlanes(plane()); } -void CrossSections::on_countSections_valueChanged(int v) +void CrossSections::countSectionsValueChanged(int v) { CrossSections::Plane type = plane(); double dist = 0; @@ -458,7 +481,7 @@ void CrossSections::on_countSections_valueChanged(int v) calcPlanes(type); } -void CrossSections::on_distance_valueChanged(double) +void CrossSections::distanceValueChanged(double) { calcPlanes(plane()); } diff --git a/src/Mod/MeshPart/Gui/CrossSections.h b/src/Mod/MeshPart/Gui/CrossSections.h index dfb139771b..ccee279409 100644 --- a/src/Mod/MeshPart/Gui/CrossSections.h +++ b/src/Mod/MeshPart/Gui/CrossSections.h @@ -55,15 +55,16 @@ protected: void changeEvent(QEvent *e) override; void keyPressEvent(QKeyEvent*) override; -private Q_SLOTS: - void on_xyPlane_clicked(); - void on_xzPlane_clicked(); - void on_yzPlane_clicked(); - void on_position_valueChanged(double); - void on_distance_valueChanged(double); - void on_countSections_valueChanged(int); - void on_checkBothSides_toggled(bool); - void on_sectionsBox_toggled(bool); +private: + void setupConnections(); + void xyPlaneClicked(); + void xzPlaneClicked(); + void yzPlaneClicked(); + void positionValueChanged(double); + void distanceValueChanged(double); + void countSectionsValueChanged(int); + void checkBothSidesToggled(bool); + void sectionsBoxToggled(bool); private: std::vector getPlanes() const; diff --git a/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp b/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp index ad07bced3a..40d30e661f 100644 --- a/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp @@ -38,6 +38,8 @@ CurveOnMeshWidget::CurveOnMeshWidget(Gui::View3DInventor* view, QWidget* parent) , myView(view) { ui->setupUi(this); + connect(ui->startButton, &QPushButton::clicked, + this, &CurveOnMeshWidget::onStartButtonClicked); this->setup(); } @@ -74,7 +76,7 @@ void CurveOnMeshWidget::changeEvent(QEvent *e) } } -void CurveOnMeshWidget::on_startButton_clicked() +void CurveOnMeshWidget::onStartButtonClicked() { int cont = ui->continuity->itemData(ui->continuity->currentIndex()).toInt(); myCurveHandler->enableApproximation(ui->groupBox_2->isChecked()); diff --git a/src/Mod/MeshPart/Gui/TaskCurveOnMesh.h b/src/Mod/MeshPart/Gui/TaskCurveOnMesh.h index 8f6f88923b..0b1f7aaa5d 100644 --- a/src/Mod/MeshPart/Gui/TaskCurveOnMesh.h +++ b/src/Mod/MeshPart/Gui/TaskCurveOnMesh.h @@ -53,8 +53,8 @@ protected: void changeEvent(QEvent *e) override; void setup(); -private Q_SLOTS: - void on_startButton_clicked(); +private: + void onStartButtonClicked(); private: Ui_TaskCurveOnMesh* ui; diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 520968a5c1..7b6b367781 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -56,7 +56,7 @@ Tessellation::Tessellation(QWidget* parent) { ui->setupUi(this); gmsh = new Mesh2ShapeGmsh(this); - connect(gmsh, &Mesh2ShapeGmsh::processed, this, &Tessellation::gmshProcessed); + setupConnections(); ui->stackedWidget->addTab(gmsh, tr("Gmsh")); @@ -77,7 +77,7 @@ Tessellation::Tessellation(QWidget* parent) ui->spinMaximumEdgeLength->setRange(0, INT_MAX); ui->comboFineness->setCurrentIndex(2); - on_comboFineness_currentIndexChanged(2); + onComboFinenessCurrentIndexChanged(2); #if !defined (HAVE_MEFISTO) ui->stackedWidget->setTabEnabled(Mefisto, false); @@ -100,12 +100,25 @@ Tessellation::~Tessellation() { } +void Tessellation::setupConnections() +{ + connect(gmsh, &Mesh2ShapeGmsh::processed, this, &Tessellation::gmshProcessed); + connect(ui->estimateMaximumEdgeLength, &QPushButton::clicked, + this, &Tessellation::onEstimateMaximumEdgeLengthClicked); + connect(ui->comboFineness, qOverload(&QComboBox::currentIndexChanged), + this, &Tessellation::onComboFinenessCurrentIndexChanged); + connect(ui->checkSecondOrder, &QCheckBox::toggled, + this, &Tessellation::onCheckSecondOrderToggled); + connect(ui->checkQuadDominated, &QCheckBox::toggled, + this, &Tessellation::onCheckQuadDominatedToggled); +} + void Tessellation::meshingMethod(int id) { ui->stackedWidget->setCurrentIndex(id); } -void Tessellation::on_comboFineness_currentIndexChanged(int index) +void Tessellation::onComboFinenessCurrentIndexChanged(int index) { if (index == 5) { ui->doubleGrading->setEnabled(true); @@ -119,27 +132,27 @@ void Tessellation::on_comboFineness_currentIndexChanged(int index) } switch (index) { - case 0: // Very coarse + case VeryCoarse: ui->doubleGrading->setValue(0.7); ui->spinEdgeElements->setValue(0.3); ui->spinCurvatureElements->setValue(1.0); break; - case 1: // Coarse + case Coarse: ui->doubleGrading->setValue(0.5); ui->spinEdgeElements->setValue(0.5); ui->spinCurvatureElements->setValue(1.5); break; - case 2: // Moderate + case Moderate: ui->doubleGrading->setValue(0.3); ui->spinEdgeElements->setValue(1.0); ui->spinCurvatureElements->setValue(2.0); break; - case 3: // Fine + case Fine: ui->doubleGrading->setValue(0.2); ui->spinEdgeElements->setValue(2.0); ui->spinCurvatureElements->setValue(3.0); break; - case 4: // Very fine + case VeryFine: ui->doubleGrading->setValue(0.1); ui->spinEdgeElements->setValue(3.0); ui->spinCurvatureElements->setValue(5.0); @@ -149,13 +162,13 @@ void Tessellation::on_comboFineness_currentIndexChanged(int index) } } -void Tessellation::on_checkSecondOrder_toggled(bool on) +void Tessellation::onCheckSecondOrderToggled(bool on) { if (on) ui->checkQuadDominated->setChecked(false); } -void Tessellation::on_checkQuadDominated_toggled(bool on) +void Tessellation::onCheckQuadDominatedToggled(bool on) { if (on) ui->checkSecondOrder->setChecked(false); @@ -178,7 +191,7 @@ void Tessellation::changeEvent(QEvent *e) QWidget::changeEvent(e); } -void Tessellation::on_estimateMaximumEdgeLength_clicked() +void Tessellation::onEstimateMaximumEdgeLengthClicked() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); if (!activeDoc) { diff --git a/src/Mod/MeshPart/Gui/Tessellation.h b/src/Mod/MeshPart/Gui/Tessellation.h index e0ffbde1c8..4d2175d42f 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.h +++ b/src/Mod/MeshPart/Gui/Tessellation.h @@ -75,6 +75,14 @@ class Tessellation : public QWidget Gmsh }; + enum { + VeryCoarse = 0, + Coarse = 1, + Moderate = 2, + Fine = 3, + VeryFine = 4 + }; + public: explicit Tessellation(QWidget* parent = nullptr); ~Tessellation() override; @@ -91,12 +99,13 @@ protected: QString getNetgenParameters() const; std::vector getUniqueColors(const std::vector& colors) const; -private Q_SLOTS: +private: + void setupConnections(); void meshingMethod(int id); - void on_estimateMaximumEdgeLength_clicked(); - void on_comboFineness_currentIndexChanged(int); - void on_checkSecondOrder_toggled(bool); - void on_checkQuadDominated_toggled(bool); + void onEstimateMaximumEdgeLengthClicked(); + void onComboFinenessCurrentIndexChanged(int); + void onCheckSecondOrderToggled(bool); + void onCheckQuadDominatedToggled(bool); void gmshProcessed(); private: