b311480e |
1 | // Created on: 1997-04-22 |
2 | // Created by: Guest Design |
3 | // Copyright (c) 1997-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. |
b311480e |
16 | |
1f7f5a90 |
17 | #include <AIS_MultipleConnectedInteractive.hxx> |
7fd59977 |
18 | |
0717ddc1 |
19 | #include <AIS_ConnectedInteractive.hxx> |
20 | #include <AIS_InteractiveContext.hxx> |
42cf5bc1 |
21 | #include <AIS_InteractiveObject.hxx> |
42cf5bc1 |
22 | #include <Prs3d_Projector.hxx> |
7fd59977 |
23 | #include <PrsMgr_ModedPresentation.hxx> |
0717ddc1 |
24 | #include <Select3D_SensitiveEntity.hxx> |
42cf5bc1 |
25 | #include <SelectMgr_EntityOwner.hxx> |
26 | #include <Standard_NotImplemented.hxx> |
0717ddc1 |
27 | #include <TopLoc_Location.hxx> |
0717ddc1 |
28 | |
92efcf78 |
29 | IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject) |
30 | |
7fd59977 |
31 | //======================================================================= |
32 | //function : AIS_MultipleConnectedInteractive |
33 | //purpose : |
34 | //======================================================================= |
35 | |
0717ddc1 |
36 | AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive() |
37 | : AIS_InteractiveObject (PrsMgr_TOP_AllView) |
38 | { |
39 | myHasOwnPresentations = Standard_False; |
f751596e |
40 | myAssemblyOwner = NULL; |
7fd59977 |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : Type |
45 | //purpose : |
46 | //======================================================================= |
47 | AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const |
0717ddc1 |
48 | { |
49 | return AIS_KOI_Object; |
50 | } |
7fd59977 |
51 | |
52 | //======================================================================= |
53 | //function : Signature |
54 | //purpose : |
55 | //======================================================================= |
56 | Standard_Integer AIS_MultipleConnectedInteractive::Signature() const |
0717ddc1 |
57 | { |
58 | return 1; |
59 | } |
7fd59977 |
60 | |
61 | //======================================================================= |
1f7f5a90 |
62 | //function : connect |
ba9e14df |
63 | //purpose : |
7fd59977 |
64 | //======================================================================= |
1f7f5a90 |
65 | Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
66 | const Handle(Geom_Transformation)& theTrsf, |
778cd667 |
67 | const Handle(Graphic3d_TransformPers)& theTrsfPers) |
7fd59977 |
68 | { |
f751596e |
69 | if (myAssemblyOwner.IsNull()) |
70 | myAssemblyOwner = new SelectMgr_EntityOwner (this); |
71 | |
0717ddc1 |
72 | Handle(AIS_InteractiveObject) anObjectToAdd; |
73 | |
74 | Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj); |
75 | if (!aMultiConnected.IsNull()) |
76 | { |
77 | Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive(); |
f751596e |
78 | aNewMultiConnected->myAssemblyOwner = myAssemblyOwner; |
1f7f5a90 |
79 | aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom()); |
0717ddc1 |
80 | |
81 | // Perform deep copy of instance tree |
82 | for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next()) |
83 | { |
84 | Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
85 | if (anInteractive.IsNull()) |
86 | { |
87 | continue; |
88 | } |
89 | |
90 | aNewMultiConnected->Connect (anInteractive); |
91 | } |
7fd59977 |
92 | |
0717ddc1 |
93 | anObjectToAdd = aNewMultiConnected; |
7fd59977 |
94 | } |
0717ddc1 |
95 | else |
96 | { |
97 | Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive(); |
1f7f5a90 |
98 | aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom()); |
0717ddc1 |
99 | |
100 | anObjectToAdd = aNewConnected; |
101 | } |
102 | |
1f7f5a90 |
103 | anObjectToAdd->SetLocalTransformation (theTrsf); |
778cd667 |
104 | if (!theTrsfPers.IsNull()) |
ba9e14df |
105 | { |
778cd667 |
106 | anObjectToAdd->SetTransformPersistence (theTrsfPers); |
ba9e14df |
107 | } |
0717ddc1 |
108 | AddChild (anObjectToAdd); |
ba9e14df |
109 | return anObjectToAdd; |
0717ddc1 |
110 | } |
111 | |
7fd59977 |
112 | //======================================================================= |
113 | //function : HasConnection |
114 | //purpose : |
115 | //======================================================================= |
116 | Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const |
117 | { |
0717ddc1 |
118 | return (Children().Size() != 0); |
7fd59977 |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : Disconnect |
123 | //purpose : |
124 | //======================================================================= |
125 | |
126 | void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj) |
127 | { |
0717ddc1 |
128 | RemoveChild (anotherIObj); |
7fd59977 |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : DisconnectAll |
133 | //purpose : |
134 | //======================================================================= |
135 | |
0717ddc1 |
136 | void AIS_MultipleConnectedInteractive::DisconnectAll() |
7fd59977 |
137 | { |
0717ddc1 |
138 | Standard_Integer aNbItemsToRemove = Children().Size(); |
139 | for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter) |
140 | { |
141 | RemoveChild (Children().First()); |
142 | } |
7fd59977 |
143 | } |
144 | |
145 | //======================================================================= |
146 | //function : Compute |
792c785c |
147 | //purpose : |
7fd59977 |
148 | //======================================================================= |
0717ddc1 |
149 | void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/, |
150 | const Handle(Prs3d_Presentation)& /*thePrs*/, |
151 | const Standard_Integer /*theMode*/) |
7fd59977 |
152 | { |
2ec85268 |
153 | Handle(AIS_InteractiveContext) aCtx = GetContext(); |
0717ddc1 |
154 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
792c785c |
155 | { |
0717ddc1 |
156 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
2ec85268 |
157 | if (!aChild.IsNull()) |
0717ddc1 |
158 | { |
2ec85268 |
159 | aChild->SetContext (aCtx); |
7fd59977 |
160 | } |
161 | } |
7fd59977 |
162 | } |
792c785c |
163 | |
7fd59977 |
164 | //======================================================================= |
165 | //function : Compute |
166 | //purpose : |
167 | //======================================================================= |
168 | |
857ffd5e |
169 | void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, |
170 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
171 | { |
0717ddc1 |
172 | PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; |
7fd59977 |
173 | } |
174 | |
175 | //======================================================================= |
176 | //function : Compute |
177 | //purpose : |
7fd59977 |
178 | //======================================================================= |
179 | |
857ffd5e |
180 | void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, |
181 | const Handle(Geom_Transformation)& aTransformation, |
182 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
183 | { |
0717ddc1 |
184 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; |
185 | } |
186 | |
187 | //======================================================================= |
188 | //function : AcceptShapeDecomposition |
189 | //purpose : |
190 | //======================================================================= |
191 | Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const |
192 | { |
193 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
194 | { |
195 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
196 | if (aChild.IsNull()) |
197 | { |
198 | continue; |
199 | } |
200 | |
201 | if (aChild->AcceptShapeDecomposition()) |
202 | { |
203 | return Standard_True; |
204 | } |
205 | } |
206 | return Standard_False; |
7fd59977 |
207 | } |
208 | |
209 | //======================================================================= |
210 | //function : ComputeSelection |
211 | //purpose : |
212 | //======================================================================= |
f751596e |
213 | void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/, |
0717ddc1 |
214 | const Standard_Integer theMode) |
7fd59977 |
215 | { |
0717ddc1 |
216 | if (theMode != 0) |
217 | { |
218 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
219 | { |
220 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
221 | if (aChild.IsNull()) |
222 | { |
223 | continue; |
224 | } |
225 | |
f751596e |
226 | if (!aChild->HasSelection (theMode)) |
0717ddc1 |
227 | { |
f751596e |
228 | aChild->RecomputePrimitives (theMode); |
0717ddc1 |
229 | } |
230 | |
f751596e |
231 | Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode); |
232 | aChild->ComputeSelection (aSelection, theMode); |
0717ddc1 |
233 | } |
234 | } |
7fd59977 |
235 | } |
c3282ec1 |
236 | |
237 | //======================================================================= |
238 | //function : GlobalSelOwner |
239 | //purpose : |
240 | //======================================================================= |
241 | Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() const |
242 | { |
243 | return myAssemblyOwner; |
244 | } |
7411850a |
245 | |
246 | //======================================================================= |
247 | //function : HasSelection |
248 | //purpose : |
249 | //======================================================================= |
250 | Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_Integer theMode) const |
251 | { |
252 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
253 | { |
254 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
255 | if (aChild.IsNull()) |
256 | continue; |
257 | |
258 | if (!aChild->HasSelection (theMode)) |
259 | return Standard_False; |
260 | } |
261 | |
262 | return Standard_True; |
263 | } |
2ec85268 |
264 | |
265 | //======================================================================= |
266 | //function : SetContext |
267 | //purpose : |
268 | //======================================================================= |
269 | void AIS_MultipleConnectedInteractive::SetContext (const Handle(AIS_InteractiveContext)& theCtx) |
270 | { |
271 | AIS_InteractiveObject::SetContext (theCtx); |
272 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
273 | { |
274 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
275 | if (!aChild.IsNull()) |
276 | { |
277 | aChild->SetContext (theCtx); |
278 | } |
279 | } |
280 | } |