[PD] hole creation

- propose valid values for the cut depth and diameter when creating new holes
- add new definitions for metric fine
- some code simplification and comments
This commit is contained in:
donovaly
2020-11-10 03:40:50 +01:00
committed by wwmayer
parent e26a9efae8
commit ea08a660eb
6 changed files with 120 additions and 10 deletions

View File

@@ -507,9 +507,39 @@ void Hole::updateHoleCutParams()
if (ThreadSize.getValue() < 0)
throw Base::IndexError("Thread size out of range");
if (holeCutType == "None")
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
// 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 = HoleCutTypeMap.find("ISO 4762")->second;
const CounterBoreDimension& dimen = counter.get_bore(threadSize);
if (HoleCutDiameter.getValue() == 0.0) {
HoleCutDiameter.setValue(dimen.diameter);
HoleCutDepth.setValue(dimen.depth);
}
if (HoleCutDepth.getValue() == 0.0)
HoleCutDepth.setValue(dimen.depth);
}
if (holeCutType == "Countersink") {
if (HoleCutDiameter.getValue() == 0.0) {
//read ISO 10642 values
const CutDimensionSet& counter = HoleCutTypeMap.find("ISO 10642")->second;
const CounterSinkDimension& dimen = counter.get_sink(threadSize);
HoleCutDiameter.setValue(dimen.diameter);
HoleCutCountersinkAngle.setValue(counter.angle);
}
}
// cut definition
if (HoleCutTypeMap.count(holeCutType) ) {
std::string threadSize { ThreadSize.getValueAsString() };
const CutDimensionSet &counter = HoleCutTypeMap.find(holeCutType)->second;
if (counter.cut_type == CutDimensionSet::Counterbore) {
const CounterBoreDimension &dimen = counter.get_bore(threadSize);
@@ -534,18 +564,17 @@ void Hole::updateHoleCutParams()
}
// handle legacy types but dont change user settings for
// user defined None, Counterbore and Countersink
// handle legacy types but dont change user settings for
// user defined None, Counterbore and Countersink
else if (holeCutType == "Cheesehead (deprecated)") {
double diameter = threadDescription[ThreadType.getValue()][ThreadSize.getValue()].diameter;
HoleCutDiameter.setValue(diameter * 1.6);
HoleCutDepth.setValue(diameter * 0.6);
}
else if (holeCutType == "Countersink socket screw (deprecated)") {
double diameter = threadDescription[ThreadType.getValue()][ThreadSize.getValue()].diameter;
HoleCutDiameter.setValue(diameter * 2.0);
HoleCutDepth.setValue(diameter * 0.0);
}
else if (holeCutType == "Cap screw (deprecated)") {
double diameter = threadDescription[ThreadType.getValue()][ThreadSize.getValue()].diameter;
HoleCutDiameter.setValue(diameter * 1.5);
HoleCutDepth.setValue(diameter * 1.25);
}
@@ -708,8 +737,8 @@ void Hole::onChanged(const App::Property *prop)
HoleCutCountersinkAngle.setReadOnly(false);
}
else {
HoleCutDiameter.setReadOnly(true);
HoleCutDepth.setReadOnly(true);
HoleCutDiameter.setReadOnly(false);
HoleCutDepth.setReadOnly(false);
HoleCutCountersinkAngle.setReadOnly(true);
}
@@ -807,8 +836,8 @@ void Hole::onChanged(const App::Property *prop)
HoleCutCountersinkAngle.setReadOnly(false);
}
else { // screw definition
HoleCutDiameter.setReadOnly(true);
HoleCutDepth.setReadOnly(true);
HoleCutDiameter.setReadOnly(false);
HoleCutDepth.setReadOnly(false);
HoleCutCountersinkAngle.setReadOnly(true);
}
ProfileBased::onChanged(&HoleCutDiameter);
@@ -1319,6 +1348,8 @@ void Hole::addCounterType(const CutDimensionSet& dimensions)
default:
return;
}
// add the collected lists of JSON definitions to the lists
// if a name doesn't already exist in the list
if (std::all_of(list->begin(), list->end(),
[name](const std::string &x){ return x != name; }))
list->push_back(dimensions.name);

View File

