From 0f0ed262e58309bcd9e5a1cb8415523821051d8d Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 16 Mar 2015 12:56:51 +0300 Subject: [PATCH] Define rigid constraint symbol --- .../SketchPlugin_ConstraintRigid.cpp | 48 ++--------- src/SketcherPrs/CMakeLists.txt | 3 + src/SketcherPrs/SketcherPrs_Factory.cpp | 10 +++ src/SketcherPrs/SketcherPrs_Factory.h | 6 ++ src/SketcherPrs/SketcherPrs_Parallel.cpp | 39 --------- src/SketcherPrs/SketcherPrs_Parallel.h | 20 +---- src/SketcherPrs/SketcherPrs_Perpendicular.cpp | 69 --------------- src/SketcherPrs/SketcherPrs_Perpendicular.h | 23 +---- src/SketcherPrs/SketcherPrs_Rigid.cpp | 80 ++++++++++++++++++ src/SketcherPrs/SketcherPrs_Rigid.h | 46 ++++++++++ src/SketcherPrs/SketcherPrs_SymbolPrs.cpp | 46 ++++++++++ src/SketcherPrs/SketcherPrs_SymbolPrs.h | 24 ++++++ src/SketcherPrs/icons/anchor.png | Bin 0 -> 374 bytes 13 files changed, 225 insertions(+), 189 deletions(-) create mode 100644 src/SketcherPrs/SketcherPrs_Rigid.cpp create mode 100644 src/SketcherPrs/SketcherPrs_Rigid.h create mode 100644 src/SketcherPrs/icons/anchor.png diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 51f4b3a01..6695a8813 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -7,6 +7,8 @@ #include "SketchPlugin_ConstraintRigid.h" #include "SketchPlugin_ConstraintParallel.h" +#include + #include #include @@ -31,50 +33,10 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious if (!sketch()) return thePrevious; - std::shared_ptr aData = data(); - std::shared_ptr anAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - if (!anAttr /*|| !anAttr->isObject()*/) - return thePrevious; - - std::shared_ptr aShape; - - if (anAttr->isObject()) { - std::shared_ptr aConst; - aConst = std::dynamic_pointer_cast(anAttr->object()); - - if (!aConst) - return thePrevious; - - std::shared_ptr aSketchFea = - std::dynamic_pointer_cast(ModelAPI_Feature::feature(aConst)); - if (aSketchFea.get() != NULL) { - if (aSketchFea->isExternal()) - return thePrevious; - } - aShape = aConst->shape(); - } - else { - std::shared_ptr aPointAttr = - std::dynamic_pointer_cast(anAttr->attr()); - if (!aPointAttr) - return thePrevious; - std::shared_ptr aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y())); - aShape = GeomAlgoAPI_PointBuilder::point(aPoint); - } - AISObjectPtr anAIS = thePrevious; - if (!anAIS) - anAIS = AISObjectPtr(new GeomAPI_AISObject); - - std::shared_ptr aPlane = sketch()->plane(); - anAIS->createFixed(aShape, aPlane); - - // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color", - SKETCH_CONSTRAINT_COLOR); - - anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); + if (!anAIS) { + anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane()); + } return anAIS; } \ No newline at end of file diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index 37ec076c9..c2ed12fda 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -9,6 +9,7 @@ SET(PROJECT_HEADERS SketcherPrs_Perpendicular.h SketcherPrs_SymbolPrs.h SketcherPrs_PositionMgr.h + SketcherPrs_Rigid.h ) SET(PROJECT_SOURCES @@ -19,6 +20,7 @@ SET(PROJECT_SOURCES SketcherPrs_Perpendicular.cpp SketcherPrs_SymbolPrs.cpp SketcherPrs_PositionMgr.cpp + SketcherPrs_Rigid.cpp ) SET(PROJECT_LIBRARIES @@ -35,6 +37,7 @@ SET(PROJECT_LIBRARIES SET(PROJECT_PICTURES icons/parallel.png icons/perpendicular.png + icons/anchor.png ) ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index 1e3e7c67b..187b94dce 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -9,6 +9,7 @@ #include #include #include +#include AISObjectPtr SketcherPrs_Factory::coincidentConstraint(SketchPlugin_Constraint* theConstraint, @@ -38,3 +39,12 @@ AISObjectPtr SketcherPrs_Factory::perpendicularConstraint(SketchPlugin_Constrain aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); return aAISObj; } + +AISObjectPtr SketcherPrs_Factory::rigidConstraint(SketchPlugin_Constraint* theConstraint, + const std::shared_ptr& thePlane) +{ + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + Handle(SketcherPrs_Rigid) aPrs = new SketcherPrs_Rigid(theConstraint, thePlane); + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); + return aAISObj; +} diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index fb287c05e..6e61853e9 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -37,6 +37,12 @@ public: /// \param thePlane the current sketch plane static AISObjectPtr perpendicularConstraint(SketchPlugin_Constraint* theConstraint, const std::shared_ptr& thePlane); + + /// Creates coincedent perpendicular presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + static AISObjectPtr rigidConstraint(SketchPlugin_Constraint* theConstraint, + const std::shared_ptr& thePlane); }; #endif diff --git a/src/SketcherPrs/SketcherPrs_Parallel.cpp b/src/SketcherPrs/SketcherPrs_Parallel.cpp index e34dfb496..380c15f9c 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.cpp +++ b/src/SketcherPrs/SketcherPrs_Parallel.cpp @@ -75,45 +75,6 @@ void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& t aGroup->AddPrimitiveArray(myPntArray); } -void SketcherPrs_Parallel::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_Parallel::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_Parallel::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_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); diff --git a/src/SketcherPrs/SketcherPrs_Parallel.h b/src/SketcherPrs/SketcherPrs_Parallel.h index 9ea829874..63aa6afc3 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.h +++ b/src/SketcherPrs/SketcherPrs_Parallel.h @@ -28,33 +28,15 @@ public: /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint, const std::shared_ptr& 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_Parallel) 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 "parallel.png"; } -private: - - void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; - - Handle(Graphic3d_ArrayOfPoints) myPntArray; + virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; }; #endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp index 05c7506b2..0c9e45da2 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp @@ -24,13 +24,6 @@ #include #include -#include -#include - -#include -#include -#include - // Function which is defined in SketchPlugin_ConstraintDistance.cpp extern std::shared_ptr getFeaturePoint(DataPtr theData, @@ -69,29 +62,6 @@ void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); gp_Pnt aP1 = aMgr->getPosition(aLine1, this); gp_Pnt aP2 = aMgr->getPosition(aLine2, this); - //std::shared_ptr aPnt1 = aLine1->firstPoint(); - //std::shared_ptr 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(), aPnt2->impl()); - //gp_Vec aShift = aVec1.Crossed(myPlane->norm()->impl()); - //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(), aPnt2->impl()); - //aShift = aVec2.Crossed(myPlane->norm()->impl()); - //aShift.Normalize(); - //aShift.Multiply(20); - //aP2.Translate(aShift); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation); aGroup->SetPrimitivesAspect(myAspect); @@ -100,45 +70,6 @@ void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3 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); diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.h b/src/SketcherPrs/SketcherPrs_Perpendicular.h index a41350b4e..87a620ab1 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.h +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.h @@ -28,33 +28,18 @@ public: Standard_EXPORT SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint, const std::shared_ptr& 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; + /// Redefine this function in order to add additiona lines of constraint base + /// \param thePrs a presentation + /// \param theColor a color of additiona lines + virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; }; #endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp new file mode 100644 index 000000000..e171bf80c --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Rigid.cpp @@ -0,0 +1,80 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Rigid.cpp +// Created: 16 February 2015 +// Author: Vitaly SMETANNIKOV + +#include "SketcherPrs_Rigid.h" +#include "SketcherPrs_Tools.h" +#include "SketcherPrs_PositionMgr.h" + +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + + +extern std::shared_ptr getFeaturePoint(DataPtr theData, + const std::string& theAttribute); + + +IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs); +IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs); + +static Handle(Image_AlienPixMap) MyPixMap; + +SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint, + const std::shared_ptr& thePlane) + : SketcherPrs_SymbolPrs(theConstraint, thePlane) +{ + myPntArray = new Graphic3d_ArrayOfPoints(1); + myPntArray->AddVertex(0., 0., 0.); +} + +void SketcherPrs_Rigid::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) +{ + prepareAspect(); + + std::shared_ptr aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A()); + if (aLine1.get() == NULL) + return; + + SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); + gp_Pnt aP1 = aMgr->getPosition(aLine1, this); + + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation); + aGroup->SetPrimitivesAspect(myAspect); + myPntArray->SetVertice(1, aP1); + aGroup->AddPrimitiveArray(myPntArray); +} + +void SketcherPrs_Rigid::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()); +} + diff --git a/src/SketcherPrs/SketcherPrs_Rigid.h b/src/SketcherPrs/SketcherPrs_Rigid.h new file mode 100644 index 000000000..29ed4544a --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Rigid.h @@ -0,0 +1,46 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Rigid.h +// Created: 16 February 2015 +// Author: Vitaly SMETANNIKOV + +#ifndef SketcherPrs_Rigid_H +#define SketcherPrs_Rigid_H + +#include "SketcherPrs_SymbolPrs.h" + +class SketchPlugin_Constraint; +class SketchPlugin_Sketch; + + +DEFINE_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs) + +/** +* \ingroup GUI +* A redefinition of standard AIS Interactive Object in order to provide +* presentation of parallel constraint +*/ +class SketcherPrs_Rigid: public SketcherPrs_SymbolPrs +{ +public: + /// Constructor + /// \param theConstraint a constraint feature + /// \param thePlane a coordinate plane of current sketch + Standard_EXPORT SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint, + const std::shared_ptr& thePlane); + + DEFINE_STANDARD_RTTI(SketcherPrs_Rigid) +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); + + virtual const char* iconName() const { return "anchor.png"; } + + /// Redefine this function in order to add additiona lines of constraint base + /// \param thePrs a presentation + /// \param theColor a color of additiona lines + virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; +}; + +#endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index 4637f910c..fe06620a3 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -11,6 +11,10 @@ #include +#include +#include +#include + #ifdef WIN32 # define FSEP "\\" @@ -79,3 +83,45 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std aLines->AddVertex(aPnt2->impl()); theGroup->AddPrimitiveArray(aLines); } + +void SketcherPrs_SymbolPrs::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_SymbolPrs::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_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer aMode) +{ + ClearSelected(); + + if (!myPntArray.IsNull()) { + Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this); + for (int i = 1; i <= myPntArray->VertexNumber(); i++) { + Handle(Select3D_SensitivePoint) aSP = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(i)); + aSelection->Add(aSP); + } + } +} diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index 6cce9503e..3fe208699 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -38,6 +38,16 @@ public: //! to this selectable object ( for fast presentation draw ) Standard_EXPORT virtual void ClearSelected(); + + //! 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); + Standard_EXPORT std::shared_ptr plane() const { return myPlane; } Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; } @@ -45,6 +55,11 @@ public: DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs) protected: + + /// Redefinition of virtual function + Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer aMode); + /// Returns an icon file name. Has to be redefined in successors virtual const char* iconName() const = 0; @@ -60,6 +75,11 @@ protected: /// \param theAttrName an attribute name which corresponds to referenced line void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const; + /// Redefine this function in order to add additiona lines of constraint base + /// \param thePrs a presentation + /// \param theColor a color of additiona lines + virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {} + protected: /// Constraint feature SketchPlugin_Constraint* myConstraint; @@ -70,9 +90,13 @@ protected: /// Aspect for entities drawing Handle(Graphic3d_AspectMarker3d) myAspect; + /// Array of symbols positions + Handle(Graphic3d_ArrayOfPoints) myPntArray; + private: /// Static map to collect constraints icons {IconName : IconPixMap} static std::map myIconsMap; + }; #endif \ No newline at end of file diff --git a/src/SketcherPrs/icons/anchor.png b/src/SketcherPrs/icons/anchor.png new file mode 100644 index 0000000000000000000000000000000000000000..5dc7b58273bd6cb0a3303d6df4e084fedc16cae6 GIT binary patch literal 374 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXPVk-lnPYy#nZ(x z#KM2-q>F-01_CaZ8C3(A!dU(o_mxZ#(l{!l(-@?4pnpg8Go$I;J-74 ztQpHPITV+K@8XCFw*F++)M0sMd2F?OCQH(?vd0!>QIBeu2)dkMw0nE&w}H#RA6~itc)Sb#~