0027957: Visualization, AIS_InteractiveContext - protect from displaying the same...
authorkgv <kgv@opencascade.com>
Thu, 13 Oct 2016 12:24:23 +0000 (15:24 +0300)
committerapn <apn@opencascade.com>
Fri, 21 Oct 2016 08:12:03 +0000 (11:12 +0300)
AIS_InteractiveContext methods adding object to the context now throws Standard_ProgramError exception
if object has been already displayed in another context.
AIS_InteractiveContext::Remove() now NULLifies context assigned to the object.

AIS_InteractiveContext now inherits from Standard_Transient instead of deprecated MMgt_TShared
and defines C++ destructor instead of method Delete().

AIS_InteractiveObject - undocumented property State() has been removed.
Undocumented property Users() has been moved to AIS_IdenticRelation.

Draw Harness command vclose now clear AIS_InteractiveContext content
before nullifying it to ensure that objects have been properly removed.

AIS_MultipleConnectedInteractive now overrides method ::SetContext()
to assign context for children objects.

17 files changed:
src/AIS/AIS_IdenticRelation.hxx
src/AIS/AIS_InteractiveContext.cxx
src/AIS/AIS_InteractiveContext.hxx
src/AIS/AIS_InteractiveContext_1.cxx
src/AIS/AIS_InteractiveContext_3.cxx
src/AIS/AIS_InteractiveObject.cxx
src/AIS/AIS_InteractiveObject.hxx
src/AIS/AIS_MultipleConnectedInteractive.cxx
src/AIS/AIS_MultipleConnectedInteractive.hxx
src/AIS/AIS_PToContext.hxx [deleted file]
src/AIS/FILES
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/vis/bug23670_1 [deleted file]
tests/bugs/vis/bug24133_2
tests/bugs/vis/bug24133_3
tests/bugs/vis/bug24133_4
tests/bugs/vis/bug2883_2 [deleted file]

index 8d06e37..8503811 100644 (file)
@@ -52,14 +52,19 @@ class AIS_IdenticRelation : public AIS_Relation
 
 public:
 
-  
-
   //! Initializes the relation of identity between the two
   //! entities, FirstShape and SecondShape. The plane
   //! aPlane is initialized in case a visual reference is
   //! needed to show identity.
   Standard_EXPORT AIS_IdenticRelation(const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
-  
+
+  Standard_Boolean HasUsers() const { return !myUsers.IsEmpty(); }
+
+  const TColStd_ListOfTransient& Users() const { return myUsers; }
+
+  void AddUser (const Handle(Standard_Transient)& theUser) { myUsers.Append (theUser); }
+
+  void ClearUsers() { myUsers.Clear(); }
 
   //! Returns true if the interactive object is movable.
     virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
@@ -73,16 +78,8 @@ public:
   //! to the object to display before computation  !!!
   Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
 
-
-
-
   DEFINE_STANDARD_RTTIEXT(AIS_IdenticRelation,AIS_Relation)
 
-protected:
-
-
-
-
 private:
 
   
@@ -136,12 +133,14 @@ private:
   
   Standard_EXPORT gp_Dir ComputeCircleDirection (const Handle(Geom_Circle)& aCirc, const TopoDS_Vertex& ConnectedVertex) const;
 
+private:
+
+  TColStd_ListOfTransient myUsers;
   Standard_Boolean isCircle;
   gp_Pnt myFAttach;
   gp_Pnt mySAttach;
   gp_Pnt myCenter;
 
-
 };
 
 
index e11557a..1551c76 100644 (file)
@@ -14,9 +14,8 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-// Modified by  XAB & Serguei Dec 97 (angle &deviation coeffts)
-
 #include <AIS_ConnectedInteractive.hxx>
+
 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
 #include <AIS_GlobalStatus.hxx>
@@ -61,9 +60,8 @@
 #include <V3d_View.hxx>
 #include <V3d_Viewer.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
 
-//#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
 namespace
 {
   typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
@@ -101,7 +99,11 @@ myIsAutoActivateSelMode(Standard_True)
   InitAttributes();
 }
 
-void AIS_InteractiveContext::Delete() const
+//=======================================================================
+//function : ~AIS_InteractiveContext
+//purpose  :
+//=======================================================================
+AIS_InteractiveContext::~AIS_InteractiveContext()
 {
   // clear the current selection
   mySelection->Clear();
@@ -121,7 +123,6 @@ void AIS_InteractiveContext::Delete() const
       anObj->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Renew);
     }
   }
