//Registering of validators
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
- aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
- aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
- aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
- aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
- aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
+ aFactory->registerValidator("PartSet_DistanceSelection", new PartSet_DistanceSelection);
+ aFactory->registerValidator("PartSet_LengthSelection", new PartSet_LengthSelection);
+ aFactory->registerValidator("PartSet_PerpendicularSelection", new PartSet_PerpendicularSelection);
+ aFactory->registerValidator("PartSet_ParallelSelection", new PartSet_ParallelSelection);
+ aFactory->registerValidator("PartSet_RadiusSelection", new PartSet_RadiusSelection);
+ aFactory->registerValidator("PartSet_RigidSelection", new PartSet_RigidSelection);
+ aFactory->registerValidator("PartSet_CoincidentSelection", new PartSet_CoincidentSelection);
+ aFactory->registerValidator("PartSet_HVDirSelection", new PartSet_HVDirSelection);
+ aFactory->registerValidator("PartSet_TangentSelection", new PartSet_TangentSelection);
+
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
return aCount;
}
-bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_DistanceSelection::isValid(const ModuleBase_ISelection* theSelection) const
{
int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection);
return (aCount > 0) && (aCount < 3);
}
-bool PartSet_LengthValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_LengthSelection::isValid(const ModuleBase_ISelection* theSelection) const
{
int aCount = shapesNbLines(theSelection);
- return (aCount > 0) && (aCount < 2);
+ return (aCount == 1);
}
-bool PartSet_PerpendicularValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_PerpendicularSelection::isValid(const ModuleBase_ISelection* theSelection) const
{
int aCount = shapesNbLines(theSelection);
return (aCount > 0) && (aCount < 3);
}
-bool PartSet_ParallelValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_ParallelSelection::isValid(const ModuleBase_ISelection* theSelection) const
{
int aCount = shapesNbLines(theSelection);
return (aCount > 0) && (aCount < 3);
}
-bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_RadiusSelection::isValid(const ModuleBase_ISelection* theSelection) const
{
QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
ModuleBase_ViewerPrs aPrs;
}
}
}
- return (aCount > 0) && (aCount < 2);
+ return (aCount == 1);
}
-bool PartSet_RigidValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_RigidSelection::isValid(const ModuleBase_ISelection* theSelection) const
+{
+ QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
+ return (aList.count() == 1);
+}
+
+
+bool PartSet_CoincidentSelection::isValid(const ModuleBase_ISelection* theSelection) const
+{
+ int aCount = shapesNbPoints(theSelection);
+ return (aCount > 0) && (aCount < 3);
+}
+
+bool PartSet_HVDirSelection::isValid(const ModuleBase_ISelection* theSelection) const
{
int aCount = shapesNbLines(theSelection);
- return (aCount > 0) && (aCount < 2);
+ return (aCount == 1);
}
+bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection) const
+{
+ QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
+ ModuleBase_ViewerPrs aPrs;
+ if (aList.size() != 2)
+ return false;
+
+ ModuleBase_ViewerPrs aPrs1 = aList.first();
+ ModuleBase_ViewerPrs aPrs2 = aList.last();
+
+ const TopoDS_Shape& aShape1 = aPrs1.shape();
+ const TopoDS_Shape& aShape2 = aPrs2.shape();
+ if (aShape1.IsNull() || aShape2.IsNull())
+ return false;
+
+ if ((aShape1.ShapeType() != TopAbs_EDGE) || (aShape2.ShapeType() != TopAbs_EDGE))
+ return false;
+
+ TopoDS_Edge aEdge1 = TopoDS::Edge(aShape1);
+ TopoDS_Edge aEdge2 = TopoDS::Edge(aShape2);
+
+ Standard_Real aStart, aEnd;
+ Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(aEdge1, aStart, aEnd);
+ Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(aEdge2, aStart, aEnd);
+
+ GeomAdaptor_Curve aAdaptor1(aCurve1);
+ GeomAdaptor_Curve aAdaptor2(aCurve2);
+ if (aAdaptor1.GetType() == GeomAbs_Circle)
+ return aAdaptor2.GetType() == GeomAbs_Line;
+ else if (aAdaptor2.GetType() == GeomAbs_Circle)
+ return aAdaptor1.GetType() == GeomAbs_Line;
+ return false;
+}
+
+
bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments) const
{
//! \ingroup Validators
//! A class to validate a selection for Distance constraint operation
-class PartSet_DistanceValidator : public ModuleBase_SelectionValidator
+class PartSet_DistanceSelection : public ModuleBase_SelectionValidator
{
public:
PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
//! \ingroup Validators
//! A class to validate a selection for Length constraint operation
-class PartSet_LengthValidator : public ModuleBase_SelectionValidator
+class PartSet_LengthSelection : public ModuleBase_SelectionValidator
{
public:
PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
//! \ingroup Validators
//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_PerpendicularValidator : public ModuleBase_SelectionValidator
+class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator
{
public:
PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
};
//! \ingroup Validators
-//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_ParallelValidator : public ModuleBase_SelectionValidator
+//! A class to validate a selection for Parallel constraint operation
+class PartSet_ParallelSelection : public ModuleBase_SelectionValidator
{
public:
PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
};
//! \ingroup Validators
-//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_RadiusValidator : public ModuleBase_SelectionValidator
+//! A class to validate a selection for Radius constraint operation
+class PartSet_RadiusSelection : public ModuleBase_SelectionValidator
{
public:
PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
};
//! \ingroup Validators
-//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_RigidValidator : public ModuleBase_SelectionValidator
+//! A class to validate a selection for Rigid constraint operation
+class PartSet_RigidSelection : public ModuleBase_SelectionValidator
+{
+ public:
+ PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+
+//! \ingroup Validators
+//! A class to validate a selection for coincedence constraint operation
+class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator
+{
+ public:
+ PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+//! \ingroup Validators
+//! A class to validate a selection for Horizontal and Vertical constraints operation
+class PartSet_HVDirSelection : public ModuleBase_SelectionValidator
+{
+ public:
+ PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+//! \ingroup Validators
+//! A class to validate a selection for Tangential constraints operation
+class PartSet_TangentSelection : public ModuleBase_SelectionValidator
{
public:
PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
};
+////////////// Attribute validators ////////////////
+
+
/**
* \ingroup Validators
* A validator which checks that objects selected for feature attributes are different (not the same)
<file>icons/tangent.png</file>
<file>icons/fillet.png</file>
<file>icons/coincedence.png</file>
+ <file>icons/mirror.png</file>
</qresource>
</RCC>
return thePrevious;
AISObjectPtr anAIS = thePrevious;
- /// TODO: Equal constraint presentation should be put here
+ if (!anAIS) {
+ anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane());
+ }
return anAIS;
}
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
- <validator id="PartSet_DistanceValidator"/>
+ <validator id="PartSet_DistanceSelection"/>
</feature>
<!-- SketchConstraintLength -->
<doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
- <validator id="PartSet_LengthValidator"/>
+ <validator id="PartSet_LengthSelection"/>
</feature>
<!-- SketchConstraintRadius -->
</shape_selector>
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed"/>
- <validator id="PartSet_RadiusValidator"/>
+ <validator id="PartSet_RadiusSelection"/>
</feature>
<!-- SketchConstraintParallel -->
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
</sketch_constraint_shape_selector>
- <validator id="PartSet_ParallelValidator"/>
+ <validator id="PartSet_ParallelSelection"/>
</feature>
<!-- SketchConstraintPerpendicular -->
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
<validator id="GeomValidators_Edge" parameters="line"/>
</sketch_constraint_shape_selector>
- <validator id="PartSet_PerpendicularValidator"/>
+ <validator id="PartSet_PerpendicularSelection"/>
</feature>
<!-- SketchConstraintCoincedence -->
<sketch_shape_selector id="ConstraintEntityB" label="Second point" tooltip="Select a second point" shape_types="vertex">
<validator id="PartSet_DifferentObjects"/>
</sketch_shape_selector>
+ <validator id="PartSet_CoincidentSelection"/>
</feature>
<!-- SketchConstraintRigid -->
<validator id="PartSet_SketchEntityValidator" parameters="SketchPoint,SketchLine,SketchCircle,SketchArc"/>
<validator id="SketchPlugin_NotFixed"/>
</shape_selector>
- <validator id="PartSet_RigidValidator"/>
+ <validator id="PartSet_RigidSelection"/>
</feature>
<!-- SketchConstraintHorizontal -->
label="Line" tooltip="Select a line" shape_types="edge">
<validator id="GeomValidators_Edge" parameters="line"/>
</sketch_constraint_shape_selector>
+ <validator id="PartSet_HVDirSelection"/>
</feature>
<!-- SketchConstraintVertical -->
label="Line" tooltip="Select a line" shape_types="edge">
<validator id="GeomValidators_Edge" parameters="line"/>
</sketch_constraint_shape_selector>
+ <validator id="PartSet_HVDirSelection"/>
</feature>
<!-- SketchConstraintEqual -->
label="Last object" tooltip="Select line or arc" shape_types="edge">
<validator id="SketchPlugin_TangentAttr" parameters="ConstraintEntityA"/>
</sketch_constraint_shape_selector>
+ <validator id="PartSet_TangentSelection"/>
</feature>
<!-- SketchConstraintMirror -->
<feature
id="SketchConstraintMirror"
- title="Mirror"
+ title="Mirror" icon=":icons/mirror.png"
tooltip="Create constraint, mirroring group of objects">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="Mirror line" tooltip="Select mirror line" shape_types="edge">
SketcherPrs_SensitivePoint.h
SketcherPrs_Radius.h
SketcherPrs_LengthDimension.h
+ SketcherPrs_Mirror.h
)
SET(PROJECT_SOURCES
SketcherPrs_SensitivePoint.cpp
SketcherPrs_Radius.cpp
SketcherPrs_LengthDimension.cpp
+ SketcherPrs_Mirror.cpp
)
SET(PROJECT_LIBRARIES
icons/vertical.png
icons/equal.png
icons/tangent.png
+ icons/mirror.png
)
ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${CAS_DEFINITIONS})
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
aGroup->SetPrimitivesAspect(aLineAspect);
- addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
- addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
+ 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);
+
+ aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+ aLine = SketcherPrs_Tools::getShape(aObj);
+ if (aLine.get() == NULL)
+ return;
+ drawShape(aLine, thePrs);
}
#include "SketcherPrs_Tangent.h"
#include "SketcherPrs_Radius.h"
#include "SketcherPrs_LengthDimension.h"
+#include "SketcherPrs_Mirror.h"
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
+CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(lengthDimensionConstraint)
+
+ /// Creates coincedent perpendicular presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(mirrorConstraint)
};
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Mirror.cpp
+// Created: 6 April 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Mirror.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <SketchPlugin_Constraint.h>
+
+#include <ModelAPI_AttributeRefList.h>
+
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Root.hxx>
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
+{
+}
+
+
+bool SketcherPrs_Mirror::updatePoints(double theStep) const
+{
+ 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();
+ std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+ if (anAttrB.get() == NULL)
+ return false;
+ 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 (aNb != anAttrC->size())
+ return false;
+
+ myPntArray = new Graphic3d_ArrayOfPoints(2 * aNb);
+ int i;
+ ObjectPtr aObj;
+ gp_Pnt aP1;
+ for (i = 0; i < aNb; i++) {
+ aObj = anAttrB->object(i);
+ aP1 = aMgr->getPosition(aObj, this, theStep);
+ myPntArray->SetVertice(i + 1, aP1);
+ }
+ for (i = 0; i < aNb; i++) {
+ aObj = anAttrC->object(i);
+ aP1 = aMgr->getPosition(aObj, this, theStep);
+ myPntArray->SetVertice(aNb + i + 1, aP1);
+ }
+ return true;
+}
+
+
+void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
+{
+ std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+ std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+ if (anAttrB.get() == NULL)
+ return;
+ std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
+ if (anAttrC.get() == NULL)
+ return;
+
+ SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ int aNb = anAttrB->size();
+ if (aNb != anAttrC->size())
+ return;
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+
+ Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+ aGroup->SetPrimitivesAspect(aLineAspect);
+
+ // Draw axis line
+ addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
+
+ // Draw source objects
+ int i;
+ ObjectPtr aObj;
+ for (i = 0; i < aNb; i++) {
+ aObj = anAttrB->object(i);
+ std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
+ if (aShape.get() != NULL)
+ drawShape(aShape, thePrs);
+ }
+ // draw mirrored objects
+ for (i = 0; i < aNb; i++) {
+ aObj = anAttrC->object(i);
+ std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
+ if (aShape.get() != NULL)
+ drawShape(aShape, thePrs);
+ }
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Mirror.h
+// Created: 6 April 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Mirror_H
+#define SketcherPrs_Mirror_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of mirror constraint
+*/
+class SketcherPrs_Mirror: public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_Mirror(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ DEFINE_STANDARD_RTTI(SketcherPrs_Mirror)
+protected:
+ virtual const char* iconName() const { return "mirror.png"; }
+
+ virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+
+ /// Update myPntArray according to presentation positions
+ /// \return true in case of success
+ virtual bool updatePoints(double theStep) const;
+};
+
+#endif
\ No newline at end of file
return;
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
- if (aShape->isEdge()) {
- Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
- aGroup->SetPrimitivesAspect(aLineAspect);
- std::shared_ptr<GeomAPI_Curve> aCurve = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
- if (aCurve->isLine()) {
- addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
- } else {
- GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
- StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
- }
- } else {
- // This is a point
- Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
- myDrawer->SetPointAspect(aPntAspect);
-
- std::shared_ptr<GeomAPI_Vertex> aVertex = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aShape));
- std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
- Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
- StdPrs_Point::Add(thePrs, aPoint, myDrawer);
- }
+ Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+ aGroup->SetPrimitivesAspect(aLineAspect);
+
+ Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
+ myDrawer->SetPointAspect(aPntAspect);
+ drawShape(aShape, thePrs);
}
#include "SketcherPrs_PositionMgr.h"
#include <GeomAPI_Edge.h>
+#include <GeomAPI_Vertex.h>
+#include <GeomAPI_Curve.h>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <AIS_InteractiveContext.hxx>
#include <V3d_Viewer.hxx>
#include <Prs3d_Root.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <StdPrs_DeflectionCurve.hxx>
+#include <StdPrs_Point.hxx>
+#include <StdPrs_Curve.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_GraphicDriver.hxx>
}
}
+void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const Handle(Prs3d_Presentation)& thePrs) const
+{
+ if (theShape->isEdge()) {
+ std::shared_ptr<GeomAPI_Curve> aCurve =
+ std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(theShape));
+ if (aCurve->isLine()) {
+ GeomAdaptor_Curve aCurv(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
+ StdPrs_Curve::Add(thePrs, aCurv, myDrawer);
+ } else {
+ GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
+ StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
+ }
+ } else if (theShape->isVertex()) {
+ std::shared_ptr<GeomAPI_Vertex> aVertex =
+ std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(theShape));
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
+ Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
+ StdPrs_Point::Add(thePrs, aPoint, myDrawer);
+ }
+}
/// \return true in case of success
virtual bool updatePoints(double theStep) const { return true; }
+ void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const Handle(Prs3d_Presentation)& thePrs) const;
+
+
protected:
/// Constraint feature
ModelAPI_Feature* myConstraint;
if ((aShape1.get() == NULL) || (aShape2.get() == NULL))
return;
-
- std::shared_ptr<GeomAPI_Curve> aCurve1 = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape1));
- std::shared_ptr<GeomAPI_Curve> aCurve2 = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape2));
- if (aCurve1->isCircle() && aCurve2->isLine()) {
- addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
- GeomAdaptor_Curve aAdaptor(aCurve1->impl<Handle(Geom_Curve)>(), aCurve1->startParam(), aCurve1->endParam());
- StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
- } else if (aCurve1->isLine() && aCurve2->isCircle()) {
- addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
- GeomAdaptor_Curve aAdaptor(aCurve2->impl<Handle(Geom_Curve)>(), aCurve2->startParam(), aCurve2->endParam());
- StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
- } else {
- // Both curves are arcs
- GeomAdaptor_Curve aAdaptor1(aCurve1->impl<Handle(Geom_Curve)>(), aCurve1->startParam(), aCurve1->endParam());
- StdPrs_DeflectionCurve::Add(thePrs, aAdaptor1, myDrawer);
- GeomAdaptor_Curve aAdaptor2(aCurve2->impl<Handle(Geom_Curve)>(), aCurve2->startParam(), aCurve2->endParam());
- StdPrs_DeflectionCurve::Add(thePrs, aAdaptor2, myDrawer);
- }
+ drawShape(aShape1, thePrs);
+ drawShape(aShape2, thePrs);
}
ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
{
std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttrName));
-
+ std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
return anAttr->object();
}