b311480e |
1 | // Created on: 1996-12-18 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
f838dac4 |
17 | #include <AIS_InteractiveObject.hxx> |
7fd59977 |
18 | |
42cf5bc1 |
19 | #include <AIS_InteractiveContext.hxx> |
7fd59977 |
20 | #include <Graphic3d_AspectFillArea3d.hxx> |
3ddebf91 |
21 | #include <Graphic3d_AspectLine3d.hxx> |
22 | #include <Graphic3d_AspectMarker3d.hxx> |
23 | #include <Graphic3d_AspectText3d.hxx> |
f751596e |
24 | #include <Graphic3d_CStructure.hxx> |
7fd59977 |
25 | #include <Graphic3d_Group.hxx> |
26 | #include <Graphic3d_Structure.hxx> |
42cf5bc1 |
27 | #include <Prs3d_LineAspect.hxx> |
28 | #include <Prs3d_PointAspect.hxx> |
29 | #include <Prs3d_Presentation.hxx> |
42cf5bc1 |
30 | #include <Prs3d_ShadingAspect.hxx> |
31 | #include <Prs3d_TextAspect.hxx> |
2b886265 |
32 | #include <PrsMgr_PresentationManager.hxx> |
7fd59977 |
33 | |
92efcf78 |
34 | IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject) |
35 | |
7fd59977 |
36 | //======================================================================= |
37 | //function : AIS_InteractiveObject |
38 | //purpose : |
39 | //======================================================================= |
f838dac4 |
40 | AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) |
41 | : SelectMgr_SelectableObject (aTypeOfPresentation3d), |
2b886265 |
42 | myCTXPtr (NULL) |
7fd59977 |
43 | { |
2b886265 |
44 | // |
7fd59977 |
45 | } |
46 | |
47 | //======================================================================= |
48 | //function : Redisplay |
36132a2e |
49 | //purpose : |
7fd59977 |
50 | //======================================================================= |
36132a2e |
51 | void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes) |
7fd59977 |
52 | { |
36132a2e |
53 | if (myCTXPtr == NULL) |
54 | return; |
55 | |
56 | myCTXPtr->Redisplay (this, Standard_False, AllModes); |
7fd59977 |
57 | } |
58 | |
630ab538 |
59 | //======================================================================= |
60 | //function : ProcessDragging |
61 | //purpose : |
62 | //======================================================================= |
63 | Standard_Boolean AIS_InteractiveObject::ProcessDragging (const Handle(AIS_InteractiveContext)&, |
64 | const Handle(V3d_View)&, |
65 | const Handle(SelectMgr_EntityOwner)&, |
66 | const Graphic3d_Vec2i&, |
67 | const Graphic3d_Vec2i&, |
68 | const AIS_DragAction) |
69 | { |
70 | return Standard_False; |
71 | } |
72 | |
7fd59977 |
73 | //======================================================================= |
74 | //function : |
75 | //purpose : |
76 | //======================================================================= |
77 | Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const |
78 | { |
79 | return myCTXPtr; |
80 | } |
81 | |
82 | //======================================================================= |
2ec85268 |
83 | //function : SetContext |
84 | //purpose : |
7fd59977 |
85 | //======================================================================= |
2ec85268 |
86 | void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& theCtx) |
7fd59977 |
87 | { |
2ec85268 |
88 | if (myCTXPtr == theCtx.get()) |
89 | { |
da0e82aa |
90 | return; |
2ec85268 |
91 | } |
92 | |
93 | myCTXPtr = theCtx.get(); |
94 | if (!theCtx.IsNull()) |
95 | { |
96 | myDrawer->Link (theCtx->DefaultDrawer()); |
97 | } |
7fd59977 |
98 | } |
99 | |
7fd59977 |
100 | //======================================================================= |
101 | //function : HasPresentation |
af324faa |
102 | //purpose : |
7fd59977 |
103 | //======================================================================= |
af324faa |
104 | Standard_Boolean AIS_InteractiveObject::HasPresentation() const |
105 | { |
f838dac4 |
106 | return HasInteractiveContext() |
107 | && myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode()); |
7fd59977 |
108 | } |
109 | |
110 | //======================================================================= |
111 | //function : Presentation |
af324faa |
112 | //purpose : |
7fd59977 |
113 | //======================================================================= |
af324faa |
114 | Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const |
115 | { |
f838dac4 |
116 | if (!HasInteractiveContext()) |
117 | { |
118 | return Handle(Prs3d_Presentation)(); |
119 | } |
120 | |
121 | Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false); |
7dd7c146 |
122 | return aPrs; |
7fd59977 |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : SetAspect |
127 | //purpose : |
128 | //======================================================================= |
2b886265 |
129 | void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect) |
2831708b |
130 | { |
7fd59977 |
131 | |
2b886265 |
132 | if (!HasPresentation()) |
133 | { |
134 | return; |
7fd59977 |
135 | } |
7fd59977 |
136 | |
2b886265 |
137 | Handle(Prs3d_Presentation) aPrs = Presentation(); |
138 | if (aPrs->Groups().IsEmpty()) |
f751596e |
139 | { |
2b886265 |
140 | return; |
f751596e |
141 | } |
2b886265 |
142 | const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last(); |
143 | if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect)) |
f751596e |
144 | { |
2b886265 |
145 | aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect()); |
f751596e |
146 | } |
2b886265 |
147 | else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect)) |
fb66bb28 |
148 | { |
2b886265 |
149 | aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect()); |
fb66bb28 |
150 | } |
2b886265 |
151 | else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect)) |
bf5f0ca2 |
152 | { |
2b886265 |
153 | aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect()); |
bf5f0ca2 |
154 | } |
2b886265 |
155 | else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect)) |
bf5f0ca2 |
156 | { |
2b886265 |
157 | aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect()); |
bf5f0ca2 |
158 | } |
159 | } |
0904aa63 |
160 | |
161 | //======================================================================= |
162 | //function : DumpJson |
163 | //purpose : |
164 | //======================================================================= |
bc73b006 |
165 | void AIS_InteractiveObject::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
0904aa63 |
166 | { |
bc73b006 |
167 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
0904aa63 |
168 | |
bc73b006 |
169 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_SelectableObject) |
170 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCTXPtr) |
171 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner) |
0904aa63 |
172 | } |