0027957: Visualization, AIS_InteractiveContext - protect from displaying the same...
[occt.git] / src / AIS / AIS_MultipleConnectedInteractive.cxx
index c22ea9a..47b4303 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_MultipleConnectedInteractive.hxx>
 
-#include <AIS_MultipleConnectedInteractive.ixx>
 #include <AIS_ConnectedInteractive.hxx>
 #include <AIS_InteractiveContext.hxx>
-
+#include <AIS_InteractiveObject.hxx>
+#include <Prs3d_Projector.hxx>
 #include <PrsMgr_ModedPresentation.hxx>
-#include <PrsMgr_Presentation.hxx>
-#include <SelectMgr_EntityOwner.hxx>
 #include <Select3D_SensitiveEntity.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard_NotImplemented.hxx>
 #include <TopLoc_Location.hxx>
-#include <NCollection_DataMap.hxx>
-#include <AIS_InteractiveObject.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject)
 
 namespace
 {
@@ -52,11 +52,9 @@ namespace
 
     Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode) const;
 
-    void Hilight (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode);
-
-    void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM,
-                           const Quantity_NameOfColor aColor,
-                           const Standard_Integer aMode);
+    void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                           const Handle(Graphic3d_HighlightStyle)& theStyle,
+                           const Standard_Integer theMode);
 
     void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer aMode);
 
@@ -103,36 +101,23 @@ Standard_Boolean SelectMgr_AssemblyEntityOwner::IsHilighted (const Handle(PrsMgr
   return Standard_False;
 }
 
-//=======================================================================
-//function : Hilight
-//purpose  : 
-//=======================================================================
-void SelectMgr_AssemblyEntityOwner::Hilight (const Handle(PrsMgr_PresentationManager)& PM,
-                                             const Standard_Integer aMode)
-{
-  if (HasSelectable())
-  {
-   PM->Highlight (myAssembly, aMode);
-  }
-}
-
 //=======================================================================
 //function : HilightWithColor
 //purpose  : 
 //=======================================================================
-void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM,
-                                                      const Quantity_NameOfColor aColor,
-                                                      const Standard_Integer aMode)
+void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                                      const Handle(Graphic3d_HighlightStyle)& theStyle,
+                                                      const Standard_Integer theMode)
 {
   if (HasSelectable())
   {
     if (IsAutoHilight())
     {
-      PM->Color (myAssembly, aColor, aMode);
+      thePM->Color (myAssembly, theStyle, theMode);
     }
     else
     {
-      myAssembly->HilightOwnerWithColor (PM, aColor, this);
+      myAssembly->HilightOwnerWithColor (thePM, theStyle, this);
     }
   }
 }
@@ -183,13 +168,12 @@ Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
 }
 
 //=======================================================================
-//function : Connect
+//function : connect
 //purpose  :
 //=======================================================================
-Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
-                                                                         const gp_Trsf&                       theTransformation,
-                                                                         const Graphic3d_TransModeFlags&      theTrsfPersFlag,
-                                                                         const gp_Pnt&                        theTrsfPersPoint)
+Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+                                                                         const Handle(Geom_Transformation)& theTrsf,
+                                                                         const Handle(Graphic3d_TransformPers)& theTrsfPers)
 {
   if (myAssemblyOwner.IsNull())
     myAssemblyOwner = new SelectMgr_EntityOwner (this);
@@ -201,7 +185,7 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const H
   { 
     Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
     aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
-    aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformation());
+    aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom());
 
     // Perform deep copy of instance tree
     for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
@@ -220,44 +204,20 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const H
   else
   {
     Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
-    aNewConnected->Connect (theAnotherObj);
-    aNewConnected->SetLocalTransformation (theAnotherObj->LocalTransformation());
+    aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom());
 
     anObjectToAdd = aNewConnected;
   }
 
-  anObjectToAdd->SetLocalTransformation (theTransformation);
-  if (theTrsfPersFlag != Graphic3d_TMF_None)
+  anObjectToAdd->SetLocalTransformation (theTrsf);
+  if (!theTrsfPers.IsNull())
   {
-    anObjectToAdd->SetTransformPersistence (theTrsfPersFlag, theTrsfPersPoint);
+    anObjectToAdd->SetTransformPersistence (theTrsfPers);
   }
   AddChild (anObjectToAdd);
   return anObjectToAdd;
 }
 
-//=======================================================================
-//function : Connect
-//purpose  :
-//=======================================================================
-Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
-{
-  return Connect (theAnotherObj, theAnotherObj->LocalTransformation(),
-                  theAnotherObj->GetTransformPersistenceMode(),
-                  theAnotherObj->GetTransformPersistencePoint());
-}
-
-//=======================================================================
-//function : Connect
-//purpose  :
-//=======================================================================
-Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
-                                                                         const gp_Trsf&                       theTransformation)
-{
-  return Connect (theAnotherObj, theTransformation,
-                  theAnotherObj->GetTransformPersistenceMode(),
-                  theAnotherObj->GetTransformPersistencePoint());
-}
-
 //=======================================================================
 //function : HasConnection
 //purpose  : 
@@ -299,17 +259,13 @@ void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_Presentation
                                                 const Handle(Prs3d_Presentation)&           /*thePrs*/,
                                                 const Standard_Integer                      /*theMode*/)
 {
+  Handle(AIS_InteractiveContext) aCtx = GetContext();
   for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
   {
     Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
-    if (aChild.IsNull())
+    if (!aChild.IsNull())
     {
-      continue;
-    }
-
-    if (!aChild->HasInteractiveContext())
-    {
-      aChild->SetContext (GetContext());
+      aChild->SetContext (aCtx);
     }
   }
 }
@@ -386,3 +342,48 @@ void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_
     }
   }
 }
+
+//=======================================================================
+//function : GlobalSelOwner
+//purpose  :
+//=======================================================================
+Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() const
+{
+  return myAssemblyOwner;
+}
+
+//=======================================================================
+//function : HasSelection
+//purpose  :
+//=======================================================================
+Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_Integer theMode) const
+{
+  for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
+  {
+    Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
+    if (aChild.IsNull())
+      continue;
+
+    if (!aChild->HasSelection (theMode))
+      return Standard_False;
+  }
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : SetContext
+//purpose  :
+//=======================================================================
+void AIS_MultipleConnectedInteractive::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
+{
+  AIS_InteractiveObject::SetContext (theCtx);
+  for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
+  {
+    Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
+    if (!aChild.IsNull())
+    {
+      aChild->SetContext (theCtx);
+    }
+  }
+}