1 // Created on: 1996-12-18
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <AIS_InteractiveObject.hxx>
19 #include <AIS_InteractiveContext.hxx>
20 #include <Graphic3d_AspectFillArea3d.hxx>
21 #include <Graphic3d_AspectLine3d.hxx>
22 #include <Graphic3d_AspectMarker3d.hxx>
23 #include <Graphic3d_AspectText3d.hxx>
24 #include <Graphic3d_CStructure.hxx>
25 #include <Graphic3d_Group.hxx>
26 #include <Graphic3d_Structure.hxx>
27 #include <Prs3d_LineAspect.hxx>
28 #include <Prs3d_PointAspect.hxx>
29 #include <Prs3d_Presentation.hxx>
30 #include <Prs3d_ShadingAspect.hxx>
31 #include <Prs3d_TextAspect.hxx>
32 #include <PrsMgr_PresentationManager.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject)
36 //=======================================================================
37 //function : AIS_InteractiveObject
39 //=======================================================================
40 AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
41 : SelectMgr_SelectableObject (aTypeOfPresentation3d),
47 //=======================================================================
48 //function : Redisplay
50 //=======================================================================
51 void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
56 myCTXPtr->Redisplay (this, Standard_False, AllModes);
59 //=======================================================================
62 //=======================================================================
63 Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
68 //=======================================================================
69 //function : SetContext
71 //=======================================================================
72 void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
74 if (myCTXPtr == theCtx.get())
79 myCTXPtr = theCtx.get();
82 myDrawer->Link (theCtx->DefaultDrawer());
86 //=======================================================================
87 //function : HasPresentation
89 //=======================================================================
90 Standard_Boolean AIS_InteractiveObject::HasPresentation() const
92 return HasInteractiveContext()
93 && myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode());
96 //=======================================================================
97 //function : Presentation
99 //=======================================================================
100 Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
102 if (!HasInteractiveContext())
104 return Handle(Prs3d_Presentation)();
107 Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false);
111 //=======================================================================
112 //function : SetAspect
114 //=======================================================================
115 void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect)
118 if (!HasPresentation())
123 Handle(Prs3d_Presentation) aPrs = Presentation();
124 if (aPrs->Groups().IsEmpty())
128 const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last();
129 if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect))
131 aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect());
133 else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect))
135 aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect());
137 else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect))
139 aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect());
141 else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect))
143 aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect());