]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Unification of the selection symbol of points
authornds <nds@opencascade.com>
Thu, 27 Apr 2017 10:22:07 +0000 (13:22 +0300)
committernds <nds@opencascade.com>
Thu, 27 Apr 2017 10:22:29 +0000 (13:22 +0300)
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h

index bdbae89880150f89b0319874da495b755e2aa5c2..f9756002817b419f9ff67860159b1dda0ebd092d 100755 (executable)
@@ -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)
index 19a84f59a3ee153fda2664759e370a0f28e9bd5c..dfaefc5cdd5e82b29013b6311c97cb1de93f4703 100644 (file)
@@ -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;