0030452: Visualization - SelectMgr_ViewerSelector::Deactivate() raises exception... WEEK-5
authorkgv <kgv@opencascade.com>
Mon, 21 Jan 2019 12:31:02 +0000 (15:31 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 31 Jan 2019 17:53:34 +0000 (20:53 +0300)
Removed unused SelectMgr_SOS_Sleeping enumeration value.
SelectMgr_ViewerSelector::Deactivate() now checks activation status before updating tolerance map.

src/SelectMgr/SelectMgr_StateOfSelection.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
tools/VInspector/VInspector_Tools.cxx

index b430d0a..71f413b 100644 (file)
 //! different state of a Selection in a ViewerSelector...
 enum SelectMgr_StateOfSelection
 {
-SelectMgr_SOS_Activated,
-SelectMgr_SOS_Deactivated,
-SelectMgr_SOS_Sleeping,
-SelectMgr_SOS_Any,
-SelectMgr_SOS_Unknown
+  SelectMgr_SOS_Any         = -2, //!< ANY selection state (for querying selections)
+  SelectMgr_SOS_Unknown     = -1, //!< selection, which has  never been in SelectMgr_SOS_Activated state (almost the same thing as SelectMgr_SOS_Deactivated)
+  SelectMgr_SOS_Deactivated =  0, //!< deactivated selection, once been in SelectMgr_SOS_Activated state
+  SelectMgr_SOS_Activated,        //!< activated selection
 };
 
 #endif // _SelectMgr_StateOfSelection_HeaderFile
index 9dbc9f6..0fb6c86 100644 (file)
@@ -137,10 +137,13 @@ void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theS
     aSelEntIter.Value()->SetActiveForSelection();
   }
 
-  theSelection->SetSelectionState (SelectMgr_SOS_Activated);
+  if (theSelection->GetSelectionState() != SelectMgr_SOS_Activated)
+  {
+    theSelection->SetSelectionState (SelectMgr_SOS_Activated);
 
-  myTolerances.Add (theSelection->Sensitivity());
-  myToUpdateTolerance = Standard_True;
+    myTolerances.Add (theSelection->Sensitivity());
+    myToUpdateTolerance = Standard_True;
+  }
 }
 
 //==================================================
@@ -154,10 +157,13 @@ void SelectMgr_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& th
     aSelEntIter.Value()->ResetSelectionActiveStatus();
   }
 
-  theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
+  if (theSelection->GetSelectionState() == SelectMgr_SOS_Activated)
+  {
+    theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
 
-  myTolerances.Decrement (theSelection->Sensitivity());
-  myToUpdateTolerance = Standard_True;
+    myTolerances.Decrement (theSelection->Sensitivity());
+    myToUpdateTolerance = Standard_True;
+  }
 }
 
 //==================================================
@@ -721,14 +727,14 @@ Standard_Boolean SelectMgr_ViewerSelector::Modes (const Handle(SelectMgr_Selecta
   Standard_Boolean hasActivatedStates = Contains (theSelectableObject);
   for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theSelectableObject->Selections()); aSelIter.More(); aSelIter.Next())
   {
-      if (theWantedState == SelectMgr_SOS_Any)
-      {
-        theModeList.Append (aSelIter.Value()->Mode());
-      }
-      else if (theWantedState == aSelIter.Value()->GetSelectionState())
-      {
-        theModeList.Append (aSelIter.Value()->Mode());
-      }
+    if (theWantedState == SelectMgr_SOS_Any)
+    {
+      theModeList.Append (aSelIter.Value()->Mode());
+    }
+    else if (theWantedState == aSelIter.Value()->GetSelectionState())
+    {
+      theModeList.Append (aSelIter.Value()->Mode());
+    }
   }
 
   return hasActivatedStates;
index 795a45e..b64359f 100644 (file)
@@ -402,11 +402,10 @@ TCollection_AsciiString VInspector_Tools::ToName (const VInspector_SelectionType
     {
       switch (theValue)
       {
-        case SelectMgr_SOS_Activated:   return "Activated";
-        case SelectMgr_SOS_Deactivated: return "Deactivated";
-        case SelectMgr_SOS_Sleeping:    return "Sleeping";
         case SelectMgr_SOS_Any:         return "Any";
         case SelectMgr_SOS_Unknown:     return "Unknown";
+        case SelectMgr_SOS_Activated:   return "Activated";
+        case SelectMgr_SOS_Deactivated: return "Deactivated";
         default: break;
       }
     }