From 9a2f5eea653f34052878cb9a402e6a8e35e59e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Sun, 10 May 2015 09:35:29 +0200 Subject: [PATCH] allow non-sketch based additive and subtractive features --- src/Mod/PartDesign/App/AppPartDesign.cpp | 5 +- src/Mod/PartDesign/App/AppPartDesign.cpp.orig | 23 +++++---- src/Mod/PartDesign/App/CMakeLists.txt | 6 +-- ...{FeatureAdditive.cpp => FeatureAddSub.cpp} | 13 +++-- .../{FeatureAdditive.h => FeatureAddSub.h} | 18 +++++-- src/Mod/PartDesign/App/FeatureGroove.cpp | 8 +-- src/Mod/PartDesign/App/FeatureGroove.h | 4 +- src/Mod/PartDesign/App/FeatureHole.cpp | 4 +- src/Mod/PartDesign/App/FeatureHole.h | 4 +- .../PartDesign/App/FeatureMultiTransform.cpp | 15 +++--- src/Mod/PartDesign/App/FeaturePad.cpp | 10 ++-- src/Mod/PartDesign/App/FeaturePad.h | 5 +- src/Mod/PartDesign/App/FeaturePocket.cpp | 11 ++-- src/Mod/PartDesign/App/FeaturePocket.h | 4 +- src/Mod/PartDesign/App/FeatureRevolution.cpp | 8 +-- src/Mod/PartDesign/App/FeatureRevolution.h | 4 +- src/Mod/PartDesign/App/FeatureScaled.cpp | 15 +++--- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 6 +-- src/Mod/PartDesign/App/FeatureSketchBased.h | 4 +- src/Mod/PartDesign/App/FeatureSubtractive.cpp | 44 ---------------- src/Mod/PartDesign/App/FeatureSubtractive.h | 50 ------------------- src/Mod/PartDesign/App/FeatureTransformed.cpp | 22 ++++---- src/Mod/PartDesign/Gui/Command.cpp | 10 +--- .../Gui/TaskTransformedParameters.cpp | 6 +-- src/Mod/PartDesign/Gui/ViewProvider.cpp | 7 +-- .../Gui/ViewProviderTransformed.cpp | 12 ++--- 26 files changed, 115 insertions(+), 203 deletions(-) rename src/Mod/PartDesign/App/{FeatureAdditive.cpp => FeatureAddSub.cpp} (85%) rename src/Mod/PartDesign/App/{FeatureAdditive.h => FeatureAddSub.h} (83%) delete mode 100644 src/Mod/PartDesign/App/FeatureSubtractive.cpp delete mode 100644 src/Mod/PartDesign/App/FeatureSubtractive.h diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index c352fb030..61125def2 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -40,8 +40,6 @@ #include "FeatureDressUp.h" #include "FeatureChamfer.h" #include "FeatureDraft.h" -#include "FeatureSubtractive.h" -#include "FeatureAdditive.h" #include "FeatureTransformed.h" #include "FeatureMirrored.h" #include "FeatureLinearPattern.h" @@ -82,9 +80,8 @@ PyMODINIT_FUNC init_PartDesign() PartDesign::Feature ::init(); PartDesign::Solid ::init(); PartDesign::DressUp ::init(); + PartDesign::FeatureAddSub ::init(); PartDesign::SketchBased ::init(); - PartDesign::Subtractive ::init(); - PartDesign::Additive ::init(); PartDesign::Transformed ::init(); PartDesign::Mirrored ::init(); PartDesign::LinearPattern ::init(); diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp.orig b/src/Mod/PartDesign/App/AppPartDesign.cpp.orig index b18162c07..6ad46eda6 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp.orig +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp.orig @@ -40,8 +40,12 @@ #include "FeatureDressUp.h" #include "FeatureChamfer.h" #include "FeatureDraft.h" +<<<<<<< c3c1399b7e8f8ceea8f3c1288ebfe0b6575f4d90 #include "FeatureSubtractive.h" #include "FeatureAdditive.h" +======= +#include "FeatureFace.h" +>>>>>>> allow non-sketch based additive and subtractive features #include "FeatureTransformed.h" #include "FeatureMirrored.h" #include "FeatureLinearPattern.h" @@ -49,7 +53,10 @@ #include "FeatureScaled.h" #include "FeatureMultiTransform.h" #include "FeatureHole.h" -#include "DatumFeature.h" +#include "DatumPlane.h" +#include "DatumLine.h" +#include "DatumPoint.h" +#include "FeatureBoolean.h" extern struct PyMethodDef PartDesign_methods[]; @@ -81,9 +88,8 @@ void PartDesignExport init_PartDesign() PartDesign::Feature ::init(); PartDesign::Solid ::init(); PartDesign::DressUp ::init(); + PartDesign::FeatureAddSub ::init(); PartDesign::SketchBased ::init(); - PartDesign::Subtractive ::init(); - PartDesign::Additive ::init(); PartDesign::Transformed ::init(); PartDesign::Mirrored ::init(); PartDesign::LinearPattern ::init(); @@ -98,16 +104,15 @@ void PartDesignExport init_PartDesign() PartDesign::Revolution ::init(); PartDesign::Groove ::init(); PartDesign::Chamfer ::init(); -<<<<<<< b1f11745d3f535813e5dea41f7a12b14fbd6389f - PartDesign::Draft ::init(); -======= - PartDesign::Face ::init(); PartDesign::Draft ::init(); - PartDesign::Datum ::init(); PartDesign::Plane ::init(); PartDesign::Line ::init(); PartDesign::Point ::init(); ->>>>>>> Second step for implementing datum features + PartDesign::Boolean ::init(); + + PartDesign::Point::initHints(); + PartDesign::Line ::initHints(); + PartDesign::Plane::initHints(); } } // extern "C" diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index d7201d894..7d17cd534 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -88,10 +88,8 @@ SET(FeaturesSketchBased_SRCS FeatureRevolution.h FeatureGroove.cpp FeatureGroove.h - FeatureAdditive.cpp - FeatureAdditive.h - FeatureSubtractive.h - FeatureSubtractive.cpp + FeatureAddSub.cpp + FeatureAddSub.h FeatureHole.h FeatureHole.cpp FeatureBoolean.h diff --git a/src/Mod/PartDesign/App/FeatureAdditive.cpp b/src/Mod/PartDesign/App/FeatureAddSub.cpp similarity index 85% rename from src/Mod/PartDesign/App/FeatureAdditive.cpp rename to src/Mod/PartDesign/App/FeatureAddSub.cpp index 57b345e5a..aaf5a8dfa 100644 --- a/src/Mod/PartDesign/App/FeatureAdditive.cpp +++ b/src/Mod/PartDesign/App/FeatureAddSub.cpp @@ -26,7 +26,7 @@ #endif -#include "FeatureAdditive.h" +#include "FeatureAddSub.h" using namespace PartDesign; @@ -34,11 +34,16 @@ using namespace PartDesign; namespace PartDesign { -PROPERTY_SOURCE(PartDesign::Additive,PartDesign::SketchBased) +PROPERTY_SOURCE(PartDesign::FeatureAddSub, PartDesign::Feature) -Additive::Additive() +FeatureAddSub::FeatureAddSub() { - ADD_PROPERTY(AddShape,(TopoDS_Shape())); + ADD_PROPERTY(AddSubShape,(TopoDS_Shape())); +} + +FeatureAddSub::Type FeatureAddSub::getAddSubType() +{ + return addSubType; } } diff --git a/src/Mod/PartDesign/App/FeatureAdditive.h b/src/Mod/PartDesign/App/FeatureAddSub.h similarity index 83% rename from src/Mod/PartDesign/App/FeatureAdditive.h rename to src/Mod/PartDesign/App/FeatureAddSub.h index fd213cf29..363349f15 100644 --- a/src/Mod/PartDesign/App/FeatureAdditive.h +++ b/src/Mod/PartDesign/App/FeatureAddSub.h @@ -27,22 +27,30 @@ #include #include -#include "FeatureSketchBased.h" +#include "Feature.h" /// Base class of all additive features in PartDesign namespace PartDesign { -class PartDesignExport Additive : public SketchBased +class PartDesignExport FeatureAddSub : public PartDesign::Feature { - PROPERTY_HEADER(PartDesign::Additive); + PROPERTY_HEADER(PartDesign::FeatureAddSub); public: - Additive(); + enum Type { + Additive = 0, + Subtractive + }; + + FeatureAddSub(); - Part::PropertyPartShape AddShape; + Type getAddSubType(); + + Part::PropertyPartShape AddSubShape; protected: + Type addSubType = Additive; }; } //namespace PartDesign diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index 8f7bbd874..f9eb3cf77 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -49,10 +49,12 @@ using namespace PartDesign; namespace PartDesign { -PROPERTY_SOURCE(PartDesign::Groove, PartDesign::Subtractive) +PROPERTY_SOURCE(PartDesign::Groove, PartDesign::SketchBased) Groove::Groove() { + addSubType = FeatureAddSub::Subtractive; + ADD_PROPERTY_TYPE(Base,(Base::Vector3d(0.0f,0.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Base"); ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0.0f,1.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Axis"); ADD_PROPERTY_TYPE(Angle,(360.0),"Groove", App::Prop_None, "Angle"); @@ -67,7 +69,7 @@ short Groove::mustExecute() const Base.isTouched() || Angle.isTouched()) return 1; - return Subtractive::mustExecute(); + return SketchBased::mustExecute(); } App::DocumentObjectExecReturn *Groove::execute(void) @@ -143,7 +145,7 @@ App::DocumentObjectExecReturn *Groove::execute(void) TopoDS_Shape result = RevolMaker.Shape(); // set the subtractive shape property for later usage in e.g. pattern result = refineShapeIfActive(result); - this->SubShape.setValue(result); + this->AddSubShape.setValue(result); // cut out groove to get one result object BRepAlgoAPI_Cut mkCut(base, result); diff --git a/src/Mod/PartDesign/App/FeatureGroove.h b/src/Mod/PartDesign/App/FeatureGroove.h index 03616a0ff..de4cfb02f 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.h +++ b/src/Mod/PartDesign/App/FeatureGroove.h @@ -25,12 +25,12 @@ #define PARTDESIGN_Groove_H #include -#include "FeatureSubtractive.h" +#include "FeatureSketchBased.h" namespace PartDesign { -class PartDesignExport Groove : public Subtractive +class PartDesignExport Groove : public SketchBased { PROPERTY_HEADER(PartDesign::Groove); diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 55d296bc5..c0524969f 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -52,10 +52,12 @@ const char* Hole::TypeEnums[] = {"Dimension","UpToLast","UpToFirst",NULL}; const char* Hole::HoleTypeEnums[]= {"Simple","Counterbore","Countersunk",NULL}; const char* Hole::ThreadEnums[] = {"None","Metric","MetricFine",NULL}; -PROPERTY_SOURCE(PartDesign::Hole, PartDesign::Subtractive) +PROPERTY_SOURCE(PartDesign::Hole, PartDesign::SketchBased) Hole::Hole() { + addSubType = FeatureAddSub::Subtractive; + ADD_PROPERTY(Type,((long)0)); Type.setEnums(TypeEnums); ADD_PROPERTY(HoleType,((long)0)); diff --git a/src/Mod/PartDesign/App/FeatureHole.h b/src/Mod/PartDesign/App/FeatureHole.h index e202544ab..8318f1f1c 100644 --- a/src/Mod/PartDesign/App/FeatureHole.h +++ b/src/Mod/PartDesign/App/FeatureHole.h @@ -25,12 +25,12 @@ #define PARTDESIGN_Hole_H #include -#include "FeatureSubtractive.h" +#include "FeatureSketchBased.h" namespace PartDesign { -class PartDesignExport Hole : public Subtractive +class PartDesignExport Hole : public SketchBased { PROPERTY_HEADER(PartDesign::Hole); diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp index 862afec8b..bfa27753a 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp @@ -30,8 +30,7 @@ #include "FeatureMultiTransform.h" #include "FeatureScaled.h" -#include "FeatureAdditive.h" -#include "FeatureSubtractive.h" +#include "FeatureAddSub.h" #include #include @@ -79,12 +78,12 @@ const std::list MultiTransform::getTransformations(const std::vector(originals.front()); TopoDS_Shape original; - if (originalFeature->getTypeId().isDerivedFrom(PartDesign::Additive::getClassTypeId())) { - PartDesign::Additive* addFeature = static_cast(originalFeature); - original = addFeature->AddShape.getShape()._Shape; - } else if (originalFeature->getTypeId().isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) { - PartDesign::Subtractive* subFeature = static_cast(originalFeature); - original = subFeature->SubShape.getShape()._Shape; + if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + PartDesign::FeatureAddSub* addFeature = static_cast(originalFeature); + if(addFeature->getAddSubType() == FeatureAddSub::Additive) + original = addFeature->AddSubShape.getShape()._Shape; + else + original = addFeature->AddSubShape.getShape()._Shape; } GProp_GProps props; diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index 90b524c1a..30b678811 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -58,10 +58,12 @@ using namespace PartDesign; const char* Pad::TypeEnums[]= {"Length","UpToLast","UpToFirst","UpToFace","TwoLengths",NULL}; -PROPERTY_SOURCE(PartDesign::Pad, PartDesign::Additive) +PROPERTY_SOURCE(PartDesign::Pad, PartDesign::SketchBased) Pad::Pad() { + addSubType = FeatureAddSub::Additive; + ADD_PROPERTY_TYPE(Type,((long)0),"Pad",App::Prop_None,"Pad type"); Type.setEnums(TypeEnums); ADD_PROPERTY_TYPE(Length,(100.0),"Pad",App::Prop_None,"Pad length"); @@ -78,7 +80,7 @@ short Pad::mustExecute() const Length2.isTouched() || UpToFace.isTouched()) return 1; - return Additive::mustExecute(); + return SketchBased::mustExecute(); } App::DocumentObjectExecReturn *Pad::execute(void) @@ -235,7 +237,9 @@ App::DocumentObjectExecReturn *Pad::execute(void) // set the additive shape property for later usage in e.g. pattern prism = refineShapeIfActive(prism); - this->AddShape.setValue(prism); + const char* name = AddSubShape.getName(); + const char* name1 = this->getPropertyName(&AddSubShape); + this->AddSubShape.setValue(prism); if (!base.IsNull()) { // Let's call algorithm computing a fuse operation: diff --git a/src/Mod/PartDesign/App/FeaturePad.h b/src/Mod/PartDesign/App/FeaturePad.h index 72b087804..032520782 100644 --- a/src/Mod/PartDesign/App/FeaturePad.h +++ b/src/Mod/PartDesign/App/FeaturePad.h @@ -27,12 +27,13 @@ #include #include #include -#include "FeatureAdditive.h" + +#include "FeatureSketchBased.h" namespace PartDesign { -class PartDesignExport Pad : public Additive +class PartDesignExport Pad : public SketchBased { PROPERTY_HEADER(PartDesign::Pad); diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index e111a0723..ef06f4265 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -54,10 +54,12 @@ using namespace PartDesign; const char* Pocket::TypeEnums[]= {"Length","ThroughAll","UpToFirst","UpToFace",NULL}; -PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::Subtractive) +PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::SketchBased) Pocket::Pocket() { + addSubType = FeatureAddSub::Subtractive; + 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"); @@ -72,7 +74,7 @@ short Pocket::mustExecute() const Length.isTouched() || UpToFace.isTouched()) return 1; - return Subtractive::mustExecute(); + return SketchBased::mustExecute(); } App::DocumentObjectExecReturn *Pocket::execute(void) @@ -176,7 +178,8 @@ App::DocumentObjectExecReturn *Pocket::execute(void) if (!mkCut.IsDone()) return new App::DocumentObjectExecReturn("Pocket: Up to face: Could not get SubShape!"); // FIXME: In some cases this affects the Shape property: It is set to the same shape as the SubShape!!!! - this->SubShape.setValue(mkCut.Shape()); + TopoDS_Shape result = refineShapeIfActive(mkCut.Shape()); + this->AddSubShape.setValue(result); this->Shape.setValue(prism); } else { TopoDS_Shape prism; @@ -187,7 +190,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void) // set the subtractive shape property for later usage in e.g. pattern prism = refineShapeIfActive(prism); - this->SubShape.setValue(prism); + this->AddSubShape.setValue(prism); // Cut the SubShape out of the base feature BRepAlgoAPI_Cut mkCut(base, prism); diff --git a/src/Mod/PartDesign/App/FeaturePocket.h b/src/Mod/PartDesign/App/FeaturePocket.h index 250bbca80..c81e54881 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.h +++ b/src/Mod/PartDesign/App/FeaturePocket.h @@ -25,12 +25,12 @@ #define PARTDESIGN_Pocket_H #include -#include "FeatureSubtractive.h" +#include "FeatureSketchBased.h" namespace PartDesign { -class PartDesignExport Pocket : public Subtractive +class PartDesignExport Pocket : public SketchBased { PROPERTY_HEADER(PartDesign::Pocket); diff --git a/src/Mod/PartDesign/App/FeatureRevolution.cpp b/src/Mod/PartDesign/App/FeatureRevolution.cpp index 35d56c930..8c2f648ba 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.cpp +++ b/src/Mod/PartDesign/App/FeatureRevolution.cpp @@ -49,10 +49,12 @@ using namespace PartDesign; namespace PartDesign { -PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::Additive) +PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::SketchBased) Revolution::Revolution() { + addSubType = FeatureAddSub::Additive; + ADD_PROPERTY_TYPE(Base,(Base::Vector3d(0.0,0.0,0.0)),"Revolution", App::Prop_ReadOnly, "Base"); ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0.0,1.0,0.0)),"Revolution", App::Prop_ReadOnly, "Axis"); ADD_PROPERTY_TYPE(Angle,(360.0),"Revolution", App::Prop_None, "Angle"); @@ -67,7 +69,7 @@ short Revolution::mustExecute() const Base.isTouched() || Angle.isTouched()) return 1; - return Additive::mustExecute(); + return SketchBased::mustExecute(); } App::DocumentObjectExecReturn *Revolution::execute(void) @@ -145,7 +147,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void) TopoDS_Shape result = RevolMaker.Shape(); result = refineShapeIfActive(result); // set the additive shape property for later usage in e.g. pattern - this->AddShape.setValue(result); + this->AddSubShape.setValue(result); if (!base.IsNull()) { // Let's call algorithm computing a fuse operation: diff --git a/src/Mod/PartDesign/App/FeatureRevolution.h b/src/Mod/PartDesign/App/FeatureRevolution.h index 14e0c9a0a..c27b9518b 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.h +++ b/src/Mod/PartDesign/App/FeatureRevolution.h @@ -25,12 +25,12 @@ #define PARTDESIGN_Revolution_H #include -#include "FeatureAdditive.h" +#include "FeatureSketchBased.h" namespace PartDesign { -class PartDesignExport Revolution : public Additive +class PartDesignExport Revolution : public SketchBased { PROPERTY_HEADER(PartDesign::Revolution); diff --git a/src/Mod/PartDesign/App/FeatureScaled.cpp b/src/Mod/PartDesign/App/FeatureScaled.cpp index d1b3aee40..d788271c9 100644 --- a/src/Mod/PartDesign/App/FeatureScaled.cpp +++ b/src/Mod/PartDesign/App/FeatureScaled.cpp @@ -29,8 +29,7 @@ #endif #include "FeatureScaled.h" -#include "FeatureAdditive.h" -#include "FeatureSubtractive.h" +#include "FeatureAddSub.h" #include #include @@ -73,12 +72,12 @@ const std::list Scaled::getTransformations(const std::vector(originals.front()); TopoDS_Shape original; - if (originalFeature->getTypeId().isDerivedFrom(PartDesign::Additive::getClassTypeId())) { - PartDesign::Additive* addFeature = static_cast(originalFeature); - original = addFeature->AddShape.getShape()._Shape; - } else if (originalFeature->getTypeId().isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) { - PartDesign::Subtractive* subFeature = static_cast(originalFeature); - original = subFeature->SubShape.getShape()._Shape; + if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + PartDesign::FeatureAddSub* Feature = static_cast(originalFeature); + if(Feature->getAddSubType() == FeatureAddSub::Additive) + original = Feature->AddSubShape.getShape()._Shape; + else + original = Feature->AddSubShape.getShape()._Shape; } GProp_GProps props; diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index b3604a45a..4968a3484 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -99,7 +99,7 @@ public: } }; -PROPERTY_SOURCE(PartDesign::SketchBased, PartDesign::Feature) +PROPERTY_SOURCE(PartDesign::SketchBased, PartDesign::FeatureAddSub) SketchBased::SketchBased() { @@ -116,7 +116,7 @@ short SketchBased::mustExecute() const Reversed.isTouched() || UpToFace.isTouched()) return 1; - return PartDesign::Feature::mustExecute(); + return PartDesign::FeatureAddSub::mustExecute(); } void SketchBased::positionBySketch(void) @@ -265,7 +265,7 @@ void SketchBased::onChanged(const App::Property* prop) this->Placement.setStatus(App::Property::ReadOnly, Sketch.getValue() != 0); } - Feature::onChanged(prop); + FeatureAddSub::onChanged(prop); } bool SketchBased::isInside(const TopoDS_Wire& wire1, const TopoDS_Wire& wire2) const diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index aff24dac1..bb2f38784 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -26,7 +26,7 @@ #include #include -#include "Feature.h" +#include "FeatureAddSub.h" class TopoDS_Shape; class TopoDS_Face; @@ -37,7 +37,7 @@ class gp_Lin; namespace PartDesign { -class PartDesignExport SketchBased : public PartDesign::Feature +class PartDesignExport SketchBased : public PartDesign::FeatureAddSub { PROPERTY_HEADER(PartDesign::SketchBased); diff --git a/src/Mod/PartDesign/App/FeatureSubtractive.cpp b/src/Mod/PartDesign/App/FeatureSubtractive.cpp deleted file mode 100644 index 55bb06835..000000000 --- a/src/Mod/PartDesign/App/FeatureSubtractive.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2011 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_ -#endif - - -#include "FeatureSubtractive.h" - - - -namespace PartDesign { - - - -PROPERTY_SOURCE(PartDesign::Subtractive,PartDesign::SketchBased) - -Subtractive::Subtractive() -{ - ADD_PROPERTY(SubShape,(TopoDS_Shape())); -} - -} diff --git a/src/Mod/PartDesign/App/FeatureSubtractive.h b/src/Mod/PartDesign/App/FeatureSubtractive.h deleted file mode 100644 index 450f457ee..000000000 --- a/src/Mod/PartDesign/App/FeatureSubtractive.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2011 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_FeatureSubtractive_H -#define PARTDESIGN_FeatureSubtractive_H - -#include -#include - -#include "FeatureSketchBased.h" - -namespace PartDesign -{ - -class PartDesignExport Subtractive : public SketchBased -{ - PROPERTY_HEADER(PartDesign::Subtractive); - -public: - Subtractive(); - - Part::PropertyPartShape SubShape; - -protected: -}; - -} //namespace PartDesign - - -#endif // PARTDESIGN_FeatureSubtractive_H diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 119f8221b..b8687e04f 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -39,11 +39,11 @@ #include "FeatureTransformed.h" #include "FeatureMultiTransform.h" -#include "FeatureAdditive.h" -#include "FeatureSubtractive.h" +#include "FeatureAddSub.h" #include "FeatureMirrored.h" #include "FeatureLinearPattern.h" #include "FeaturePolarPattern.h" +#include "FeatureSketchBased.h" #include #include @@ -219,19 +219,15 @@ App::DocumentObjectExecReturn *Transformed::execute(void) TopoDS_Shape shape; bool fuse; - if ((*o)->getTypeId().isDerivedFrom(PartDesign::Additive::getClassTypeId())) { - PartDesign::Additive* addFeature = static_cast(*o); - shape = addFeature->AddShape.getShape()._Shape; + if ((*o)->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + PartDesign::FeatureAddSub* feature = static_cast(*o); + shape = feature->AddSubShape.getShape()._Shape; if (shape.IsNull()) return new App::DocumentObjectExecReturn("Shape of additive feature is empty"); - fuse = true; - } else if ((*o)->getTypeId().isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) { - PartDesign::Subtractive* subFeature = static_cast(*o); - shape = subFeature->SubShape.getShape()._Shape; - if (shape.IsNull()) - return new App::DocumentObjectExecReturn("Shape of subtractive feature is empty"); - fuse = false; - } else { + + fuse = (feature->getAddSubType() == FeatureAddSub::Additive) ? true : false; + } + else { return new App::DocumentObjectExecReturn("Only additive and subtractive features can be transformed"); } diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 13493bd04..b972d0113 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -67,8 +67,6 @@ #include #include #include -#include -#include #include #include #include @@ -1559,14 +1557,10 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which, // Get a valid original from the user // First check selections - std::vector features = cmd->getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId()); - std::vector subtractive = cmd->getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId()); - features.insert(features.end(), subtractive.begin(), subtractive.end()); + std::vector features = cmd->getSelection().getObjectsOfType(PartDesign::FeatureAddSub::getClassTypeId()); // Next create a list of all eligible objects if (features.size() == 0) { - features = cmd->getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId()); - subtractive = cmd->getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId()); - features.insert(features.end(), subtractive.begin(), subtractive.end()); + features = cmd->getDocument()->getObjectsOfType(PartDesign::FeatureAddSub::getClassTypeId()); // If there is more than one selected or eligible object, show dialog and let user pick one if (features.size() > 1) { std::vector status; diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index ad6e3f877..aac548643 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -45,9 +45,8 @@ #include #include #include -#include -#include #include +#include #include "ReferenceSelection.h" using namespace PartDesignGui; @@ -105,8 +104,7 @@ const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChang PartDesign::Transformed* pcTransformed = getObject(); App::DocumentObject* selectedObject = pcTransformed->getDocument()->getObject(msg.pObjectName); - if (selectedObject->isDerivedFrom(PartDesign::Additive::getClassTypeId()) || - selectedObject->isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) { + if (selectedObject->isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { // Do the same like in TaskDlgTransformedParameters::accept() but without doCommand std::vector originals = pcTransformed->Originals.getValues(); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 955723919..0db0c7da4 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -103,13 +103,10 @@ void ViewProvider::unsetEdit(int ModNum) void ViewProvider::updateData(const App::Property* prop) { if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && - strcmp(prop->getName(),"AddShape") == 0) { - return; - } - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && - strcmp(prop->getName(),"SubShape") == 0) { + strcmp(prop->getName(),"AddSubShape") == 0) { return; } + inherited::updateData(prop); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp index 41e4f96ac..e3a6ada4f 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp @@ -56,9 +56,8 @@ #include #include #include -#include -#include #include +#include using namespace PartDesignGui; @@ -209,12 +208,9 @@ void ViewProviderTransformed::recomputeFeature(void) if (o->second.empty()) continue; TopoDS_Shape shape; - if ((o->first)->getTypeId().isDerivedFrom(PartDesign::Additive::getClassTypeId())) { - PartDesign::Additive* addFeature = static_cast(o->first); - shape = addFeature->AddShape.getShape()._Shape; - } else if ((o->first)->getTypeId().isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) { - PartDesign::Subtractive* subFeature = static_cast(o->first); - shape = subFeature->SubShape.getShape()._Shape; + if ((o->first)->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + PartDesign::FeatureAddSub* feature = static_cast(o->first); + shape = feature->AddSubShape.getShape()._Shape; } if (shape.IsNull()) continue;