0028726: Quantity_NameOfColor should be replaced by Quantity_Color in function input...
[occt.git] / src / AIS / AIS_InteractiveObject.cxx
index 3e97b9c..fba30b6 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-// Modified :   22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets 
-
-#define BUC60577        //GG_101099     Enable to compute correctly
-//                      transparency with more than one object in the view.
-
-#define GER61351       //GG_171199     Enable to set an object RGB color
-//                     instead a restricted object NameOfColor. 
-//                     Add SetCurrentFacingModel() method
-
-#define BUC60632       //GG 15/03/00 Add protection on SetDisplayMode()
-//                     method, compute only authorized presentation.
-
-#define OCC708          //SAV unsetting transformation correctly
-
-#include <AIS_InteractiveObject.ixx>
+#include <AIS_InteractiveObject.hxx>
 
+#include <AIS_GraphicTool.hxx>
+#include <AIS_InteractiveContext.hxx>
 #include <Aspect_PolygonOffsetMode.hxx>
-#include <Prs3d_ShadingAspect.hxx>
+#include <Bnd_Box.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_BndBox4f.hxx>
+#include <Graphic3d_CStructure.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Prs3d_BasicAspect.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_PointAspect.hxx>
-#include <Prs3d_TextAspect.hxx>
 #include <Prs3d_Presentation.hxx>
 #include <Prs3d_Root.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
 #include <PrsMgr_ModedPresentation.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <AIS_GraphicTool.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Structure.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject)
 
 //=======================================================================
 //function : AIS_InteractiveObject
 //purpose  : 
 //=======================================================================
-
-AIS_InteractiveObject::
-AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
-SelectMgr_SelectableObject(aTypeOfPresentation3d),
-myDrawer(new AIS_Drawer()),
-myTransparency(0.),
-myOwnColor(Quantity_NOC_WHITE),
-myOwnMaterial(Graphic3d_NOM_DEFAULT),
-myHilightMode(-1),
-myOwnWidth(0.0),
-myInfiniteState(Standard_False),
-hasOwnColor(Standard_False),
-hasOwnMaterial(Standard_False),
-myCurrentFacingModel(Aspect_TOFM_BOTH_SIDE),
-myRecomputeEveryPrs(Standard_True),
-myCTXPtr(NULL),
-mySelPriority(-1),
-myDisplayMode (-1),
-mySelectionMode(0),
-mystate(0)
+AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
+: SelectMgr_SelectableObject (aTypeOfPresentation3d),
+  myCTXPtr (NULL),
+  myOwnWidth (0.0),
+  myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
+  myInfiniteState (Standard_False),
+  hasOwnColor (Standard_False),
+  hasOwnMaterial (Standard_False),
+  myRecomputeEveryPrs (Standard_True)
 {
-  Handle (AIS_InteractiveContext) Bid;
-  myCTXPtr = Bid.operator->();
-#ifdef GER61351
   SetCurrentFacingModel();
-#endif
 }
 
 //=======================================================================
 //function : Redisplay
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes)
+void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
 {
-  Update(AllModes);
-  UpdateSelection();
+  if (myCTXPtr == NULL)
+    return;
+
+  myCTXPtr->Redisplay (this, Standard_False, AllModes);
 }
 
 //=======================================================================
@@ -116,16 +98,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  : 
@@ -136,21 +108,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;
-  if (myDrawer.IsNull()) {
-    myDrawer = new AIS_Drawer;
-#ifdef DEB
-    cout << "AIS_InteractiveObject::SetContext DRAWER NUL!" << endl;
-#endif
   }
-  myDrawer->Link(aCtx->DefaultDrawer());
+
+  myCTXPtr = theCtx.get();
+  if (!theCtx.IsNull())
+  {
+    myDrawer->Link (theCtx->DefaultDrawer());
+  }
 }
 
 //=======================================================================
@@ -174,63 +146,21 @@ void AIS_InteractiveObject::ClearOwner()
 }
 
 //=======================================================================
-//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  : 
-//=======================================================================
-void AIS_InteractiveObject::SetDisplayMode(const Standard_Integer aMode)
-{
-#ifdef BUC60632
-  if( AcceptDisplayMode(aMode) )
-#endif
-    myDisplayMode = aMode;
-}
-  
-
-//=======================================================================
-//function : 
-//purpose  : 
+//function : SetDisplayMode
+//purpose  :
 //=======================================================================
