0027819: Visualization - provide a possibility to redefine SelectMgr_SelectableObject...
[occt.git] / src / SelectMgr / SelectMgr_SelectableObject.cxx
index 9c3fe8c..f0d3e83 100644 (file)
@@ -39,6 +39,8 @@
 #include <Standard_Type.hxx>
 #include <TopLoc_Location.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject)
+
 static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq,
                                 const Handle (SelectMgr_Selection)& theSel)
 {
@@ -67,20 +69,29 @@ SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPrese
   myHilightDrawer->Link (myDrawer);
 }
 
+//==================================================
+// Function: Destructor
+// Purpose : Clears all selections of the object
+//==================================================
+SelectMgr_SelectableObject::~SelectMgr_SelectableObject()
+{
+  for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx)
+  {
+    myselections.Value (aSelIdx)->Clear();
+  }
+}
 
 //==================================================
-// Function: 
+// Function: HasSelection
 // Purpose :
 //==================================================
-
-Standard_Boolean SelectMgr_SelectableObject
-::HasSelection(const Standard_Integer aMode) const
+Standard_Boolean SelectMgr_SelectableObject::HasSelection (const Standard_Integer theMode) const
 {
-  Standard_Boolean Found=Standard_False;
-  for (Standard_Integer I=1;I<= myselections.Length() && !Found;I++)
-    { if(((myselections.Value(I))->Mode())==aMode) 
-        return Standard_True;
-    }
+  for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx)
+  {
+    if (((myselections.Value (aSelIdx))->Mode()) == theMode)
+      return Standard_True;
+  }
   return Standard_False;
 }
 
@@ -172,7 +183,6 @@ void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean update)
 const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject
 ::Selection(const Standard_Integer aMode) const
 {
-  static Handle(SelectMgr_Selection) bidsel;
   Standard_Boolean Found = Standard_False;
   Standard_Integer Rank=0;
   for (Standard_Integer i=1;i<=myselections.Length() && !Found;i++)
@@ -401,12 +411,12 @@ void SelectMgr_SelectableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId)
 }
 
 //=======================================================================
-//function : UpdateSelection
+//function : updateSelection
 //purpose  : Sets update status FULL to selections of the object. Must be
 //           used as the only method of UpdateSelection from outer classes
 //           to prevent BVH structures from being outdated.
 //=======================================================================
-void SelectMgr_SelectableObject::UpdateSelection (const Standard_Integer theMode)
+void SelectMgr_SelectableObject::updateSelection (const Standard_Integer theMode)
 {
   if (theMode == -1)
   {