FreeCAD C++
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Attacher::AttachEngine Class Referenceabstract

#include <Mod/Part/App/Attacher.h>

Detailed Description

The AttachEngine class is the placement calculation routine, modes, hints and so on. It can be used separately, without deriving from AttachableObject.

Public Member Functions

Base::Placement placementFactory (const gp_Dir &ZAxis, gp_Vec XAxis, gp_Pnt Origin, gp_Pnt refOrg=gp_Pnt(), bool useRefOrg_Line=false, bool useRefOrg_Plane=false, bool makeYVertical=false, bool makeLegacyFlatFaceOrientation=false, Base::Placement *placeOfRef=0) const
 placementFactory calculates placement from Z axis direction, optional X axis direction, and origin point. More...
 
virtual void suggestMapModes (SuggestResult &result) const
 suggestMapModes is the procedure that knows everything about mapping modes. It returns the most appropriate mapping mode, as well as list of all modes that will accept the set of references. In case no modes apply, extra information regarding reasons is returned in msg. More...
 
void EnableAllSupportedModes (void)
 EnableAllModes enables all modes that have shape type lists filled. The function acts on modeEnabled array.
 
- Public Member Functions inherited from Base::BaseClass
 BaseClass ()
 Construction.
 
virtual ~BaseClass ()
 Destruction.
 

Static Public Member Functions

static eRefType getShapeType (const TopoDS_Shape &sh)
 getShapeType by shape. Will never set rtFlagHasPlacement. More...
 
static eRefType getShapeType (const App::DocumentObject *obj, const std::string &subshape)
 getShapeType by link content. Will include rtFlagHasPlacement, if applies. More...
 
static eRefType downgradeType (eRefType type)
 downgradeType converts a more-specific type into a less-specific type (e.g. rtCircle->rtCurve, rtCurve->rtEdge, rtEdge->rtAnything) More...
 
static int getTypeRank (eRefType type)
 getTypeRank determines, how specific is the supplied shape type. The ranks are outlined in definition of eRefType. The ranks are defined by implementation of downgradeType(). More...
 
static int isShapeOfType (eRefType shapeType, eRefType requirement)
 isShapeOfType tests if a shape fulfills the requirement of a mode, and returns a score of how spot on was the requirement. More...
 
static std::string getModeName (eMapMode mmode)
 getModeName More...
 
static void verifyReferencesAreSafe (const App::PropertyLinkSubList &references)
 verifyReferencesAreSafe: checks if pointers in references still point to objects contained in open documents. This guarantees the links are valid. Throws Base::Exception if invalid links are found.
 

Public Attributes

std::vector< bool > modeEnabled
 modeEnabled is an indicator, whether some mode is ever suggested or not. Set to false to suppress suggesting some mode, like so: modeEnabled[mmModeIDontLike] = false;
 

Member Function Documentation

◆ downgradeType()

static eRefType Attacher::AttachEngine::downgradeType ( eRefType  type)
static

downgradeType converts a more-specific type into a less-specific type (e.g. rtCircle->rtCurve, rtCurve->rtEdge, rtEdge->rtAnything)

Parameters
type
Returns
the downgraded type.

◆ getModeName()

static std::string Attacher::AttachEngine::getModeName ( eMapMode  mmode)
static

getModeName

Parameters
mmode
Returns
returns a string that identifies the attachment mode in enum property.

◆ getShapeType() [1/2]

static eRefType Attacher::AttachEngine::getShapeType ( const TopoDS_Shape &  sh)
static

getShapeType by shape. Will never set rtFlagHasPlacement.

Parameters
sh
Returns

◆ getShapeType() [2/2]

static eRefType Attacher::AttachEngine::getShapeType ( const App::DocumentObject obj,
const std::string &  subshape 
)
static

getShapeType by link content. Will include rtFlagHasPlacement, if applies.

Parameters
obj
subshape(input). Can be empty string (then, whole object will be used for shape type testing)
Returns

◆ getTypeRank()

static int Attacher::AttachEngine::getTypeRank ( eRefType  type)
static

getTypeRank determines, how specific is the supplied shape type. The ranks are outlined in definition of eRefType. The ranks are defined by implementation of downgradeType().

Parameters
type
Returns
number of times the type can be downgradeType() before it becomes rtAnything

◆ isShapeOfType()

static int Attacher::AttachEngine::isShapeOfType ( eRefType  shapeType,
eRefType  requirement 
)
static

isShapeOfType tests if a shape fulfills the requirement of a mode, and returns a score of how spot on was the requirement.

Parameters
shapeType(use return value of AttachEngine::getShapeType)
requirement
Returns
: -1 - doesn't fulfill, 0 - compatible topology, but incompatible specific (e.g. rtLine, rtCircle); 1 - valid by generic type (e.g. rtCircle is rtEdge), 2 and up - more and more specific match (according to rank of requirement)

◆ placementFactory()

Base::Placement Attacher::AttachEngine::placementFactory ( const gp_Dir &  ZAxis,
gp_Vec  XAxis,
gp_Pnt  Origin,
gp_Pnt  refOrg = gp_Pnt(),
bool  useRefOrg_Line = false,
bool  useRefOrg_Plane = false,
bool  makeYVertical = false,
bool  makeLegacyFlatFaceOrientation = false,
Base::Placement placeOfRef = 0 
) const

placementFactory calculates placement from Z axis direction, optional X axis direction, and origin point.

Parameters
ZAxis(input) mandatory. Z axis of the returned placement will strictly coincide with ZAxis.
XAxis(input) optional (i.e., can be zero). Sets the preferred X axis orientation. If it is not perpendicular to ZAxis, it will be forced to be. If XAxis is zero, the effect is equivalent to setting makeYVertical to true.
Origin(input) mandatory.
refOrg(input). The point that will be used in case any of useRefOrg_XX parameters is true.
useRefOrg_Line(input). If true, Origin will be moved along ZAxis to be as close as possible to refOrg.
useRefOrg_Plane(input). If true, Origin will be moved in XAxis-YAxis plane to be as close as possible to refOrg.
makeYVertical(input). If true, XAxis is ignored, and X and Y axes are defined in order to make Y axis go as upwards as possible. If ZAxis is strictly upwards, XY will match global XY. If ZAxis is strictly downwards, XAxis will be the reversed global X axis.
makeLegacyFlatFaceOrientation(input). Modifies the behavior of makeYVertical to match the logic that was used in mapping of sketches to flat faces in FreeCAD prior to introduction of Attacher. Set makeYVertical to true if using this.
Returns
the resulting placement. ReverseXY property of Attacher will be automatically applied.

◆ suggestMapModes()

virtual void Attacher::AttachEngine::suggestMapModes ( SuggestResult result) const
virtual

suggestMapModes is the procedure that knows everything about mapping modes. It returns the most appropriate mapping mode, as well as list of all modes that will accept the set of references. In case no modes apply, extra information regarding reasons is returned in msg.

Parameters
result(output). Returns results of suggestion, such as best fit mode, list of all modes that apply, hints, etc.