From e2f883fcc4d6708bc8fc30aa19b827dc6a9f8a1d Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 8 Jan 2022 00:45:19 +0100 Subject: [PATCH] [PD] Pad/Pocket: sort out common code - sort out a constraint used by Pad and Pocket - also unify Length2 parameter naming --- src/Mod/PartDesign/App/FeatureExtrude.cpp | 1 + src/Mod/PartDesign/App/FeatureExtrude.h | 2 ++ src/Mod/PartDesign/App/FeaturePad.cpp | 5 ++--- src/Mod/PartDesign/App/FeaturePocket.cpp | 13 ++++++------- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index 23cbd25cee..914ba2a851 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -61,6 +61,7 @@ PROPERTY_SOURCE(PartDesign::FeatureExtrude, PartDesign::ProfileBased) FeatureExtrude::FeatureExtrude() { + signedLengthConstraint = { -DBL_MAX, DBL_MAX, 1.0 }; } short FeatureExtrude::mustExecute() const diff --git a/src/Mod/PartDesign/App/FeatureExtrude.h b/src/Mod/PartDesign/App/FeatureExtrude.h index 70e73e1e1c..f09457dde0 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.h +++ b/src/Mod/PartDesign/App/FeatureExtrude.h @@ -47,6 +47,8 @@ public: App::PropertyLength Offset; App::PropertyLinkSub ReferenceAxis; + App::PropertyQuantityConstraint::Constraints signedLengthConstraint; + /** @name methods override feature */ //@{ short mustExecute() const; diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index 033891ebc6..72e77dfda0 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -66,15 +66,14 @@ Pad::Pad() ADD_PROPERTY_TYPE(Type, (0L), "Pad", App::Prop_None, "Pad type"); Type.setEnums(TypeEnums); - ADD_PROPERTY_TYPE(Length, (100.0), "Pad", App::Prop_None,"Pad length"); - ADD_PROPERTY_TYPE(Length2, (100.0), "Pad", App::Prop_None,"Second Pad length"); + ADD_PROPERTY_TYPE(Length, (100.0), "Pad", App::Prop_None, "Pad length"); + ADD_PROPERTY_TYPE(Length2, (100.0), "Pad", App::Prop_None, "Pad length in 2nd direction"); ADD_PROPERTY_TYPE(UseCustomVector, (false), "Pad", App::Prop_None, "Use custom vector for pad direction"); ADD_PROPERTY_TYPE(Direction, (Base::Vector3d(1.0, 1.0, 1.0)), "Pad", App::Prop_None, "Pad direction vector"); ADD_PROPERTY_TYPE(ReferenceAxis, (0), "Pad", App::Prop_None, "Reference axis of direction"); ADD_PROPERTY_TYPE(AlongSketchNormal, (true), "Pad", App::Prop_None, "Measure pad length along the sketch normal direction"); ADD_PROPERTY_TYPE(UpToFace, (0), "Pad", App::Prop_None, "Face where pad will end"); ADD_PROPERTY_TYPE(Offset, (0.0), "Pad", App::Prop_None, "Offset from face in which pad will end"); - static const App::PropertyQuantityConstraint::Constraints signedLengthConstraint = {-DBL_MAX, DBL_MAX, 1.0}; Offset.setConstraints(&signedLengthConstraint); // Remove the constraints and keep the type to allow to accept negative values diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index 329de73bdb..962563f518 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -63,18 +63,17 @@ Pocket::Pocket() { addSubType = FeatureAddSub::Subtractive; - ADD_PROPERTY_TYPE(Type,((long)0),"Pocket",App::Prop_None,"Pocket type"); + ADD_PROPERTY_TYPE(Type, ((long)0), "Pocket", App::Prop_None, "Pocket type"); Type.setEnums(TypeEnums); - ADD_PROPERTY_TYPE(Length,(100.0),"Pocket",App::Prop_None,"Pocket length"); - ADD_PROPERTY_TYPE(Length2,(100.0),"Pocket",App::Prop_None,"P"); + ADD_PROPERTY_TYPE(Length, (100.0), "Pocket", App::Prop_None, "Pocket length"); + ADD_PROPERTY_TYPE(Length2, (100.0), "Pocket", App::Prop_None, "Pocket length in 2nd direction"); ADD_PROPERTY_TYPE(UseCustomVector, (false), "Pocket", App::Prop_None, "Use custom vector for pocket direction"); ADD_PROPERTY_TYPE(Direction, (Base::Vector3d(1.0, 1.0, 1.0)), "Pocket", App::Prop_None, "Pocket direction vector"); ADD_PROPERTY_TYPE(ReferenceAxis, (0), "Pocket", App::Prop_None, "Reference axis of direction"); ADD_PROPERTY_TYPE(AlongSketchNormal, (true), "Pocket", App::Prop_None, "Measure pocket length along the sketch normal direction"); - ADD_PROPERTY_TYPE(UpToFace,(0),"Pocket",App::Prop_None,"Face where pocket will end"); - ADD_PROPERTY_TYPE(Offset,(0.0),"Pocket",App::Prop_None,"Offset from face in which pocket will end"); - static const App::PropertyQuantityConstraint::Constraints signedLengthConstraint = {-DBL_MAX, DBL_MAX, 1.0}; - Offset.setConstraints ( &signedLengthConstraint ); + ADD_PROPERTY_TYPE(UpToFace, (0), "Pocket", App::Prop_None, "Face where pocket will end"); + ADD_PROPERTY_TYPE(Offset, (0.0), "Pocket", App::Prop_None, "Offset from face in which pocket will end"); + Offset.setConstraints(&signedLengthConstraint); // Remove the constraints and keep the type to allow to accept negative values // https://forum.freecadweb.org/viewtopic.php?f=3&t=52075&p=448410#p447636