-  MMgt_TShared::Delete();
 }
 
 //=======================================================================
@@ -389,11 +390,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   if (theDispStatus == AIS_DS_Temporary
   && !HasOpenedContext())
   {
@@ -494,11 +491,7 @@ void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   if (HasOpenedContext())
   {
     myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
@@ -775,6 +768,15 @@ void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIOb
     return;
   }
 
+  if (theIObj->HasInteractiveContext())
+  {
+    if (theIObj->myCTXPtr != this)
+    {
+      Standard_ProgramError::Raise ("AIS_InteractiveContext - object has been displayed in another context!");
+    }
+    theIObj->SetContext (Handle(AIS_InteractiveContext)());
+  }
+
   if (HasOpenedContext())
   {
     myLocalContexts (myCurLocalIndex)->Remove (theIObj);
@@ -857,9 +859,7 @@ void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject
   if (theObj.IsNull())
     return;
 
-  if (!theObj->HasInteractiveContext())
-    theObj->SetContext (this);
-
+  setContextToObject (theObj);
   if (!HasOpenedContext())
   {
     if (!myObjects.IsBound (theObj))
@@ -1115,11 +1115,7 @@ void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObj
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   if (myObjects.IsBound (theIObj))
   {
     Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
@@ -1523,11 +1519,7 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)
                                              const Standard_Integer               theMode,
                                              const Standard_Boolean               theToUpdateViewer)
 {
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext(this);
-  }
-
+  setContextToObject (theIObj);
   if (!myObjects.IsBound (theIObj))
   {
     theIObj->SetDisplayMode (theMode);
@@ -1729,10 +1721,7 @@ void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theI
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
+  setContextToObject (theIObj);
   theIObj->SetColor (theColor);
   redisplayPrsRecModes (theIObj, theToUpdateViewer);
 }
@@ -1765,12 +1754,8 @@ void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_Interacti
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
   // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  setContextToObject (theIObj);
   if (theIObj->Type() != AIS_KOI_Object
    && theIObj->Type() != AIS_KOI_Shape)
   {
@@ -1799,12 +1784,8 @@ void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_Intera
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  setContextToObject (theIObj);
   if (theIObj->Type() != AIS_KOI_Object
    && theIObj->Type() != AIS_KOI_Shape)
   {
@@ -1833,12 +1814,8 @@ void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObje
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  setContextToObject (theIObj);
   if (theIObj->Type() != AIS_KOI_Shape)
   {
     return;
@@ -1866,12 +1843,8 @@ void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveO
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  setContextToObject (theIObj);
   if (theIObj->Type() != AIS_KOI_Shape)
   {
     return;
@@ -1908,12 +1881,8 @@ void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_Interacti
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  setContextToObject (theIObj);
   if (theIObj->Type() != AIS_KOI_Shape)
   {
     return;
@@ -1940,12 +1909,8 @@ void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveO
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+  setContextToObject (theIObj);
   if (theIObj->Type() != AIS_KOI_Shape)
   {
     return;
@@ -2025,11 +1990,7 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   theIObj->SetWidth (theWidth);
   redisplayPrsRecModes (theIObj, theToUpdateViewer);
   if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj))
@@ -2080,11 +2041,7 @@ void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& t
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   theIObj->SetMaterial (theName);
   redisplayPrsRecModes (theIObj, theToUpdateViewer);
 }
@@ -2117,11 +2074,7 @@ void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   if (!theIObj->IsTransparent()
     && theValue <= 0.05)
   {
@@ -2194,11 +2147,7 @@ void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObj
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
-
+  setContextToObject (theIObj);
   theIObj->SetAttributes (theDrawer);
   Update (theIObj, theToUpdateViewer);
 }
@@ -2215,10 +2164,7 @@ void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveO
     return;
   }
 
-  if (!theIObj->HasInteractiveContext())
-  {
-    theIObj->SetContext (this);
-  }
+  setContextToObject (theIObj);
   theIObj->UnsetAttributes();
   Update (theIObj, theToUpdateViewer);
 }
index 198a44f..27dbee7 100644 (file)
@@ -30,7 +30,6 @@
 #include <Standard_Integer.hxx>
 #include <AIS_DataMapOfILC.hxx>
 #include <AIS_SequenceOfInteractive.hxx>
-#include <MMgt_TShared.hxx>
 #include <AIS_DisplayStatus.hxx>
 #include <AIS_KindOfInteractive.hxx>
 #include <Standard_Real.hxx>
@@ -67,10 +66,6 @@ class Standard_Transient;
 class SelectMgr_Filter;
 class TCollection_AsciiString;
 
-
-class AIS_InteractiveContext;
-DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, MMgt_TShared)
-
 //! The Interactive Context allows you to manage
 //! graphic behavior and selection of Interactive Objects
 //! in one or more viewers. Class methods make this
@@ -133,19 +128,19 @@ DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, MMgt_TShared)
 //! selection mode is equal to 0, but it might be redefined if needed. Sub-part selection
 //! of the objects without using local context provides a possibility to activate part
 //! selection modes along with global selection mode.
-class AIS_InteractiveContext : public MMgt_TShared
+class AIS_InteractiveContext : public Standard_Transient
 {
-
+  friend class AIS_LocalContext;
+  DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
 public:
 
-  
-
   //! Constructs the interactive context object defined by
   //! the principal viewer MainViewer.
   Standard_EXPORT AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer);
-  
-  Standard_EXPORT virtual void Delete() const Standard_OVERRIDE;
-  
+
+  //! Destructor.
+  Standard_EXPORT virtual ~AIS_InteractiveContext();
+
   Standard_EXPORT void SetAutoActivateSelection (const Standard_Boolean Auto);
   
   Standard_EXPORT Standard_Boolean GetAutoActivateSelection() const;
@@ -1599,12 +1594,6 @@ public:
   //! Redraws immediate structures in all views of the viewer given taking into account its visibility.
   Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer);
 
