Skip to content

Commit

Permalink
Attacher: split Attacher3d and AttacherPlane
Browse files Browse the repository at this point in the history
Even though they share all the functionality now, I split them, to allow
independent user-friendly mode names.
  • Loading branch information
DeepSOIC committed Apr 21, 2016
1 parent c56dfa2 commit 4313738
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
30 changes: 30 additions & 0 deletions src/Mod/Part/App/Attacher.cpp
Expand Up @@ -59,6 +59,7 @@
using namespace Part;
using namespace Attacher;

//These strings are for mode list enum property.
const char* AttachEngine::eMapModeStrings[]= {
"Deactivated",
"Translate",
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 6 additions & 8 deletions src/Mod/Part/App/Attacher.h
Expand Up @@ -360,17 +360,15 @@ class PartExport AttachEngine3D : public AttachEngine
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<eMapMode>* allmodes = 0, std::vector<QString>* 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
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/App/DatumPlane.cpp
Expand Up @@ -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)));
Expand Down

0 comments on commit 4313738

Please sign in to comment.