-void AIS_InteractiveObject::SetSelectionMode(const Standard_Integer aMode)
+void AIS_InteractiveObject::SetDisplayMode (const Standard_Integer theMode)
 {
-  mySelectionMode = aMode;
+  if (AcceptDisplayMode (theMode))
+  {
+    myDrawer->SetDisplayMode (theMode);
+  }
 }
 
-
-
 //=======================================================================
 //function : 
 //purpose  : 
 //=======================================================================
-#ifdef GER61351
 void AIS_InteractiveObject::SetCurrentFacingModel(const Aspect_TypeOfFacingModel aModel) {
   myCurrentFacingModel = aModel;
 }
@@ -243,28 +173,15 @@ void AIS_InteractiveObject::SetCurrentFacingModel(const Aspect_TypeOfFacingModel
 Aspect_TypeOfFacingModel AIS_InteractiveObject::CurrentFacingModel() const {
   return myCurrentFacingModel;
 }
-#endif
-
-//=======================================================================
-//function : SetColor
-//purpose  : 
-//=======================================================================
-
-void AIS_InteractiveObject::SetColor(const Quantity_NameOfColor aColor)
-#ifdef GER61351
-{
-  SetColor(Quantity_Color(aColor));
-}
 
 //=======================================================================
 //function : SetColor
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveObject::SetColor(const Quantity_Color &aColor)
-#endif
+void AIS_InteractiveObject::SetColor(const Quantity_Color& theColor)
 {
-  myOwnColor = aColor;
+  myDrawer->SetColor (theColor);
   hasOwnColor = Standard_True;
 }
 
@@ -295,130 +212,87 @@ void AIS_InteractiveObject::UnsetWidth()
   myOwnWidth = 0.;
 }
 
-
 //=======================================================================
-//function : 
-//purpose  : 
+//function : Material
+//purpose  :
 //=======================================================================
-//POP pour K4L
-void AIS_InteractiveObject::SetMaterial(const Graphic3d_NameOfMaterial aName)
-//void AIS_InteractiveObject::SetMaterial(const Graphic3d_NameOfPhysicalMaterial aName)
+Graphic3d_NameOfMaterial AIS_InteractiveObject::Material() const
 {
-  if( HasColor() || IsTransparent() || HasMaterial() )
-    {
-      myDrawer->ShadingAspect()->SetMaterial(aName);
-    }
-  else 
-    {
-      myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
-      
-      myDrawer->ShadingAspect()->SetMaterial(aName);
-#ifndef BUC60577       //???
-      myDrawer->ShadingAspect()->SetColor(AIS_GraphicTool::GetInteriorColor(myDrawer->Link()));
-#endif
-    }
-  myOwnMaterial  = aName;
-  hasOwnMaterial = Standard_True;
+  return myDrawer->ShadingAspect()->Material().Name();
 }
+
 //=======================================================================
 //function : SetMaterial
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-void AIS_InteractiveObject::SetMaterial(const Graphic3d_MaterialAspect& aMat)
+void AIS_InteractiveObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
 {
-#ifdef BUC60577
-  if( HasColor() || IsTransparent() || HasMaterial() )
-#else
-  if(hasOwnColor ||(myTransparency==0.0) || hasOwnMaterial )
-#endif
-    {
-      myDrawer->ShadingAspect()->SetMaterial(aMat);
-    }
-  else 
+  if (!myDrawer->HasOwnShadingAspect())
+  {
+    myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+    if (myDrawer->HasLink())
     {
-      myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
-      myDrawer->ShadingAspect()->SetMaterial(aMat);
+      *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
     }
+  }
+
+  myDrawer->ShadingAspect()->SetMaterial (theMaterial);
   hasOwnMaterial = Standard_True;
-  
 }
+
 //=======================================================================