@@ -136,10 +136,13 @@ INSTALL(
set(PartDesignHoleDefines
Resources/Hole/din7984.json
Resources/Hole/iso10642.json
Resources/Hole/iso10642-fine.json
Resources/Hole/iso14583.json
Resources/Hole/iso14583-fine.json
Resources/Hole/iso14583part.json
Resources/Hole/iso4762_7089.json
Resources/Hole/iso4762.json
Resources/Hole/iso4762-fine.json
)
add_custom_target(PartDesignHole ALL SOURCES

View File

@@ -141,8 +141,8 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare
ui->HoleCutCountersinkAngle->setEnabled(true);
}
else {
ui->HoleCutDiameter->setEnabled(false);
ui->HoleCutDepth->setEnabled(false);
ui->HoleCutDiameter->setEnabled(true);
ui->HoleCutDepth->setEnabled(true);
ui->HoleCutCountersinkAngle->setEnabled(false);
}

View File

@@ -0,0 +1,22 @@
{
"name": "ISO 10642",
"cut_type": "countersink",
"thread_type": "metricfine",
"angle": 90,
"data": [
{ "thread": "M3x0.35", "diameter": 6.7 },
{ "thread": "M4x0.5", "diameter": 9.0 },
{ "thread": "M5x0.5", "diameter": 12.2 },
{ "thread": "M6x0.75", "diameter": 13.5 },
{ "thread": "M8x0.75", "diameter": 18.0 },
{ "thread": "M8x1.0", "diameter": 18.0 },
{ "thread": "M10x1", "diameter": 22.4 },
{ "thread": "M10x1.25", "diameter": 22.4 },
{ "thread": "M12x1.25", "diameter": 26.8 },
{ "thread": "M12x1.5", "diameter": 26.8 },
{ "thread": "M14x1.5", "diameter": 30.9 },
{ "thread": "M16x1.5", "diameter": 33.6 },
{ "thread": "M20x1.5", "diameter": 40.3 },
{ "thread": "M20x2.0", "diameter": 40.3 }
]
}

View File

@@ -0,0 +1,18 @@
{
"name": "ISO 14583",
"cut_type": "counterbore",
"thread_type": "metricfine",
"data": [
{ "thread": "M2x0.25", "diameter": 4.4, "depth": 2.0 },
{ "thread": "M2.5x0.35", "diameter": 5.4, "depth": 2.5 },
{ "thread": "M3x0.35", "diameter": 6.0, "depth": 2.8 },
{ "thread": "M3.5x0.35", "diameter": 7.6, "depth": 3.0 },
{ "thread": "M4x0.5", "diameter": 8.6, "depth": 3.5 },
{ "thread": "M5x0.5", "diameter": 10.1, "depth": 4.1 },
{ "thread": "M6x0.75", "diameter": 12.6, "depth": 5.0 },
{ "thread": "M8x0.75", "diameter": 16.6, "depth": 6.6 },
{ "thread": "M8x1.0", "diameter": 16.6, "depth": 6.6 },
{ "thread": "M10x1", "diameter": 20.8, "depth": 8.1 },
{ "thread": "M10x1.25", "diameter": 20.8, "depth": 8.1 }
]
}

View File

@@ -0,0 +1,36 @@
{
"name": "ISO 4762",
"cut_type": "counterbore",
"thread_type": "metricfine",
"data": [
{ "thread": "M1.6x0.2", "diameter": 3.5, "depth": 1.7 },
{ "thread": "M2x0.25", "diameter": 4.4, "depth": 2.1 },
{ "thread": "M2.5x0.35", "diameter": 5.5, "depth": 3.0 },
{ "thread": "M3x0.35", "diameter": 6.5, "depth": 3.4 },
{ "thread": "M3.5x0.35", "diameter": 6.5, "depth": 3.9 },
{ "thread": "M4x0.5", "diameter": 8.0, "depth": 4.4 },
{ "thread": "M5x0.5", "diameter": 10.0, "depth": 5.4 },
{ "thread": "M6x0.75", "diameter": 11.0, "depth": 6.4 },
{ "thread": "M8x0.75", "diameter": 15.0, "depth": 8.6 },
{ "thread": "M8x1.0", "diameter": 15.0, "depth": 8.6 },
{ "thread": "M10x1", "diameter": 18.0, "depth": 10.6 },
{ "thread": "M10x1.25", "diameter": 18.0, "depth": 10.6 },
{ "thread": "M12x1.25", "diameter": 20.0, "depth": 12.6 },
{ "thread": "M12x1.5", "diameter": 20.0, "depth": 12.6 },
{ "thread": "M14x1.5", "diameter": 24.0, "depth": 14.6 },
{ "thread": "M16x1.5", "diameter": 26.0, "depth": 16.6 },
{ "thread": "M18x1.5", "diameter": 30.0, "depth": 18.6 },
{ "thread": "M18x2.0", "diameter": 30.0, "depth": 18.6 },
{ "thread": "M20x1.5", "diameter": 33.0, "depth": 20.6 },
{ "thread": "M20x2.0", "diameter": 33.0, "depth": 20.6 },
{ "thread": "M22x1.5", "diameter": 36.0, "depth": 22.8 },
{ "thread": "M22x2.0", "diameter": 36.0, "depth": 22.8 },
{ "thread": "M24x2.0", "diameter": 40.0, "depth": 24.8 },
{ "thread": "M27x2.0", "diameter": 46.0, "depth": 31.0 },
{ "thread": "M30x2.0", "diameter": 50.0, "depth": 34.0 },
{ "thread": "M33x2.0", "diameter": 54.0, "depth": 36.0 },
{ "thread": "M36x3.0", "diameter": 58.0, "depth": 37.0 },
{ "thread": "M42x3.0", "diameter": 69.0, "depth": 43.0 },
{ "thread": "M48x3.0", "diameter": 78.0, "depth": 49.0 }
]
}