From db40acce72cca587ba0a7cada169e9b7a5634cda Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Mon, 21 Apr 2025 11:54:23 -0300 Subject: [PATCH] refactor: add disambiguation to clearance hole names and use names from the standard (#19869) * PD: refactor: threadFit use standard naming and add disambiguation * PD: fix: do not use variables for tr --- src/Mod/PartDesign/App/FeatureHole.cpp | 12 ++++- src/Mod/PartDesign/App/FeatureHole.h | 2 + src/Mod/PartDesign/Gui/TaskHoleParameters.cpp | 47 +++++++++---------- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index e6485b79d1..47c69790c3 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -69,8 +69,11 @@ namespace PartDesign { const char* Hole::DepthTypeEnums[] = { "Dimension", "ThroughAll", /*, "UpToFirst", */ nullptr }; const char* Hole::ThreadDepthTypeEnums[] = { "Hole Depth", "Dimension", "Tapped (DIN76)", nullptr }; const char* Hole::ThreadTypeEnums[] = { "None", "ISOMetricProfile", "ISOMetricFineProfile", "UNC", "UNF", "UNEF", "NPT", "BSP", "BSW", "BSF", nullptr}; -const char* Hole::ClearanceMetricEnums[] = { "Standard", "Close", "Wide", nullptr}; + +const char* Hole::ClearanceNoneEnums[] = { "-", "-", "-", nullptr}; +const char* Hole::ClearanceMetricEnums[] = { "Medium", "Fine", "Coarse", nullptr}; const char* Hole::ClearanceUTSEnums[] = { "Normal", "Close", "Loose", nullptr }; +const char* Hole::ClearanceOtherEnums[] = { "Normal", "Close", "Wide", nullptr }; const char* Hole::DrillPointEnums[] = { "Flat", "Angled", nullptr}; /* "None" profile */ @@ -526,7 +529,7 @@ const std::vector Hole::threadDescription[] = const double Hole::metricHoleDiameters[51][4] = { /* ISO metric clearance hole diameters according to ISO 273 */ - // {screw diameter, close, standard, coarse} + // {screw diameter, fine, medium, 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}, @@ -1415,6 +1418,7 @@ void Hole::onChanged(const App::Property* prop) Threaded.setValue(false); ModelThread.setValue(false); UseCustomThreadClearance.setValue(false); + ThreadFit.setEnums(ClearanceNoneEnums); } else if (type == "ISOMetricProfile") { ThreadClass.setEnums(ThreadClass_ISOmetric_Enums); @@ -1444,18 +1448,22 @@ void Hole::onChanged(const App::Property* prop) else if (type == "BSP") { ThreadClass.setEnums(ThreadClass_None_Enums); HoleCutType.setEnums(HoleCutType_BSP_Enums); + ThreadFit.setEnums(ClearanceMetricEnums); } else if (type == "NPT") { ThreadClass.setEnums(ThreadClass_None_Enums); HoleCutType.setEnums(HoleCutType_NPT_Enums); + ThreadFit.setEnums(ClearanceUTSEnums); } else if (type == "BSW") { ThreadClass.setEnums(ThreadClass_BSW_Enums); HoleCutType.setEnums(HoleCutType_BSW_Enums); + ThreadFit.setEnums(ClearanceOtherEnums); } else if (type == "BSF") { ThreadClass.setEnums(ThreadClass_BSF_Enums); HoleCutType.setEnums(HoleCutType_BSF_Enums); + ThreadFit.setEnums(ClearanceOtherEnums); } bool isNone = type == "None"; diff --git a/src/Mod/PartDesign/App/FeatureHole.h b/src/Mod/PartDesign/App/FeatureHole.h index 0478261d62..484bbbab54 100644 --- a/src/Mod/PartDesign/App/FeatureHole.h +++ b/src/Mod/PartDesign/App/FeatureHole.h @@ -119,8 +119,10 @@ private: static const char* DepthTypeEnums[]; static const char* ThreadDepthTypeEnums[]; static const char* ThreadTypeEnums[]; + static const char* ClearanceNoneEnums[]; static const char* ClearanceMetricEnums[]; static const char* ClearanceUTSEnums[]; + static const char* ClearanceOtherEnums[]; static const char* DrillPointEnums[]; static const char* ThreadDirectionEnums[]; diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp index 658b3314f9..e9de2e21ba 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp @@ -66,10 +66,10 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare ui->ThreadType->addItem(tr("UTS coarse"), QByteArray("UTS")); ui->ThreadType->addItem(tr("UTS fine"), QByteArray("UTS")); ui->ThreadType->addItem(tr("UTS extra fine"), QByteArray("UTS")); - ui->ThreadType->addItem(tr("ANSI pipes"), QByteArray("None")); - ui->ThreadType->addItem(tr("ISO/BSP pipes"), QByteArray("None")); - ui->ThreadType->addItem(tr("BSW whitworth"), QByteArray("None")); - ui->ThreadType->addItem(tr("BSF whitworth fine"), QByteArray("None")); + ui->ThreadType->addItem(tr("ANSI pipes"), QByteArray("UTS")); + ui->ThreadType->addItem(tr("ISO/BSP pipes"), QByteArray("ISO")); + ui->ThreadType->addItem(tr("BSW whitworth"), QByteArray("Other")); + ui->ThreadType->addItem(tr("BSF whitworth fine"), QByteArray("Other")); // read values from the hole properties auto pcHole = getObject(); @@ -655,29 +655,26 @@ void TaskHoleParameters::threadTypeChanged(int index) ui->labelSize->setHidden(isNone); ui->ClearanceWidget->setHidden(isNone || isThreaded); - if (TypeClass == QByteArray("ISO")) { - // the names of the clearance types are different in ISO and UTS - ui->ThreadFit->setItemText( - 0, - QCoreApplication::translate("TaskHoleParameters", "Standard", nullptr)); - ui->ThreadFit->setItemText( - 1, - QCoreApplication::translate("TaskHoleParameters", "Close", nullptr)); - ui->ThreadFit->setItemText( - 2, - QCoreApplication::translate("TaskHoleParameters", "Wide", nullptr)); + if (TypeClass == QByteArray("None")) { + QString noneText = QStringLiteral("-"); + ui->ThreadFit->setItemText(0, noneText); + ui->ThreadFit->setItemText(1, noneText); + ui->ThreadFit->setItemText(2, noneText); + } + else if (TypeClass == QByteArray("ISO")) { + ui->ThreadFit->setItemText(0, tr("Medium", "Distance between thread crest and hole wall, use ISO-273 nomenclature or equivalent if possible")); + ui->ThreadFit->setItemText(1, tr("Fine", "Distance between thread crest and hole wall, use ISO-273 nomenclature or equivalent if possible")); + ui->ThreadFit->setItemText(2, tr("Coarse", "Distance between thread crest and hole wall, use ISO-273 nomenclature or equivalent if possible")); } else if (TypeClass == QByteArray("UTS")) { - // the names of the clearance types are different in ISO and UTS - ui->ThreadFit->setItemText( - 0, - QCoreApplication::translate("TaskHoleParameters", "Normal", nullptr)); - ui->ThreadFit->setItemText( - 1, - QCoreApplication::translate("TaskHoleParameters", "Close", nullptr)); - ui->ThreadFit->setItemText( - 2, - QCoreApplication::translate("TaskHoleParameters", "Loose", nullptr)); + ui->ThreadFit->setItemText(0, tr("Normal", "Distance between thread crest and hole wall, use ASME B18.2.8 nomenclature or equivalent if possible")); + ui->ThreadFit->setItemText(1, tr("Close", "Distance between thread crest and hole wall, use ASME B18.2.8 nomenclature or equivalent if possible")); + ui->ThreadFit->setItemText(2, tr("Loose", "Distance between thread crest and hole wall, use ASME B18.2.8 nomenclature or equivalent if possible")); + } + else { + ui->ThreadFit->setItemText(0, tr("Normal", "Distance between thread crest and hole wall")); + ui->ThreadFit->setItemText(1, tr("Close", "Distance between thread crest and hole wall")); + ui->ThreadFit->setItemText(2, tr("Wide", "Distance between thread crest and hole wall")); } // Class and cut type