-//function : 
-//purpose  : 
+//function : UnsetMaterial
+//purpose  :
 //=======================================================================
 void AIS_InteractiveObject::UnsetMaterial()
 {
-#ifdef BUC60577
-  if( !HasMaterial() ) return;
-  if( HasColor() || IsTransparent()) {
-    myDrawer->ShadingAspect()->SetMaterial(
-               AIS_GraphicTool::GetMaterial(myDrawer->Link()));
-    if( HasColor() ) SetColor(myOwnColor);
-    if( IsTransparent() ) SetTransparency(myTransparency);
+  if (!HasMaterial())
+  {
+    return;
   }
-#else
-  if(!hasOwnMaterial) return;
-  if(hasOwnColor ||(myTransparency==0.0))
+
+  if (HasColor() || IsTransparent())
+  {
+    if(myDrawer->HasLink())
     {
-      myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
+      myDrawer->ShadingAspect()->SetMaterial (AIS_GraphicTool::GetMaterial (myDrawer->Link()));
     }
-#endif
-  else{
-    Handle(Prs3d_ShadingAspect) SA;
-    myDrawer->SetShadingAspect(SA);
+
+    if (HasColor())
+    {
+      SetColor (myDrawer->Color());
+    }
+
+    if (IsTransparent())
+    {
+      SetTransparency (myDrawer->Transparency());
+    }
+  }
+  else
+  {
+    Handle(Prs3d_ShadingAspect) anAspect;
+    myDrawer->SetShadingAspect (anAspect);
   }
+
   hasOwnMaterial = Standard_False;
 }
 
 //=======================================================================
 //function : SetTransparency
-//purpose  : 
+//purpose  :
 //=======================================================================
-void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue)
+void AIS_InteractiveObject::SetTransparency (const Standard_Real theValue)
 {
-
-#ifdef BUC60577                     // Back & Front material can be different !
-
-  if(!HasColor() && !IsTransparent() && !HasMaterial() ) {
-        myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
-      if(!myDrawer->Link().IsNull())
-        myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
+  if (!myDrawer->HasOwnShadingAspect())
+  {
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+    if(myDrawer->HasLink())
+      myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
   }
-  Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
-  Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
-  FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
-  myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
-  myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
-#else
-  if(aValue<0.0 || aValue>1.0) return;
-  
-  if(aValue<=0.05) 
-    {
-      UnsetTransparency();
-      return;
-    }
-  
 
-  if(hasOwnColor || hasOwnMaterial || myTransparency> 0.0)
-    {
-      Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
-      Mat.SetTransparency(aValue);
-      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Mat);
-      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Mat);
-    }
-  else
-    {
-      myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
-      if(!myDrawer->Link().IsNull())
-       myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
-      Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
-      Mat.SetTransparency(aValue);
-      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Mat);
-      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Mat);
-    }
-#endif
-  myTransparency = aValue;
+  myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue));
+  myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (Standard_ShortReal(theValue));
+  myDrawer->SetTransparency (Standard_ShortReal(theValue));
 }
 
 //=======================================================================
@@ -427,30 +301,16 @@ void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue)
 //=======================================================================
 void AIS_InteractiveObject::UnsetTransparency()
 {
-#ifdef BUC60577                     // Back & Front material can be different !
-    if(HasColor() || HasMaterial() )
-    {
-      Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
-      Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
-      FMat.SetTransparency(0.); BMat.SetTransparency(0.);
-      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
-      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
-    }
-#else
-    if(hasOwnColor || hasOwnMaterial )
-    {
-      Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
-      Mat.SetTransparency(0.0);
-//      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Mat);
-//      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Mat);
-       myDrawer->ShadingAspect()->SetMaterial(Mat);
-    }
-#endif
+  if(HasColor() || HasMaterial() )
+  {
+    myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (0.0f);
+    myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (0.0f);
+  }
   else{
     Handle (Prs3d_ShadingAspect) SA;
     myDrawer->SetShadingAspect(SA);
   }
-  myTransparency =0.0;
+  myDrawer->SetTransparency (0.0f);
 }
 //=======================================================================
 //function : Transparency
@@ -458,34 +318,23 @@ void AIS_InteractiveObject::UnsetTransparency()
 //=======================================================================
 Standard_Real AIS_InteractiveObject::Transparency() const 
 {
-  return (myTransparency<=0.05 ? 0 : myTransparency);
+  return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency());
 // Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
 // return Mat.Transparency();
 }
 
