0025576: Visualization - implement AIS_ConnectedInteractive::AcceptDisplayMode()
[occt.git] / src / AIS / AIS_ConnectedInteractive.cxx
index 74c2dc8..d2d5010 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <Standard_NotImplemented.hxx>
 
-#include <AIS_ConnectedInteractive.ixx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <Select3D_SensitiveEntity.hxx>
+#include <AIS_ConnectedInteractive.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+#include <BRepTools.hxx>
 #include <Geom_Transformation.hxx>
-
+#include <gp_Trsf.hxx>
+#include <NCollection_DataMap.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
 #include <PrsMgr_ModedPresentation.hxx>
 #include <PrsMgr_Presentation.hxx>
-
-#include <StdSelect_BRepOwner.hxx>
-
+#include <Select3D_SensitiveEntity.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <Standard_ProgramError.hxx>
+#include <Standard_Type.hxx>
+#include <StdPrs_HLRPolyShape.hxx>
+#include <StdPrs_WFShape.hxx>
 #include <StdSelect.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS_Shape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_OrientedShapeMapHasher.hxx>
 
-#include <AIS_InteractiveContext.hxx>
-#include <BRepTools.hxx>
-#include <Precision.hxx>
-#include <AIS_Drawer.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <Standard_ProgramError.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_HLRPolyShape.hxx>
-#include <Prs3d_Drawer.hxx>
-
-#include <AIS_Shape.hxx>
-
-#include <NCollection_DataMap.hxx>
-
+IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject)
 
 //=======================================================================
 //function : AIS_ConnectedInteractive
@@ -55,21 +56,6 @@ AIS_InteractiveObject(aTypeOfPresentation3d)
   SetHilightMode(0);
 }
 
-//=======================================================================
-//function : Type
-//purpose  : 
-//=======================================================================
-AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
-{
-  return AIS_KOI_Object;
-}
-
-Standard_Integer AIS_ConnectedInteractive::Signature() const
-{
-  return 0;
-}
-
-
 //=======================================================================
 //function : Connect
 //purpose  : 
@@ -205,7 +191,7 @@ void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjec
     case TopAbs_WIRE:
     {
       thePresentation->SetDisplayPriority (4);
-      StdPrs_WFDeflectionShape::Add (thePresentation, theShape, myDrawer);
+      StdPrs_WFShape::Add (thePresentation, theShape, myDrawer);
       break;
     }
     default:
@@ -226,7 +212,8 @@ void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjec
       // process HLRAngle and HLRDeviationCoefficient()
       Standard_Real aPrevAngle = myDrawer->HLRAngle();
       Standard_Real aNewAngle = aDefaultDrawer->HLRAngle();
-      if (Abs (aNewAngle - aPrevAngle) > Precision::Angular())
+      if (myDrawer->IsAutoTriangulation() &&
+          Abs (aNewAngle - aPrevAngle) > Precision::Angular())
       {
         BRepTools::Clean (theShape);
       }
@@ -287,31 +274,30 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
 
   if (!myReference->HasSelection (theMode))
   {
-    myReference->UpdateSelection (theMode);
+    myReference->RecomputePrimitives (theMode);
   }
 
   const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection (theMode);
   Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
   Handle(Select3D_SensitiveEntity) aSensitive, aNewSensitive;
-  
+
+  TopLoc_Location aLocation (Transformation());
+  anOwner->SetLocation (aLocation);
+
   if (TheRefSel->IsEmpty())
   {
-    myReference->UpdateSelection (theMode);
+    myReference->RecomputePrimitives (theMode);
   }
 
   for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next())
   {
-    aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive());
+    aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive()->BaseSensitive());
     if (!aSensitive.IsNull())
     {
-      TopLoc_Location aLocation (Transformation());
       // Get the copy of SE3D
-      aNewSensitive = aSensitive->GetConnected (aLocation);
+      aNewSensitive = aSensitive->GetConnected();
 
       aNewSensitive->Set(anOwner);
-      // In case if SE3D caches some location-dependent data
-      // that must be updated after setting OWN
-      aNewSensitive->SetLocation (aLocation);
 
       theSelection->Add (aNewSensitive);
     }
@@ -330,13 +316,13 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
     Shapes2EntitiesMap;
 
   if (!myReference->HasSelection (theMode))
-    myReference->UpdateSelection (theMode);
+    myReference->RecomputePrimitives (theMode);
    
   const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode);
 
   if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full)
   {
-    myReference->UpdateSelection (theMode);
+    myReference->RecomputePrimitives (theMode);
   }
   
   Handle(StdSelect_BRepOwner) anOwner;
@@ -352,7 +338,7 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
   // sensitive entities associated with aMode 
   for (aRefSel->Init(); aRefSel->More(); aRefSel->Next())
   {
-    aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive()); 
+    aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive()->BaseSensitive());
     if(!aSE.IsNull())
     {
       anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId());
@@ -376,17 +362,14 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
                                        this, 
                                        aSEList.First()->OwnerId()->Priority(), 
                                        Standard_True);
+    anOwner->SetLocation (Transformation());
 
     for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next())
-    {      
+    {
       aSE = aListIt.Value();
 
-      TopLoc_Location aLocation (Transformation());
-      aNewSE = aSE->GetConnected (aDummyLoc);
+      aNewSE = aSE->GetConnected();
       aNewSE->Set (anOwner);
-      // In case if aSE caches some location-dependent data 
-      // that must be updated after setting anOwner
-      aNewSE->SetLocation (aLocation);
 
       theSelection->Add (aNewSE);
     }