-
-friend class AIS_LocalContext;
-
-
-  DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext,MMgt_TShared)
-
 protected:
 
   Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
@@ -1700,6 +1689,22 @@ protected:
       ? aHiDrawer->SelectionStyle() : mySelStyle;
   }
 
+  //! Assign the context to the object or throw exception if object was already assigned to another context.
+  void setContextToObject (const Handle(AIS_InteractiveObject)& theObj)
+  {
+    if (theObj->HasInteractiveContext())
+    {
+      if (theObj->myCTXPtr != this)
+      {
+        Standard_ProgramError::Raise ("AIS_InteractiveContext - object has been already displayed in another context!");
+      }
+    }
+    else
+    {
+      theObj->SetContext (this);
+    }
+  }
+
 protected:
 
   AIS_DataMapOfIOStatus myObjects;
@@ -1730,14 +1735,10 @@ protected:
   Standard_Boolean myZDetectionFlag;
   Standard_Boolean myIsAutoActivateSelMode;
 
-
 };
 
+DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient)
 
 #include <AIS_InteractiveContext.lxx>
 
-
-
-
-
 #endif // _AIS_InteractiveContext_HeaderFile
index efbfd12..aebe4eb 100644 (file)
@@ -1163,9 +1163,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveOb
   if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
     return;
 
-  if (!theObject->HasInteractiveContext())
-    theObject->SetContext (this);
-
+  setContextToObject (theObject);
   const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
 
   if (anOwner.IsNull() || !anOwner->HasSelectable())
index 80fcd2a..e01b842 100644 (file)
@@ -51,9 +51,7 @@ void AIS_InteractiveContext::SetPolygonOffsets(
   if ( anObj.IsNull() )
     return;
 
-  if( !anObj->HasInteractiveContext() )
-    anObj->SetContext( this );
-
+  setContextToObject (anObj);
   anObj->SetPolygonOffsets( aMode, aFactor, aUnits );
 
   if ( updateviewer ) {
index 80e93b6..7e3dcf5 100644 (file)
@@ -65,11 +65,8 @@ myCurrentFacingModel(Aspect_TOFM_BOTH_SIDE),
 myRecomputeEveryPrs(Standard_True),
 myCTXPtr(NULL),
 mySelPriority(-1),
-myDisplayMode (-1),
-mystate(0)
+myDisplayMode (-1)
 {
-  Handle (AIS_InteractiveContext) Bid;
-  myCTXPtr = Bid.operator->();
   SetCurrentFacingModel();
 }
 
@@ -109,16 +106,6 @@ Standard_Integer AIS_InteractiveObject::Signature() const
 Standard_Boolean  AIS_InteractiveObject::RecomputeEveryPrs() const 
 {return myRecomputeEveryPrs;}
 
-//=======================================================================
-//function : 
-//purpose  : 
-//=======================================================================
-Standard_Boolean AIS_InteractiveObject::HasInteractiveContext() const 
-{
-  Handle (AIS_InteractiveContext) aNull;
-  return  (myCTXPtr != aNull.operator->());
-}
-
 //=======================================================================
 //function : 
 //purpose  : 
@@ -129,15 +116,21 @@ Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
 }
 
 //=======================================================================
-//function : 
-//purpose  : 
+//function : SetContext
+//purpose  :
 //=======================================================================
-void AIS_InteractiveObject::SetContext(const Handle(AIS_InteractiveContext)& aCtx)
+void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
 {
-  myCTXPtr = aCtx.operator->();
-  if( aCtx.IsNull())
+  if (myCTXPtr == theCtx.get())
+  {
     return;
-  myDrawer->Link(aCtx->DefaultDrawer());
+  }
+
+  myCTXPtr = theCtx.get();
+  if (!theCtx.IsNull())
+  {
+    myDrawer->Link (theCtx->DefaultDrawer());
+  }
 }
 
 //=======================================================================
@@ -160,35 +153,6 @@ void AIS_InteractiveObject::ClearOwner()
   myOwner.Nullify();
 }
 
