b311480e |
1 | // Created on: 1995-02-20 |
2 | // Created by: Mister rmi |
3 | // Copyright (c) 1995-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 <SelectMgr_SelectableObject.hxx> |
7fd59977 |
18 | |
7f917335 |
19 | #include <Graphic3d_AspectLine3d.hxx> |
20 | #include <Graphic3d_AspectMarker3d.hxx> |
42cf5bc1 |
21 | #include <Prs3d_Drawer.hxx> |
22 | #include <Prs3d_LineAspect.hxx> |
23 | #include <Prs3d_PlaneAspect.hxx> |
24 | #include <Prs3d_PointAspect.hxx> |
25 | #include <Prs3d_Presentation.hxx> |
2b886265 |
26 | #include <PrsMgr_PresentationManager.hxx> |
42cf5bc1 |
27 | #include <Select3D_SensitiveEntity.hxx> |
42cf5bc1 |
28 | #include <SelectMgr_EntityOwner.hxx> |
c04c30b3 |
29 | #include <SelectMgr_IndexedMapOfOwner.hxx> |
42cf5bc1 |
30 | #include <SelectMgr_Selection.hxx> |
31 | #include <SelectMgr_SelectionManager.hxx> |
32 | #include <Standard_NoSuchObject.hxx> |
33 | #include <Standard_NotImplemented.hxx> |
0717ddc1 |
34 | #include <TopLoc_Location.hxx> |
7fd59977 |
35 | |
92efcf78 |
36 | IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject) |
37 | |
b5cce1ab |
38 | namespace |
7fd59977 |
39 | { |
2b886265 |
40 | static const Handle(SelectMgr_Selection) THE_NULL_SELECTION; |
41 | static const Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER; |
b5cce1ab |
42 | } |
7fd59977 |
43 | |
7fd59977 |
44 | //================================================== |
f838dac4 |
45 | // Function: SelectMgr_SelectableObject |
7fd59977 |
46 | // Purpose : |
47 | //================================================== |
48 | |
c3282ec1 |
49 | SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) |
50 | : PrsMgr_PresentableObject (aTypeOfPresentation3d), |
2b886265 |
51 | myGlobalSelMode (0), |
2b886265 |
52 | myAutoHilight (Standard_True) |
7f917335 |
53 | { |
f838dac4 |
54 | // |
7f917335 |
55 | } |
7fd59977 |
56 | |
4c0d97ac |
57 | //================================================== |
58 | // Function: Destructor |
59 | // Purpose : Clears all selections of the object |
60 | //================================================== |
61 | SelectMgr_SelectableObject::~SelectMgr_SelectableObject() |
62 | { |
b5cce1ab |
63 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
7411850a |
64 | { |
b5cce1ab |
65 | aSelIter.Value()->Clear(); |
7411850a |
66 | } |
7fd59977 |
67 | } |
68 | |
69 | //================================================== |
f751596e |
70 | // Function: RecomputePrimitives |
71 | // Purpose : IMPORTANT: Do not use this method to update |
72 | // selection primitives except implementing custom |
73 | // selection manager! This method does not take |
74 | // into account necessary BVH updates, but may |
75 | // invalidate the pointers it refers to. |
76 | // TO UPDATE SELECTION properly from outside classes, |
77 | // use method UpdateSelection. |
7fd59977 |
78 | //================================================== |
f751596e |
79 | void SelectMgr_SelectableObject::RecomputePrimitives() |
7fd59977 |
80 | { |
b5cce1ab |
81 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
82 | { |
83 | RecomputePrimitives (aSelIter.Value()->Mode()); |
84 | } |
7fd59977 |
85 | } |
86 | |
7fd59977 |
87 | //================================================== |
f751596e |
88 | // Function: RecomputePrimitives |
89 | // Purpose : IMPORTANT: Do not use this method to update |
90 | // selection primitives except implementing custom |
91 | // selection manager! This method does not take |
92 | // into account necessary BVH updates, but may |
93 | // invalidate the pointers it refers to. |
94 | // TO UPDATE SELECTION properly from outside classes, |
95 | // use method UpdateSelection. |
7fd59977 |
96 | //================================================== |
f751596e |
97 | void SelectMgr_SelectableObject::RecomputePrimitives (const Standard_Integer theMode) |
7fd59977 |
98 | { |
b5cce1ab |
99 | SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject* > (Parent()); |
100 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
101 | { |
b5cce1ab |
102 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
103 | if (aSel->Mode() == theMode) |
f751596e |
104 | { |
b5cce1ab |
105 | aSel->Clear(); |
106 | ComputeSelection (aSel, theMode); |
107 | aSel->UpdateStatus (SelectMgr_TOU_Partial); |
108 | aSel->UpdateBVHStatus (SelectMgr_TBU_Renew); |
109 | if (theMode == 0 && aSelParent != NULL) |
f751596e |
110 | { |
b5cce1ab |
111 | if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner()) |
112 | { |
113 | SetAssemblyOwner (anAsmOwner, theMode); |
114 | } |
f751596e |
115 | } |
7fd59977 |
116 | return; |
117 | } |
118 | } |
f751596e |
119 | |
120 | Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode); |
121 | ComputeSelection (aNewSel, theMode); |
122 | |
b5cce1ab |
123 | if (theMode == 0 && aSelParent != NULL) |
f751596e |
124 | { |
b5cce1ab |
125 | if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner()) |
126 | { |
127 | SetAssemblyOwner (anAsmOwner, theMode); |
128 | } |
f751596e |
129 | } |
130 | |
131 | aNewSel->UpdateStatus (SelectMgr_TOU_Partial); |
132 | aNewSel->UpdateBVHStatus (SelectMgr_TBU_Add); |
133 | |
134 | myselections.Append (aNewSel); |
7fd59977 |
135 | } |
136 | |
137 | //================================================== |
138 | // Function: ClearSelections |
139 | // Purpose : |
140 | //================================================== |
b5cce1ab |
141 | void SelectMgr_SelectableObject::ClearSelections (const Standard_Boolean theToUpdate) |
7fd59977 |
142 | { |
b5cce1ab |
143 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
144 | { |
145 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
146 | aSel->Clear(); |
147 | aSel->UpdateBVHStatus (SelectMgr_TBU_Remove); |
148 | if (theToUpdate) |
f751596e |
149 | { |
b5cce1ab |
150 | aSel->UpdateStatus (SelectMgr_TOU_Full); |
f751596e |
151 | } |
7fd59977 |
152 | } |
153 | } |
154 | |
155 | |
156 | //================================================== |
157 | // Function: Selection |
158 | // Purpose : |
159 | //================================================== |
160 | |
b5cce1ab |
161 | const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::Selection (const Standard_Integer theMode) const |
7fd59977 |
162 | { |
b5cce1ab |
163 | if (theMode == -1) |
164 | { |
165 | return THE_NULL_SELECTION; |
166 | } |
167 | |
168 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
169 | { |
170 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
171 | if (aSel->Mode() == theMode) |
7fd59977 |
172 | { |
b5cce1ab |
173 | return aSel; |
174 | } |
175 | } |
176 | return THE_NULL_SELECTION; |
7fd59977 |
177 | } |
178 | |
7fd59977 |
179 | //================================================== |
180 | // Function: AddSelection |
181 | // Purpose : |
182 | //================================================== |
183 | |
b5cce1ab |
184 | void SelectMgr_SelectableObject::AddSelection (const Handle(SelectMgr_Selection)& theSel, |
185 | const Standard_Integer theMode) |
7fd59977 |
186 | { |
b5cce1ab |
187 | if(theSel->IsEmpty()) |
f751596e |
188 | { |
b5cce1ab |
189 | ComputeSelection(theSel, theMode); |
190 | theSel->UpdateStatus(SelectMgr_TOU_Partial); |
191 | theSel->UpdateBVHStatus (SelectMgr_TBU_Add); |
7fd59977 |
192 | } |
b5cce1ab |
193 | |
194 | Standard_Boolean isReplaced = Standard_False; |
195 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
196 | { |
b5cce1ab |
197 | if (aSelIter.Value()->Mode() == theMode) |
7fd59977 |
198 | { |
f751596e |
199 | isReplaced = Standard_True; |
b5cce1ab |
200 | myselections.Remove (aSelIter); |
201 | break; |
7fd59977 |
202 | } |
f751596e |
203 | } |
204 | |
b5cce1ab |
205 | myselections.Append (theSel); |
f751596e |
206 | if (isReplaced) |
207 | { |
208 | myselections.Last()->UpdateBVHStatus (SelectMgr_TBU_Renew); |
209 | } |
210 | |
b5cce1ab |
211 | if (theMode == 0) |
f751596e |
212 | { |
b5cce1ab |
213 | SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject* > (Parent()); |
214 | if (aSelParent != NULL) |
69ff08ff |
215 | { |
b5cce1ab |
216 | if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner()) |
217 | { |
218 | SetAssemblyOwner (anAsmOwner, theMode); |
219 | } |
69ff08ff |
220 | } |
f751596e |
221 | } |
7fd59977 |
222 | } |
223 | |
7fd59977 |
224 | //======================================================================= |
0717ddc1 |
225 | //function : ReSetTransformation |
b5cce1ab |
226 | //purpose : |
7fd59977 |
227 | //======================================================================= |
0717ddc1 |
228 | void SelectMgr_SelectableObject::ResetTransformation() |
7fd59977 |
229 | { |
b5cce1ab |
230 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
231 | { |
b5cce1ab |
232 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
233 | aSel->UpdateStatus (SelectMgr_TOU_Partial); |
234 | aSel->UpdateBVHStatus (SelectMgr_TBU_None); |
7fd59977 |
235 | } |
236 | |
0717ddc1 |
237 | PrsMgr_PresentableObject::ResetTransformation(); |
7fd59977 |
238 | } |
239 | |
7fd59977 |
240 | //======================================================================= |
0717ddc1 |
241 | //function : UpdateTransformation |
b5cce1ab |
242 | //purpose : |
7fd59977 |
243 | //======================================================================= |
825aa485 |
244 | void SelectMgr_SelectableObject::UpdateTransformation() |
7fd59977 |
245 | { |
b5cce1ab |
246 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
825aa485 |
247 | { |
b5cce1ab |
248 | aSelIter.Value()->UpdateStatus (SelectMgr_TOU_Partial); |
7fd59977 |
249 | } |
7fd59977 |
250 | |
825aa485 |
251 | PrsMgr_PresentableObject::UpdateTransformation(); |
1b63268e |
252 | if (!mySelectionPrs.IsNull()) |
253 | { |
254 | mySelectionPrs->SetTransformation (TransformationGeom()); |
255 | } |
256 | if (!myHilightPrs.IsNull()) |
257 | { |
258 | myHilightPrs->SetTransformation (TransformationGeom()); |
259 | } |
7fd59977 |
260 | } |
261 | |
7fd59977 |
262 | //======================================================================= |
0717ddc1 |
263 | //function : UpdateTransformation |
b5cce1ab |
264 | //purpose : |
7fd59977 |
265 | //======================================================================= |
b5cce1ab |
266 | void SelectMgr_SelectableObject::UpdateTransformations (const Handle(SelectMgr_Selection)& theSel) |
7fd59977 |
267 | { |
b5cce1ab |
268 | const TopLoc_Location aSelfLocation (Transformation()); |
b5cce1ab |
269 | for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) |
270 | { |
0ef04197 |
271 | if (const Handle(Select3D_SensitiveEntity)& aSensEntity = aSelEntIter.Value()->BaseSensitive()) |
b5cce1ab |
272 | { |
0ef04197 |
273 | if (const Handle(SelectMgr_EntityOwner)& aEOwner = aSensEntity->OwnerId()) |
b5cce1ab |
274 | { |
0ef04197 |
275 | aEOwner->SetLocation (aSelfLocation); |
b5cce1ab |
276 | } |
7fd59977 |
277 | } |
278 | } |
279 | } |
280 | |
281 | //======================================================================= |
282 | //function : HilightSelected |
b5cce1ab |
283 | //purpose : |
7fd59977 |
284 | //======================================================================= |
2b886265 |
285 | void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager)&, |
b5cce1ab |
286 | const SelectMgr_SequenceOfOwner&) |
7fd59977 |
287 | { |
9775fa61 |
288 | throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightSelected"); |
7fd59977 |
289 | } |
290 | |
291 | //======================================================================= |
292 | //function : ClearSelected |
b5cce1ab |
293 | //purpose : |
7fd59977 |
294 | //======================================================================= |
b5cce1ab |
295 | void SelectMgr_SelectableObject::ClearSelected() |
7fd59977 |
296 | { |
b5cce1ab |
297 | if(!mySelectionPrs.IsNull()) |
298 | { |
2b442de5 |
299 | mySelectionPrs->Clear(); |
b5cce1ab |
300 | } |
7fd59977 |
301 | } |
302 | |
731c9b5b |
303 | //======================================================================= |
304 | //function : ClearDynamicHighlight |
305 | //purpose : |
306 | //======================================================================= |
2b886265 |
307 | void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr) |
731c9b5b |
308 | { |
309 | theMgr->ClearImmediateDraw(); |
310 | } |
311 | |
7fd59977 |
312 | //======================================================================= |
313 | //function : HilightOwnerWithColor |
b5cce1ab |
314 | //purpose : |
7fd59977 |
315 | //======================================================================= |
2b886265 |
316 | void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)&, |
f838dac4 |
317 | const Handle(Prs3d_Drawer)&, |
8e5fb5ea |
318 | const Handle(SelectMgr_EntityOwner)&) |
7fd59977 |
319 | { |
9775fa61 |
320 | throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightOwnerWithColor"); |
7fd59977 |
321 | } |
322 | |
7fd59977 |
323 | //======================================================================= |
324 | //function : GetHilightPresentation |
b5cce1ab |
325 | //purpose : |
7fd59977 |
326 | //======================================================================= |
2b886265 |
327 | Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& theMgr) |
7fd59977 |
328 | { |
778cd667 |
329 | if (myHilightPrs.IsNull() && !theMgr.IsNull()) |
330 | { |
331 | myHilightPrs = new Prs3d_Presentation (theMgr->StructureManager()); |
332 | myHilightPrs->SetTransformPersistence (TransformPersistence()); |
e2aba8eb |
333 | myHilightPrs->SetClipPlanes (myClipPlanes); |
1b63268e |
334 | myHilightPrs->SetTransformation (TransformationGeom()); |
778cd667 |
335 | } |
7fd59977 |
336 | |
337 | return myHilightPrs; |
338 | } |
339 | |
7fd59977 |
340 | //======================================================================= |
341 | //function : GetSelectPresentation |
b5cce1ab |
342 | //purpose : |
7fd59977 |
343 | //======================================================================= |
2b886265 |
344 | Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager)& theMgr) |
7fd59977 |
345 | { |
778cd667 |
346 | if (mySelectionPrs.IsNull() && !theMgr.IsNull()) |
347 | { |
348 | mySelectionPrs = new Prs3d_Presentation (theMgr->StructureManager()); |
349 | mySelectionPrs->SetTransformPersistence (TransformPersistence()); |
e2aba8eb |
350 | mySelectionPrs->SetClipPlanes (myClipPlanes); |
1b63268e |
351 | mySelectionPrs->SetTransformation (TransformationGeom()); |
7fd59977 |
352 | } |
778cd667 |
353 | |
7fd59977 |
354 | return mySelectionPrs; |
355 | } |
356 | |
905b0e31 |
357 | //======================================================================= |
358 | //function : ErasePresentations |
359 | //purpose : |
360 | //======================================================================= |
361 | void SelectMgr_SelectableObject::ErasePresentations (Standard_Boolean theToRemove) |
362 | { |
363 | if (!mySelectionPrs.IsNull()) |
364 | { |
365 | mySelectionPrs->Erase(); |
366 | if (theToRemove) |
367 | { |
368 | mySelectionPrs->Clear(); |
369 | mySelectionPrs.Nullify(); |
370 | } |
371 | } |
372 | if (!myHilightPrs.IsNull()) |
373 | { |
374 | myHilightPrs->Erase(); |
375 | if (theToRemove) |
376 | { |
377 | myHilightPrs->Clear(); |
378 | myHilightPrs.Nullify(); |
379 | } |
380 | } |
381 | } |
382 | |
59f45b7c |
383 | //======================================================================= |
384 | //function : SetZLayer |
385 | //purpose : |
386 | //======================================================================= |
a1954302 |
387 | void SelectMgr_SelectableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId) |
59f45b7c |
388 | { |
59f45b7c |
389 | // update own presentations |
a1954302 |
390 | PrsMgr_PresentableObject::SetZLayer (theLayerId); |
59f45b7c |
391 | |
392 | // update selection presentations |
393 | if (!mySelectionPrs.IsNull()) |
394 | mySelectionPrs->SetZLayer (theLayerId); |
395 | |
396 | if (!myHilightPrs.IsNull()) |
397 | myHilightPrs->SetZLayer (theLayerId); |
398 | |
399 | // update all entity owner presentations |
b5cce1ab |
400 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
59f45b7c |
401 | { |
b5cce1ab |
402 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
403 | for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) |
59f45b7c |
404 | { |
0ef04197 |
405 | if (const Handle(Select3D_SensitiveEntity)& aEntity = aSelEntIter.Value()->BaseSensitive()) |
59f45b7c |
406 | { |
0ef04197 |
407 | if (const Handle(SelectMgr_EntityOwner)& aOwner = aEntity->OwnerId()) |
b5cce1ab |
408 | { |
a1954302 |
409 | aOwner->SetZLayer (theLayerId); |
b5cce1ab |
410 | } |
59f45b7c |
411 | } |
412 | } |
413 | } |
414 | } |
6262338c |
415 | |
e2aba8eb |
416 | //======================================================================= |
417 | //function : UpdateClipping |
418 | //purpose : |
419 | //======================================================================= |
420 | void SelectMgr_SelectableObject::UpdateClipping() |
421 | { |
422 | PrsMgr_PresentableObject::UpdateClipping(); |
423 | if (!mySelectionPrs.IsNull()) |
424 | { |
425 | mySelectionPrs->SetClipPlanes (myClipPlanes); |
426 | } |
427 | if (!myHilightPrs.IsNull()) |
428 | { |
429 | myHilightPrs->SetClipPlanes (myClipPlanes); |
430 | } |
431 | } |
432 | |
f751596e |
433 | //======================================================================= |
21a2b7cc |
434 | //function : updateSelection |
f751596e |
435 | //purpose : Sets update status FULL to selections of the object. Must be |
436 | // used as the only method of UpdateSelection from outer classes |
437 | // to prevent BVH structures from being outdated. |
438 | //======================================================================= |
21a2b7cc |
439 | void SelectMgr_SelectableObject::updateSelection (const Standard_Integer theMode) |
f751596e |
440 | { |
441 | if (theMode == -1) |
442 | { |
b5cce1ab |
443 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
444 | { |
b5cce1ab |
445 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
f751596e |
446 | aSel->UpdateStatus (SelectMgr_TOU_Full); |
447 | } |
f751596e |
448 | return; |
449 | } |
450 | |
b5cce1ab |
451 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
452 | { |
b5cce1ab |
453 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
454 | if (aSel->Mode() == theMode) |
f751596e |
455 | { |
b5cce1ab |
456 | aSel->UpdateStatus (SelectMgr_TOU_Full); |
f751596e |
457 | return; |
458 | } |
459 | } |
460 | } |
461 | |
f751596e |
462 | //======================================================================= |
463 | //function : SetAssemblyOwner |
464 | //purpose : Sets common entity owner for assembly sensitive object entities |
465 | //======================================================================= |
466 | void SelectMgr_SelectableObject::SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, |
467 | const Standard_Integer theMode) |
468 | { |
469 | if (theMode == -1) |
470 | { |
b5cce1ab |
471 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
472 | { |
b5cce1ab |
473 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
474 | for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) |
f751596e |
475 | { |
b5cce1ab |
476 | aSelEntIter.Value()->BaseSensitive()->Set (theOwner); |
f751596e |
477 | } |
478 | } |
f751596e |
479 | return; |
480 | } |
481 | |
b5cce1ab |
482 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
f751596e |
483 | { |
b5cce1ab |
484 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
485 | if (aSel->Mode() == theMode) |
f751596e |
486 | { |
b5cce1ab |
487 | for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) |
f751596e |
488 | { |
b5cce1ab |
489 | aSelEntIter.Value()->BaseSensitive()->Set (theOwner); |
f751596e |
490 | } |
491 | return; |
492 | } |
493 | } |
494 | } |
495 | |
b586500b |
496 | //======================================================================= |
497 | //function : BndBoxOfSelected |
02974a19 |
498 | //purpose : |
b586500b |
499 | //======================================================================= |
02974a19 |
500 | Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners) |
b586500b |
501 | { |
b586500b |
502 | if (theOwners->IsEmpty()) |
02974a19 |
503 | return Bnd_Box(); |
b586500b |
504 | |
02974a19 |
505 | Bnd_Box aBnd; |
b5cce1ab |
506 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) |
b586500b |
507 | { |
b5cce1ab |
508 | const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); |
b586500b |
509 | if (aSel->GetSelectionState() != SelectMgr_SOS_Activated) |
510 | continue; |
511 | |
b5cce1ab |
512 | for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) |
b586500b |
513 | { |
0ef04197 |
514 | const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId(); |
b586500b |
515 | if (theOwners->Contains (anOwner)) |
516 | { |
b5cce1ab |
517 | Select3D_BndBox3d aBox = aSelEntIter.Value()->BaseSensitive()->BoundingBox(); |
02974a19 |
518 | aBnd.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(), |
519 | aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z()); |
b586500b |
520 | } |
521 | } |
522 | } |
523 | |
524 | return aBnd; |
525 | } |
c3282ec1 |
526 | |
527 | //======================================================================= |
528 | //function : GlobalSelOwner |
529 | //purpose : Returns entity owner corresponding to selection of the object as a whole |
530 | //======================================================================= |
531 | Handle(SelectMgr_EntityOwner) SelectMgr_SelectableObject::GlobalSelOwner() const |
532 | { |
c3282ec1 |
533 | const Handle(SelectMgr_Selection)& aGlobalSel = Selection (myGlobalSelMode); |
b5cce1ab |
534 | if (!aGlobalSel.IsNull() |
535 | && !aGlobalSel->IsEmpty()) |
536 | { |
0ef04197 |
537 | return aGlobalSel->Entities().First()->BaseSensitive()->OwnerId(); |
b5cce1ab |
538 | } |
539 | return THE_NULL_ENTITYOWNER; |
540 | } |
c3282ec1 |
541 | |
b5cce1ab |
542 | //======================================================================= |
543 | //function : GetAssemblyOwner |
544 | //purpose : |
545 | //======================================================================= |
546 | const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwner() const |
547 | { |
548 | return THE_NULL_ENTITYOWNER; |
c3282ec1 |
549 | } |
0904aa63 |
550 | |
551 | // ======================================================================= |
552 | // function : DumpJson |
553 | // purpose : |
554 | // ======================================================================= |
bc73b006 |
555 | void SelectMgr_SelectableObject::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
0904aa63 |
556 | { |
bc73b006 |
557 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
0904aa63 |
558 | |
bc73b006 |
559 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, PrsMgr_PresentableObject) |
560 | |
561 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySelectionPrs.get()) |
562 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHilightPrs.get()) |
563 | |
564 | for (SelectMgr_SequenceOfSelection::Iterator anIterator (myselections); anIterator.More(); anIterator.Next()) |
565 | { |
566 | const Handle(SelectMgr_Selection)& aSelection = anIterator.Value(); |
567 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aSelection.get()) |
568 | } |
569 | |
570 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGlobalSelMode) |
571 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight) |
0904aa63 |
572 | } |