]> OCCT Git - occt-copy.git/commitdiff
0031150: Visualization - provide interface to change selection entities sensitivity... CR31150
authornds <nds@opencascade.com>
Mon, 11 Nov 2019 11:52:52 +0000 (14:52 +0300)
committernds <nds@opencascade.com>
Mon, 11 Nov 2019 11:52:52 +0000 (14:52 +0300)
24 files changed:
src/Select3D/Select3D_SensitiveBox.hxx
src/Select3D/Select3D_SensitiveCircle.cxx
src/Select3D/Select3D_SensitiveCircle.hxx
src/Select3D/Select3D_SensitiveCurve.cxx
src/Select3D/Select3D_SensitiveCurve.hxx
src/Select3D/Select3D_SensitiveEntity.cxx
src/Select3D/Select3D_SensitiveEntity.hxx
src/Select3D/Select3D_SensitiveFace.hxx
src/Select3D/Select3D_SensitivePoint.cxx
src/Select3D/Select3D_SensitivePoint.hxx
src/Select3D/Select3D_SensitivePoly.hxx
src/Select3D/Select3D_SensitivePrimitiveArray.hxx
src/Select3D/Select3D_SensitiveSegment.hxx
src/Select3D/Select3D_SensitiveSet.hxx
src/Select3D/Select3D_SensitiveTriangle.hxx
src/Select3D/Select3D_SensitiveTriangulation.hxx
src/Select3D/Select3D_SensitiveWire.hxx
src/SelectMgr/FILES
src/SelectMgr/SelectMgr_MapOfSensitivityFactor.hxx [new file with mode: 0644]
src/SelectMgr/SelectMgr_SelectableObject.hxx
src/SelectMgr/SelectMgr_Selection.cxx
src/SelectMgr/SelectMgr_Selection.hxx
src/SelectMgr/SelectMgr_SelectionManager.cxx
src/SelectMgr/SelectMgr_SelectionManager.hxx

index cb735264c2a9d7be51b7d0179f56379a88728126..e379ed1b4e921efb140fb5c3e36616e17a01e7c2 100644 (file)
@@ -70,6 +70,9 @@ public:
   //! transformation is set, it will be applied
   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index e1523f1e4be9e7988b83d93d765f6e9ba66a887d..2f7f10782c877823e561ec37d3aff70a1dff6501 100644 (file)
@@ -108,7 +108,7 @@ Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_Entity
 
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
-    SetSensitivityFactor (6);
+    SetSensitivityFactor (Sensitivity());
   }
 }
 
@@ -166,7 +166,7 @@ Select3D_SensitiveCircle::Select3D_SensitiveCircle (const Handle(SelectMgr_Entit
 
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
-    SetSensitivityFactor (6);
+    SetSensitivityFactor (Sensitivity());
   }
 }
 
@@ -190,7 +190,7 @@ Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_Entity
 
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
-    SetSensitivityFactor (6);
+    SetSensitivityFactor (Sensitivity());
   }
 }
 
@@ -215,7 +215,7 @@ Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_Entity
 
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
-    SetSensitivityFactor (6);
+    SetSensitivityFactor (Sensitivity());
   }
 }
 
index 9f9e2884fdb64eb7177c2d2a7fec58433229134f..87c65961dfafb033225a7cedc5c59a90242020cf 100644 (file)
@@ -89,6 +89,9 @@ public:
   //! Builds BVH tree for a circle's edge segments if needed
   Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 6; }
+
 protected:
 
   //! Calculates distance from the 3d projection of used-picked screen point
index 06669d2e959fa6ad004ae168acbac97de5d6ccdb..c33e5ca10f34a9743932afae6ab747d05be98950 100644 (file)
@@ -32,7 +32,7 @@ Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityO
   myCurve (theCurve)
 {
   loadPoints (theCurve, theNbPnts);
-  SetSensitivityFactor (3);
+  SetSensitivityFactor (Sensitivity());
 }
 
 //==================================================
@@ -44,7 +44,7 @@ Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityO
 : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True)
 
 {
-  SetSensitivityFactor (3);
+  SetSensitivityFactor (Sensitivity());
 }
 
 //==================================================