-//=======================================================================
-//function : 
-//purpose  : 
-//=======================================================================
-Standard_Boolean AIS_InteractiveObject::HasUsers() const 
-{
-  return (!myUsers.IsEmpty());
-}
-
-
-//=======================================================================
-//function : 
-//purpose  : 
-//=======================================================================
-void AIS_InteractiveObject::AddUser(const Handle(Standard_Transient)& aUser)
-{
-  myUsers.Append(aUser);
-}
-
-//=======================================================================
-//function : 
-//purpose  : 
-//=======================================================================
-void AIS_InteractiveObject::ClearUsers()
-{
-  myUsers.Clear();
-}
-
-
 //=======================================================================
 //function : 
 //purpose  : 
index d7a08e2..a4b6a36 100644 (file)
 #ifndef _AIS_InteractiveObject_HeaderFile
 #define _AIS_InteractiveObject_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <AIS_PToContext.hxx>
-#include <TColStd_ListOfTransient.hxx>
-#include <Standard_Real.hxx>
-#include <Quantity_Color.hxx>
-#include <Graphic3d_NameOfMaterial.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Boolean.hxx>
 #include <Aspect_TypeOfFacingModel.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <SelectMgr_SelectableObject.hxx>
-#include <PrsMgr_TypeOfPresentation3d.hxx>
 #include <AIS_KindOfInteractive.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <Standard_ShortReal.hxx>
-class Standard_Transient;
+#include <Graphic3d_NameOfMaterial.hxx>
+#include <PrsMgr_TypeOfPresentation3d.hxx>
+#include <SelectMgr_SelectableObject.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListOfTransient.hxx>
+#include <Quantity_Color.hxx>
+
 class AIS_InteractiveContext;
-class Quantity_Color;
 class Graphic3d_MaterialAspect;
 class Prs3d_Presentation;
 class Prs3d_BasicAspect;
 class Bnd_Box;
 
-
-class AIS_InteractiveObject;
-DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)
-
-
 //! Defines a class of objects with display and selection services.
 //! Entities which are visualized and selected are
 //! Interactive Objects. You can make use of classes of
