/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- //SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// \brief Use plugin manager for features creation
SketchPlugin_ConstraintParallel();
};
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Sketch.h>
+#include <SketcherPrs_Factory.h>
+
#include <GeomDataAPI_Point2D.h>
#include <GeomAPI_Pnt2d.h>
#include <GeomAPI_Pnt.h>
if (!sketch())
return thePrevious;
- std::shared_ptr<ModelAPI_Data> aData = data();
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = std::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = std::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
- if (!anAttr1 || !anAttr1->isObject() || !anAttr2 || !anAttr2->isObject())
- return thePrevious;
-
- FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object());
- if (!aFeature)
- return thePrevious;
- std::shared_ptr<SketchPlugin_Line> aLine1Feature =
- std::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
-
- aFeature = ModelAPI_Feature::feature(anAttr2->object());
- if (!aFeature)
- return thePrevious;
- std::shared_ptr<SketchPlugin_Line> aLine2Feature =
- std::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
-
- if (!aLine1Feature || !aLine2Feature)
- return thePrevious;
-
- std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
- std::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
- std::shared_ptr<ModelAPI_ResultConstruction> aConst1 = std::dynamic_pointer_cast<
- ModelAPI_ResultConstruction>(anAttr1->object());
- if (aConst1)
- aLine1 = aConst1->shape();
- std::shared_ptr<ModelAPI_ResultConstruction> aConst2 = std::dynamic_pointer_cast<
- ModelAPI_ResultConstruction>(anAttr2->object());
- if (aConst2)
- aLine2 = aConst2->shape();
-
AISObjectPtr anAIS = thePrevious;
- if (!anAIS)
- anAIS = AISObjectPtr(new GeomAPI_AISObject);
- anAIS->createPerpendicular(aLine1, aLine2, aPlane);
-
- // Set color from preferences
- std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color",
- SKETCH_CONSTRAINT_COLOR);
- anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+ if (!anAIS) {
+ anAIS = SketcherPrs_Factory::perpendicularConstraint(this, sketch()->coordinatePlane());
+ }
return anAIS;
}
-void SketchPlugin_ConstraintPerpendicular::move(double theDeltaX, double theDeltaY)
-{
- //Flyout point of the constraint follows it's features
- return;
-}
-
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// \brief Use plugin manager for features creation
SketchPlugin_ConstraintPerpendicular();
};
SketcherPrs.h
SketcherPrs_Coincident.h
SketcherPrs_Factory.h
- SketcherPrs_Parallel.h
- SketcherPrs_Tools.h
+ SketcherPrs_Parallel.h
+ SketcherPrs_Tools.h
+ SketcherPrs_Perpendicular.h
)
SET(PROJECT_SOURCES
SketcherPrs_Coincident.cpp
SketcherPrs_Factory.cpp
- SketcherPrs_Parallel.cpp
- SketcherPrs_Tools.cpp
+ SketcherPrs_Parallel.cpp
+ SketcherPrs_Tools.cpp
+ SketcherPrs_Perpendicular.cpp
)
SET(PROJECT_LIBRARIES
SET(PROJECT_PICTURES
icons/parallel.png
+ icons/perpendicular.png
)
ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
#include <SketcherPrs_Coincident.h>
#include <SketcherPrs_Parallel.h>
+#include <SketcherPrs_Perpendicular.h>
AISObjectPtr SketcherPrs_Factory::coincidentConstraint(SketchPlugin_Constraint* theConstraint,
Handle(SketcherPrs_Parallel) aPrs = new SketcherPrs_Parallel(theConstraint, thePlane);
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
return aAISObj;
-}
\ No newline at end of file
+}
+
+AISObjectPtr SketcherPrs_Factory::perpendicularConstraint(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(SketcherPrs_Perpendicular) aPrs = new SketcherPrs_Perpendicular(theConstraint, thePlane);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+ return aAISObj;
+}
/// \param thePlane the current sketch plane
static AISObjectPtr parallelConstraint(SketchPlugin_Constraint* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+ /// Creates coincedent perpendicular presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ static AISObjectPtr perpendicularConstraint(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
};
#endif
#include <AIS_Drawer.hxx>
#include <gp_Pnt2d.hxx>
-#include <Image_AlienPixMap.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Root.hxx>
extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
const std::string& theAttribute);
-#ifdef WIN32
-# define FSEP "\\"
-#else
-# define FSEP "/"
-#endif
-
-IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, AIS_InteractiveObject);
-IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, AIS_InteractiveObject);
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
static Handle(Image_AlienPixMap) MyPixMap;
SketcherPrs_Parallel::SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
- : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
- if (MyPixMap.IsNull()) {
- TCollection_AsciiString aFile(getenv("NewGeomResources"));
- aFile += FSEP;
- aFile += "parallel.png";
- MyPixMap = new Image_AlienPixMap();
- if (!MyPixMap->Load(aFile))
- MyPixMap.Nullify();
- }
- if (!MyPixMap.IsNull()) {
- myAspect = new Graphic3d_AspectMarker3d(MyPixMap);
- myPntArray = new Graphic3d_ArrayOfPoints(2);
- myPntArray->AddVertex(0., 0., 0.);
- myPntArray->AddVertex(0. ,0., 0.);
- }
- SetAutoHilight(Standard_False);
+ myPntArray = new Graphic3d_ArrayOfPoints(2);
+ myPntArray->AddVertex(0., 0., 0.);
+ myPntArray->AddVertex(0. ,0., 0.);
}
void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
- if (myAspect.IsNull())
- return;
+ prepareAspect();
std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
if (aLine1.get() == NULL)
(aPnt1->z() + aPnt2->z())/2.);
gp_Vec aVec2(aPnt1->impl<gp_Pnt>(), aPnt2->impl<gp_Pnt>());
- aShift = aVec1.Crossed(myPlane->norm()->impl<gp_Dir>());
+ aShift = aVec2.Crossed(myPlane->norm()->impl<gp_Dir>());
aShift.Normalize();
aShift.Multiply(20);
aP2.Translate(aShift);
const Standard_Integer aMode)
{
ClearSelected();
- std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
- if (aLine1.get() == NULL)
- return;
-
- std::shared_ptr<GeomAPI_Edge> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
- if (aLine2.get() == NULL)
- return;
Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitivePoint) aSP1 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(1));
void SketcherPrs_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
{
- std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
- if (aLine1.get() == NULL)
- return;
-
- std::shared_ptr<GeomAPI_Edge> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
- if (aLine2.get() == NULL)
- return;
-
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
aGroup->SetPrimitivesAspect(aLineAspect);
- std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine1->firstPoint();
- std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine1->lastPoint();
- Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
- aLines->AddVertex(aPnt1->impl<gp_Pnt>());
- aLines->AddVertex(aPnt2->impl<gp_Pnt>());
- aGroup->AddPrimitiveArray(aLines);
-
- aPnt1 = aLine2->firstPoint();
- aPnt2 = aLine2->lastPoint();
- aLines = new Graphic3d_ArrayOfSegments(2, 1);
- aLines->AddVertex(aPnt1->impl<gp_Pnt>());
- aLines->AddVertex(aPnt2->impl<gp_Pnt>());
- aGroup->AddPrimitiveArray(aLines);
+ addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
+ addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
}
-void SketcherPrs_Parallel::ClearSelected()
-{
- Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );
- if( !aSelectionPrs.IsNull() ) {
- aSelectionPrs->Clear();
- }
-}
#ifndef SketcherPrs_Parallel_H
#define SketcherPrs_Parallel_H
-#include <GeomAPI_Ax3.h>
-#include <GeomAPI_Edge.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <Graphic3d_ArrayOfPoints.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Standard_DefineHandle.hxx>
+#include "SketcherPrs_SymbolPrs.h"
class SketchPlugin_Constraint;
class SketchPlugin_Sketch;
-DEFINE_STANDARD_HANDLE(SketcherPrs_Parallel, AIS_InteractiveObject)
+DEFINE_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs)
/**
* \ingroup GUI
* A redefinition of standard AIS Interactive Object in order to provide
-* presentation of coincident constraint
+* presentation of parallel constraint
*/
-class SketcherPrs_Parallel: public AIS_InteractiveObject
+class SketcherPrs_Parallel: public SketcherPrs_SymbolPrs
{
public:
/// Constructor
- /// \param theResult a result object
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
Standard_EXPORT SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
- //! Method which clear all selected owners belonging
- //! to this selectable object ( for fast presentation draw )
- Standard_EXPORT virtual void ClearSelected();
-
DEFINE_STANDARD_RTTI(SketcherPrs_Parallel)
protected:
/// Redefinition of virtual function
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) ;
+ virtual const char* iconName() const { return "parallel.png"; }
+
private:
void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
- SketchPlugin_Constraint* myConstraint;
- std::shared_ptr<GeomAPI_Ax3> myPlane;
- Handle(Graphic3d_AspectMarker3d) myAspect;
Handle(Graphic3d_ArrayOfPoints) myPntArray;
};
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Perpendicular.cpp
+// Created: 12 March 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Perpendicular.h"
+#include "SketcherPrs_Tools.h"
+
+#include <GeomAPI_Pnt.h>
+
+#include <SketchPlugin_Constraint.h>
+
+#include <AIS_Drawer.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+#include <Graphic3d_MarkerImage.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+
+#include <Select3D_SensitivePoint.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+// Function which is defined in SketchPlugin_ConstraintDistance.cpp
+extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
+ const std::string& theAttribute);
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
+{
+ myPntArray = new Graphic3d_ArrayOfPoints(2);
+ myPntArray->AddVertex(0., 0., 0.);
+ myPntArray->AddVertex(0. ,0., 0.);
+}
+
+void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ prepareAspect();
+
+ std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ if (aLine1.get() == NULL)
+ return;
+
+ std::shared_ptr<GeomAPI_Edge> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+ if (aLine2.get() == NULL)
+ return;
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine1->firstPoint();
+ std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine1->lastPoint();
+ gp_Pnt aP1((aPnt1->x() + aPnt2->x())/2.,
+ (aPnt1->y() + aPnt2->y())/2.,
+ (aPnt1->z() + aPnt2->z())/2.);
+
+ gp_Vec aVec1(aPnt1->impl<gp_Pnt>(), aPnt2->impl<gp_Pnt>());
+ gp_Vec aShift = aVec1.Crossed(myPlane->norm()->impl<gp_Dir>());
+ aShift.Normalize();
+ aShift.Multiply(20);
+ aP1.Translate(aShift);
+
+ aPnt1 = aLine2->firstPoint();
+ aPnt2 = aLine2->lastPoint();
+ gp_Pnt aP2((aPnt1->x() + aPnt2->x())/2.,
+ (aPnt1->y() + aPnt2->y())/2.,
+ (aPnt1->z() + aPnt2->z())/2.);
+
+ gp_Vec aVec2(aPnt1->impl<gp_Pnt>(), aPnt2->impl<gp_Pnt>());
+ aShift = aVec2.Crossed(myPlane->norm()->impl<gp_Dir>());
+ aShift.Normalize();
+ aShift.Multiply(20);
+ aP2.Translate(aShift);
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+ aGroup->SetPrimitivesAspect(myAspect);
+ myPntArray->SetVertice(1, aP1);
+ myPntArray->SetVertice(2, aP2);
+ aGroup->AddPrimitiveArray(myPntArray);
+}
+
+void SketcherPrs_Perpendicular::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer aMode)
+{
+ ClearSelected();
+
+ Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this);
+ Handle(Select3D_SensitivePoint) aSP1 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(1));
+ Handle(Select3D_SensitivePoint) aSP2 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(2));
+ aSelection->Add(aSP1);
+ aSelection->Add(aSP2);
+}
+
+void SketcherPrs_Perpendicular::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const SelectMgr_SequenceOfOwner& theOwners)
+{
+
+ Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM );
+ aSelectionPrs->Clear();
+ drawLines(aSelectionPrs, Quantity_NOC_WHITE);
+
+ aSelectionPrs->SetDisplayPriority(9);
+ aSelectionPrs->Display();
+ thePM->Highlight(this);
+}
+
+void SketcherPrs_Perpendicular::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner)
+{
+ thePM->Color(this, theColor);
+
+ Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
+ aHilightPrs->Clear();
+ drawLines(aHilightPrs, theColor);
+
+ if (thePM->IsImmediateModeOn())
+ thePM->AddToImmediateList(aHilightPrs);
+}
+
+
+void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
+{
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+
+ 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());
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Perpendicular.h
+// Created: 12 March 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Perpendicular_H
+#define SketcherPrs_Perpendicular_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of perpendicular constraint
+*/
+class SketcherPrs_Perpendicular: public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+ //! Method which draws selected owners ( for fast presentation draw )
+ Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const SelectMgr_SequenceOfOwner& theOwners);
+
+ //! Method which hilight an owner belonging to
+ //! this selectable object ( for fast presentation draw )
+ Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
+
+
+ DEFINE_STANDARD_RTTI(SketcherPrs_Perpendicular)
+protected:
+ /// Redefinition of virtual function
+ Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+ /// Redefinition of virtual function
+ Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer aMode) ;
+
+ virtual const char* iconName() const { return "perpendicular.png"; }
+
+private:
+
+ void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+
+ Handle(Graphic3d_ArrayOfPoints) myPntArray;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_SymbolPrs.cpp
+// Created: 12 March 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_SymbolPrs.h"
+#include "SketcherPrs_Tools.h"
+
+#include <GeomAPI_Edge.h>
+
+#include <Graphic3d_ArrayOfSegments.hxx>
+
+
+#ifdef WIN32
+# define FSEP "\\"
+#else
+# define FSEP "/"
+#endif
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
+
+
+std::map<const char*, Handle(Image_AlienPixMap)> SketcherPrs_SymbolPrs::myIconsMap;
+
+
+SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+ : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+{
+ SetAutoHilight(Standard_False);
+}
+
+Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
+{
+ if (myIconsMap.count(iconName()) == 1) {
+ return myIconsMap[iconName()];
+ }
+ TCollection_AsciiString aFile(getenv("NewGeomResources"));
+ aFile += FSEP;
+ aFile += iconName();
+ Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
+ if (aPixMap->Load(aFile)) {
+ myIconsMap[iconName()] = aPixMap;
+ return aPixMap;
+ }
+ return Handle(Image_AlienPixMap)();
+}
+
+void SketcherPrs_SymbolPrs::ClearSelected()
+{
+ Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );
+ if( !aSelectionPrs.IsNull() ) {
+ aSelectionPrs->Clear();
+ }
+}
+
+void SketcherPrs_SymbolPrs::prepareAspect()
+{
+ if (myAspect.IsNull()) {
+ myAspect = new Graphic3d_AspectMarker3d(icon());
+ }
+}
+
+void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
+{
+ std::shared_ptr<GeomAPI_Edge> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
+ if (aLine.get() == NULL)
+ return;
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine->firstPoint();
+ std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine->lastPoint();
+
+ Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
+ aLines->AddVertex(aPnt1->impl<gp_Pnt>());
+ aLines->AddVertex(aPnt2->impl<gp_Pnt>());
+ theGroup->AddPrimitiveArray(aLines);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_SymbolPrs.h
+// Created: 12 March 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_SymbolPrs_H
+#define SketcherPrs_SymbolPrs_H
+
+#include <AIS_InteractiveObject.hxx>
+#include <GeomAPI_Ax3.h>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Image_AlienPixMap.hxx>
+
+#include <Standard_DefineHandle.hxx>
+#include <map>
+
+class SketchPlugin_Constraint;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
+
+/**
+* \ingroup GUI
+* A base class of constraint presentation which is represented by an icon
+*/
+class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+ //! Method which clear all selected owners belonging
+ //! to this selectable object ( for fast presentation draw )
+ Standard_EXPORT virtual void ClearSelected();
+
+ DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
+
+protected:
+ /// Returns an icon file name. Has to be redefined in successors
+ virtual const char* iconName() const = 0;
+
+ /// Check and creates if it is necessary myAspect member.
+ /// It has to be called before the object computation
+ virtual void prepareAspect();
+
+ /// Returns icon corresponded to the current constraint type
+ Handle(Image_AlienPixMap) icon();
+
+ /// Add a line into the given group
+ /// \param theGroup a group for drawing
+ /// \param theAttrName an attribute name which corresponds to referenced line
+ void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
+
+protected:
+ /// Constraint feature
+ SketchPlugin_Constraint* myConstraint;
+
+ /// Plane of the current sketcher
+ std::shared_ptr<GeomAPI_Ax3> myPlane;
+
+ /// Aspect for entities drawing
+ Handle(Graphic3d_AspectMarker3d) myAspect;
+
+private:
+ /// Static map to collect constraints icons {IconName : IconPixMap}
+ static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
+};
+
+#endif
\ No newline at end of file