@@ -55,7 +55,7 @@ Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityO
                                                   const TColgp_Array1OfPnt& thePoints)
 : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True)
 {
-  SetSensitivityFactor (3);
+  SetSensitivityFactor (Sensitivity());
 }
 
 //==================================================
index 1e63a87bdc49bee1ca4b48700a5193e3185ffd77..3e972089886973176e9722bc0933d2b0ce3d5605 100644 (file)
@@ -53,6 +53,9 @@ public:
   //! Returns the copy of this
   Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 3; }
+
 private:
 
   void loadPoints (const Handle(Geom_Curve)& aCurve,
index 43804bad6973f73113b42733d4bc1147826cb015..421847c9cf58b1f39fde3250e0f6c97f545b2536 100644 (file)
@@ -26,7 +26,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveEntity, Standard_Transient)
 //=======================================================================
 Select3D_SensitiveEntity::Select3D_SensitiveEntity (const Handle(SelectMgr_EntityOwner)& theOwnerId)
 : myOwnerId (theOwnerId),
-  mySFactor (2)
+  mySFactor (Sensitivity())
 {
   //
 }
index 277a9d87de865e8616626e653fac41c82a72ea77..4c3a8d4a91b95e35b0989450f0342002c2aefcf9 100644 (file)
@@ -91,6 +91,9 @@ public:
   //! Otherwise, returns identity matrix.
   virtual gp_GTrsf InvInitLocation() const { return gp_GTrsf(); }
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
 
index 2a0af16113004d4037e11c4104ead6bc0677b48a..6e59cf19617e492298feaea486d3a3e01f29359b 100644 (file)
@@ -73,6 +73,9 @@ public:
   //! Returns the amount of sub-entities (points or planar convex polygons)
   Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 72facedce07c1cb1cffbff692a14bd1d5a706ee5..492e57f418bfa91a2c462dc107223f4565f891f0 100644 (file)