@@ -74,11 +59,10 @@ DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)
 //! affect the same attributes in the Drawer.
 class AIS_InteractiveObject : public SelectMgr_SelectableObject
 {
-
+  friend class AIS_InteractiveContext;
+  DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
 public:
 
-  
-
   //! Returns the kind of Interactive Object:
   //! -   None
   //! -   Datum
@@ -125,8 +109,8 @@ public:
   //! Mode 2 :  Selection Of Edges
   //! Mode 3 :  Selection Of Wires
   //! Mode 4 :  Selection Of Faces ...
-    virtual Standard_Boolean AcceptShapeDecomposition() const;
-  
+  virtual Standard_Boolean AcceptShapeDecomposition() const { return Standard_False; }
+
   //! change the current facing model apply on polygons for
   //! SetColor(), SetTransparency(), SetMaterial() methods
   //! default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes is
@@ -185,17 +169,15 @@ public:
   //! considered as infinite, i.e. its graphic presentations
   //! are not taken in account for View FitAll...
   Standard_EXPORT void SetInfiniteState (const Standard_Boolean aFlag = Standard_True);
-  
 
   //! Returns true if the interactive object is infinite. In this
   //! case, its graphic presentations are not taken into
   //! account in the fit-all view.
-    Standard_Boolean IsInfinite() const;
-  
-  //! Indicates whether the Interactive Object has a pointer
-  //! to an interactive context.
-  Standard_EXPORT Standard_Boolean HasInteractiveContext() const;
-  
+  Standard_Boolean IsInfinite() const { return myInfiniteState; }
+
+  //! Indicates whether the Interactive Object has a pointer to an interactive context.
+  Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
+
   //! Returns the context pointer to the interactive context.
   Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
   
@@ -218,32 +200,23 @@ public:
   //! edges, wires, and faces.
   //! -   Users, presentable objects connecting to sensitive
   //! primitives, or a shape which has been decomposed.
-    const Handle(Standard_Transient)& GetOwner() const;
-  
-  //! Allows you to attribute the owner ApplicativeEntity to
+  const Handle(Standard_Transient)& GetOwner() const { return myOwner; }
+
+  //! Allows you to attribute the owner theApplicativeEntity to
   //! an Interactive Object. This can be a shape for a set of
   //! sub-shapes or a sub-shape for sub-shapes which it
   //! is composed of. The owner takes the form of a transient.
-    void SetOwner (const Handle(Standard_Transient)& ApplicativeEntity);
-  
+  void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; }
+
   //! Each Interactive Object has methods which allow us
   //! to attribute an Owner to it in the form of a Transient.
   //! This method removes the owner from the graphic entity.
   Standard_EXPORT void ClearOwner();
-  
-  Standard_EXPORT Standard_Boolean HasUsers() const;
-  
-    const TColStd_ListOfTransient& Users() const;
-  
-  Standard_EXPORT void AddUser (const Handle(Standard_Transient)& aUser);
-  
-  Standard_EXPORT void ClearUsers();
-  
 
   //! Returns true if the Interactive Object has a display
   //! mode setting. Otherwise, it is displayed in Neutral Point.
-    Standard_Boolean HasDisplayMode() const;
-  
+  Standard_Boolean HasDisplayMode() const { return myDisplayMode != -1; }
+
   //! Sets the display mode aMode for the interactive object.
   //! An object can have its own temporary display mode,
   //! which is different from that proposed by the interactive context.
@@ -252,17 +225,17 @@ public:
   //! -   AIS_Shaded
   //! This range can, however, be extended through the creation of new display modes.
   Standard_EXPORT void SetDisplayMode (const Standard_Integer aMode);
-  
+
   //! Removes display mode settings from the interactive object.
-    void UnsetDisplayMode();
-  
+  void UnsetDisplayMode() { myDisplayMode = -1; }
+
   //! Returns the display mode setting of the Interactive Object.
   //! The range of possibilities is the following:
   //! -   AIS_WireFrame
   //! -   AIS_Shaded
   //! This range can, however, be extended through the
   //! creation of new display modes.
-    Standard_Integer DisplayMode() const;
+  Standard_Integer DisplayMode() const { return myDisplayMode; }
 
   //! Returns the selection priority setting. -1 indicates that there is none.
   //! You can modify the selection priority of an owner to
@@ -281,20 +254,20 @@ public:
   //! -   priority 5 - its origin
   //! -   priority 3 - its axes
   //! -   priority 2 - its planes
-    Standard_Integer SelectionPriority() const;
-  
-  //! Allows you to provide a setting aPriority for selection priority.
+  Standard_Integer SelectionPriority() const { return mySelPriority; }
+
+  //! Allows you to provide a setting thePriority for selection priority.
   //! You can modify selection priority of an owner to make
   //! one entity more selectionable than another one. The
   //! default selection priority for an owner is 5, for
   //! example. To increase selection priority, choose a
   //! setting between 5 and 10. An entity with priority 7 will
   //! take priority over one with a setting of 6.
-    void SetSelectionPriority (const Standard_Integer aPriority);
-  
+  void SetSelectionPriority (const Standard_Integer thePriority) { mySelPriority = thePriority; }
+
   //! Removes the setting for selection priority. SelectionPriority then returns -1.
-    void UnsetSelectionPriority();
-  
+  void UnsetSelectionPriority() { mySelPriority = -1; }
+
   //! Returns true if there is a setting for selection priority.
   //! You can modify selection priority of an owner to make
   //! one entity more selectionable than another one. The
