From 4df61e993cd75bda273160624b912d40ebae2410 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Wed, 22 Jan 2025 23:19:12 -0300 Subject: [PATCH] PD(hole taskpanel): Include depth on diagram feat(PD): hole diagram add include depth refactor(PD): hole taskpanel: images add background --- .../PartDesign/Gui/Resources/PartDesign.qrc | 4 + .../images/hole_counterbore_angled.svg | 135 ++++++++-------- .../hole_counterbore_angled_included.svg | 129 ++++++++++++++++ .../images/hole_counterbore_flat.svg | 34 +++-- .../images/hole_counterdrill_angled.svg | 69 ++++----- .../hole_counterdrill_angled_included.svg | 129 ++++++++++++++++ .../images/hole_counterdrill_flat.svg | 21 ++- .../images/hole_countersink_angled.svg | 23 ++- .../hole_countersink_angled_included.svg | 138 +++++++++++++++++ .../images/hole_countersink_flat.svg | 29 ++-- .../Gui/Resources/images/hole_none_angled.svg | 60 ++++---- .../images/hole_none_angled_included.svg | 110 +++++++++++++ .../Gui/Resources/images/hole_none_flat.svg | 10 +- src/Mod/PartDesign/Gui/TaskHoleParameters.cpp | 144 ++++++------------ src/Mod/PartDesign/Gui/TaskHoleParameters.h | 2 +- 15 files changed, 745 insertions(+), 292 deletions(-) create mode 100644 src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_angled_included.svg create mode 100644 src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled_included.svg create mode 100644 src/Mod/PartDesign/Gui/Resources/images/hole_countersink_angled_included.svg create mode 100644 src/Mod/PartDesign/Gui/Resources/images/hole_none_angled_included.svg diff --git a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc index c396d0e1b1..50e86ec8d7 100644 --- a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc +++ b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc @@ -57,9 +57,13 @@ icons/PartDesign_Thickness.svg icons/PartDesignWorkbench.svg images/hole_counterbore_angled.svg + images/hole_counterbore_angled_included.svg images/hole_counterdrill_angled.svg + images/hole_counterdrill_angled_included.svg images/hole_countersink_angled.svg + images/hole_countersink_angled_included.svg images/hole_none_angled.svg + images/hole_none_angled_included.svg images/hole_counterbore_flat.svg images/hole_counterdrill_flat.svg images/hole_countersink_flat.svg diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_angled.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_angled.svg index 3af7cd85c9..1202071514 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_angled.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_angled.svg @@ -21,24 +21,24 @@ xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> + + +Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_flat.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_flat.svg index 658e019a88..440eb10f65 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_flat.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_counterbore_flat.svg @@ -18,18 +18,18 @@ xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled.svg index 35a15ef4a0..85093f317b 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled.svg @@ -21,18 +21,18 @@ xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled_included.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled_included.svg new file mode 100644 index 0000000000..e6e3b847bb --- /dev/null +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_angled_included.svg @@ -0,0 +1,129 @@ + + + +Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_flat.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_flat.svg index 83eb5a6c97..2c2202e673 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_flat.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_counterdrill_flat.svg @@ -21,18 +21,18 @@ xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_angled_included.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_angled_included.svg new file mode 100644 index 0000000000..5ee7c6e9a6 --- /dev/null +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_angled_included.svg @@ -0,0 +1,138 @@ + + + +Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_flat.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_flat.svg index 9be9f59f9b..fab3cb98a0 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_flat.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_countersink_flat.svg @@ -21,18 +21,18 @@ xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled.svg index 5c44120455..8611932f54 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled.svg @@ -21,18 +21,18 @@ xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled_included.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled_included.svg new file mode 100644 index 0000000000..15483344b8 --- /dev/null +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_none_angled_included.svg @@ -0,0 +1,110 @@ + + + +Alfredo MonclusFreeCAD LGPL2+FreeCAD diff --git a/src/Mod/PartDesign/Gui/Resources/images/hole_none_flat.svg b/src/Mod/PartDesign/Gui/Resources/images/hole_none_flat.svg index b543ab3dad..4181b96502 100644 --- a/src/Mod/PartDesign/Gui/Resources/images/hole_none_flat.svg +++ b/src/Mod/PartDesign/Gui/Resources/images/hole_none_flat.svg @@ -21,18 +21,18 @@ xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">HoleCutType->setCurrentIndex(pcHole->HoleCutType.getValue()); - bool isNotCut = pcHole->HoleCutType.getValue() == 0L; - ui->labelHoleCutDiameter->setHidden(isNotCut); - ui->labelHoleCutDepth->setHidden(isNotCut); - ui->labelHoleCutCountersinkAngle->setHidden(isNotCut); - ui->HoleCutDiameter->setHidden(isNotCut); - ui->HoleCutDepth->setHidden(isNotCut); - ui->HoleCutCountersinkAngle->setHidden(isNotCut); - ui->HoleCutCustomValues->setChecked(pcHole->HoleCutCustomValues.getValue()); ui->HoleCutCustomValues->setHidden( pcHole->HoleCutType.getValue() < 5 @@ -191,7 +183,7 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare std::string(pcHole->ThreadDepthType.getValueAsString()) == "Dimension" ); - setCutPixmap(); + setCutDiagram(); // clang-format off connect(ui->Threaded, &QCheckBox::clicked, @@ -334,7 +326,7 @@ void TaskHoleParameters::threadDepthChanged(double value) { if (auto hole = getObject()) { hole->ThreadDepth.setValue(value); - setCutPixmap(); + setCutDiagram(); recomputeFeature(); } } @@ -398,57 +390,28 @@ void TaskHoleParameters::holeCutTypeChanged(int index) // the type is a countersink and thus if HoleCutCountersinkAngle can be enabled std::string HoleCutTypeString = hole->HoleCutType.getValueAsString(); - bool isNotCut = HoleCutTypeString == "None"; - ui->labelHoleCutDiameter->setHidden(isNotCut); - ui->labelHoleCutDepth->setHidden(isNotCut); - ui->labelHoleCutCountersinkAngle->setHidden(isNotCut); - ui->HoleCutDiameter->setHidden(isNotCut); - ui->HoleCutDepth->setHidden(isNotCut); - ui->HoleCutCountersinkAngle->setHidden(isNotCut); - - if (HoleCutTypeString == "None" || HoleCutTypeString == "Counterbore" - || HoleCutTypeString == "Countersink" || HoleCutTypeString == "Counterdrill") { + if ( + HoleCutTypeString == "None" + || HoleCutTypeString == "Counterbore" + || HoleCutTypeString == "Countersink" + || HoleCutTypeString == "Counterdrill" + ) { ui->HoleCutCustomValues->setVisible(false); - if (HoleCutTypeString == "None") { - ui->HoleCutDiameter->setEnabled(false); - ui->HoleCutDepth->setEnabled(false); - ui->labelHoleCutCountersinkAngle->setVisible(false); - ui->HoleCutCountersinkAngle->setVisible(false); - } - if (HoleCutTypeString == "Counterbore") { - ui->labelHoleCutCountersinkAngle->setVisible(false); - ui->HoleCutCountersinkAngle->setVisible(false); - } - if (HoleCutTypeString == "Countersink") { - ui->labelHoleCutCountersinkAngle->setVisible(true); - ui->HoleCutCountersinkAngle->setVisible(true); - } } else { // screw definition // we can have the case that we have no normed values // in this case HoleCutCustomValues is read-only AND true - if (ui->HoleCutCustomValues->isChecked()) { - ui->HoleCutDiameter->setEnabled(true); - ui->HoleCutDepth->setEnabled(true); - if (!hole->HoleCutCountersinkAngle.isReadOnly()) { - ui->HoleCutCountersinkAngle->setVisible(true); - ui->labelHoleCutCountersinkAngle->setVisible(true); - ui->HoleCutCountersinkAngle->setEnabled(true); - } - } - else { - ui->HoleCutCustomValues->setVisible(true); - ui->HoleCutDiameter->setEnabled(false); - ui->HoleCutDepth->setEnabled(false); - ui->HoleCutCountersinkAngle->setEnabled(false); - ui->labelHoleCutCountersinkAngle->setVisible(true); - ui->HoleCutCountersinkAngle->setVisible(true); - } + bool isCustom = ui->HoleCutCustomValues->isChecked(); + ui->HoleCutDiameter->setEnabled(isCustom); + ui->HoleCutDepth->setEnabled(isCustom); + ui->HoleCutCountersinkAngle->setEnabled( + isCustom && !hole->HoleCutCountersinkAngle.isReadOnly() + ); } - setCutPixmap(); + setCutDiagram(); } -void TaskHoleParameters::setCutPixmap() +void TaskHoleParameters::setCutDiagram() { auto hole = getObject(); const std::string holeCutTypeString = hole->HoleCutType.getValueAsString(); @@ -465,54 +428,46 @@ void TaskHoleParameters::setCutPixmap() holeCutTypeString == "Counterbore" || hole->isDynamicCounterbore(threadTypeString, holeCutTypeString) ); - bool isCounterdrill = ( - holeCutTypeString == "Counterdrill" - ); + bool isCounterdrill = (holeCutTypeString == "Counterdrill"); + bool includeAngle = hole->DrillForDepth.getValue(); + bool isNotCut = holeCutTypeString == "None"; + ui->labelHoleCutDiameter->setHidden(isNotCut); + ui->labelHoleCutDepth->setHidden(isNotCut); + ui->HoleCutDiameter->setHidden(isNotCut); + ui->HoleCutDepth->setHidden(isNotCut); + + std::string baseFileName; if (isCounterbore) { - if (isAngled) { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_counterbore_angled.svg")) - ); - } else { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_counterbore_flat.svg")) - ); - } + baseFileName = "hole_counterbore"; + ui->HoleCutCountersinkAngle->setVisible(false); + ui->labelHoleCutCountersinkAngle->setVisible(false); } else if (isCountersink) { - if (isAngled) { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_countersink_angled.svg")) - ); - } else { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_countersink_flat.svg")) - ); - } + baseFileName = "hole_countersink"; + ui->HoleCutCountersinkAngle->setVisible(true); + ui->labelHoleCutCountersinkAngle->setVisible(true); } else if (isCounterdrill) { - if (isAngled) { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_counterdrill_angled.svg")) - ); - } else { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_counterdrill_flat.svg")) - ); - } + baseFileName = "hole_counterdrill"; + ui->HoleCutCountersinkAngle->setVisible(true); + ui->labelHoleCutCountersinkAngle->setVisible(true); } else { - if (isAngled) { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_none_angled.svg")) - ); - } else { - ui->cutDiagram->setPixmap( - QPixmap(QString::fromUtf8(":/images/hole_none_flat.svg")) - ); - } + baseFileName = "hole_none"; + ui->HoleCutCountersinkAngle->setVisible(false); + ui->labelHoleCutCountersinkAngle->setVisible(false); } + + if (isAngled) { + baseFileName += includeAngle ? "_angled_included" : "_angled"; + } else { + baseFileName += "_flat"; + } + + ui->cutDiagram->setPixmap( + QPixmap(QString::fromUtf8((":images/" + baseFileName + ".svg").c_str())) + ); } void TaskHoleParameters::holeCutCustomValuesChanged() @@ -599,7 +554,7 @@ void TaskHoleParameters::depthChanged(int index) ui->DrillPointAngled->setEnabled(DepthisDimension); ui->DrillPointAngle->setEnabled(DepthisDimension); ui->DrillForDepth->setEnabled(DepthisDimension); - setCutPixmap(); + setCutDiagram(); } void TaskHoleParameters::depthValueChanged(double value) @@ -617,7 +572,7 @@ void TaskHoleParameters::drillPointChanged() hole->DrillPoint.setValue(angled); ui->DrillPointAngle->setEnabled(angled); ui->DrillForDepth->setEnabled(angled); - setCutPixmap(); + setCutDiagram(); recomputeFeature(); } } @@ -636,6 +591,7 @@ void TaskHoleParameters::drillForDepthChanged() hole->DrillForDepth.setValue(ui->DrillForDepth->isChecked()); recomputeFeature(); } + setCutDiagram(); } void TaskHoleParameters::taperedChanged() diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.h b/src/Mod/PartDesign/Gui/TaskHoleParameters.h index f9fd063311..a3f2e30c62 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.h +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.h @@ -108,7 +108,7 @@ private Q_SLOTS: void updateViewChanged(bool isChecked); void threadDepthTypeChanged(int index); void threadDepthChanged(double value); - void setCutPixmap(); + void setCutDiagram(); private: class Observer : public App::DocumentObserver {