0023432: Connected Interactive Objects computed without Interactive Context
[occt.git] / src / AIS / AIS_ConnectedInteractive.cxx
index c38c8d2..72a3a31 100755 (executable)
@@ -105,30 +105,39 @@ void AIS_ConnectedInteractive::Disconnect()
 }
 //=======================================================================
 //function : Compute
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-void AIS_ConnectedInteractive::
-Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
-       const Handle(Prs3d_Presentation)& aPresentation, 
-       const Standard_Integer aMode)
+void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+                                        const Handle(Prs3d_Presentation)&           thePrs,
+                                        const Standard_Integer                      theMode)
 {
-  static Handle(Geom_Transformation) myPrsTrans ;
+  if (!(HasLocation() || HasConnection()))
+  {
+    return;
+  }
 
-  if(!(HasLocation() ||HasConnection())) return;
-  
-  if(HasConnection()){
-    aPresentation->Clear(Standard_False);
-    aPresentation->RemoveAll();
-    aPresentationManager->Connect( this,myReference, aMode, aMode);
-    if(aPresentationManager->Presentation(myReference,aMode)->MustBeUpdated())
-      aPresentationManager->Update(myReference,aMode);
-    
+  if (HasConnection())
+  {
+    thePrs->Clear (Standard_False);
+    thePrs->RemoveAll();
+
+    if (!myReference->HasInteractiveContext())
+    {
+      myReference->SetContext (GetContext());
+    }
+    thePrsMgr->Connect (this, myReference, theMode, theMode);
+    if (thePrsMgr->Presentation (myReference, theMode)->MustBeUpdated())
+    {
+      thePrsMgr->Update (myReference, theMode);
+    }
+  }
+
+  if (HasLocation())
+  {
+    Handle(Geom_Transformation) aPrsTrans = new Geom_Transformation (myLocation.Transformation());
+    thePrsMgr->Transform (this, aPrsTrans, theMode);
   }
-  if(HasLocation()){
-    myPrsTrans = new Geom_Transformation(myLocation.Transformation());
-    aPresentationManager->Transform(this, myPrsTrans, aMode);  }
-  aPresentation->ReCompute();
+  thePrs->ReCompute();
 }
 
 void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)