@@ -302,11 +275,11 @@ public:
   //! example. To increase selection priority, choose a
   //! setting between 5 and 10. An entity with priority 7 will
   //! take priority over one with a setting of 6.
-    Standard_Boolean HasSelectionPriority() const;
-  
+  Standard_Boolean HasSelectionPriority() const { return mySelPriority != -1; }
+
   //! Returns true if the Interactive Object is in highlight mode.
-    Standard_Boolean HasHilightMode() const;
-  
+  Standard_Boolean HasHilightMode() const { return myHilightMode != -1; }
+
   //! Returns the setting for highlight mode.
   //! At dynamic detection, the presentation echoed by the
   //! Interactive Context, is by default the presentation
@@ -321,39 +294,39 @@ public:
   //! wireframe presentation or with shading, we want to
   //! systematically highlight the wireframe presentation.
   //! Consequently, we set the highlight mode to 0.
-    Standard_Integer HilightMode() const;
-  
-  //! Sets the highlight mode anIndex for the interactive object.
+  Standard_Integer HilightMode() const { return myHilightMode; }
+
+  //! Sets the highlight mode theMode for the interactive object.
   //! If, for example, you want to systematically highlight
   //! the wireframe presentation of a shape - whether
   //! visualized in wireframe presentation or with shading -
   //! you set the highlight mode to 0.
-    void SetHilightMode (const Standard_Integer anIndex);
-  
+  void SetHilightMode (const Standard_Integer theMode) { myHilightMode = theMode; }
+
   //! Allows the user to take a given Prs for hilight
   //! ex : for a shape which would be displayed in shading mode
   //! the hilight Prs is the wireframe mode.
   //! if No specific hilight mode is defined, the displayed Prs
   //! will be the hilighted one.
-    void UnsetHilightMode();
-  
+  void UnsetHilightMode() { myHilightMode = -1; }
+
   //! Returns true if the Interactive Object has color.
-    Standard_Boolean HasColor() const;
-  
+  Standard_Boolean HasColor() const { return hasOwnColor; }
+
   //! Returns the color setting of the Interactive Object.
-    virtual Quantity_NameOfColor Color() const;
-  
-    virtual void Color (Quantity_Color& aColor) const;
-  
+  virtual Quantity_NameOfColor Color() const { return myOwnColor.Name(); }
+
+  virtual void Color (Quantity_Color& theColor) const { theColor = myOwnColor; }
+
   //! Returns true if the Interactive Object has width.
-    Standard_Boolean HasWidth() const;
-  
+  Standard_Boolean HasWidth() const { return myOwnWidth != 0.0; }
+
   //! Returns the width setting of the Interactive Object.
-  Standard_Real Width() const;
-  
+  Standard_Real Width() const { return myOwnWidth; }
+
   //! Returns true if the Interactive Object has a setting for material.
-  Standard_Boolean HasMaterial() const;
-  
+  Standard_Boolean HasMaterial() const { return hasOwnMaterial; }
+
   //! Returns the current material setting.
   //! This will be on of the following materials:
   //! -   Brass
@@ -362,8 +335,8 @@ public:
   //! -   Pewter
   //! -   Silver
   //! -   Stone.
-  virtual Graphic3d_NameOfMaterial Material() const;
-  
+  virtual Graphic3d_NameOfMaterial Material() const { return myOwnMaterial; }
+
   //! Sets the name aName for material defining this
   //! display attribute for the interactive object.
   //! Material aspect determines shading aspect, color and
@@ -386,8 +359,8 @@ public:
   Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6);
   
   //! Returns true if there is a transparency setting.
-    Standard_Boolean IsTransparent() const;
-  
+  Standard_Boolean IsTransparent() const { return myTransparency > 0.005; }
+
   //! Returns the transparency setting.
   //! This will be between 0.0 and 1.0.
   //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
@@ -398,11 +371,7 @@ public:
   
   //! Clears settings provided by the drawing tool aDrawer.
   Standard_EXPORT virtual void UnsetAttributes() Standard_OVERRIDE;
-  
-    void State (const Standard_Integer theState);
-  
-    Standard_Integer State() const;
-  
+
   //! Returns TRUE when this object has a presentation
   //! in the current DisplayMode()
   Standard_EXPORT Standard_Boolean HasPresentation() const;
@@ -459,10 +428,15 @@ public:
   //! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object).
   Standard_EXPORT void SynchronizeAspects();
 
-friend class AIS_InteractiveContext;
+private:
 
