const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
+ // Get point of the presentation
std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint,
SketchPlugin_Constraint::ENTITY_A());
if (aPnt.get() == NULL)
if (aPtA.IsNull()) {
aPtA = new Graphic3d_AspectMarker3d ();
}
+ // Create the presentation as a combination of standard point markers
+
+ // The external yellow contour
aPtA->SetType(Aspect_TOM_RING3);
aPtA->SetScale(2.);
aPtA->SetColor(Quantity_NOC_YELLOW);
aPntArray->AddVertex (aPoint->x(), aPoint->y(), aPoint->z());
aGroup->AddPrimitiveArray (aPntArray);
+ // Make a black mid ring
aPtA->SetType(Aspect_TOM_RING1);
aPtA->SetScale(1.);
aPtA->SetColor(Quantity_NOC_BLACK);
aGroup->SetPrimitivesAspect(aPtA);
aGroup->AddPrimitiveArray (aPntArray);
+ // Make an internal ring
aPtA->SetType(Aspect_TOM_POINT);
aPtA->SetScale(5.);
aGroup->SetPrimitivesAspect(aPtA);
void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
-// if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
-// Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10);
-// Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint);
-// aSelection->Add(aSp);
-// }
+ // There is no selection of coincident - a point is selected instead of coincidence
}
void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
return false;
+ // Set points of the presentation
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
aGroup->SetPrimitivesAspect(aLineAspect);
+ // Draw first line
ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aObj);
if (aLine.get() == NULL)
return;
drawShape(aLine, thePrs);
+ // Draw second line
aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
aLine = SketcherPrs_Tools::getShape(aObj);
if (aLine.get() == NULL)
#include "SketcherPrs_Transformation.h"
#include "SketcherPrs_Angle.h"
+// Macros for constraint presentation definition
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
const std::shared_ptr<GeomAPI_Ax3>& thePlane) \
CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
-
+// Non-standard constraints definition
AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
{
if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
return false;
+ // Set point of the symbol
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
gp_Pnt aP1 = aMgr->getPosition(aObj, this, theStep);
myPntArray->SetVertice(1, aP1);
{
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+ // Draw constrained object
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
aGroup->SetPrimitivesAspect(aLineAspect);
if (!getPoints(aPnt1, aPnt2))
return;
+ // compute flyout distance
double aD = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
SetFlyout(SketcherPrs_Tools::getFlyoutDistance(myConstraint));
SetMeasuredGeometry(aPnt1, aPnt2, myPlane->impl<gp_Ax3>());
+
+ // Update variable aspect parameters (depending on viewer scale)
myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());
myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length());
// The value of vertical aligment is sometimes changed
myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER);
+
AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode);
}
{
DataPtr aData = myConstraint->data();
if (myConstraint->getKind() == SketchPlugin_ConstraintLength::ID()) {
+ // The constraint is length
std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>
(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
return false;
+ // Get geometry of the object
DataPtr aLineData = aFeature->data();
std::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>
return true;
} else if (myConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) {
+ // The constraint is distance
std::shared_ptr<GeomDataAPI_Point2D> aPoint_A = SketcherPrs_Tools::getFeaturePoint(
aData, SketchPlugin_Constraint::ENTITY_A(), myPlane);
std::shared_ptr<GeomDataAPI_Point2D> aPoint_B = SketcherPrs_Tools::getFeaturePoint(
std::shared_ptr<GeomAPI_Pnt2d> aPnt_A;
std::shared_ptr<GeomAPI_Pnt2d> aPnt_B;
if (aPoint_A && aPoint_B) {
+ // Both objects are points
aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
+ // First object is line
FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
aData, SketchPlugin_Constraint::ENTITY_A());
if (aLine) {
aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
}
} else if (aPoint_A && !aPoint_B) {
+ // Second object is line
FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
aData, SketchPlugin_Constraint::ENTITY_B());
if (aLine) {
aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
}
}
- if (!aPnt_A || !aPnt_B)
+ if (!aPnt_A || !aPnt_B) // Objects not found
return false;
+ // Get points from these objects
std::shared_ptr<GeomAPI_Pnt> aPoint1 = myPlane->to3D(aPnt_A->x(), aPnt_A->y());
std::shared_ptr<GeomAPI_Pnt> aPoint2 = myPlane->to3D(aPnt_B->x(), aPnt_B->y());
thePnt1 = aPoint1->impl<gp_Pnt>();
void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer theMode)
{
+ // Map the application selection modes to standard ones
Standard_Integer aMode;
switch (theMode) {
case 0: // we should use selection of all objects
bool SketcherPrs_Mirror::updatePoints(double theStep) const
{
+ // Get axis of mirror
ObjectPtr aAxisObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
if (SketcherPrs_Tools::getShape(aAxisObj).get() == NULL)
return false;
std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+ // Get source objects
std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
if (anAttrB.get() == NULL)
return false;
+ // Get mirrored objects
std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
if (anAttrC.get() == NULL)
return false;
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
int aNb = anAttrB->size();
+ // If size of source objects and mirrored ones is not equal then the constraint is not computed
if (aNb != anAttrC->size())
return false;
int i;
ObjectPtr aObj;
gp_Pnt aP1;
+ // get position for each source object
for (i = 0; i < aNb; i++) {
aObj = anAttrB->object(i);
aP1 = aMgr->getPosition(aObj, this, theStep);
myPntArray->SetVertice(i + 1, aP1);
}
+ // Get position of each mirrored object
for (i = 0; i < aNb; i++) {
aObj = anAttrC->object(i);
aP1 = aMgr->getPosition(aObj, this, theStep);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
- //Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
- //aGroup->SetPrimitivesAspect(aLineAspect);
-
// drawListOfShapes uses myDrawer for attributes definition
Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1);
myDrawer->SetLineAspect(aLnAspect);
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
+ // Create default array
myPntArray = new Graphic3d_ArrayOfPoints(2);
myPntArray->AddVertex(0., 0., 0.);
myPntArray->AddVertex(0., 0., 0.);
if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
return false;
+ // Compute position of symbols
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
aGroup->SetPrimitivesAspect(aLineAspect);
+ // Draw constrained lines
addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
}
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
+ // Create default array
myPntArray = new Graphic3d_ArrayOfPoints(2);
myPntArray->AddVertex(0., 0., 0.);
myPntArray->AddVertex(0., 0., 0.);
if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
return false;
+ // Compute position of symbols
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
aGroup->SetPrimitivesAspect(aLineAspect);
+ // Draw constrained lines
addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
}
static SketcherPrs_PositionMgr* MyPosMgr = NULL;
-
+// The class is implemented as a singlton
SketcherPrs_PositionMgr* SketcherPrs_PositionMgr::get()
{
if (MyPosMgr == NULL)
const SketcherPrs_SymbolPrs* thePrs)
{
if (myShapes.count(theLine) == 1) {
+ // Find the map and add new [Presentation - Index] pair
PositionsMap& aPosMap = myShapes[theLine];
if (aPosMap.count(thePrs) == 1) {
+ // return existing index
return aPosMap[thePrs];
} else {
+ // Add a new [Presentation - Index] pair
int aInd = aPosMap.size();
aPosMap[thePrs] = aInd;
return aInd;
}
} else {
+ // Create a new map with initial index
PositionsMap aPosMap;
aPosMap[thePrs] = 0;
myShapes[theLine] = aPosMap;
(aPnt1->z() + aPnt2->z())/2.);
} else {
+ // this is a circle or arc
double aMidParam = (aCurve->startParam() + aCurve->endParam()) / 2.;
std::shared_ptr<GeomAPI_Pnt> aPnt = aCurve->getPoint(aMidParam);
aP = aPnt->impl<gp_Pnt>();
std::shared_ptr<GeomAPI_Dir> aDir = thePrs->plane()->dirX();
aVec1 = gp_Vec(aDir->impl<gp_Dir>());
}
+ // Compute shifting vector for a one symbol
gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl<gp_Dir>());
aShift.Normalize();
aShift.Multiply(theStep * 0.8);
+ // Shift the position coordinate according to position index
int aPos = getPositionIndex(theShape, thePrs);
int aM = 1;
if ((aPos % 2) == 0) {
{
std::map<ObjectPtr, PositionsMap>::iterator aIt;
std::list<ObjectPtr> aToDel;
+ // Clear map for deleted presentation
for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) {
PositionsMap& aPosMap = aIt->second;
if (aPosMap.count(thePrs) > 0) {
+ // Erase index
aPosMap.erase(aPosMap.find(thePrs));
if (aPosMap.size() == 0)
+ // Delete the map
aToDel.push_back(aIt->first);
else {
+ // Reindex objects positions in order to avoid spaces
PositionsMap::iterator aIt;
int i = 0;
for (aIt = aPosMap.begin(); aIt != aPosMap.end(); aIt++, i++)
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), myPlane(thePlane)
{
+ // Set default values of the presentation
myAspect = new Prs3d_DimensionAspect();
myAspect->MakeArrows3d(false);
myAspect->MakeText3d(false);
void SketcherPrs_Radius::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer theMode)
{
+ // Map the application selection modes to standard ones
Standard_Integer aMode;
switch (theMode) {
case 0: // we should use selection of all objects
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
+ // Set default points array
myPntArray = new Graphic3d_ArrayOfPoints(1);
myPntArray->AddVertex(0., 0., 0.);
}
std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(SketchPlugin_Constraint::ENTITY_A());
AttributePtr aRefAttr = anAttr->attr();
if (anAttr->isObject()) {
+ // The constraint attached to an object
ObjectPtr aObj = anAttr->object();
if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
return false;
gp_Pnt aP1 = aMgr->getPosition(aObj, this, theStep);
myPntArray->SetVertice(1, aP1);
} else {
+ // The constraint attached to a point
std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_A());
if (aPnt.get() == NULL)
return false;
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
std::shared_ptr<GeomAPI_Shape> aShape;
if (aFeature.get()) {
+ // If constraint attached to a feature
const std::list<ResultPtr>& aResults = aFeature->results();
std::list<ResultPtr>::const_iterator aIt;
+ // Find a shape
for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
aShape = (*aIt)->shape();
if (aShape->isEdge())
break;
}
} else {
+ // Else it is a result
aShape = SketcherPrs_Tools::getShape(aObj);
}
if (aShape.get() == NULL)
SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs()
{
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ // Empty memory in position manager
aMgr->deleteConstraint(this);
}
if (myIconsMap.count(iconName()) == 1) {
return myIconsMap[iconName()];
}
+ // Load icon for the presentation
char* aEnv = getenv("NEWGEOM_ROOT_DIR");
if (aEnv != NULL) {
TCollection_AsciiString aFile(aEnv);
return aPixMap;
}
}
+ // The icon for constraint is not found
static const char aMsg[] = "Error! constraint images are not found";
cout<<aMsg<<endl;
Events_Error::send(aMsg);
void SketcherPrs_SymbolPrs::prepareAspect()
{
+ // Create an aspect with the icon
if (myAspect.IsNull()) {
Handle(Image_AlienPixMap) aIcon = icon();
if (aIcon.IsNull())
std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
+ // Draw line by two points
Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
aLines->AddVertex(aPnt1->impl<gp_Pnt>());
aLines->AddVertex(aPnt2->impl<gp_Pnt>());
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
+ // Create an icon
prepareAspect();
Handle(AIS_InteractiveContext) aCtx = GetContext();
aDriver->UserDrawCallback() = SymbolPrsCallBack;
}
+ // Update points with default shift value
if (!updatePoints(20)) {
return;
}
myOwner = new SelectMgr_EntityOwner(this);
}
+ // Create sensitive point for each symbol
mySPoints.Clear();
for (int i = 1; i <= aNbVertex; i++) {
Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, i);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
aGroup->SetPrimitivesAspect(myAspect);
+ // Recompute boundary box of the group
Graphic3d_BndBox4f& aBnd = aGroup->ChangeBoundingBox();
gp_Pnt aVert;
aBnd.Clear();
aBnd.Add (Graphic3d_Vec4((float)aVert.X(), (float)aVert.Y(), (float)aVert.Z(), 1.0f));
}
+ // Pint the group with custom procedure (see Render)
aGroup->UserDraw(this, true);
// Disable frustum culling for this object by marking it as mutable
Handle(OpenGl_View) aView = theWorkspace->ActiveView();
double aScale = aView->Camera()->Scale();
+ // Update points coordinate taking the viewer scale into account
if (!updatePoints(MyDist * aScale))
return;
myVboAttribs = new SketcherPrs_VertexBuffer(*aAttribs);
}
+ // Update drawing attributes
if (!myVboAttribs->init(aCtx, 0, aAttribs->NbElements, aAttribs->Data(), GL_NONE, aAttribs->Stride)) {
myVboAttribs->Release (aCtx.operator->());
myVboAttribs.Nullify();
if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
aLineColor = theWorkspace->HighlightColor;
+ // Set lighting of the symbol
if (toHilight)
aCtx->core11fwd->glDisable (GL_LIGHTING);
else
void SketcherPrs_SymbolPrs::Release (OpenGl_Context* theContext)
{
+ // Release OpenGl resources
if (!myVboAttribs.IsNull()) {
if (theContext) {
theContext->DelayedRelease (myVboAttribs);
const Handle(Prs3d_Presentation)& thePrs) const
{
if (theShape->isEdge()) {
+ // The shape is edge
std::shared_ptr<GeomAPI_Curve> aCurve =
std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(theShape));
if (aCurve->isLine()) {
+ // The shape is line
GeomAdaptor_Curve aCurv(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
StdPrs_Curve::Add(thePrs, aCurv, myDrawer);
} else {
+ // The shape is circle or arc
GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
}
} else if (theShape->isVertex()) {
+ // draw vertex
std::shared_ptr<GeomAPI_Vertex> aVertex =
std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(theShape));
std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
void SketcherPrs_SymbolPrs::BoundingBox (Bnd_Box& theBndBox)
{
Select3D_BndBox3d aTmpBox;
- for (Select3D_EntitySequenceIter aPntIter (mySPoints); aPntIter.More(); aPntIter.Next())
- {
+ for (Select3D_EntitySequenceIter aPntIter (mySPoints); aPntIter.More(); aPntIter.Next()) {
const Handle(Select3D_SensitiveEntity)& anEnt = aPntIter.Value();
aTmpBox.Combine (anEnt->BoundingBox());
}
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
+ // Init default points
myPntArray = new Graphic3d_ArrayOfPoints(2);
myPntArray->AddVertex(0., 0., 0.);
myPntArray->AddVertex(0., 0., 0.);
if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
return false;
+ // Compute points coordinates
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
}
//*************************************************************************************
+/// Find an attribute of the given object which corresponds to a vetrex
+/// defined by a shape
+/// \param theObject an object
+/// \param theShape a vertex
+/// \param thePlane a projection plane (sketcher plane)
std::shared_ptr<GeomDataAPI_Point2D> findGeomPoint(ObjectPtr theObject,
const TopoDS_Shape& theShape,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
ObjectPtr anObject = anAttr->object();
aFeature = ModelAPI_Feature::feature(anObject);
if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) {
+ // Attribute refers to a point
aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
}
else {
+ // if the attribute refers on another object
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aRes.get()) {
GeomShapePtr aShape = aRes->shape();
}
}
else if (anAttr->attr()) {
+ // If attribute is a point
aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
}
}
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
std::shared_ptr<GeomAPI_Pnt2d> aCenter;
- if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ if (aFeature->getKind() == SketchPlugin_Arc::ID()) { // arc
aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aFeature->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt();
- } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+ } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aFeature->attribute(SketchPlugin_Circle::CENTER_ID()))->pnt();
- } else
+ } else
return std::shared_ptr<GeomAPI_Pnt>();
std::shared_ptr<GeomAPI_Pnt2d> anOrigin(new GeomAPI_Pnt2d(0.0, 0.0));
namespace SketcherPrs_Tools {
-/// Enumeration with modes for activation of selection custom presentations
-enum SelectionModes {
- /// Start of enumeration
- Sel_Mode_First = 100,
+ /// Enumeration with modes for activation of selection custom presentations
+ enum SelectionModes {
+ /// Start of enumeration
+ Sel_Mode_First = 100,
- /// Selection mode for all constraints exclude dimensions
- Sel_Constraint,
+ /// Selection mode for all constraints exclude dimensions
+ Sel_Constraint,
- /// Selection mode for whole dimension
- Sel_Dimension_All,
+ /// Selection mode for whole dimension
+ Sel_Dimension_All,
- /// Selection mode for line of dimension
- Sel_Dimension_Line,
+ /// Selection mode for line of dimension
+ Sel_Dimension_Line,
- /// Selection mode foe text of dimension
- Sel_Dimension_Text
-};
+ /// Selection mode foe text of dimension
+ Sel_Dimension_Text
+ };
+ /// Returns result object referenced by feature
+ /// \param theFeature a feature
+ /// \param theAttrName an attribute name
SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
const std::string& theAttrName);
+ /// Returns shape from result object (or NULL)
+ /// \param theObject a result object
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
+
+ /// Returns point from a line feature
+ /// \param theFeature a line feature
+ /// \param theAttrName an attribute of the point
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
const std::string& theAttrName);
+
+ /// Returns point projected on a line
+ /// \param theLine a line
+ /// \param thePoint a projecting point
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
const FeaturePtr theLine,
const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
const std::string& theAttribute);
/// Obtain the point object from specified constraint parameter
+ /// \param theData a data object
+ /// \param theAttribute an attribute name
+ /// \param thePlane a projection plane (sketcher plane)
SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
const std::string& theAttribute,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ /// Returns value of dimension arrows size
SKETCHERPRS_EXPORT double getArrowSize();
+ /// Set value of dimension arrows size
+ /// \param theSize a size value
SKETCHERPRS_EXPORT void setArrowSize(double theSize);
+ /// Set value of dimension text height
+ /// \param theHeight a height value
SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
+ /// Returns value of dimension text height
SKETCHERPRS_EXPORT double getTextHeight();
+ /// Returns default value of dimension text height
SKETCHERPRS_EXPORT double getDefaultTextHeight();
+ /// Get flayout distance of the dimension constraint
+ /// \param theConstraint a dimension constraint object
SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
+ /// Compute anchor pint for radius dimension
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
const ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
bool SketcherPrs_Transformation::updatePoints(double theStep) const
{
std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+ // Get transformated objects list
std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
if (anAttrB.get() == NULL)
return false;
int i;
ObjectPtr aObj;
gp_Pnt aP1;
+ // Compute points of symbols
for (i = 0; i < aNbB; i++) {
aObj = anAttrB->object(i);
aP1 = aMgr->getPosition(aObj, this, theStep);
drawListOfShapes(anAttrB, thePrs);
if (myConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
+ // If it is translation
std::shared_ptr<GeomDataAPI_Point2D> aStart = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID()));
std::shared_ptr<GeomDataAPI_Point2D> aEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_MultiTranslation::END_POINT_ID()));
if (aStart.get() && aEnd.get() && aStart->isInitialized() && aEnd->isInitialized()) {
+ // Add start point
std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aStart->x(), aStart->y());
Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
StdPrs_Point::Add(thePrs, aPoint, myDrawer);
+ // Add end point
aPnt = myPlane->to3D(aEnd->x(), aEnd->y());
aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
StdPrs_Point::Add(thePrs, aPoint, myDrawer);
}
} else if (myConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
+ // if it is rotation
std::shared_ptr<GeomDataAPI_Point2D> aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_MultiRotation::CENTER_ID()));
if (aCenter.get() && aCenter->isInitialized()) {
+ // Show center of rotation
std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aCenter->x(), aCenter->y());
Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
StdPrs_Point::Add(thePrs, aPoint, myDrawer);