From 575b2dd0048dd38dbe495cc29ebf665fcb74b51f Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 27 Apr 2017 13:22:07 +0300 Subject: [PATCH] Unification of the selection symbol of points --- src/ModuleBase/ModuleBase_ResultPrs.cpp | 45 +++++++++++++++++++++---- src/ModuleBase/ModuleBase_ResultPrs.h | 18 +++++++--- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index bdbae8988..f97560028 100755 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -91,11 +91,14 @@ void ModuleBase_ResultPrs::Compute( } void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) + const Standard_Integer theMode) { - if (aMode > TopAbs_SHAPE) { + if (appendVertexSelection(aSelection, theMode)) + return; + + if (theMode > TopAbs_SHAPE) { // In order to avoid using custom selection modes - if (aMode == ModuleBase_ResultPrs::Sel_Result) { + if (theMode == ModuleBase_ResultPrs::Sel_Result) { AIS_Shape::ComputeSelection(aSelection, TopAbs_COMPOUND); } return; @@ -103,7 +106,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a // TODO: OCCT issue should be created for the COMPOUND processing // before it is fixed, the next workaround in necessary - if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) { + if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) { const TopoDS_Shape& aShape = Shape(); TopExp_Explorer aCompExp(aShape, TopAbs_COMPOUND); // do not activate in compound mode shapes which do not contain compounds @@ -111,7 +114,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a return; } - if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) { + if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) { // Limit selection area only by actual object (Shape) ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult); if (aCompSolid.get()) { @@ -140,7 +143,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a } //AIS_Shape::ComputeSelection(aSelection, 0); } - AIS_Shape::ComputeSelection(aSelection, aMode); + AIS_Shape::ComputeSelection(aSelection, theMode); if (myAdditionalSelectionPriority > 0) { for (aSelection->Init(); aSelection->More(); aSelection->Next()) { @@ -152,6 +155,34 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a } } +bool ModuleBase_ResultPrs::appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer theMode) +{ + if (Shape().ShapeType() == TopAbs_VERTEX) { + const TopoDS_Shape& aShape = Shape(); + + int aPriority = StdSelect_BRepSelectionTool::GetStandardPriority(aShape, TopAbs_VERTEX); + double aDeflection = Prs3d::GetDeflection(aShape, myDrawer); + + /// The cause of this method is the last parameter of BRep owner setting into True. + /// That means that owner should behave like it comes from decomposition. (In this case, OCCT + /// visualizes it in Ring style) OCCT version is 7.0.0 with path for SHAPER module. + Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(aShape, aPriority, Standard_True); + StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection, + aDeflection, myDrawer->HLRAngle(), 9, 500); + + for (aSelection->Init(); aSelection->More(); aSelection->Next()) { + Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner) + ::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId()); + anOwner->Set(this); + } + return true; + } + return false; +} + +/* OBSOLETE void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, const TopoDS_Shape& theShape) { @@ -169,7 +200,7 @@ void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection myDrawer->IsAutoTriangulation()); } catch ( Standard_Failure ) { } -} +}*/ void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, const SelectMgr_SequenceOfOwner& theOwners) diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 19a84f59a..dfaefc5cd 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -39,9 +39,9 @@ public: /// Highlight the presentation with the given color /// \param aPM a presentations manager /// \param theStyle a style of presentation - /// \param aMode a drawing mode + /// \param theMode a drawing mode virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM, - const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer aMode = 0) + const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode = 0) { Selectable()->HilightOwnerWithColor(aPM, theStyle, this); } @@ -105,14 +105,22 @@ protected: /// Redefinition of virtual function Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) ; + const Standard_Integer theMode) ; private: + /// If the shape of this presentation is Vertex, it appends custom sensitive and owners for it. + /// Owner is a usual Brep owner with "isDecomposite" in true. It is necessary to have "Ring" + /// highlight/selected marker. + /// \param theSelection a current filled selection + /// \param theMode a selection mode + /// \return true if the owner is created + bool appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer theMode); /// Appens sensitive and owners for wires of the given shape into selection /// \param theSelection a current filled selection /// \param theShape a shape - void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, - const TopoDS_Shape& theShape); + //void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, + // const TopoDS_Shape& theShape); /// Reference to result object ResultPtr myResult; -- 2.39.2