+  Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const;
 
-  DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject)
+  Standard_EXPORT void MustRecomputePrs (const Standard_Integer aMode) const;
+
+  Standard_EXPORT const TColStd_ListOfInteger& ListOfRecomputeModes() const;
+
+  Standard_EXPORT void SetRecomputeOk();
 
 protected:
 
@@ -483,33 +457,15 @@ protected:
   Standard_Boolean myRecomputeEveryPrs;
   TColStd_ListOfInteger myToRecomputeModes;
 
-
 private:
 
-  
-  Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const;
-  
-  Standard_EXPORT void MustRecomputePrs (const Standard_Integer aMode) const;
-  
-  Standard_EXPORT const TColStd_ListOfInteger& ListOfRecomputeModes() const;
-  
-  Standard_EXPORT void SetRecomputeOk();
-
-  AIS_PToContext myCTXPtr;
+  AIS_InteractiveContext* myCTXPtr;
   Handle(Standard_Transient) myOwner;
-  TColStd_ListOfTransient myUsers;
   Standard_Integer mySelPriority;
   Standard_Integer myDisplayMode;
-  Standard_Integer mystate;
-
 
 };
 
-
-#include <AIS_InteractiveObject.lxx>
-
-
-
-
+DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)
 
 #endif // _AIS_InteractiveObject_HeaderFile
index 69de42e..47b4303 100644 (file)
@@ -259,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())
-    {
-      continue;
-    }
-
-    if (!aChild->HasInteractiveContext())
+    if (!aChild.IsNull())
     {
-      aChild->SetContext (GetContext());
+      aChild->SetContext (aCtx);
     }
   }
 }
@@ -374,3 +370,20 @@ Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_
 
   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);
+    }
+  }
+}
index 144f931..97d060d 100644 (file)
@@ -79,6 +79,9 @@ public:
   //! children of multiple connected interactive object.
   Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const Standard_OVERRIDE;
 
+  //! Assigns interactive context.
+  Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& theCtx) Standard_OVERRIDE;
+
 public: // short aliases to Connect() method
 
   //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
diff --git a/src/AIS/AIS_PToContext.hxx b/src/AIS/AIS_PToContext.hxx
deleted file mode 100644 (file)
index ab5cbca..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_PToContext_HeaderFile
-#define _AIS_PToContext_HeaderFile
-
-class AIS_InteractiveContext;
-typedef AIS_InteractiveContext* AIS_PToContext;
-
-#endif // _AIS_PToContext_HeaderFile
index dd9f93a..254e329 100644 (file)
@@ -137,7 +137,6 @@ AIS_Point.hxx
 AIS_Point.lxx
 AIS_PointCloud.cxx
 AIS_PointCloud.hxx
-AIS_PToContext.hxx
 AIS_RadiusDimension.cxx
 AIS_RadiusDimension.hxx
 AIS_Relation.cxx
index e130388..bd57553 100644 (file)
@@ -1138,6 +1138,8 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
           break;
         }
       }
+
+      aCurrentContext->RemoveAll (Standard_False);
       if(isRemoveDriver)
       {
         ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver());
diff --git a/tests/bugs/vis/bug23670_1 b/tests/bugs/vis/bug23670_1
deleted file mode 100644 (file)
index 65dfcd6..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-puts "============"
-puts "OCC23670"
-puts "============"
-puts ""
-############################################################################
-# Support for multiple 3D views
-############################################################################
-
-#test case for vinit and vactivate commands
-#create view with default name Driver1/Viewer1/View1
-vinit
-vinit MyDriver/MyViewer/View1
-vinit MyDriver/MyViewer/MyView
-vactivate Driver1/Viewer1/View1
-box a 10 10 10
-vdisplay a
-vfit
-vactivate MyDriver/MyViewer/MyView
-#activate MyDriver/MyViewer/View1
-vactivate View1
-box b 5 5 5 10 10 10
-vdisplay a b
-vfit
-#disactivate active view
-vactivate none
-vactivate Driver1/Viewer1/View1
-vsetdispmode 1
-set x_coord 205
-set y_coord 180
-checkcolor $x_coord $y_coord 1 0.87 0.15
-
-vactivate MyDriver/MyViewer/MyView
-vsetdispmode 1
-checkcolor $x_coord $y_coord 0 0 0
-
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
-
index c99087a..db3edb0 100644 (file)
@@ -11,10 +11,10 @@ pload VISUALIZATION
 vfont add [locate_data_file DejaVuSans.ttf] SansFont
 
 vinit