@@ -26,7 +26,7 @@ Select3D_SensitivePoint::Select3D_SensitivePoint (const Handle(SelectMgr_EntityO
                                                   const gp_Pnt& thePoint)
 : Select3D_SensitiveEntity (theOwner)
 {
-  SetSensitivityFactor (12);
+  SetSensitivityFactor (Sensitivity());
   myPoint = thePoint;
 }
 
index 5906c5181dc742f07217bae4e1c1a273eeea780a..934362ff66e3ff5618c705994928bfa9ce881072 100644 (file)
@@ -50,6 +50,9 @@ public:
   //! transformation is set, it will be applied
   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 12; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 7b71d10920163480f94abb78e5e35e7c0d666e6b..c54fc5a843d3949b9bbbb3c0b36c592f4d9409f5 100644 (file)
@@ -92,6 +92,9 @@ public:
   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index b06a1a269aa655b994b5816961b929cdb337d625..a7696e2723823787d2e510a7f930468f8976bfc5 100644 (file)
@@ -197,6 +197,9 @@ public:
   //! Return the second node of last topmost detected edge or -1 if undefined (axis picking).
   Standard_Integer LastDetectedEdgeNode2() const { return myDetectedEdgeNode2; }
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 17ff4c3b96f45252be3a6930234c5bd5fb8d63ad..7bccf542564ca949d5eb579d40e2b5f4f144dc59 100644 (file)
@@ -70,6 +70,9 @@ public:
   //! changes the end point of the segment
   void EndPoint (const gp_Pnt& thePnt) { myEnd = thePnt; }
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 261c4cb315fc49358e18b7b5fce7ff24eef543bb..c4cbd8cdb88f0ed7c7e41534f5e13c3de18caa34 100644 (file)
@@ -96,6 +96,9 @@ public:
   //! Returns a number of nodes in 1 BVH leaf
   Standard_Integer GetLeafNodeSize() const { return myContent.Builder()->LeafNodeSize(); }
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 6e0b789769827b8d0537657de0f589059af7e483..0636b7a08cb2bb2e1169cd83fcaeb2a52a3f258a 100644 (file)
@@ -67,6 +67,9 @@ public:
 
   virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE { return myCentroid; }
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 92ef699d55ef2d810daa0931102b2b1bc4c890f6..403ba717acb2624c98de874ac149b348bfbc135d 100644 (file)
@@ -93,6 +93,9 @@ public:
 
   const TopLoc_Location& GetInitLocation() const { return myInitLocation; }
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index eca3ac58e72d814538442c2bf46bbea5f4a5e7f8..ede721b5a4f27158d5bc98c114486dafdd37b3d5 100644 (file)
@@ -68,6 +68,9 @@ public:
   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
 
+  //! Returns default sensitivity factor of the type
+  static Standard_Integer Sensitivity() { return 2; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
index 1978fa8d5910b81cd9ffb3666227bfdf90db1396..85181f39a67b537740ef620173d9c2cdc2bbecf1 100755 (executable)
@@ -17,6 +17,7 @@ SelectMgr_IndexedDataMapOfOwnerCriterion.hxx
 SelectMgr_IndexedMapOfOwner.hxx
 SelectMgr_ListIteratorOfListOfFilter.hxx
 SelectMgr_ListOfFilter.hxx
+SelectMgr_MapOfSensitivityFactor.hxx
 SelectMgr_OrFilter.cxx
 SelectMgr_OrFilter.hxx
 SelectMgr_PickingStrategy.hxx
diff --git a/src/SelectMgr/SelectMgr_MapOfSensitivityFactor.hxx b/src/SelectMgr/SelectMgr_MapOfSensitivityFactor.hxx
new file mode 100644 (file)
index 0000000..ac5bca6
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef SelectMgr_MapOfSensitivityFactor_HeaderFile
+#define SelectMgr_MapOfSensitivityFactor_HeaderFile
+
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <NCollection_DataMap.hxx>
+
+typedef NCollection_DataMap<TCollection_AsciiString, Standard_Integer> SelectMgr_MapOfSensitivityFactor;
+
+
+#endif
index 73885090a2d4d6b0916698f8cc4010e32ddd8cc3..aacce9f14b523e61b125a67d29cc7917c5a1ee8b 100644 (file)
@@ -211,6 +211,7 @@ protected:
 protected:
 
   SelectMgr_SequenceOfSelection myselections;    //!< list of selections
+  NCollection_Map<Standard_Integer, Standard_Integer> mySensitivityFactors; //!< container of sensitive factor values
   Handle(Prs3d_Presentation)    mySelectionPrs;  //!< optional presentation for highlighting selected object
   Handle(Prs3d_Presentation)    myHilightPrs;    //!< optional presentation for highlighting detected object
   Standard_Integer              myGlobalSelMode; //!< global selection mode
index 7a1cef72f17781e2d60ad9aaf0f6338f0f695cc4..1e0ef0d4a0f73de973323ad9357e446eace40e6e 100644 (file)
@@ -81,6 +81,10 @@ void SelectMgr_Selection::Add (const Handle(Select3D_SensitiveEntity)& theSensit
   }
   else
   {
+    Standard_Integer aSensitivityFactor;
+    if (mySensitivityFactors.Find (anEntity->DynamicType()->Name(), aSensitivityFactor))
+      anEntity->BaseSensitive()->SetSensitivityFactor (aSensitivityFactor);
+
     mySensFactor = Max (mySensFactor, anEntity->BaseSensitive()->SensitivityFactor());
   }
 }      
@@ -117,6 +121,27 @@ void SelectMgr_Selection::SetSensitivity (const Standard_Integer theNewSens)
   }
 }
 
+// =======================================================================
+// function : SensitivityFactor
+// purpose  :
+// =======================================================================
+Standard_Boolean SelectMgr_Selection::SensitivityFactor (const TCollection_AsciiString& theType, Standard_Integer& theValue)
+{
+  return mySensitivityFactors.Find (theType, theValue);
+}
+
+// =======================================================================
+// function : DumpJson
+// purpose  :
+// =======================================================================
+void SelectMgr_Selection::SetSensitivityFactor (const TCollection_AsciiString& theType, const Standard_Integer theValue)
+{
+  if (!mySensitivityFactors.IsBound (theType))
+  {
+    mySensitivityFactors.Bind (theType, theValue);
+  }
+}
+
 // =======================================================================
 // function : DumpJson
 // purpose  :
index e5ec664251be34958e43ef3dbe4776cb13d36b5c..dd603b45026c3be77569739ff05840f34486fe9e 100644 (file)
@@ -18,6 +18,7 @@
 #define _SelectMgr_Selection_HeaderFile
 
 #include <NCollection_Vector.hxx>