-//=======================================================================
-//function : SetAttributes
-//purpose  : 
-//=======================================================================
-
-void AIS_InteractiveObject::SetAttributes(const Handle(AIS_Drawer)& aDrawer)
-{myDrawer = aDrawer;}
-
-
 //=======================================================================
 //function : UnsetAttributes
 //purpose  : 
 //=======================================================================
 void AIS_InteractiveObject::UnsetAttributes()
 {
-  Handle(AIS_Drawer) dr = new AIS_Drawer();
-  if(myDrawer->HasLink())
-    dr->Link(myDrawer->Link());
-  myDrawer       = dr;
+  SelectMgr_SelectableObject::UnsetAttributes();
+
   hasOwnColor    = Standard_False;
   hasOwnMaterial = Standard_False;
   myOwnWidth     = 0.0;
-  myTransparency = 0.0;
+  myDrawer->SetTransparency (0.0f);
 }
 
 //=======================================================================
@@ -550,8 +399,8 @@ void AIS_InteractiveObject::SetInfiniteState(const Standard_Boolean aFlag)
 //=======================================================================
 Standard_Boolean AIS_InteractiveObject::HasPresentation() const
 {
-  return !GetContext().IsNull()
-       && GetContext()->MainPrsMgr()->HasPresentation (this, myDisplayMode);
+  return HasInteractiveContext()
+      && myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode());
 }
 
 //=======================================================================
@@ -560,8 +409,14 @@ Standard_Boolean AIS_InteractiveObject::HasPresentation() const
 //=======================================================================
 Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
 {
-  return HasPresentation()
-       ? GetContext()->MainPrsMgr()->Presentation (this, myDisplayMode)->Presentation()
+  if (!HasInteractiveContext())
+  {
+    return Handle(Prs3d_Presentation)();
+  }
+
+  Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false);
+  return !aPrs.IsNull()
+       ? aPrs->Presentation()
        : Handle(Prs3d_Presentation)();
 }
 
@@ -569,15 +424,14 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
 //function : SetAspect 
 //purpose  : 
 //=======================================================================
