diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index ed920b772..ce5c2b839 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -59,6 +59,7 @@ using namespace Part; using namespace Attacher; +//These strings are for mode list enum property. const char* AttachEngine::eMapModeStrings[]= { "Deactivated", "Translate", @@ -1252,6 +1253,35 @@ double AttachEngine3D::calculateFoldAngle(gp_Vec axA, gp_Vec axB, gp_Vec edA, gp } +//================================================================================= + +TYPESYSTEM_SOURCE(Attacher::AttachEnginePlane, Attacher::AttachEngine); + +AttachEnginePlane::AttachEnginePlane() +{ + //re-used 3d modes: all of Attacher3d + AttachEngine3D attacher3D; + this->modeRefTypes = attacher3D.modeRefTypes; + this->EnableAllSupportedModes(); +} + +AttachEnginePlane *AttachEnginePlane::copy() const +{ + AttachEnginePlane* p = new AttachEnginePlane; + p->setUp(*this); + return p; +} + +Base::Placement AttachEnginePlane::calculateAttachedPlacement(Base::Placement origPlacement) const +{ + //re-use Attacher3d + Base::Placement plm; + AttachEngine3D attacher3D; + attacher3D.setUp(*this); + plm = attacher3D.calculateAttachedPlacement(origPlacement); + return plm; +} + //================================================================================= TYPESYSTEM_SOURCE(Attacher::AttachEngineLine, Attacher::AttachEngine); diff --git a/src/Mod/Part/App/Attacher.h b/src/Mod/Part/App/Attacher.h index bd7716e05..baa33b6e1 100644 --- a/src/Mod/Part/App/Attacher.h +++ b/src/Mod/Part/App/Attacher.h @@ -360,17 +360,15 @@ private: double calculateFoldAngle(gp_Vec axA, gp_Vec axB, gp_Vec edA, gp_Vec edB) const; }; -typedef AttachEngine3D AttachEnginePlane ;//no separate class for planes, for now. Can be added later, if required. -/* -class AttachEngine2D : public AttachEngine +//attacher specialized for datum planes +class PartExport AttachEnginePlane : public AttachEngine { + TYPESYSTEM_HEADER(); +public: AttachEnginePlane(); - virtual AttachEnginePlane* copy() const {return new AttachEnginePlane(*this);} - virtual Base::Placement calculateAttachedPlacement(void) const; - virtual eMapMode listMapModes(eSuggestResult &msg, std::vector* allmodes = 0, std::vector* nextRefTypeHint = 0) const; - ~AttachEnginePlane(){}; + virtual AttachEnginePlane* copy() const; + virtual Base::Placement calculateAttachedPlacement(Base::Placement origPlacement) const; }; -*/ //attacher specialized for datum lines class PartExport AttachEngineLine : public AttachEngine diff --git a/src/Mod/PartDesign/App/DatumPlane.cpp b/src/Mod/PartDesign/App/DatumPlane.cpp index 0287a2c12..21962440a 100644 --- a/src/Mod/PartDesign/App/DatumPlane.cpp +++ b/src/Mod/PartDesign/App/DatumPlane.cpp @@ -40,7 +40,7 @@ PROPERTY_SOURCE(PartDesign::Plane, Part::Datum) Plane::Plane() { - this->setAttacher(new AttachEngine3D); + this->setAttacher(new AttachEnginePlane); // Create a shape, which will be used by the Sketcher. Them main function is to avoid a dependency of // Sketcher on the PartDesign module BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(0,0,1)));