+#include <SelectMgr_MapOfSensitivityFactor.hxx>
 #include <SelectMgr_SensitiveEntity.hxx>
 #include <SelectMgr_StateOfSelection.hxx>
 #include <SelectMgr_TypeOfBVHUpdate.hxx>
@@ -139,12 +140,26 @@ public:
   //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
   Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
 
+  //!< Returns container of default sensitive factor values
+  const SelectMgr_MapOfSensitivityFactor& SensitivityFactors() const { return mySensitivityFactors; }
+
+  //!< Sets sensitive factor value for some type
+  Standard_EXPORT Standard_Boolean SensitivityFactor (const TCollection_AsciiString& theType, Standard_Integer& theValue);
+
+  //!< Sets sensitive factor value for some type
+  Standard_EXPORT void SetSensitivityFactor (const TCollection_AsciiString& theType, const Standard_Integer theValue);
+
+  //!< Returns container of default sensitive factor values
+  void SetSensitivityFactors (const SelectMgr_MapOfSensitivityFactor& theValues) { mySensitivityFactors = theValues; }
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
 
 private:
 
   NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
+
+  SelectMgr_MapOfSensitivityFactor                      mySensitivityFactors;
   Standard_Integer                                      myEntityIter;
   Standard_Integer                                      myMode;
   SelectMgr_TypeOfUpdate                                myUpdateStatus;
index 195ed54c754b0a9cda1096a24d36adf518c1c813..5bbeec58fdf6d60816cae20e103e0f9203b384aa 100644 (file)
@@ -27,7 +27,7 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient)
 // Purpose :
 //==================================================
 SelectMgr_SelectionManager::SelectMgr_SelectionManager (const Handle(SelectMgr_ViewerSelector)& theSelector)
-: mySelector (theSelector)
+: mySelector (theSelector), myDefaultSensitivityFactor (2)
 {
   //
 }
@@ -558,6 +558,15 @@ void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr
   }
 }
 
+//=======================================================================
+//function : SetDefaultSelectionSensitivity
+//purpose  :
+//=======================================================================
+void SelectMgr_SelectionManager::SetDefaultSensitivityFactor (const TCollection_AsciiString& theType, const Standard_Integer theValue)
+{
+  mySensitivityFactors.Bind (theType, theValue);
+}
+
 //=======================================================================
 //function : UpdateSelection
 //purpose  :
index 7c81974652ad708b3bf02d433e75b38c92d30a23..f53a7c0afe413bd2c20060da018a6b2656c30406 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef _SelectMgr_SelectionManager_HeaderFile
 #define _SelectMgr_SelectionManager_HeaderFile
 
+#include <SelectMgr_MapOfSensitivityFactor.hxx>
 #include <SelectMgr_ViewerSelector.hxx>
 #include <SelectMgr_TypeOfUpdate.hxx>
 
@@ -99,6 +100,18 @@ public:
                                                 const Standard_Integer theMode,
                                                 const Standard_Integer theNewSens);
 
+  //!< Sets default sensitive factor, used for types where other is not defined
+  Standard_Integer DefaultSensitivityFactor() const { return myDefaultSensitivityFactor; }
+
+  //!< Returns default sensitive factor
+  void SetDefaultSensitivityFactor (const Standard_Integer theValue) { myDefaultSensitivityFactor = theValue; }
+
+  //!< Sets sensitive factor values for some type
+  Standard_EXPORT void SetDefaultSensitivityFactor (const TCollection_AsciiString& theType, const Standard_Integer theValue);
+
+  //!< Returns container of default sensitive factor values
+  const SelectMgr_MapOfSensitivityFactor& DefaultSensitivityFactors() const { return mySensitivityFactors; }
+
   //! Re-adds selectable object in BVHs in all viewer selectors.
   Standard_EXPORT void UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObj);
 
@@ -121,6 +134,8 @@ private:
 
   Handle(SelectMgr_ViewerSelector)                    mySelector;
   NCollection_Map<Handle(SelectMgr_SelectableObject)> myGlobal;
+  SelectMgr_MapOfSensitivityFactor mySensitivityFactors; //!< container of sensitive factor values
+  Standard_Integer myDefaultSensitivityFactor;
 
 };