From 877e8d14e5a83671e434c67f4a5665aca249a2f2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 20 Nov 2021 10:34:01 +0100 Subject: [PATCH] PD: Add common base class for Pad/Pocket --- src/Mod/PartDesign/App/AppPartDesign.cpp | 1 + src/Mod/PartDesign/App/CMakeLists.txt | 2 + src/Mod/PartDesign/App/FeatureExtrude.cpp | 80 +++++++++++++++++++++++ src/Mod/PartDesign/App/FeatureExtrude.h | 61 +++++++++++++++++ src/Mod/PartDesign/App/FeaturePad.h | 6 +- src/Mod/PartDesign/App/FeaturePocket.h | 3 +- 6 files changed, 146 insertions(+), 7 deletions(-) create mode 100644 src/Mod/PartDesign/App/FeatureExtrude.cpp create mode 100644 src/Mod/PartDesign/App/FeatureExtrude.h diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index ce39347034..f130609fc0 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -103,6 +103,7 @@ PyMOD_INIT_FUNC(_PartDesign) PartDesign::MultiTransform ::init(); PartDesign::Hole ::init(); PartDesign::Body ::init(); + PartDesign::FeatureExtrude ::init(); PartDesign::Pad ::init(); PartDesign::Pocket ::init(); PartDesign::Fillet ::init(); diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index a623563930..d74a77c1d5 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -87,6 +87,8 @@ SET(FeaturesDressUp_SRCS SOURCE_GROUP("DressUpFeatures" FILES ${FeaturesDressUp_SRCS}) SET(FeaturesSketchBased_SRCS + FeatureExtrude.cpp + FeatureExtrude.h FeatureSketchBased.cpp FeatureSketchBased.h FeaturePad.cpp diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp new file mode 100644 index 0000000000..4b281efbad --- /dev/null +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -0,0 +1,80 @@ +/*************************************************************************** + * Copyright (c) 2010 Juergen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +#include +#include +#include +#include +#include + +#include "FeatureExtrude.h" + +using namespace PartDesign; + + +PROPERTY_SOURCE(PartDesign::FeatureExtrude, PartDesign::ProfileBased) + +FeatureExtrude::FeatureExtrude() +{ +} + +short FeatureExtrude::mustExecute() const +{ + if (Placement.isTouched() || + Type.isTouched() || + Length.isTouched() || + Length2.isTouched() || + UseCustomVector.isTouched() || + Direction.isTouched() || + ReferenceAxis.isTouched() || + AlongSketchNormal.isTouched() || + Offset.isTouched() || + UpToFace.isTouched()) + return 1; + return ProfileBased::mustExecute(); +} diff --git a/src/Mod/PartDesign/App/FeatureExtrude.h b/src/Mod/PartDesign/App/FeatureExtrude.h new file mode 100644 index 0000000000..a2fd9ea2e0 --- /dev/null +++ b/src/Mod/PartDesign/App/FeatureExtrude.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (c) 2010 Juergen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef PARTDESIGN_FEATURE_EXTRUDE_H +#define PARTDESIGN_FEATURE_EXTRUDE_H + +#include +#include +#include + +#include "FeatureSketchBased.h" + +namespace PartDesign +{ + +class PartDesignExport FeatureExtrude : public ProfileBased +{ + PROPERTY_HEADER(PartDesign::FeatureExtrude); + +public: + FeatureExtrude(); + + App::PropertyEnumeration Type; + App::PropertyLength Length; + App::PropertyLength Length2; + App::PropertyBool UseCustomVector; + App::PropertyVector Direction; + App::PropertyBool AlongSketchNormal; + App::PropertyLength Offset; + App::PropertyLinkSub ReferenceAxis; + + /** @name methods override feature */ + //@{ + short mustExecute() const; + //@} +}; + +} //namespace PartDesign + + +#endif // PARTDESIGN_FEATURE_EXTRUDE_H diff --git a/src/Mod/PartDesign/App/FeaturePad.h b/src/Mod/PartDesign/App/FeaturePad.h index 775102f1b4..7723ec379a 100644 --- a/src/Mod/PartDesign/App/FeaturePad.h +++ b/src/Mod/PartDesign/App/FeaturePad.h @@ -24,11 +24,7 @@ #ifndef PARTDESIGN_Pad_H #define PARTDESIGN_Pad_H -#include -#include -#include - -#include "FeatureSketchBased.h" +#include "FeatureExtrude.h" namespace PartDesign { diff --git a/src/Mod/PartDesign/App/FeaturePocket.h b/src/Mod/PartDesign/App/FeaturePocket.h index 9fb580f4cf..01dba2f70c 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.h +++ b/src/Mod/PartDesign/App/FeaturePocket.h @@ -24,8 +24,7 @@ #ifndef PARTDESIGN_Pocket_H #define PARTDESIGN_Pocket_H -#include -#include "FeatureSketchBased.h" +#include "FeatureExtrude.h" namespace PartDesign {