From d1071026e7c3b39134f212d39b7288094cd5847c Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 13 Dec 2020 06:12:35 +0100 Subject: [PATCH] [PD] fix blind hole depth handling as reported in https://tracker.freecadweb.org/view.php?id=3818 we treat the blind hole depth not according to the conventions. The size of the drill point due to the angle is normally not taken into account but FC does this in any case. This PR adds therefore an option, that is by default off, to take the drill point size into account. Without the option, (the new default) the depth is calculated according to the conventions. The PR also removes unused widgets and restored the tab order in the .ui file. The thread parameters were never used. In case we made in future the decision to carve into holes real (modeled) threads, we need a special UI for that solution anyway so having the dead code in is not helpful at all. --- src/Mod/PartDesign/App/FeatureHole.cpp | 119 ++++---- src/Mod/PartDesign/App/FeatureHole.h | 1 + src/Mod/PartDesign/Gui/TaskHoleParameters.cpp | 121 ++++---- src/Mod/PartDesign/Gui/TaskHoleParameters.h | 2 + src/Mod/PartDesign/Gui/TaskHoleParameters.ui | 258 +++++++----------- .../PartDesign/PartDesignTests/TestHole.py | 1 + 6 files changed, 216 insertions(+), 286 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 1808d0b1e7..444005fdee 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -591,6 +591,8 @@ Hole::Hole() DrillPoint.setEnums(DrillPointEnums); ADD_PROPERTY_TYPE(DrillPointAngle, (118.0), "Hole", App::Prop_None, "Drill point angle"); + ADD_PROPERTY_TYPE(DrillForDepth, ((long)0), "Hole", App::Prop_None, + "The size of the drill point will be taken into\n account for the depth of blind holes"); ADD_PROPERTY_TYPE(Tapered, (false),"Hole", App::Prop_None, "Tapered"); @@ -1043,19 +1045,19 @@ void Hole::onChanged(const App::Property *prop) } else if (prop == &DepthType) { Depth.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); + DrillForDepth.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); } ProfileBased::onChanged(prop); } /** - * Compute 2D intersection between the lines (pa1, pa2) and (pb1, pb2). + * Computes 2D intersection between the lines (pa1, pa2) and (pb1, pb2). * The lines are assumed to be crossing, and it is an error * to specify parallel lines. + * Only the x and y coordinates of the points are used to compute the 2D intersection. * - * Only the x and y coordinates are used to compute the 2D intersection. - * + * The result are the x and y coordinate of the intersection point. */ - static void computeIntersection(gp_Pnt pa1, gp_Pnt pa2, gp_Pnt pb1, gp_Pnt pb2, double & x, double & y) { double vx1 = pa1.X() - pa2.X(); @@ -1200,7 +1202,7 @@ App::DocumentObjectExecReturn *Hole::execute(void) base.Move(invObjLoc); if (profileshape.IsNull()) - return new App::DocumentObjectExecReturn("Pocket: Creating a face from sketch failed"); + return new App::DocumentObjectExecReturn("Hole error: Creating a face from sketch failed"); profileshape.Move(invObjLoc); /* Build the prototype hole */ @@ -1238,10 +1240,10 @@ App::DocumentObjectExecReturn *Hole::execute(void) length = 1e4; } else - return new App::DocumentObjectExecReturn("Hole: Unsupported length specification."); + return new App::DocumentObjectExecReturn("Hole error: Unsupported length specification"); - if (length <= 0) - return new App::DocumentObjectExecReturn("Hole: Invalid hole depth"); + if (length <= 0.0) + return new App::DocumentObjectExecReturn("Hole error: Invalid hole depth"); BRepBuilderAPI_MakeWire mkWire; const std::string holeCutType = HoleCutType.getValueAsString(); @@ -1253,26 +1255,27 @@ App::DocumentObjectExecReturn *Hole::execute(void) holeCutType == "Cheesehead (deprecated)" || holeCutType == "Cap screw (deprecated)" || isDynamicCounterbore(threadType, holeCutType)); - double hasTaperedAngle = Tapered.getValue() ? Base::toRadians( TaperedAngle.getValue() ) : Base::toRadians(90.0); - double radiusBottom = Diameter.getValue() / 2.0 - length * 1.0 / tan( hasTaperedAngle ); + double TaperedAngleVal = Tapered.getValue() ? Base::toRadians( TaperedAngle.getValue() ) : Base::toRadians(90.0); + double radiusBottom = Diameter.getValue() / 2.0 - length / tan(TaperedAngleVal); double radius = Diameter.getValue() / 2.0; double holeCutRadius = HoleCutDiameter.getValue() / 2.0; gp_Pnt firstPoint(0, 0, 0); gp_Pnt lastPoint(0, 0, 0); - double length1 = 0; + double lengthCounter = 0.0; + double xPosCounter = 0.0; + double zPosCounter = 0.0; - if ( hasTaperedAngle <= 0 || hasTaperedAngle > Base::toRadians( 180.0 ) ) - return new App::DocumentObjectExecReturn("Hole: Invalid taper angle."); + if (TaperedAngleVal <= 0.0 || TaperedAngleVal > Base::toRadians( 180.0 ) ) + return new App::DocumentObjectExecReturn("Hole error: Invalid taper angle"); if ( isCountersink ) { - double x, z; double countersinkAngle = Base::toRadians( HoleCutCountersinkAngle.getValue() / 2.0 ); if ( countersinkAngle <= 0 || countersinkAngle > Base::toRadians( 180.0 ) ) - return new App::DocumentObjectExecReturn("Hole: Invalid countersink angle."); + return new App::DocumentObjectExecReturn("Hole error: Invalid countersink angle"); if (holeCutRadius < radius) - return new App::DocumentObjectExecReturn("Hole: Hole cut diameter too small."); + return new App::DocumentObjectExecReturn("Hole error: Hole cut diameter too small"); // Top point gp_Pnt newPoint = toPnt(holeCutRadius * xDir); @@ -1282,28 +1285,27 @@ App::DocumentObjectExecReturn *Hole::execute(void) computeIntersection(gp_Pnt( holeCutRadius, 0, 0 ), gp_Pnt( holeCutRadius - sin( countersinkAngle ), -cos( countersinkAngle ), 0 ), gp_Pnt( radius, 0, 0 ), - gp_Pnt( radiusBottom, -length, 0), x, z ); - if (-length > z) - return new App::DocumentObjectExecReturn("Hole: Invalid countersink."); + gp_Pnt( radiusBottom, -length, 0), xPosCounter, zPosCounter); + if (-length > zPosCounter) + return new App::DocumentObjectExecReturn("Hole error: Invalid countersink"); - length1 = z; + lengthCounter = zPosCounter; - newPoint = toPnt(x * xDir + z * zDir); + newPoint = toPnt(xPosCounter * xDir + zPosCounter * zDir); mkWire.Add( BRepBuilderAPI_MakeEdge( lastPoint, newPoint ) ); lastPoint = newPoint; } else if ( isCounterbore ) { double holeCutDepth = HoleCutDepth.getValue(); - double x, z; - if (holeCutDepth <= 0) - return new App::DocumentObjectExecReturn("Hole: Hole cut depth must be greater than zero."); + if (holeCutDepth <= 0.0) + return new App::DocumentObjectExecReturn("Hole error: Hole cut depth must be greater than zero"); if (holeCutDepth > length) - return new App::DocumentObjectExecReturn("Hole: Hole cut depth must be less than hole depth."); + return new App::DocumentObjectExecReturn("Hole error: Hole cut depth must be less than hole depth"); if (holeCutRadius < radius) - return new App::DocumentObjectExecReturn("Hole: Hole cut diameter too small."); + return new App::DocumentObjectExecReturn("Hole error: Hole cut diameter too small"); // Top point gp_Pnt newPoint = toPnt(holeCutRadius * xDir); @@ -1311,7 +1313,7 @@ App::DocumentObjectExecReturn *Hole::execute(void) lastPoint = newPoint; // Bottom of counterbore - newPoint = toPnt(holeCutRadius * xDir -holeCutDepth * zDir); + newPoint = toPnt(holeCutRadius * xDir - holeCutDepth * zDir); mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); lastPoint = newPoint; @@ -1319,10 +1321,10 @@ App::DocumentObjectExecReturn *Hole::execute(void) computeIntersection(gp_Pnt( 0, -holeCutDepth, 0 ), gp_Pnt( holeCutRadius, -holeCutDepth, 0 ), gp_Pnt( radius, 0, 0 ), - gp_Pnt( radiusBottom, length, 0 ), x, z ); + gp_Pnt( radiusBottom, length, 0 ), xPosCounter, zPosCounter); - length1 = z; - newPoint = toPnt(x * xDir + z * zDir); + lengthCounter = zPosCounter; + newPoint = toPnt(xPosCounter * xDir + zPosCounter * zDir); mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); lastPoint = newPoint; } @@ -1330,10 +1332,12 @@ App::DocumentObjectExecReturn *Hole::execute(void) gp_Pnt newPoint = toPnt(radius * xDir); mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); lastPoint = newPoint; - length1 = 0; + lengthCounter = 0.0; } std::string drillPoint = DrillPoint.getValueAsString(); + double xPosDrill = 0.0; + double zPosDrill = 0.0; if (drillPoint == "Flat") { gp_Pnt newPoint = toPnt(radiusBottom * xDir + -length * zDir); mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); @@ -1345,30 +1349,47 @@ App::DocumentObjectExecReturn *Hole::execute(void) } else if (drillPoint == "Angled") { double drillPointAngle = Base::toRadians( ( 180.0 - DrillPointAngle.getValue() ) / 2.0 ); - double x, z; gp_Pnt newPoint; + bool isDrillForDepth = DrillForDepth.getValue(); - if ( drillPointAngle <= 0 || drillPointAngle > Base::toRadians( 180.0 ) ) - return new App::DocumentObjectExecReturn("Hole: Invalid drill point angle."); + // the angle is in any case > 0 and < 90 but nevertheless this safeguard: + if ( drillPointAngle <= 0.0 || drillPointAngle >= Base::toRadians( 180.0 ) ) + return new App::DocumentObjectExecReturn("Hole error: Invalid drill point angle"); - computeIntersection(gp_Pnt( 0, -length, 0 ), - gp_Pnt( cos( drillPointAngle ), -length + sin( drillPointAngle ), 0), - gp_Pnt(radius, 0, 0), - gp_Pnt(radiusBottom, -length, 0), x, z); + // if option to take drill point size into account + // the next wire point is the intersection of the drill edge and the hole edge + if (isDrillForDepth) { + computeIntersection(gp_Pnt(0, -length, 0), + gp_Pnt(radius, radius * tan(drillPointAngle) - length, 0), + gp_Pnt(radius, 0, 0), + gp_Pnt(radiusBottom, -length, 0), xPosDrill, zPosDrill); + if (zPosDrill > 0 || zPosDrill >= lengthCounter) + return new App::DocumentObjectExecReturn("Hole error: Invalid drill point"); - if (z > 0 || z >= length1) - return new App::DocumentObjectExecReturn("Hole: Invalid drill point."); + newPoint = toPnt(xPosDrill * xDir + zPosDrill * zDir); + mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); + lastPoint = newPoint; - newPoint = toPnt(x * xDir + z * zDir); - mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); - lastPoint = newPoint; + newPoint = toPnt(-length * zDir); + mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); + lastPoint = newPoint; + } + else { + xPosDrill = radiusBottom; + zPosDrill = -length; - newPoint = toPnt(-length * zDir); - mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); - lastPoint = newPoint; + newPoint = toPnt(xPosDrill * xDir + zPosDrill * zDir); + mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); + lastPoint = newPoint; + + // the end point is the size of the drill tip + newPoint = toPnt((-length - radius * tan(drillPointAngle)) * zDir); + mkWire.Add(BRepBuilderAPI_MakeEdge(lastPoint, newPoint)); + lastPoint = newPoint; + } } - mkWire.Add( BRepBuilderAPI_MakeEdge(lastPoint, firstPoint) ); + mkWire.Add( BRepBuilderAPI_MakeEdge(lastPoint, firstPoint) ); TopoDS_Wire wire = mkWire.Wire(); @@ -1382,10 +1403,10 @@ App::DocumentObjectExecReturn *Hole::execute(void) protoHole = RevolMaker.Shape(); if (protoHole.IsNull()) - return new App::DocumentObjectExecReturn("Hole: Resulting shape is empty"); + return new App::DocumentObjectExecReturn("Hole error: Resulting shape is empty"); } else - return new App::DocumentObjectExecReturn("Hole: Could not revolve sketch!"); + return new App::DocumentObjectExecReturn("Hole error: Could not revolve sketch"); #if 0 // Make thread diff --git a/src/Mod/PartDesign/App/FeatureHole.h b/src/Mod/PartDesign/App/FeatureHole.h index 66dde28a3a..72cf07fc13 100644 --- a/src/Mod/PartDesign/App/FeatureHole.h +++ b/src/Mod/PartDesign/App/FeatureHole.h @@ -64,6 +64,7 @@ public: App::PropertyLength Depth; App::PropertyEnumeration DrillPoint; App::PropertyAngle DrillPointAngle; + App::PropertyBool DrillForDepth; App::PropertyBool Tapered; App::PropertyAngle TaperedAngle; diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp index 407f5465b5..0e9878f8ba 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp @@ -67,17 +67,6 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - /* Remove actual threading parameters for now */ - ui->ModelActualThread->setVisible(false); - ui->ThreadPitch->setVisible(false); - ui->ThreadCutOffInner->setVisible(false); - ui->ThreadCutOffOuter->setVisible(false); - ui->ThreadAngle->setVisible(false); - ui->label_Pitch->setVisible(false); - ui->label_CutoffInner->setVisible(false); - ui->label_CutoffOuter->setVisible(false); - ui->label_Angle->setVisible(false); - ui->ThreadType->addItem(tr("None"), QByteArray("None")); ui->ThreadType->addItem(tr("ISO metric regular profile"), QByteArray("ISO")); ui->ThreadType->addItem(tr("ISO metric fine profile"), QByteArray("ISO")); @@ -88,11 +77,6 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare // read values from the hole properties PartDesign::Hole* pcHole = static_cast(vp->getObject()); ui->Threaded->setChecked(pcHole->Threaded.getValue()); - ui->ModelActualThread->setChecked(pcHole->ModelActualThread.getValue()); - ui->ThreadPitch->setValue(pcHole->ThreadPitch.getValue()); - ui->ThreadAngle->setValue(pcHole->ThreadAngle.getValue()); - ui->ThreadCutOffInner->setValue(pcHole->ThreadCutOffInner.getValue()); - ui->ThreadCutOffOuter->setValue(pcHole->ThreadCutOffOuter.getValue()); ui->ThreadType->setCurrentIndex(pcHole->ThreadType.getValue()); ui->ThreadSize->clear(); const char** cursor = pcHole->ThreadSize.getEnums(); @@ -167,6 +151,12 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare else 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") + ui->DrillForDepth->setEnabled(true); + else + ui->DrillForDepth->setEnabled(false); ui->Tapered->setChecked(pcHole->Tapered.getValue()); // Angle is only enabled (sensible) if tapered ui->TaperedAngle->setEnabled(pcHole->Tapered.getValue()); @@ -175,11 +165,6 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare connect(ui->Threaded, SIGNAL(clicked(bool)), this, SLOT(threadedChanged())); connect(ui->ThreadType, SIGNAL(currentIndexChanged(int)), this, SLOT(threadTypeChanged(int))); - connect(ui->ModelActualThread, SIGNAL(clicked(bool)), this, SLOT(modelActualThreadChanged())); - connect(ui->ThreadPitch, SIGNAL(valueChanged(double)), this, SLOT(threadPitchChanged(double))); - connect(ui->ThreadAngle, SIGNAL(valueChanged(double)), this, SLOT(threadAngleChanged(double))); - connect(ui->ThreadCutOffInner, SIGNAL(valueChanged(double)), this, SLOT(threadCutOffInnerChanged(double))); - connect(ui->ThreadCutOffOuter, SIGNAL(valueChanged(double)), this, SLOT(threadCutOffOuterChanged(double))); connect(ui->ThreadSize, SIGNAL(currentIndexChanged(int)), this, SLOT(threadSizeChanged(int))); connect(ui->ThreadClass, SIGNAL(currentIndexChanged(int)), this, SLOT(threadClassChanged(int))); connect(ui->ThreadFit, SIGNAL(currentIndexChanged(int)), this, SLOT(threadFitChanged(int))); @@ -195,16 +180,13 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare connect(ui->drillPointFlat, SIGNAL(clicked(bool)), this, SLOT(drillPointChanged())); connect(ui->drillPointAngled, SIGNAL(clicked(bool)), this, SLOT(drillPointChanged())); connect(ui->DrillPointAngle, SIGNAL(valueChanged(double)), this, SLOT(drillPointAngledValueChanged(double))); + connect(ui->DrillForDepth, SIGNAL(clicked(bool)), this, SLOT(drillForDepthChanged())); connect(ui->Tapered, SIGNAL(clicked(bool)), this, SLOT(taperedChanged())); connect(ui->Reversed, SIGNAL(clicked(bool)), this, SLOT(reversedChanged())); connect(ui->TaperedAngle, SIGNAL(valueChanged(double)), this, SLOT(taperedAngleChanged(double))); vp->show(); - ui->ThreadPitch->bind(pcHole->ThreadPitch); - ui->ThreadAngle->bind(pcHole->ThreadAngle); - ui->ThreadCutOffInner->bind(pcHole->ThreadCutOffInner); - ui->ThreadCutOffOuter->bind(pcHole->ThreadCutOffOuter); ui->Diameter->bind(pcHole->Diameter); ui->HoleCutDiameter->bind(pcHole->HoleCutDiameter); ui->HoleCutDepth->bind(pcHole->HoleCutDepth); @@ -236,7 +218,7 @@ void TaskHoleParameters::modelActualThreadChanged() { PartDesign::Hole* pcHole = static_cast(vp->getObject()); - pcHole->ModelActualThread.setValue(ui->ModelActualThread->isChecked()); + pcHole->ModelActualThread.setValue(false); recomputeFeature(); } @@ -333,6 +315,12 @@ void TaskHoleParameters::depthChanged(int index) PartDesign::Hole* pcHole = static_cast(vp->getObject()); pcHole->DepthType.setValue(index); + + // disable DrillforDepth if not 'Dimension' + if (std::string(pcHole->DepthType.getValueAsString()) == "Dimension") + ui->DrillForDepth->setEnabled(true); + else + ui->DrillForDepth->setEnabled(false); recomputeFeature(); } @@ -348,12 +336,17 @@ void TaskHoleParameters::drillPointChanged() { PartDesign::Hole* pcHole = static_cast(vp->getObject()); - if (sender() == ui->drillPointFlat) + if (sender() == ui->drillPointFlat) { pcHole->DrillPoint.setValue((long)0); - else if (sender() == ui->drillPointAngled) + ui->DrillForDepth->setEnabled(false); + } + else if (sender() == ui->drillPointAngled) { pcHole->DrillPoint.setValue((long)1); - else - assert( 0 ); + ui->DrillForDepth->setEnabled(true); + } + else { + assert(0); + } recomputeFeature(); } @@ -365,6 +358,14 @@ void TaskHoleParameters::drillPointAngledValueChanged(double value) recomputeFeature(); } +void TaskHoleParameters::drillForDepthChanged() +{ + PartDesign::Hole* pcHole = static_cast(vp->getObject()); + + pcHole->DrillForDepth.setValue(ui->DrillForDepth->isChecked()); + recomputeFeature(); +} + void TaskHoleParameters::taperedChanged() { PartDesign::Hole* pcHole = static_cast(vp->getObject()); @@ -528,46 +529,6 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property } ui->Threaded->setDisabled(ro); } - else if (&Prop == &pcHole->ModelActualThread) { - if (ui->ModelActualThread->isChecked() ^ pcHole->ModelActualThread.getValue()) { - ui->ModelActualThread->blockSignals(true); - ui->ModelActualThread->setChecked(pcHole->ModelActualThread.getValue()); - ui->ModelActualThread->blockSignals(false); - } - ui->ModelActualThread->setDisabled(ro); - } - else if (&Prop == &pcHole->ThreadPitch) { - if (ui->ThreadPitch->value().getValue() != pcHole->ThreadPitch.getValue()) { - ui->ThreadPitch->blockSignals(true); - ui->ThreadPitch->setValue(pcHole->ThreadPitch.getValue()); - ui->ThreadPitch->blockSignals(false); - } - ui->ThreadPitch->setDisabled(ro); - } - else if (&Prop == &pcHole->ThreadAngle) { - if (ui->ThreadAngle->value().getValue() != pcHole->ThreadAngle.getValue()) { - ui->ThreadAngle->blockSignals(true); - ui->ThreadAngle->setValue(pcHole->ThreadAngle.getValue()); - ui->ThreadAngle->blockSignals(false); - } - ui->ThreadAngle->setDisabled(ro); - } - else if (&Prop == &pcHole->ThreadCutOffInner) { - if (ui->ThreadCutOffInner->value().getValue() != pcHole->ThreadCutOffInner.getValue()) { - ui->ThreadCutOffInner->blockSignals(true); - ui->ThreadCutOffInner->setValue(pcHole->ThreadCutOffInner.getValue()); - ui->ThreadCutOffInner->blockSignals(false); - } - ui->ThreadCutOffInner->setDisabled(ro); - } - else if (&Prop == &pcHole->ThreadCutOffOuter) { - if (ui->ThreadCutOffOuter->value().getValue() != pcHole->ThreadCutOffOuter.getValue()) { - ui->ThreadCutOffOuter->blockSignals(true); - ui->ThreadCutOffOuter->setValue(pcHole->ThreadCutOffOuter.getValue()); - ui->ThreadCutOffOuter->blockSignals(false); - } - ui->ThreadCutOffOuter->setDisabled(ro); - } else if (&Prop == &pcHole->ThreadType) { ui->ThreadType->setEnabled(true); @@ -742,6 +703,15 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property } ui->DrillPointAngle->setDisabled(ro); } + else if (&Prop == &pcHole->DrillForDepth) { + ui->DrillForDepth->setEnabled(true); + if (ui->DrillForDepth->isChecked() ^ pcHole->DrillForDepth.getValue()) { + ui->DrillForDepth->blockSignals(true); + ui->DrillForDepth->setChecked(pcHole->DrillForDepth.getValue()); + ui->DrillForDepth->blockSignals(false); + } + ui->DrillForDepth->setDisabled(ro); + } else if (&Prop == &pcHole->Tapered) { ui->Tapered->setEnabled(true); if (ui->Tapered->isChecked() ^ pcHole->Tapered.getValue()) { @@ -866,6 +836,11 @@ bool TaskHoleParameters::getTapered() const return ui->Tapered->isChecked(); } +bool TaskHoleParameters::getDrillForDepth() const +{ + return ui->DrillForDepth->isChecked(); +} + Base::Quantity TaskHoleParameters::getTaperedAngle() const { return ui->TaperedAngle->value(); @@ -878,10 +853,6 @@ void TaskHoleParameters::apply() isApplying = true; - ui->ThreadPitch->apply(); - ui->ThreadAngle->apply(); - ui->ThreadCutOffInner->apply(); - ui->ThreadCutOffOuter->apply(); ui->Diameter->apply(); ui->HoleCutDiameter->apply(); ui->HoleCutDepth->apply(); @@ -910,6 +881,8 @@ void TaskHoleParameters::apply() FCMD_OBJ_CMD(obj,"DepthType = " << getDepthType()); if (!pcHole->DrillPoint.isReadOnly()) FCMD_OBJ_CMD(obj,"DrillPoint = " << getDrillPoint()); + if (!pcHole->DrillForDepth.isReadOnly()) + FCMD_OBJ_CMD(obj, "DrillForDepth = " << (getDrillForDepth() ? 1 : 0)); if (!pcHole->Tapered.isReadOnly()) FCMD_OBJ_CMD(obj,"Tapered = " << getTapered()); diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.h b/src/Mod/PartDesign/Gui/TaskHoleParameters.h index 9c74bb30af..bfa22a693c 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.h +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.h @@ -76,6 +76,7 @@ public: Base::Quantity getDepth() const; long getDrillPoint() const; Base::Quantity getDrillPointAngle() const; + bool getDrillForDepth() const; bool getTapered() const; Base::Quantity getTaperedAngle() const; @@ -100,6 +101,7 @@ private Q_SLOTS: void depthValueChanged(double value); void drillPointChanged(); void drillPointAngledValueChanged(double value); + void drillForDepthChanged(); void taperedChanged(); void reversedChanged(); void taperedAngleChanged(double value); diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.ui b/src/Mod/PartDesign/Gui/TaskHoleParameters.ui index c723acb05c..37becccf82 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.ui @@ -6,8 +6,8 @@ 0 0 - 441 - 710 + 354 + 463 @@ -66,116 +66,7 @@ - - - - false - - - Model actual thread - - - - - - - false - - - Pitch - - - - - - - false - - - mm - - - 0.000000000000000 - - - - - - - <b>Hole cut</b> - - - - - - - false - - - Angle - - - - - - - false - - - deg - - - 0.000000000000000 - - - - - - - false - - - Cutoff inner - - - - - - - false - - - mm - - - 0.000000000000000 - - - - - - - false - - - Cutoff outer - - - - - - - false - - - mm - - - 0.000000000000000 - - - - + @@ -191,7 +82,7 @@ - + @@ -204,7 +95,7 @@ - + Left hand @@ -214,7 +105,7 @@ - + @@ -227,7 +118,7 @@ - + @@ -243,14 +134,14 @@ - + Clearance - + @@ -285,7 +176,7 @@ Only available for holes without thread - + @@ -298,7 +189,7 @@ Only available for holes without thread - + @@ -317,7 +208,7 @@ Only available for holes without thread - + Qt::Horizontal @@ -333,7 +224,20 @@ Only available for holes without thread - + + + + + 0 + 0 + + + + Diameter + + + + @@ -358,20 +262,7 @@ Only available for holes without thread - - - - - 0 - 0 - - - - Diameter - - - - + @@ -384,7 +275,7 @@ Only available for holes without thread - + @@ -410,7 +301,7 @@ Only available for holes without thread - + @@ -423,7 +314,14 @@ Only available for holes without thread - + + + + <b>Hole cut</b> + + + + @@ -436,7 +334,7 @@ Only available for holes without thread - + @@ -455,14 +353,14 @@ Only available for holes without thread - + Diameter - + @@ -490,14 +388,14 @@ Only available for holes without thread - + Depth - + @@ -522,14 +420,14 @@ Only available for holes without thread - + Countersink angle - + @@ -551,7 +449,7 @@ Only available for holes without thread - + @@ -567,7 +465,7 @@ Only available for holes without thread - + Type @@ -577,7 +475,7 @@ Only available for holes without thread - + @@ -593,7 +491,7 @@ Only available for holes without thread - + @@ -609,7 +507,7 @@ Only available for holes without thread - + @@ -625,21 +523,32 @@ Only available for holes without thread - + + + + The size of the drill point will be taken into +account for the depth of blind holes + + + Take into account for depth + + + + <b>Misc</b> - + Tapered - + Taper angle for the hole @@ -655,7 +564,7 @@ over 90: larger hole radius at the bottom - + Reverses the hole direction @@ -679,6 +588,29 @@ over 90: larger hole radius at the bottom
Gui/PrefWidgets.h
+ + ThreadType + Threaded + directionRightHand + directionLeftHand + ThreadSize + ThreadFit + ThreadClass + Diameter + DepthType + Depth + HoleCutType + HoleCutDiameter + HoleCutDepth + HoleCutCountersinkAngle + drillPointFlat + drillPointAngled + DrillPointAngle + DrillForDepth + Tapered + TaperedAngle + Reversed + @@ -688,12 +620,12 @@ over 90: larger hole radius at the bottom setEnabled(bool) - 40 - 540 + 49 + 451 - 136 - 540 + 163 + 453 @@ -708,8 +640,8 @@ over 90: larger hole radius at the bottom 63 - 322 - 254 + 344 + 142 @@ -724,8 +656,8 @@ over 90: larger hole radius at the bottom 63 - 136 - 280 + 163 + 168 diff --git a/src/Mod/PartDesign/PartDesignTests/TestHole.py b/src/Mod/PartDesign/PartDesignTests/TestHole.py index cc838f4a3b..a32dd11bd4 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestHole.py +++ b/src/Mod/PartDesign/PartDesignTests/TestHole.py @@ -86,6 +86,7 @@ class TestHole(unittest.TestCase): self.Hole.DepthType = 0 self.Hole.DrillPoint = 1 self.Hole.Tapered = 0 + self.Hole.DrillForDepth = 1 self.Doc.recompute() self.assertEqual(len(self.Hole.Shape.Faces), 8)