-void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect,
-                                     const Standard_Boolean globalChange) {
+void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect)
+{
 
   if( HasPresentation() ) {
     Handle(Prs3d_Presentation) prs = Presentation();
     { Handle(Prs3d_ShadingAspect) aspect =
                        Handle(Prs3d_ShadingAspect)::DownCast(anAspect);
       if( !aspect.IsNull() ) {
-        if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
         Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
         return;
       }
@@ -585,7 +439,6 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect,
     { Handle(Prs3d_LineAspect) aspect =
                        Handle(Prs3d_LineAspect)::DownCast(anAspect);
       if( !aspect.IsNull() ) {
-        if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
         Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
         return;
       }
@@ -593,7 +446,6 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect,
     { Handle(Prs3d_PointAspect) aspect =
                        Handle(Prs3d_PointAspect)::DownCast(anAspect);
       if( !aspect.IsNull() ) {
-        if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
         Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
         return;
       }
@@ -601,7 +453,6 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect,
     { Handle(Prs3d_TextAspect) aspect =
                        Handle(Prs3d_TextAspect)::DownCast(anAspect);
       if( !aspect.IsNull() ) {
-        if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
         Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
         return;
       }
@@ -629,7 +480,6 @@ void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer    aMode,
     if ( !aPrs3d.IsNull() ) {
       const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
       if( !aStruct.IsNull() ) {
-        aStruct->SetPrimitivesAspect( myDrawer->ShadingAspect()->Aspect() );
         // Workaround for issue 23115: Need to update also groups, because their
         // face aspect ALWAYS overrides the structure's.
         const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
@@ -642,12 +492,7 @@ void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer    aMode,
             continue;
           }
 
-          Handle(Graphic3d_AspectFillArea3d) aFaceAsp = new Graphic3d_AspectFillArea3d();
-          Handle(Graphic3d_AspectLine3d)     aLineAsp = new Graphic3d_AspectLine3d();
-          Handle(Graphic3d_AspectMarker3d)   aPntAsp  = new Graphic3d_AspectMarker3d();
-          Handle(Graphic3d_AspectText3d)     aTextAsp = new Graphic3d_AspectText3d();
-          // TODO: Add methods for retrieving individual aspects from Graphic3d_Group
-          aGrp->GroupPrimitivesAspect(aLineAsp, aTextAsp, aPntAsp, aFaceAsp);
+          Handle(Graphic3d_AspectFillArea3d) aFaceAsp = aGrp->FillAreaAspect();
           aFaceAsp->SetPolygonOffsets(aMode, aFactor, aUnits);
           aGrp->SetGroupPrimitivesAspect(aFaceAsp);
         }
@@ -663,7 +508,7 @@ void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer    aMode,
 Standard_Boolean AIS_InteractiveObject::HasPolygonOffsets() const
 {
   return !( myDrawer->ShadingAspect().IsNull() || 
-          ( !myDrawer->Link().IsNull() && 
+          ( myDrawer->HasLink() &&
           myDrawer->ShadingAspect() == myDrawer->Link()->ShadingAspect() ) );
 }
 
@@ -678,3 +523,124 @@ void AIS_InteractiveObject::PolygonOffsets(Standard_Integer&    aMode,
   if( HasPolygonOffsets() )
     myDrawer->ShadingAspect()->Aspect()->PolygonOffsets( aMode, aFactor, aUnits );
 }
+
+//=======================================================================
+//function : BoundingBox
+//purpose  : Returns bounding box of object correspondingly to its
+//           current display mode
+//=======================================================================
+void AIS_InteractiveObject::BoundingBox (Bnd_Box& theBndBox)
+{
+  if (myDrawer->DisplayMode() == -1)
+  {
+    if (!myPresentations.IsEmpty())
+    {
+      const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations.First().Presentation();
+      const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
+      const Graphic3d_BndBox3d& aBndBox = aStruct->CStructure()->BoundingBox();
+
+      if (!aBndBox.IsValid())
+      {
+        theBndBox.SetVoid();
+        return;
+      }
+
+      theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
+                        aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
+      return;
+    }
+    else
+    {
+      for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (Children()); aPrsIter.More(); aPrsIter.Next())
+      {
+        Handle(AIS_InteractiveObject) aChild (Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value()));
+        if (aChild.IsNull())
+        {
+          continue;
+        }
+        Bnd_Box aBox;
+        aChild->BoundingBox (aBox);
+        theBndBox.Add (aBox);
+      }
+      return;
+    }
+  }
+  else
+  {
+    for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
+    {
+      if (myPresentations (aPrsIter).Mode() == myDrawer->DisplayMode())
+      {
+        const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
+        const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
+        const Graphic3d_BndBox3d& aBndBox = aStruct->CStructure()->BoundingBox();
+
+        if (!aBndBox.IsValid())
+        {
+          theBndBox.SetVoid();
+          return;
+        }
+
+        theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
+                          aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
+        return;
+      }
+    }
+  }
+}
+
+//=======================================================================
+//function : SetIsoOnTriangulation
+//purpose  : Enables or disables isoline on triangulation building
+//=======================================================================
+void AIS_InteractiveObject::SetIsoOnTriangulation (const Standard_Boolean theIsEnabled)
+{
+  myDrawer->SetIsoOnTriangulation (theIsEnabled);
+}
+
+//=======================================================================
+//function : SynchronizeAspects
+//purpose  :
+//=======================================================================
+void AIS_InteractiveObject::SynchronizeAspects()
+{
+  for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
+  {
+    const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
+    if (aPrs3d.IsNull()
+     || aPrs3d->Presentation().IsNull())
+    {
+      continue;
+    }
+
+    for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
+    {
+      Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
+      if (aGrp.IsNull())
+      {
+        continue;
+      }
+
+      Handle(Graphic3d_AspectLine3d)     aLineAspect   = aGrp->LineAspect();
+      Handle(Graphic3d_AspectFillArea3d) aFaceAspect   = aGrp->FillAreaAspect();
+      Handle(Graphic3d_AspectMarker3d)   aMarkerAspect = aGrp->MarkerAspect();
+      Handle(Graphic3d_AspectText3d)     aTextAspect   = aGrp->TextAspect();
+      if (!aLineAspect.IsNull())
+      {
+        aGrp->SetGroupPrimitivesAspect (aLineAspect);
+      }
+      if (!aFaceAspect.IsNull())
+      {
+        aGrp->SetGroupPrimitivesAspect (aFaceAspect);
+      }
+      if (!aMarkerAspect.IsNull())
+      {
+        aGrp->SetGroupPrimitivesAspect (aMarkerAspect);
+      }
+      if (!aTextAspect.IsNull())
+      {
+        aGrp->SetGroupPrimitivesAspect (aTextAspect);
+      }
+    }
+  }
+}