Attacher: split Attacher3d and AttacherPlane

Even though they share all the functionality now, I split them, to allow
independent user-friendly mode names.
This commit is contained in:
DeepSOIC 2016-04-20 01:44:25 +03:00
parent c56dfa254c
commit 431373823d
3 changed files with 37 additions and 9 deletions

View File

@ -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);

View File

@ -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<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

View File

@ -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)));