-vpoint angleP1 0 0 0
-vpoint angleP2 50 50 50
-vpoint angleP3 50 50 100
-vdimension dim1 -angle -shapes angleP1 angleP2 angleP3 -font SansFont
+vpoint angle1P1 0 0 0
+vpoint angle1P2 50 50 50
+vpoint angle1P3 50 50 100
+vdimension dim1 -angle -shapes angle1P1 angle1P2 angle1P3 -font SansFont
 vfit
 vmoveto 249 206
 
@@ -27,8 +27,10 @@ if { $stat != 1 } {
    puts "Error : Highlighting of angle dimension with 2d text is wrong."
 }
 vinit Viewer2/View2
-vdisplay angleP1 angleP2 angleP3
-vdimension dim2 -angle -text 3d -shapes angleP1 angleP2 angleP3 -font SansFont
+vpoint angle2P1 0 0 0
+vpoint angle2P2 50 50 50
+vpoint angle2P3 50 50 100
+vdimension dim2 -angle -text 3d -shapes angle2P1 angle2P2 angle2P3 -font SansFont
 vfit
 vmoveto 263 251
 
index 5c58b80..636de0c 100644 (file)
@@ -14,9 +14,9 @@ vinit
 vpoint radP1 0 0 0
 vpoint radP2 50 50 0
 vpoint radP3 100 0 0
-vcircle circle radP1 radP2 radP3 0
+vcircle circle1 radP1 radP2 radP3 0
 verase radP1 radP2 radP3
-vdimension dim1 -radius -shapes circle -font SansFont
+vdimension dim1 -radius -shapes circle1 -font SansFont
 vfit
 vmoveto 123 158
 
@@ -30,8 +30,8 @@ if { $stat != 1 } {
 }
 
 vinit Viewer2/View2
-vdisplay circle
-vdimension dim2 -radius -text 3d -shapes circle -font SansFont
+vcircle circle2 radP1 radP2 radP3 0
+vdimension dim2 -radius -text 3d -shapes circle2 -font SansFont
 vfit
 vmoveto 191 196
 
index 3a25505..e21948e 100644 (file)
@@ -14,9 +14,9 @@ vinit
 vpoint diamP1 0 0 0
 vpoint diamP2 50 50 0
 vpoint diamP3 100 0 0
-vcircle circle diamP1 diamP2 diamP3 0
+vcircle circle1 diamP1 diamP2 diamP3 0
 verase diamP1 diamP2 diamP3
-vdimension dim1 -diameter -shapes circle -font SansFont
+vdimension dim1 -diameter -shapes circle1 -font SansFont
 vfit
 vmoveto 208 205
 
@@ -30,8 +30,8 @@ if { $stat != 1 } {
 }
 
 vinit Viewer2/View2
-vdisplay circle
-vdimension dim2 -diameter -text 3d -shapes circle -font SansFont
+vcircle circle2 diamP1 diamP2 diamP3 0
+vdimension dim2 -diameter -text 3d -shapes circle2 -font SansFont
 vfit
 vmoveto 208 205
 
diff --git a/tests/bugs/vis/bug2883_2 b/tests/bugs/vis/bug2883_2
deleted file mode 100644 (file)
index b090fd1..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-puts "=========="
-puts "OCC2883"
-puts "=========="
-puts ""
-########################################################################
-# It is impossible to set material, color and transparency to compound
-########################################################################
-
-set FilePath_v1 ${imagedir}/bug2883_2_v1.png
-set FilePath_v2 ${imagedir}/bug2883_2_v2.png
-
-file delete -force ${FilePath_v1}
-file delete -force ${FilePath_v2}
-
-box b1 0 0 0 1 2 3
-box b2 4 0 0 3 1 2
-vinit drv1/v1/v1
-vsetdispmode 1
-vdisplay b1 b2
-vfit
-vinit drv1/v2/v1
-vsetdispmode 1
-vdisplay b1 b2
-vfit
-vsetcolor b1 RED
-vactivate drv1/v1/v1
-vdump ${FilePath_v1}
-vactivate drv1/v2/v1
-vdump ${FilePath_v2}
-set info [diffimage ${FilePath_v1} ${FilePath_v2} 0 0 0]
-if { $info != 0 } {
-  puts "Error: images v1 and v2 are different"
-} else {
-  puts "OK: images v1 and v2 are similar"
-}
-
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png