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