0024343: AIS_DisplayStatus - outdated description
[occt.git] / src / AIS / AIS_InteractiveContext_1.cxx
index b9341e1..4b0b4a6 100755 (executable)
 //                       DetectedCurrentShape(),DetectedCurrentObject()
 //                       methods
 
-#define IMP191001      //GG Avoid to raise when switching with the 
-//                     SetAutomaticHilight() method.
-//                     Thanks to IFO of SAMTECH company for this improvment.
-
 #define OCC138          //VTN Avoding infinit loop in AddOrRemoveCurrentObject method.
 
 #define OCC9657
@@ -146,7 +142,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix
                                   const Standard_Integer YPix, 
                                   const Handle(V3d_View)& aView)
 {
-  if(HasOpenedContext()&& aView->Viewer()!=myCollectorVwr){
+  if(HasOpenedContext()){
     myWasLastMain = Standard_True;
     return myLocalContexts(myCurLocalIndex)->MoveTo(XPix,YPix,aView);
   }
@@ -169,13 +165,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix
     myLastPicked = myLastinMain;
     myWasLastMain = Standard_True;
   }
-  else if (aView->Viewer()== myCollectorVwr){
-    pmgr = myCollectorPM;
-    selector=myCollectorSel;
-    myLastPicked = myLastinColl;
-    ismain = Standard_False;
-    myWasLastMain = Standard_False;
-  }
   else 
     return AIS_SOD_Error;
   
@@ -207,13 +196,14 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix
   selector->Init();
   if ( selector->More() )
   {
-    if ( HasOpenedContext() )
+    if ( HasOpenedContext() ) 
+    {
       if ( !myFilters->IsOk( selector->OnePicked() ) ) 
-       return AIS_SOD_AllBad;
+        return AIS_SOD_AllBad;
       else
         if ( !myLocalContexts( myCurLocalIndex )->Filter()->IsOk( selector->OnePicked() ) )
           return AIS_SOD_AllBad;
-    
+    }
  
     // Does nothing if previously detected object is equal to the current one
     if ( selector->OnePicked()->Selectable() == myLastPicked )
@@ -224,72 +214,64 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix
     // is needed only if myToHilightSelected flag is true. In this case previously detected
     // object has been already highlighted with myHilightColor during previous MoveTo() 
     // method call. As result it is necessary to rehighligt it with mySelectionColor.
-    if ( !myLastPicked.IsNull() )
+    if (!myLastPicked.IsNull())
     {
-      Standard_Integer HiMod =  
-        myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
-      if ( myLastPicked->State() != 1 )
+      Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
+      if (myLastPicked->State() != 1)
       {
-       pmgr->Unhighlight( myLastPicked, HiMod );
+        pmgr->Unhighlight (myLastPicked, aHiMod);
         UpdVwr = Standard_True;
       }
-      else if ( myToHilightSelected )
+      else if (myToHilightSelected)
       {
-        pmgr->Color( myLastPicked, mySelectionColor, HiMod );
+        pmgr->Color (myLastPicked, mySelectionColor, aHiMod);
         UpdVwr = Standard_True;
       }
     }
-    
+
     // Initialize myLastPicked field with currently detected object
-    Handle(SelectMgr_SelectableObject) SO = selector->OnePicked()->Selectable();
-    myLastPicked = *((Handle(AIS_InteractiveObject)*)&SO);
-    
+    myLastPicked = Handle(AIS_InteractiveObject)::DownCast (selector->OnePicked()->Selectable());
+
     if ( ismain )
       myLastinMain = myLastPicked;
-    else 
-      myLastinColl = myLastPicked;
-#ifdef IMP191001
+
     // Highlight detected object if it is not selected or myToHilightSelected flag is true
-    if ( !myLastPicked.IsNull() && 
-         ( myLastPicked->State()!= 1 || myToHilightSelected ) )
-#else
-     if ( myLastPicked->State()!= 1 )
-#endif
+    if (!myLastPicked.IsNull()
+     && (myLastPicked->State()!= 1 || myToHilightSelected))
     {
-      Standard_Integer HiMod =  
-        myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
-      pmgr->Color( myLastPicked, myHilightColor, HiMod );
+      Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
+      pmgr->Color (myLastPicked, myHilightColor, aHiMod);
       UpdVwr = Standard_True;
     }
-    
-    if ( myLastPicked->State()==1 )
+
+    if (!myLastPicked.IsNull()
+      && myLastPicked->State() == 1)
+    {
       TheStat = AIS_SOD_Selected;
+    }
   }
   else 
   {
-    // Previously detected object is unhilighted if it is not selected or hilighted 
-    // with selection color if it is selected. 
+    // Previously detected object is unhilighted if it is not selected or hilighted
+    // with selection color if it is selected.
     TheStat = AIS_SOD_Nothing;
-    if ( !myLastPicked.IsNull() )
+    if (!myLastPicked.IsNull())
     {
-      Standard_Integer HiMod =  
-        myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
-      if ( myLastPicked->State() != 1 )
+      Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
+      if (myLastPicked->State() != 1)
       {
-       pmgr->Unhighlight( myLastPicked, HiMod );
+        pmgr->Unhighlight (myLastPicked, aHiMod);
         UpdVwr = Standard_True;
       }
-      else if ( myToHilightSelected )
+      else if (myToHilightSelected)
       {
-        pmgr->Color( myLastPicked, mySelectionColor, HiMod );
+        pmgr->Color (myLastPicked, mySelectionColor, aHiMod);
         UpdVwr = Standard_True;
       }
     }
-    
+
     if ( ismain )
       myLastinMain.Nullify();
-    else
-      myLastinColl.Nullify();
   }
   
   if(UpdVwr) aView->Viewer()->Update();
@@ -324,12 +306,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Integer XPMin,
   if(aView->Viewer()== myMainVwr) {
     selector= myMainSel;
     myWasLastMain = Standard_True;}
-  
-  else if (aView->Viewer()==myCollectorVwr){
-    selector= myCollectorSel;
-    myWasLastMain = Standard_False;}
-  
-  
+
   selector->Pick(XPMin,YPMin,XPMax,YPMax,aView);
   AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
 
@@ -394,12 +371,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const TColgp_Array1OfPnt2d& aPol
   if(aView->Viewer()== myMainVwr) {
     selector= myMainSel;
     myWasLastMain = Standard_True;}
-  
-  else if (aView->Viewer()==myCollectorVwr){
-    selector= myCollectorSel;
-    myWasLastMain = Standard_False;}
-  
-  
+
   selector->Pick(aPolyline,aView);
   AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
 
@@ -453,7 +425,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Boolean updatevie
     if(myWasLastMain)
       return myLocalContexts(myCurLocalIndex)->Select(updateviewer);
     else
-      // picking was done in the collector, special processing is required...
       {
        myLocalContexts(myCurLocalIndex)->SetSelected(myLastPicked,updateviewer);
        return AIS_SOP_OneSelected;
@@ -466,12 +437,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Boolean updatevie
       if(updateviewer)
        UpdateCurrentViewer();}
   }
