diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 444005fdee..9c014d291f 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -424,7 +424,9 @@ const double Hole::metricHoleDiameters[36][4] = { 6.0, 6.4, 6.6, 7.0}, { 7.0, 7.4, 7.6, 8.0}, { 8.0, 8.4, 9.0, 10.0}, + // 9.0 undefined { 10.0, 10.5, 11.0, 12.0}, + // 11.0 undefined { 12.0, 13.0, 13.5, 14.5}, { 14.0, 15.0, 15.5, 16.5}, { 16.0, 17.0, 17.5, 18.5}, @@ -612,6 +614,10 @@ void Hole::updateHoleCutParams() return; } + // get diameter and size + double diameterVal = Diameter.getValue(); + + // handle thread types std::string threadType = ThreadType.getValueAsString(); if (threadType == "ISOMetricProfile" || threadType == "ISOMetricFineProfile") { if (ThreadSize.getValue() < 0) { @@ -619,35 +625,50 @@ void Hole::updateHoleCutParams() return; } - // get diameter and size - double diameter = threadDescription[ThreadType.getValue()][ThreadSize.getValue()].diameter; std::string threadSize{ ThreadSize.getValueAsString() }; // we don't update for these settings but we need to set a value for new holes + // furthermore we must assure the hole cut diameter is not <= the hole diameter // if we have a cut but the values are zero, we assume it is a new hole // we take in this case the values from the norm ISO 4762 or ISO 10642 if (holeCutType == "Counterbore") { // read ISO 4762 values const CutDimensionSet& counter = find_cutDimensionSet(threadType, "ISO 4762"); const CounterBoreDimension& dimen = counter.get_bore(threadSize); - if (HoleCutDiameter.getValue() == 0.0) { - HoleCutDiameter.setValue(dimen.diameter); - HoleCutDepth.setValue(dimen.depth); + if (HoleCutDiameter.getValue() == 0.0 || HoleCutDiameter.getValue() <= diameterVal) { + // there is no norm defining counterbores for all sizes, thus we need to use the + // same fallback as for the case HoleCutTypeMap.count(key) + if (dimen.diameter != 0.0) { + HoleCutDiameter.setValue(dimen.diameter); + HoleCutDepth.setValue(dimen.depth); + } + else { + // valid values for visual feedback + HoleCutDiameter.setValue(Diameter.getValue() + 0.1); + HoleCutDepth.setValue(0.1); + } } if (HoleCutDepth.getValue() == 0.0) HoleCutDepth.setValue(dimen.depth); + HoleCutCountersinkAngle.setReadOnly(true); } else if (holeCutType == "Countersink") { // read ISO 10642 values const CutDimensionSet& counter = find_cutDimensionSet(threadType, "ISO 10642"); - if (HoleCutDiameter.getValue() == 0.0) { + if (HoleCutDiameter.getValue() == 0.0 || HoleCutDiameter.getValue() <= diameterVal) { const CounterSinkDimension& dimen = counter.get_sink(threadSize); - HoleCutDiameter.setValue(dimen.diameter); + if (dimen.diameter != 0.0) { + HoleCutDiameter.setValue(dimen.diameter); + } + else { + HoleCutDiameter.setValue(Diameter.getValue() + 0.1); + } HoleCutCountersinkAngle.setValue(counter.angle); } if (HoleCutCountersinkAngle.getValue() == 0.0) { HoleCutCountersinkAngle.setValue(counter.angle); } + HoleCutCountersinkAngle.setReadOnly(false); } // cut definition @@ -688,39 +709,38 @@ void Hole::updateHoleCutParams() // handle legacy types but don’t change user settings for // user defined None, Counterbore and Countersink else if (holeCutType == "Cheesehead (deprecated)") { - HoleCutDiameter.setValue(diameter * 1.6); - HoleCutDepth.setValue(diameter * 0.6); + HoleCutDiameter.setValue(diameterVal * 1.6); + HoleCutDepth.setValue(diameterVal * 0.6); } else if (holeCutType == "Countersink socket screw (deprecated)") { - HoleCutDiameter.setValue(diameter * 2.0); - HoleCutDepth.setValue(diameter * 0.0); + HoleCutDiameter.setValue(diameterVal * 2.0); + HoleCutDepth.setValue(diameterVal * 0.0); if (HoleCutCountersinkAngle.getValue() == 0.0) { HoleCutCountersinkAngle.setValue(90.0); } } else if (holeCutType == "Cap screw (deprecated)") { - HoleCutDiameter.setValue(diameter * 1.5); - HoleCutDepth.setValue(diameter * 1.25); + HoleCutDiameter.setValue(diameterVal * 1.5); + HoleCutDepth.setValue(diameterVal * 1.25); } } else { // we have an UTS profile or none - // get diameter - double diameter = threadDescription[ThreadType.getValue()][ThreadSize.getValue()].diameter; // we don't update for these settings but we need to set a value for new holes + // furthermore we must assure the hole cut diameter is not <= the hole diameter // if we have a cut but the values are zero, we assume it is a new hole // we use rules of thumbs as proposal if (holeCutType == "Counterbore") { - if (HoleCutDiameter.getValue() == 0.0) { - HoleCutDiameter.setValue(diameter * 1.6); - HoleCutDepth.setValue(diameter * 0.9); + if (HoleCutDiameter.getValue() == 0.0 || HoleCutDiameter.getValue() <= diameterVal) { + HoleCutDiameter.setValue(diameterVal * 1.6); + HoleCutDepth.setValue(diameterVal * 0.9); } if (HoleCutDepth.getValue() == 0.0) - HoleCutDepth.setValue(diameter * 0.9); + HoleCutDepth.setValue(diameterVal * 0.9); } else if (holeCutType == "Countersink") { - if (HoleCutDiameter.getValue() == 0.0) { - HoleCutDiameter.setValue(diameter * 1.7); + if (HoleCutDiameter.getValue() == 0.0 || HoleCutDiameter.getValue() <= diameterVal) { + HoleCutDiameter.setValue(diameterVal * 1.7); // 82 degrees for UTS, 90 otherwise if (threadType != "None") HoleCutCountersinkAngle.setValue(82.0); @@ -996,10 +1016,14 @@ void Hole::onChanged(const App::Property *prop) ThreadCutOffOuter.setReadOnly(v); } else if (prop == &DrillPoint) { - if (DrillPoint.getValue() == 1) + if (DrillPoint.getValue() == 1) { DrillPointAngle.setReadOnly(false); - else + DrillForDepth.setReadOnly(false); + } + else { DrillPointAngle.setReadOnly(true); + DrillForDepth.setReadOnly(true); + } } else if (prop == &Tapered) { if (Tapered.getValue()) @@ -1009,11 +1033,16 @@ void Hole::onChanged(const App::Property *prop) } else if (prop == &ThreadSize) { updateDiameterParam(); - updateHoleCutParams(); + // updateHoleCutParams() will later automatically be called because updateDiameterParam() changes &Diameter } else if (prop == &ThreadFit) { updateDiameterParam(); } + else if (prop == &Diameter) { + // a changed diameter means we also need to check the hole cut + // because the hole cut diameter must not be <= than the diameter + updateHoleCutParams(); + } else if (prop == &HoleCutType) { std::string holeCutType; if (HoleCutType.isValid()) @@ -1045,6 +1074,8 @@ void Hole::onChanged(const App::Property *prop) } else if (prop == &DepthType) { Depth.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); + DrillPoint.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); + DrillPointAngle.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); DrillForDepth.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); } ProfileBased::onChanged(prop); diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp index 0e9878f8ba..8e281f7dcf 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp @@ -152,11 +152,28 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare ui->drillPointAngled->setChecked(true); ui->DrillPointAngle->setValue(pcHole->DrillPointAngle.getValue()); ui->DrillForDepth->setChecked(pcHole->DrillForDepth.getValue()); - // DrillForDepth is only enabled (sensible) if type is 'Dimension' - if (std::string(pcHole->DepthType.getValueAsString()) == "Dimension") + // drill point settings are only enabled (sensible) if type is 'Dimension' + if (std::string(pcHole->DepthType.getValueAsString()) == "Dimension") { + ui->drillPointFlat->setEnabled(true); + ui->drillPointAngled->setEnabled(true); + ui->DrillPointAngle->setEnabled(true); ui->DrillForDepth->setEnabled(true); - else + } + else { + ui->drillPointFlat->setEnabled(false); + ui->drillPointAngled->setEnabled(false); + ui->DrillPointAngle->setEnabled(false); ui->DrillForDepth->setEnabled(false); + } + // drill point is sensible but flat, disable angle and option + if (!ui->drillPointFlat->isChecked()) { + ui->DrillPointAngle->setEnabled(true); + ui->DrillForDepth->setEnabled(true); + } + else { + ui->DrillPointAngle->setEnabled(false); + ui->DrillForDepth->setEnabled(false); + } ui->Tapered->setChecked(pcHole->Tapered.getValue()); // Angle is only enabled (sensible) if tapered ui->TaperedAngle->setEnabled(pcHole->Tapered.getValue()); @@ -171,7 +188,7 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare connect(ui->Diameter, SIGNAL(valueChanged(double)), this, SLOT(threadDiameterChanged(double))); connect(ui->directionRightHand, SIGNAL(clicked(bool)), this, SLOT(threadDirectionChanged())); connect(ui->directionLeftHand, SIGNAL(clicked(bool)), this, SLOT(threadDirectionChanged())); - connect(ui->HoleCutType, SIGNAL(currentIndexChanged(int)), this, SLOT(holeCutChanged(int))); + connect(ui->HoleCutType, SIGNAL(currentIndexChanged(int)), this, SLOT(holeCutTypeChanged(int))); connect(ui->HoleCutDiameter, SIGNAL(valueChanged(double)), this, SLOT(holeCutDiameterChanged(double))); connect(ui->HoleCutDepth, SIGNAL(valueChanged(double)), this, SLOT(holeCutDepthChanged(double))); connect(ui->HoleCutCountersinkAngle, SIGNAL(valueChanged(double)), this, SLOT(holeCutCountersinkAngleChanged(double))); @@ -254,7 +271,7 @@ void TaskHoleParameters::threadCutOffOuterChanged(double value) recomputeFeature(); } -void TaskHoleParameters::holeCutChanged(int index) +void TaskHoleParameters::holeCutTypeChanged(int index) { if (index < 0) return; @@ -306,7 +323,7 @@ void TaskHoleParameters::holeCutCountersinkAngleChanged(double value) { PartDesign::Hole* pcHole = static_cast(vp->getObject()); - pcHole->HoleCutCountersinkAngle.setValue((double)value); + pcHole->HoleCutCountersinkAngle.setValue(value); recomputeFeature(); } @@ -316,11 +333,19 @@ void TaskHoleParameters::depthChanged(int index) pcHole->DepthType.setValue(index); - // disable DrillforDepth if not 'Dimension' - if (std::string(pcHole->DepthType.getValueAsString()) == "Dimension") + // disable drill point widgets if not 'Dimension' + if (std::string(pcHole->DepthType.getValueAsString()) == "Dimension") { + ui->drillPointFlat->setEnabled(true); + ui->drillPointAngled->setEnabled(true); + ui->DrillPointAngle->setEnabled(true); ui->DrillForDepth->setEnabled(true); - else + } + else { + ui->drillPointFlat->setEnabled(false); + ui->drillPointAngled->setEnabled(false); + ui->DrillPointAngle->setEnabled(false); ui->DrillForDepth->setEnabled(false); + } recomputeFeature(); } diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.h b/src/Mod/PartDesign/Gui/TaskHoleParameters.h index bfa22a693c..894c4314a6 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.h +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.h @@ -93,7 +93,7 @@ private Q_SLOTS: void threadAngleChanged(double value); void threadDiameterChanged(double value); void threadDirectionChanged(); - void holeCutChanged(int index); + void holeCutTypeChanged(int index); void holeCutDiameterChanged(double value); void holeCutDepthChanged(double value); void holeCutCountersinkAngleChanged(double value); diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.ui b/src/Mod/PartDesign/Gui/TaskHoleParameters.ui index 37becccf82..27a6b7ac60 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.ui @@ -6,7 +6,7 @@ 0 0 - 354 + 335 463 @@ -40,10 +40,10 @@ - + - + 0 0 @@ -58,6 +58,12 @@ + + + 0 + 0 + + Whether the hole gets a thread @@ -84,6 +90,12 @@ + + + 0 + 0 + + @@ -97,6 +109,12 @@ + + + 0 + 0 + + Left hand @@ -121,37 +139,43 @@ - + 0 0 - 140 + 16777215 16777215 - + + + + 0 + 0 + + Clearance - + - + 0 0 - 110 + 16777215 16777215 @@ -192,14 +216,14 @@ Only available for holes without thread - + 0 0 - 140 + 16777215 16777215 @@ -208,23 +232,7 @@ Only available for holes without thread - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 13 - 20 - - - - - + @@ -237,17 +245,17 @@ Only available for holes without thread - + - + 0 0 - 110 + 16777215 16777215 @@ -278,14 +286,14 @@ Only available for holes without thread - + 0 0 - 140 + 16777215 16777215 @@ -301,10 +309,10 @@ Only available for holes without thread - + - + 0 0 @@ -334,10 +342,10 @@ Only available for holes without thread - + - + 0 0 @@ -355,15 +363,21 @@ Only available for holes without thread + + + 0 + 0 + + Diameter - + - + 0 0 @@ -390,15 +404,21 @@ Only available for holes without thread + + + 0 + 0 + + Depth - + - + 0 0 @@ -422,15 +442,21 @@ Only available for holes without thread + + + 0 + 0 + + Countersink angle - + - + 0 0 @@ -467,6 +493,12 @@ Only available for holes without thread + + + 0 + 0 + + Type @@ -478,7 +510,7 @@ Only available for holes without thread - + 0 0 @@ -494,7 +526,7 @@ Only available for holes without thread - + 0 0 @@ -507,10 +539,10 @@ Only available for holes without thread - + - + 0 0 @@ -523,8 +555,14 @@ Only available for holes without thread - + + + + 0 + 0 + + The size of the drill point will be taken into account for the depth of blind holes @@ -543,6 +581,12 @@ account for the depth of blind holes + + + 0 + 0 + + Tapered @@ -550,6 +594,12 @@ account for the depth of blind holes + + + 0 + 0 + + Taper angle for the hole 90 degree: straight hole @@ -564,8 +614,14 @@ over 90: larger hole radius at the bottom - + + + + 0 + 0 + + Reverses the hole direction @@ -574,7 +630,7 @@ over 90: larger hole radius at the bottom - + @@ -620,28 +676,12 @@ over 90: larger hole radius at the bottom setEnabled(bool) - 49 - 451 + 40 + 540 - 163 - 453 - - - - - Threaded - clicked(bool) - ThreadFit - setEnabled(bool) - - 136 - 63 - - - 344 - 142 + 540 @@ -656,14 +696,30 @@ over 90: larger hole radius at the bottom 63 - 163 - 168 + 136 + 280 + + + + + Threaded + clicked(bool) + ThreadFit + setEnabled(bool) + + + 136 + 63 + + + 322 + 254 - +