From 873fa449ce7ad151fa980a99ab22f95a4b9c0e1f Mon Sep 17 00:00:00 2001 From: Leandro Heck <1277920+leoheck@users.noreply.github.com> Date: Wed, 22 Oct 2025 19:00:11 -0300 Subject: [PATCH] PD: Show custom direction settings on Pad/Pocket only when necessary. (#24642) * PD: Show custom direction settings on Pad/Pocket only when necessary. * Update the visibility of parameters. --- .../PartDesign/Gui/TaskExtrudeParameters.cpp | 88 ++++++++++--------- .../PartDesign/Gui/TaskExtrudeParameters.h | 1 - .../PartDesign/Gui/TaskPadPocketParameters.ui | 35 +++----- 3 files changed, 59 insertions(+), 65 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index ad68b7471f..a6128d00b0 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -90,8 +90,6 @@ void TaskExtrudeParameters::setupDialog() ui->ZDirectionEdit->setDecimals(UserDecimals); ui->checkBoxAlongDirection->setChecked(extrude->AlongSketchNormal.getValue()); - ui->checkBoxDirection->setChecked(extrude->UseCustomVector.getValue()); - onDirectionToggled(ui->checkBoxDirection->isChecked()); ui->XDirectionEdit->setValue(extrude->Direction.getValue().x); ui->YDirectionEdit->setValue(extrude->Direction.getValue().y); @@ -312,8 +310,6 @@ void TaskExtrudeParameters::connectSlots() this, &TaskExtrudeParameters::onDirectionCBChanged); connect(ui->checkBoxAlongDirection, &QCheckBox::toggled, this, &TaskExtrudeParameters::onAlongSketchNormalChanged); - connect(ui->checkBoxDirection, &QCheckBox::toggled, - this, &TaskExtrudeParameters::onDirectionToggled); connect(ui->XDirectionEdit, qOverload(&QDoubleSpinBox::valueChanged), this, &TaskExtrudeParameters::onXDirectionEditChanged); connect(ui->YDirectionEdit, qOverload(&QDoubleSpinBox::valueChanged), @@ -732,10 +728,14 @@ void TaskExtrudeParameters::fillDirectionCombo() bool hasCustom = extrude->UseCustomVector.getValue(); if (indexOfCurrent != -1 && !hasCustom) { ui->directionCB->setCurrentIndex(indexOfCurrent); + updateDirectionEdits(); + setDirectionMode(indexOfCurrent); } if (hasCustom) { ui->directionCB->setCurrentIndex(DirectionModes::Custom); + setDirectionMode(ui->directionCB->currentIndex()); } + } void TaskExtrudeParameters::addAxisToCombo(App::DocumentObject* linkObj, @@ -773,10 +773,6 @@ void TaskExtrudeParameters::updateWholeUI(Type type, Side side) // Side 2 is only visible if in TwoSides mode, and we pass whether it should receive focus. updateSideUI(m_side2, type, mode2, isSide2GroupVisible, (side == Side::Second)); - bool side1HasLength = (mode1 == Mode::Dimension); - bool side2HasLength = (sidesMode == SidesMode::TwoSides && mode2 == Mode::Dimension); - ui->checkBoxAlongDirection->setVisible(side1HasLength || side2HasLength); - ui->checkBoxReversed->setEnabled(sidesMode != SidesMode::Symmetric || mode1 != Mode::Dimension); } @@ -909,16 +905,6 @@ void TaskExtrudeParameters::onAlongSketchNormalChanged(bool on) } } -void TaskExtrudeParameters::onDirectionToggled(bool on) -{ - if (on) { - ui->groupBoxDirection->show(); - } - else { - ui->groupBoxDirection->hide(); - } -} - void TaskExtrudeParameters::onAllFacesToggled(bool on, Side side) { auto& sideCtrl = getSideController(side); @@ -992,33 +978,49 @@ void TaskExtrudeParameters::setDirectionMode(int index) return; } - // disable AlongSketchNormal when the direction is already normal - if (index == DirectionModes::Normal) { - ui->checkBoxAlongDirection->setEnabled(false); - } - else { - ui->checkBoxAlongDirection->setEnabled(true); - } + switch (index) { - // if custom direction is used, show it - if (index == DirectionModes::Custom) { - ui->checkBoxDirection->setChecked(true); - extrude->UseCustomVector.setValue(true); - } - else { - extrude->UseCustomVector.setValue(false); - } + case DirectionModes::Normal: + ui->groupBoxDirection->hide(); - // if we don't use custom direction, only allow one to show its direction - if (index != DirectionModes::Custom) { - ui->XDirectionEdit->setEnabled(false); - ui->YDirectionEdit->setEnabled(false); - ui->ZDirectionEdit->setEnabled(false); - } - else { - ui->XDirectionEdit->setEnabled(true); - ui->YDirectionEdit->setEnabled(true); - ui->ZDirectionEdit->setEnabled(true); + extrude->UseCustomVector.setValue(false); + ui->XDirectionEdit->setEnabled(false); + ui->YDirectionEdit->setEnabled(false); + ui->ZDirectionEdit->setEnabled(false); + + ui->checkBoxAlongDirection->setEnabled(false); + ui->checkBoxAlongDirection->hide(); + + break; + + // Covered by the default option + // case DirectionModes::Select: + + case DirectionModes::Custom: + ui->groupBoxDirection->show(); + + extrude->UseCustomVector.setValue(true); + ui->XDirectionEdit->setEnabled(true); + ui->YDirectionEdit->setEnabled(true); + ui->ZDirectionEdit->setEnabled(true); + + ui->checkBoxAlongDirection->setEnabled(true); + ui->checkBoxAlongDirection->show(); + break; + + default: + ui->groupBoxDirection->show(); + + updateDirectionEdits(); + + extrude->UseCustomVector.setValue(false); + ui->XDirectionEdit->setEnabled(false); + ui->YDirectionEdit->setEnabled(false); + ui->ZDirectionEdit->setEnabled(false); + + ui->checkBoxAlongDirection->setEnabled(true); + ui->checkBoxAlongDirection->show(); + break; } } diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h index 7c3937092d..44c486e546 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h @@ -162,7 +162,6 @@ protected Q_SLOTS: private Q_SLOTS: void onDirectionCBChanged(int); void onAlongSketchNormalChanged(bool); - void onDirectionToggled(bool); void onXDirectionEditChanged(double); void onYDirectionEditChanged(double); void onZDirectionEditChanged(double); diff --git a/src/Mod/PartDesign/Gui/TaskPadPocketParameters.ui b/src/Mod/PartDesign/Gui/TaskPadPocketParameters.ui index ba6aa7a858..d19bdd301b 100644 --- a/src/Mod/PartDesign/Gui/TaskPadPocketParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPadPocketParameters.ui @@ -512,6 +512,20 @@ Direction + + + + true + + + If unchecked, the length will be +measured along the specified direction + + + Length along sketch normal + + + @@ -547,13 +561,6 @@ from the model as reference - - - Show direction - - - - true @@ -662,20 +669,6 @@ the sketch plane's normal vector will be used - - - - true - - - If unchecked, the length will be -measured along the specified direction - - - Length along sketch normal - - -