-  else if (!myWasLastMain && !myLastinColl.IsNull()){
-    if(myLastinColl->State()!=1){
-      SetCurrentObject(myLastinColl,Standard_False);
-      if(updateviewer)
-       UpdateCollector();}
-  }
   else{
     AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
     Handle(AIS_Selection) S = AIS_Selection::CurrentSelection();
@@ -492,9 +457,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Boolean updatevie
     AIS_Selection::Select();
     if(updateviewer){
       if(myWasLastMain)
-       UpdateCurrentViewer();
-      else
-       UpdateCollector();
+        UpdateCurrentViewer();
     }
   }
   Standard_Integer NS = NbCurrents();
@@ -523,10 +486,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const Standard_Boolean upda
   }
   if(myWasLastMain && !myLastinMain.IsNull())
     AddOrRemoveCurrentObject(myLastinMain,updateviewer);
-  else if (!myWasLastMain && !myLastinColl.IsNull())
-    AddOrRemoveCurrentObject(myLastinColl,updateviewer);
-  
-  
+
   Standard_Integer NS = NbCurrents();
   if(NS==0) return AIS_SOP_NothingSelected;
   if(NS==1) return AIS_SOP_OneSelected;
@@ -557,10 +517,6 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const Standard_Integer XPMi
   if(aView->Viewer()== myMainVwr) {
     selector= myMainSel;
     myWasLastMain = Standard_True;}
-  
-  else if (aView->Viewer()==myCollectorVwr){
-    selector= myCollectorSel;
-    myWasLastMain = Standard_False;}
   else
     return AIS_SOP_NothingSelected;
   
@@ -604,10 +560,6 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect( const TColgp_Array1OfPnt2d
         selector= myMainSel;
         myWasLastMain = Standard_True;
     }
-    else if ( aView->Viewer() == myCollectorVwr ) {
-        selector= myCollectorSel;
-        myWasLastMain = Standard_False;
-    }
     else
         return AIS_SOP_NothingSelected;