From 371c23a584869b2fce014c5a01eaa9500eb5fbaa Mon Sep 17 00:00:00 2001 From: donovaly Date: Mon, 16 Nov 2020 04:03:55 +0100 Subject: [PATCH] [PD] more hole fixes - there is the ISO 273 describing clearance holes, so we need to take these values. Only if we have a size not defined in the norm, we calculate - add the coarse (wide) type for clearance holes from ISO 273 - add all screw thread sizes defined in DIN 13/ISO 261 - rearrange thread dialog to make it more compact - change name "fit" to "clearance" as discussed - add tooltips to the dialog - fix issue with TaperedAngle dialog field - change a size name because the norms define "M1" not "M1.0" --- src/Mod/PartDesign/App/FeatureHole.cpp | 170 ++- src/Mod/PartDesign/App/FeatureHole.h | 3 +- src/Mod/PartDesign/Gui/TaskHoleParameters.cpp | 6 +- src/Mod/PartDesign/Gui/TaskHoleParameters.ui | 974 +++++++++++------- 4 files changed, 745 insertions(+), 408 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index cc18c739e9..8bdb637933 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -71,7 +71,7 @@ namespace PartDesign { const char* Hole::DepthTypeEnums[] = { "Dimension", "ThroughAll", /*, "UpToFirst", */ NULL }; const char* Hole::ThreadTypeEnums[] = { "None", "ISOMetricProfile", "ISOMetricFineProfile", "UNC", "UNF", "UNEF", NULL}; -const char* Hole::ThreadFitEnums[] = { "Standard", "Close", NULL}; +const char* Hole::ThreadFitEnums[] = { "Standard", "Close", "Wide", NULL}; const char* Hole::DrillPointEnums[] = { "Flat", "Angled", NULL}; /* "None" profile */ @@ -95,34 +95,49 @@ const Hole::ThreadDescription Hole::threadDescription[][171] = /* ISO metric regular */ { - { "M1.6", 1.60, 0.35 }, - { "M2", 2.00, 0.40 }, - { "M2.5", 2.50, 0.45 }, - { "M3", 3.00, 0.50 }, - { "M3.5", 3.50, 0.60 }, - { "M4", 4.00, 0.70 }, - { "M5", 5.00, 0.80 }, - { "M6", 6.00, 1.00 }, - { "M8", 8.00, 1.25 }, - { "M10", 10.00, 1.50 }, - { "M12", 12.00, 1.75 }, - { "M14", 14.00, 2.00 }, - { "M16", 16.00, 2.00 }, - { "M20", 20.00, 2.50 }, - { "M22", 22.00, 2.50 }, - { "M24", 24.00, 3.00 }, - { "M27", 27.00, 3.00 }, - { "M30", 30.00, 3.50 }, - { "M36", 36.00, 4.00 }, - { "M42", 42.00, 4.50 }, - { "M48", 48.00, 5.00 }, - { "M56", 56.00, 5.50 }, - { "M64", 64.00, 6.00 }, - { "M68", 68.00, 6.00 }, + { "M1", 1.0, 0.25 }, + { "M1.1", 1.1, 0.25 }, + { "M1.2", 1.2, 0.25 }, + { "M1.4", 1.4, 0.30 }, + { "M1.6", 1.6, 0.35 }, + { "M1.8", 1.8, 0.35 }, + { "M2", 2.0, 0.40 }, + { "M2.2", 2.2, 0.45 }, + { "M2.5", 2.5, 0.45 }, + { "M3", 3.0, 0.50 }, + { "M3.5", 3.5, 0.60 }, + { "M4", 4.0, 0.70 }, + { "M4.5", 4.5, 0.75 }, + { "M5", 5.0, 0.80 }, + { "M6", 6.0, 1.00 }, + { "M7", 7.0, 1.00 }, + { "M8", 8.0, 1.25 }, + { "M9", 9.0, 1.25 }, + { "M10", 10.0, 1.50 }, + { "M11", 11.0, 1.50 }, + { "M12", 12.0, 1.75 }, + { "M14", 14.0, 2.00 }, + { "M16", 16.0, 2.00 }, + { "M18", 18.0, 2.50 }, + { "M20", 20.0, 2.50 }, + { "M22", 22.0, 2.50 }, + { "M24", 24.0, 3.00 }, + { "M27", 27.0, 3.00 }, + { "M30", 30.0, 3.50 }, + { "M36", 36.0, 4.00 }, + { "M39", 39.0, 4.00 }, + { "M42", 42.0, 4.50 }, + { "M45", 45.0, 4.50 }, + { "M48", 48.0, 5.00 }, + { "M52", 52.0, 5.00 }, + { "M56", 56.0, 5.50 }, + { "M60", 60.0, 5.50 }, + { "M64", 64.0, 6.00 }, + { "M68", 68.0, 6.00 }, }, /* ISO metric fine */ { - { "M1.0x0.2", 1.0, 0.20 }, + { "M1x0.2", 1.0, 0.20 }, { "M1.1x0.2", 1.1, 0.20 }, { "M1.2x0.2", 1.2, 0.20 }, { "M1.4x0.2", 1.4, 0.20 }, @@ -356,19 +371,62 @@ const Hole::ThreadDescription Hole::threadDescription[][171] = }; +const double Hole::metricHoleDiameters[35][4] = +{ + /* ISO metric according to ISO 273 */ + // {screw diameter, close, standard, coarse} + { 1.0, 1.1, 1.2, 1.3}, + { 1.2, 1.3, 1.4, 1.5}, + { 1.4, 1.5, 1.6, 1.8}, + { 1.6, 1.7, 1.8, 2.0}, + { 1.8, 2.0, 2.1, 2.2}, + { 2.0, 2.2, 2.4, 2.6}, + { 2.5, 2.7, 2.9, 3.1}, + { 3.0, 3.2, 3.4, 3.6}, + { 3.5, 3.7, 3.9, 4.2}, + { 4.0, 4.3, 4.5, 4.8}, + { 4.5, 4.8, 5.0, 5.3}, + { 5.0, 5.3, 5.5, 5.8}, + { 6.0, 6.4, 6.6, 7.0}, + { 7.0, 7.4, 7.6, 8.0}, + { 8.0, 8.4, 9.0, 10.0}, + { 10.0, 10.5, 11.0, 12.0}, + { 12.0, 13.0, 13.5, 14.5}, + { 14.0, 15.0, 15.5, 16.5}, + { 16.0, 17.0, 17.5, 18.5}, + { 18.0, 19.0, 20.0, 21.0}, + { 20.0, 21.0, 22.0, 24.0}, + { 22.0, 23.0, 24.0, 26.0}, + { 24.0, 25.0, 26.0, 28.0}, + { 27.0, 28.0, 30.0, 32.0}, + { 30.0, 31.0, 33.0, 35.0}, + { 36.0, 37.0, 39.0, 42.0}, + { 39.0, 40.0, 42.0, 45.0}, + { 42.0, 43.0, 45.0, 48.0}, + { 45.0, 46.0, 48.0, 52.0}, + { 48.0, 50.0, 52.0, 56.0}, + { 52.0, 54.0, 56.0, 62.0}, + { 56.0, 58.0, 62.0, 66.0}, + { 60.0, 62.0, 66.0, 70.0}, + { 64.0, 66.0, 70.0, 74.0}, + { 68.0, 70.0, 77.0, 78.0} +}; + /* ISO coarse metric enums */ std::vector Hole::HoleCutType_ISOmetric_Enums = { "None", "Counterbore", "Countersink", "Cheesehead (deprecated)", "Countersink socket screw (deprecated)", "Cap screw (deprecated)" }; -const char* Hole::ThreadSize_ISOmetric_Enums[] = { "M1.6", "M2", "M2.5", "M3", - "M3.5", "M4", "M5", "M6", - "M8", "M10", "M12", "M14", - "M16", "M20", "M22", "M24", - "M27", "M30", "M36", "M42", - "M48", "M56", "M64", "M68", NULL }; +const char* Hole::ThreadSize_ISOmetric_Enums[] = { "M1", "M1.1", "M1.2", "M1.4", "M1.6", + "M1.8", "M2", "M2.2", "M2.5", "M3", + "M3.5", "M4", "M4.5", "M5", "M6", + "M7", "M8", "M9", "M10", "M11", + "M12", "M14", "M16", "M18", "M20", + "M22", "M24", "M27", "M30", "M33", + "M36", "M39", "M42", "M45", "M48", + "M52", "M56", "M60", "M64", "M68", NULL }; const char* Hole::ThreadClass_ISOmetric_Enums[] = { "4G", "4H", "5G", "5H", "6G", "6H", "7G", "7H","8G", "8H", NULL }; std::vector Hole::HoleCutType_ISOmetricfine_Enums = { "None", "Counterbore", "Countersink", "Cheesehead (deprecated)", "Countersink socket screw (deprecated)", "Cap screw (deprecated)" }; const char* Hole::ThreadSize_ISOmetricfine_Enums[] = { - "M1.0x0.2", "M1.1x0.2", "M1.2x0.2", "M1.4x0.2", + "M1x0.2", "M1.1x0.2", "M1.2x0.2", "M1.4x0.2", "M1.6x0.2", "M1.8x0.2", "M2x0.25", "M2.2x0.25", "M2.5x0.35", "M3x0.35", "M3.5x0.35", "M4x0.5", "M4.5x0.5", "M5x0.5", "M5.5x0.5", @@ -679,12 +737,50 @@ void Hole::updateDiameterParam() diameter = diameter - pitch; } else { + bool found = false; + int MatrixRowSize = sizeof(metricHoleDiameters) / sizeof(metricHoleDiameters[0]); switch ( ThreadFit.getValue() ) { - case 0: /* standard */ - diameter = ( 5 * ( (int)( ( diameter * 110 ) / 5 ) ) ) / 100.0; + case 0: /* standard fit */ + // read diameter out of matrix + for (int i = 0; i < MatrixRowSize; i++) { + if (metricHoleDiameters[i][0] == diameter) { + diameter = metricHoleDiameters[i][2]; + found = true; + break; + } + } + // if nothing was found, we must calculate + if (!found) { + diameter = (5 * ((int)((diameter * 110) / 5))) / 100.0; + } break; - case 1: /* close */ - diameter = ( 5 * ( (int)( ( diameter * 105 ) / 5 ) ) ) / 100.0; + case 1: /* close fit */ + // read diameter out of matrix + for (int i = 0; i < MatrixRowSize; i++) { + if (metricHoleDiameters[i][0] == diameter) { + diameter = metricHoleDiameters[i][1]; + found = true; + break; + } + } + // if nothing was found, we must calculate + if (!found) { + diameter = (5 * ((int)((diameter * 105) / 5))) / 100.0; + } + break; + case 2: /* wide fit */ + // read diameter out of matrix + for (int i = 0; i < MatrixRowSize; i++) { + if (metricHoleDiameters[i][0] == diameter) { + diameter = metricHoleDiameters[i][3]; + found = true; + break; + } + } + // if nothing was found, we must calculate + if (!found) { + diameter = (5 * ((int)((diameter * 115) / 5))) / 100.0; + } break; default: assert( 0 ); diff --git a/src/Mod/PartDesign/App/FeatureHole.h b/src/Mod/PartDesign/App/FeatureHole.h index 57ea0cc4fc..c6638bf3db 100644 --- a/src/Mod/PartDesign/App/FeatureHole.h +++ b/src/Mod/PartDesign/App/FeatureHole.h @@ -84,9 +84,10 @@ public: double diameter; double pitch; } ThreadDescription; - static const ThreadDescription threadDescription[][171]; + static const double metricHoleDiameters[35][4]; + virtual void Restore(Base::XMLReader & reader); virtual void updateProps(); diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp index 671d6a0873..407f5465b5 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp @@ -167,7 +167,9 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare else ui->drillPointAngled->setChecked(true); ui->DrillPointAngle->setValue(pcHole->DrillPointAngle.getValue()); - ui->Tapered->setChecked(pcHole->ModelActualThread.getValue()); + ui->Tapered->setChecked(pcHole->Tapered.getValue()); + // Angle is only enabled (sensible) if tapered + ui->TaperedAngle->setEnabled(pcHole->Tapered.getValue()); ui->TaperedAngle->setValue(pcHole->TaperedAngle.getValue()); ui->Reversed->setChecked(pcHole->Reversed.getValue()); @@ -793,7 +795,7 @@ long TaskHoleParameters::getThreadClass() const long TaskHoleParameters::getThreadFit() const { - // the fit is independent if the hole is threaded or not + // the fit (clearance) is independent if the hole is threaded or not // since an unthreaded hole for a screw can also have a close fit return ui->ThreadFit->currentIndex(); } diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.ui b/src/Mod/PartDesign/Gui/TaskHoleParameters.ui index d5f0f480e0..33def9abea 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.ui @@ -6,97 +6,21 @@ 0 0 - 356 - 583 + 373 + 560 + + + 0 + 0 + + Task Hole Parameters - - - - <b>Misc</b> - - - - - - - false - - - deg - - - 0.000000000000000 - - - - - - - - 0 - 0 - - - - Type - - - - - - - - - - - 0 - 0 - - - - <b>Drill point</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Fit - - - - - - - false - - - mm - - - 0.000000000000000 - - - - - - - false - - - Cutoff outer - - - - + false @@ -109,43 +33,192 @@ - - + + + + + 0 + 0 + + + + + 140 + 16777215 + + + + + Dimension + + + + + Through all + + + + + + + + + 0 + 0 + + + + + 110 + 16777215 + + + + Hole diameter + + + mm + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + + 110 + 16777215 + + + + Hole clearance +Only available for holes without thread + + + + Standard + + + + + Close + + + + + Wide + + + + + + false - Cutoff inner + Angle - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 20 + + + + + + + + <b>Hole cut</b> + + + + + + + Thread direction + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + Right hand + + + + + + + Left hand + + + + + + + + + + false + + + mm + + + 0.000000000000000 + + + + - - mm + + + 0 + 0 + - - 0.000000000000000 - - - 0.100000000000000 - - - - - - - mm - - - 0.000000000000000 - - - - - - - Qt::NoContextMenu + + + 16777215 + 16777215 + mm @@ -158,8 +231,59 @@ - + + + + false + + + Model actual thread + + + + + + + + 0 + 0 + + + + Depth + + + + + + + + 0 + 0 + + + + Profile + + + + + + + 0 + 0 + + + + + 140 + 16777215 + + + + Ending of the hole if 'Depth' is set to 'Dimension' + 0 @@ -179,7 +303,7 @@ - + 0 0 @@ -194,7 +318,7 @@ - + 0 0 @@ -206,6 +330,12 @@ + + + 0 + 0 + + deg @@ -219,34 +349,23 @@ - - - - false + + + + + 0 + 0 + - - mm - - - 0.000000000000000 + + + 16777215 + 16777215 + - - - - mm - - - - - - - Reversed - - - - + @@ -259,243 +378,53 @@ - - - - - 0 - 0 - - - - Diameter - - - - - - - - 0 - 0 - - - - Depth - - - - - - - Diameter - - - - - - - <b>Threading and size</b> - - - - - - - deg - - - 0.000000000000000 - - - - - - - Tolerance class for threaded holes according to the hole profile - - - - - - - deg - - - 0.000000000000000 - - - - - - - Threaded - - - - + Tapered - - + + false - Angle + Cutoff inner - - + + - + 0 0 - - - Dimension - - - - - Through all - - - - - - - - - - - - - - Type + + + 140 + 16777215 + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Countersink angle - - - - - - - Depth - - - - - - - <b>Hole cut</b> - - - - - - - false - - - Pitch - - - - - - - - 0 - 0 - - - - Profile - - - - - - - - 0 - 0 - - - - Direction - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Right hand - - - - - - - Left hand - - - - - - - - - Hole fit, only available for holes without thread + Tolerance class for threaded holes according to hole profile + + + + + + + + 0 + 0 + + + + mm - - - Standard fit - - - - - Close fit - - @@ -511,28 +440,288 @@ - - + + + + + 0 + 0 + + + + <b>Drill point</b> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Type + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + false - Model actual thread + Cutoff outer - - - - Qt::Horizontal + + + + + 0 + 0 + - + + Type + + + + + + + false + + + deg + + + 0.000000000000000 + + + + + + + <b>Threading and size</b> + + + + + + + + 0 + 0 + + + - 40 - 20 + 140 + 16777215 - + + Cut type for screw heads + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + deg + + + 0.000000000000000 + + + + + + + <b>Misc</b> + + + + + + + + 0 + 0 + + + + Direction + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + Diameter + + + + + + + Depth + + + + + + + Countersink angle + + + + + + + Diameter + + + + + + + Clearance + + + + + + + false + + + mm + + + 0.000000000000000 + + + + + + + Whether the hole gets a thread + + + Threaded + + + + + + + + 0 + 0 + + + + + 140 + 16777215 + + + + + + + + + 120 + 16777215 + + + + Taper angle for the hole +90 degree: straight hole +under 90: smaller hole radius at the bottom +over 90: larger hole radius at the bottom + + + deg + + + 0.000000000000000 + + + + + + + false + + + Pitch + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Qt::NoContextMenu + + + mm + + + 0.000000000000000 + + + 0.100000000000000 + + + + + + + Reverses the hole direction + + + Reversed + + @@ -549,5 +738,54 @@ - + + + Tapered + clicked(bool) + TaperedAngle + setEnabled(bool) + + + 40 + 540 + + + 136 + 540 + + + + + Threaded + clicked(bool) + ThreadFit + setEnabled(bool) + + + 136 + 63 + + + 322 + 254 + + + + + Threaded + clicked(bool) + ThreadClass + setEnabled(bool) + + + 136 + 63 + + + 136 + 280 + + + +