b311480e |
1 | // Created on: 1997-01-17 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | //Modified by ROB : Traque des UpdateConversion intempestifs. |
22 | |
23 | #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods. |
24 | |
25 | #define BUC60722 //GG_040900 Disable detection on an unviewable object |
26 | |
27 | #define IMP160701 //SZV Add InitDetected(),MoreDetected(),NextDetected(), |
28 | // DetectedCurrentShape(),DetectedCurrentObject() |
29 | // methods |
30 | |
31 | #define ALE70590 //GG Avoid raise especially under W2000-SP2 |
32 | // when opening many local context due to a |
33 | // system error in the selection name computation routine. |
34 | // Many thanks to Philippe CARRET for the helpfull he has |
35 | // give to accelerate the resolution of this problem. |
36 | |
37 | #include <AIS_LocalContext.ixx> |
38 | #include <SelectMgr_OrFilter.hxx> |
39 | #include <SelectMgr_CompositionFilter.hxx> |
40 | #include <AIS_LocalStatus.hxx> |
41 | #include <AIS_Shape.hxx> |
42 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
43 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
44 | #include <AIS_ListOfInteractive.hxx> |
45 | #include <AIS_DataMapIteratorOfDataMapOfSelStat.hxx> |
46 | #include <TopAbs_ShapeEnum.hxx> |
47 | #include <Graphic3d_Structure.hxx> |
48 | #include <Prs3d_LineAspect.hxx> |
49 | #include <Prs3d_PlaneAspect.hxx> |
50 | #include <Prs3d_PointAspect.hxx> |
51 | #include <Prs3d_Presentation.hxx> |
52 | #include <Aspect_TypeOfMarker.hxx> |
53 | #include <StdSelect_ShapeTypeFilter.hxx> |
54 | #include <AIS_Selection.hxx> |
55 | #include <V3d_Viewer.hxx> |
56 | #include <V3d_View.hxx> |
57 | #include <Visual3d_TransientManager.hxx> |
58 | #include <Visual3d_View.hxx> |
59 | |
60 | #ifdef ALE70590 |
61 | #include <stdio.h> |
62 | #else |
63 | #include <Standard_SStream.hxx> |
64 | #endif |
65 | |
66 | static TCollection_AsciiString AIS_Local_SelName(const Standard_Address address, |
67 | const Standard_Integer anIndex) |
68 | { |
69 | // TCollection_AsciiString SelName; |
70 | #ifdef ALE70590 |
71 | char string[100]; |
72 | sprintf(string,"%p_%d", address, anIndex); // works under any system |
73 | TCollection_AsciiString SelName(string); |
74 | #else |
75 | Standard_SStream stream; |
76 | stream<<address; // something is wrong here using the SStream because |
77 | // the following access to rdbuf crash for an unknown reason |
78 | // especially under W2000 with SP2 and sometime under WNT and W98. |
79 | // NOTE that stream is not ended by a NULL char and it's probably |
80 | // one of the reasons why this crash. |
81 | // In any case the resulting ascii string give a wrong and random |
82 | // name under WINDOWS ! |
83 | TCollection_AsciiString SelName(stream.rdbuf()->str()); |
84 | // SelName = TCollection_AsciiString("AIS_Local_"); |
85 | TCollection_AsciiString theind(anIndex); |
86 | SelName += "_"; |
87 | SelName += theind; |
88 | #endif |
89 | return SelName; |
90 | } |
91 | |
92 | |
93 | //======================================================================= |
94 | //function : AIS_LocalContext |
95 | //purpose : |
96 | //======================================================================= |
97 | |
98 | |
99 | AIS_LocalContext::AIS_LocalContext(){} |
100 | |
101 | AIS_LocalContext::AIS_LocalContext(const Handle(AIS_InteractiveContext)& aCtx, |
102 | const Standard_Integer Index, |
103 | const Standard_Boolean LoadDisplayed, |
104 | const Standard_Boolean AcceptStandardModes, |
105 | const Standard_Boolean AcceptEraseOfTemp, |
106 | const Standard_Boolean BothViewers): |
107 | myCTX(aCtx), |
108 | myLoadDisplayed(LoadDisplayed), |
109 | myAcceptStdMode(AcceptStandardModes), |
110 | myAcceptErase(AcceptEraseOfTemp), |
111 | mySM(aCtx->SelectionManager()), |
112 | myMainVS(new StdSelect_ViewerSelector3d(aCtx->MainSelector()->Projector())), |
113 | myFilters(new SelectMgr_OrFilter()), |
114 | myAutoHilight(Standard_True), |
115 | mylastindex(0), |
116 | mylastgood(0), |
117 | myCurDetected(0) |
118 | #ifdef IMP160701 |
119 | ,myAISCurDetected(0) |
120 | #endif |
121 | { |
122 | myMainPM = aCtx->MainPrsMgr(); |
123 | mySelName = AIS_Local_SelName(this, Index); |
124 | AIS_Selection::CreateSelection(mySelName.ToCString()); |
125 | |
126 | mySM->Add(myMainVS); |
127 | if(myLoadDisplayed) LoadContextObjects(); |
128 | Process(Standard_False); |
129 | |
130 | } |
131 | |
132 | |
133 | //======================================================================= |
134 | //function : SetContext |
135 | //purpose : |
136 | //======================================================================= |
137 | |
138 | void AIS_LocalContext::SetContext(const Handle(AIS_InteractiveContext)& aCtx) |
139 | { myCTX = aCtx;} |
140 | |
141 | //======================================================================= |
142 | //function : Display |
143 | //purpose : |
144 | //======================================================================= |
145 | |
146 | Standard_Boolean AIS_LocalContext::Display(const Handle(AIS_InteractiveObject)& anInteractive, |
147 | const Standard_Integer WhichMode, |
148 | const Standard_Boolean AllowShapeDecomposition, |
149 | const Standard_Integer ActivationMode) |
150 | { |
151 | if(myActiveObjects.IsBound(anInteractive)){ |
152 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
153 | |
154 | if(STAT->DisplayMode() == -1){ |
155 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
156 | myMainPM->Display(anInteractive,WhichMode); |
157 | if(STAT->IsTemporary()) |
158 | STAT->SetDisplayMode(WhichMode); |
159 | } |
160 | else if(STAT->DisplayMode()!=WhichMode && STAT->IsTemporary()){ |
161 | myMainPM->Erase(anInteractive,STAT->DisplayMode()); |
162 | STAT->SetDisplayMode(WhichMode); |
163 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
164 | myMainPM->Display(anInteractive,WhichMode); |
165 | } |
166 | |
167 | if(ActivationMode!=-1){ |
168 | if(!STAT->IsActivated(ActivationMode)){ |
169 | STAT->ClearSelectionModes(); |
170 | mySM->Load(anInteractive,myMainVS); |
171 | STAT->AddSelectionMode(ActivationMode); |
172 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
173 | } |
174 | } |
175 | } |
176 | else { |
177 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
178 | |
179 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
180 | Att->SetDecomposition(Standard_True); |
181 | else |
182 | Att->SetDecomposition(Standard_False); |
81bba717 |
183 | // status temporary or not |
7fd59977 |
184 | if(myCTX->DisplayStatus(anInteractive) == AIS_DS_None || |
185 | myCTX->DisplayStatus(anInteractive) == AIS_DS_Temporary) |
186 | Att->SetTemporary(Standard_True); |
187 | else |
188 | Att->SetTemporary(Standard_False); |
189 | |
190 | |
191 | |
192 | if(!myCTX->IsDisplayed(anInteractive,WhichMode)){ |
193 | |
194 | //storing information.... |
195 | Att->SetDisplayMode(WhichMode); |
196 | if (ActivationMode!=-1) |
197 | Att->AddSelectionMode(ActivationMode); |
198 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
199 | Att->SetHilightMode(HiMod); |
200 | |
201 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
202 | myMainPM->Display(anInteractive,WhichMode); |
203 | |
204 | if(ActivationMode!=-1){ |
205 | mySM->Load(anInteractive,myMainVS); |
206 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
207 | } |
208 | } |
209 | else{ |
210 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
211 | Att->SetHilightMode(HiMod); |
212 | } |
213 | myActiveObjects.Bind(anInteractive,Att); |
214 | } |
215 | Process(anInteractive); |
216 | |
217 | |
218 | |
219 | |
220 | return Standard_True; |
221 | } |
222 | |
223 | //======================================================================= |
224 | //function : Load |
225 | //purpose : |
226 | //======================================================================= |
227 | |
228 | Standard_Boolean AIS_LocalContext:: |
229 | Load(const Handle(AIS_InteractiveObject)& anInteractive, |
230 | const Standard_Boolean AllowShapeDecomposition, |
231 | const Standard_Integer ActivationMode) |
232 | { |
233 | if(myActiveObjects.IsBound(anInteractive)) return Standard_False; |
234 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
235 | |
236 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
237 | Att->SetDecomposition(Standard_True); |
238 | else |
239 | Att->SetDecomposition(Standard_False); |
240 | |
241 | if(!myCTX->IsDisplayed(anInteractive)) |
242 | Att->SetTemporary(Standard_True); |
243 | else |
244 | Att->SetTemporary(Standard_False); |
245 | Att->SetDisplayMode(-1); |
246 | |
247 | //storing information.... |
248 | if(ActivationMode!=-1) |
249 | Att->AddSelectionMode(ActivationMode); |
250 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode():0; |
251 | Att->SetHilightMode(HiMod); |
252 | //Action |
253 | |
254 | mySM->Load(anInteractive,myMainVS); |
255 | if(ActivationMode != -1){ |
256 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
257 | } |
258 | myActiveObjects.Bind(anInteractive,Att); |
259 | Process(anInteractive); |
260 | return Standard_True; |
261 | } |
262 | |
263 | //======================================================================= |
264 | //function : ClearPrs |
265 | //purpose : |
266 | //======================================================================= |
267 | |
268 | Standard_Boolean AIS_LocalContext:: |
269 | ClearPrs(const Handle(AIS_InteractiveObject)& anInteractive, |
270 | const Standard_Integer aMode) |
271 | { |
272 | if(!myActiveObjects.IsBound(anInteractive)) |
273 | return Standard_False; |
274 | |
275 | Standard_Boolean jobdone(Standard_False); |
276 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
277 | |
278 | //Display step |
279 | if(STAT->IsSubIntensityOn()) { |
280 | STAT->SubIntensityOff(); |
281 | if(STAT->HilightMode()==aMode) |
282 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
283 | } |
284 | myMainPM->Clear(anInteractive,aMode); // correction connexions 23/09/97 |
285 | jobdone = Standard_True; |
286 | if(STAT->DisplayMode()==aMode) |
287 | STAT->SetDisplayMode(-1); |
288 | return jobdone; |
289 | } |
290 | //======================================================================= |
291 | //function : Erase |
292 | //purpose : |
293 | //======================================================================= |
294 | |
295 | Standard_Boolean AIS_LocalContext:: |
296 | Erase(const Handle(AIS_InteractiveObject)& anInteractive) |
297 | { |
298 | if(!myActiveObjects.IsBound(anInteractive)) |
299 | return Standard_False; |
300 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
301 | |
302 | //Display step |
303 | if(STAT->IsSubIntensityOn()) { |
304 | STAT->SubIntensityOff(); |
305 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
306 | } |
307 | |
308 | Standard_Boolean status(Standard_False); |
309 | |
310 | if(STAT->DisplayMode()!=-1) { |
311 | if(IsSelected(anInteractive)) |
312 | AddOrRemoveSelected(anInteractive); |
313 | if(myMainPM->IsHighlighted(anInteractive,STAT->HilightMode())) |
314 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
315 | myMainPM->Erase(anInteractive,STAT->DisplayMode()); |
316 | STAT->SetDisplayMode(-1); |
317 | status = Standard_True; |
318 | } |
319 | if(STAT->IsTemporary()){ |
320 | if(myMainPM->IsDisplayed(anInteractive,STAT->HilightMode())) |
321 | myMainPM->Erase(anInteractive,STAT->HilightMode()); |
322 | } |
323 | //selection step |
324 | |
325 | TColStd_ListIteratorOfListOfInteger It(STAT->SelectionModes()); |
326 | for(;It.More();It.Next()) |
327 | mySM->Deactivate(anInteractive,It.Value(),myMainVS); |
328 | // STAT->ClearSelectionModes(); |
329 | return status; |
330 | } |
331 | |
332 | |
333 | //======================================================================= |
334 | //function : SetShapeDecomposition |
335 | //purpose : |
336 | //======================================================================= |
337 | |
338 | void AIS_LocalContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& aStoredObject, |
339 | const Standard_Boolean aStatus) |
340 | { |
341 | if(!myActiveObjects.IsBound(aStoredObject)) return; |
342 | |
343 | if(aStatus == myActiveObjects(aStoredObject)->Decomposed()) |
344 | return; |
345 | |
346 | myActiveObjects(aStoredObject)->SetDecomposition(aStatus); |
347 | |
348 | Process(aStoredObject); |
349 | } |
350 | |
351 | //======================================================================= |
352 | //function : Clear |
353 | //purpose : |
354 | //======================================================================= |
355 | |
356 | void AIS_LocalContext::Clear(const AIS_ClearMode aType) |
357 | { |
358 | switch (aType){ |
359 | case AIS_CM_All: |
360 | { |
361 | ClearObjects(); |
362 | myFilters->Clear(); |
363 | while(!myListOfStandardMode.IsEmpty()) |
364 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
365 | break; |
366 | } |
367 | case AIS_CM_Interactive: |
368 | ClearObjects(); |
369 | break; |
370 | case AIS_CM_Filters: |
371 | myFilters->Clear(); |
372 | break; |
373 | case AIS_CM_StandardModes: |
374 | { |
375 | while(!myListOfStandardMode.IsEmpty()) |
376 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
377 | break; |
378 | } |
379 | case AIS_CM_TemporaryShapePrs: |
380 | ClearDetected(); |
381 | } |
382 | UpdateSort(); |
383 | } |
384 | //======================================================================= |
385 | //function : ActivateMode |
386 | //purpose : |
387 | //======================================================================= |
388 | |
389 | void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
390 | const Standard_Integer aMode) |
391 | { |
392 | if(!myActiveObjects.IsBound(aSelectable)) return; |
393 | // if(myActiveObjects(aSelectable)->SelectionMode()!=aMode) |
394 | // mySM->Deactivate(aSelectable,aMode,myMainVS); |
395 | if(aMode != -1){ |
396 | myActiveObjects(aSelectable)->AddSelectionMode(aMode); |
397 | mySM->Activate(aSelectable,aMode,myMainVS); |
398 | } |
399 | UpdateSort(); |
400 | } |
401 | //======================================================================= |
402 | //function : ActivateMode |
403 | //purpose : |
404 | //======================================================================= |
405 | |
406 | void AIS_LocalContext::DeactivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
407 | const Standard_Integer aMode) |
408 | { |
409 | if(!myActiveObjects.IsBound(aSelectable)) return; |
410 | |
411 | if(aMode==-1) return; |
412 | |
413 | myActiveObjects(aSelectable)->RemoveSelectionMode(aMode); |
414 | mySM->Deactivate(aSelectable,aMode,myMainVS); |
415 | UpdateSort(); |
416 | |
417 | } |
418 | //======================================================================= |
419 | //function : ActivateMode |
420 | //purpose : |
421 | //======================================================================= |
422 | |
423 | void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectable) |
424 | { |
425 | if(!myActiveObjects.IsBound(aSelectable)) return; |
426 | |
427 | mySM->Deactivate(aSelectable,myMainVS); |
428 | myActiveObjects(aSelectable)->ClearSelectionModes(); |
429 | UpdateSort(); |
430 | } |
431 | |
432 | //======================================================================= |
433 | //function : Remove |
434 | //purpose : |
435 | //======================================================================= |
436 | |
437 | Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& aSelectable) |
438 | { |
439 | if(!myActiveObjects.IsBound(aSelectable)) return Standard_False; |
440 | |
441 | if(IsSelected(aSelectable)) |
442 | AddOrRemoveSelected(aSelectable,Standard_False); |
443 | |
444 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(aSelectable); |
445 | |
446 | TColStd_ListIteratorOfListOfInteger It; |
447 | Standard_Boolean jobdone(Standard_False); |
81bba717 |
448 | // it is checked which were the temporary attributes |
449 | // and they are set to 0 |
7fd59977 |
450 | |
81bba717 |
451 | // desactivate standard modes |
7fd59977 |
452 | if(Att->Decomposed()){ |
453 | for(It.Initialize(myListOfStandardMode);It.More();It.Next()){ |
454 | mySM->Deactivate(aSelectable,It.Value(),myMainVS); |
455 | } |
456 | } |
457 | |
81bba717 |
458 | // if object or temporary presentations... |
7fd59977 |
459 | if(Att->IsTemporary()) |
460 | { |
461 | if(Att->IsSubIntensityOn()) |
462 | myMainPM->Unhighlight(aSelectable,Att->HilightMode()); |
463 | |
81bba717 |
464 | // remove if bug on clear correct... |
7fd59977 |
465 | myMainPM->Erase(aSelectable,Att->DisplayMode()); |
466 | myMainPM->Clear(aSelectable,Att->DisplayMode()); |
467 | if(myMainPM->IsDisplayed(aSelectable,Att->HilightMode())) |
468 | myMainPM->Erase(aSelectable,Att->HilightMode()); |
469 | // myMainPM->Clear(aSelectable,Att->HilightMode()); |
470 | jobdone = Standard_True; |
471 | } |
81bba717 |
472 | // if below intensity |
7fd59977 |
473 | else |
474 | { |
475 | if(Att->IsSubIntensityOn()) |
476 | myCTX->SubIntensityOff(aSelectable); |
477 | } |
81bba717 |
478 | // desactivate stored proper modes |
7fd59977 |
479 | for(It.Initialize(Att->SelectionModes());It.More();It.Next()){ |
480 | mySM->Deactivate(aSelectable,It.Value(),myMainVS); |
481 | } |
ab943560 |
482 | // pop : si je laisses cela plantes dans les elements de construction |
483 | // alors a toi de jouer ROB |
7fd59977 |
484 | // RemoveSelected(aSelectable); |
485 | |
486 | if(IsSelected(aSelectable)) |
487 | AddOrRemoveSelected(aSelectable); |
488 | myActiveObjects.UnBind(aSelectable); |
489 | |
490 | //Last detected object keeps for lastindex initialization. |
491 | Handle(SelectMgr_EntityOwner) aLastPicked = myMainVS->OnePicked(); |
492 | |
493 | UpdateSort(); |
494 | |
495 | //Object removes from SelectMgr |
496 | if( mySM->Contains(aSelectable) ) |
497 | mySM->Remove(aSelectable); |
498 | |
499 | //Object removes from Detected sequence |
500 | AIS_SequenceOfInteractive detectAIS; |
501 | |
502 | Standard_Integer i = 1; |
503 | for(i = 1 ; i < myAISDetectedSeq.Length(); i++) |
504 | { |
505 | Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); |
506 | if( !anObj.IsNull() && anObj != aSelectable ) |
507 | myAISDetectedSeq.Remove( i ); |
508 | } |
509 | |
510 | Standard_Integer aHM = aSelectable->HasHilightMode() ? aSelectable->HilightMode() : 0; |
511 | |
512 | //EntityOwners remove from AIS_Selection |
513 | Handle(AIS_Selection) aSel = AIS_Selection::Selection(mySelName.ToCString()); |
514 | AIS_NListTransient::Iterator anIter(aSel->Objects()); |
515 | AIS_NListTransient removeEntites; |
516 | for(; anIter.More(); anIter.Next()){ |
517 | const Handle(Standard_Transient)& Tr = anIter.Value(); |
518 | if (!Tr.IsNull()){ |
519 | const Handle(SelectMgr_EntityOwner)& anOwnr = *((const Handle(SelectMgr_EntityOwner)*) &Tr); |
520 | if(anOwnr->Selectable() == aSelectable){ |
521 | removeEntites.Append(Tr); |
522 | if(IsSelected(anOwnr)) |
523 | anOwnr->Unhilight(myMainPM, aHM);//Unhilight selected |
524 | } |
525 | } |
526 | } |
527 | AIS_NListTransient::Iterator anIterRemove(removeEntites); |
528 | for(; anIterRemove.More(); anIterRemove.Next()) |
529 | aSel->Select(anIterRemove.Value());//EntityOwner removes from the selection data |
530 | |
531 | //EntityOwners remove from myMapOfOwner |
532 | SelectMgr_IndexedMapOfOwner ownersToKeep; |
533 | const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); |
534 | for(i = 1; i <= myMapOfOwner.Extent(); i++){ |
535 | const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner(i) ; |
536 | if(!anOwner.IsNull()) |
537 | if(anOwner->Selectable() != aSelectable) |
538 | ownersToKeep.Add(anOwner); |
539 | else |
540 | { |
541 | if(anOwner->IsHilighted(myMainPM, aHM)) |
542 | { |
543 | for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) |
544 | Unhilight(anOwner, aViewer->ActiveView()); |
545 | } |
546 | } |
547 | } |
548 | myMapOfOwner.Clear(); |
549 | myMapOfOwner.Assign(ownersToKeep); |
550 | mylastindex = myMapOfOwner.FindIndex(aLastPicked); |
551 | |
552 | return Standard_True; |
553 | } |
554 | |
555 | //======================================================================= |
556 | //function : ActivateStandardMode |
557 | //purpose : |
558 | //======================================================================= |
559 | |
560 | void AIS_LocalContext::ActivateStandardMode(const TopAbs_ShapeEnum aType) |
561 | { |
562 | |
81bba717 |
563 | //check if it is not in the list |
7fd59977 |
564 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
565 | for(;It.More();It.Next()) |
566 | if(It.Value()==aType) return; |
567 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
568 | |
569 | |
81bba717 |
570 | // create a hidden filter answering ok to the type except for : |
571 | // if the type is shape... |
572 | // if the filters already impact at the type <aType> |
7fd59977 |
573 | if(aType != TopAbs_SHAPE){ |
574 | if(myStdFilters[IMode].IsNull()) |
575 | myStdFilters[IMode] = new StdSelect_ShapeTypeFilter(aType); |
576 | if(!HasFilters(aType)) |
577 | myFilters->Add(myStdFilters[IMode]); |
578 | } |
579 | |
81bba717 |
580 | // the mode is activated for all objects of type Shape |
581 | // accepting the decomposition in standard mode. |
7fd59977 |
582 | myListOfStandardMode.Append(IMode); |
583 | |
584 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
585 | |
586 | for(;ItM.More();ItM.Next()){ |
587 | #ifdef BUC60722 |
588 | AIS_DisplayStatus DS = |
589 | myCTX->DisplayStatus(Handle(AIS_InteractiveObject)::DownCast(ItM.Key())); |
590 | if( ItM.Value()->Decomposed() && (DS != AIS_DS_FullErased) ) |
591 | #else |
592 | if(ItM.Value()->Decomposed()) |
593 | #endif |
594 | myCTX->SelectionManager()->Activate(ItM.Key(), |
595 | IMode, |
596 | myMainVS); |
597 | } |
598 | |
599 | } |
600 | |
601 | //======================================================================= |
602 | //function : DeActivateStandardMode |
603 | //purpose : |
604 | //======================================================================= |
605 | |
606 | void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType) |
607 | { |
608 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
609 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
610 | for(;It.More();It.Next()) |
611 | if(It.Value()==IMode) { |
612 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
613 | |
614 | for(;ItM.More();ItM.Next()){ |
615 | if(ItM.Value()->Decomposed()){ |
616 | myCTX->SelectionManager()->Deactivate(ItM.Key(), |
617 | IMode, |
618 | myMainVS); |
619 | ItM.Value()->RemoveSelectionMode(IMode); |
620 | } |
621 | } |
622 | myListOfStandardMode.Remove(It); |
623 | if(myFilters->IsIn(myStdFilters[IMode])) |
624 | myFilters->Remove(myStdFilters[IMode]); |
625 | UpdateSort(); |
626 | return; |
627 | } |
628 | UpdateSort(); |
629 | } |
630 | |
631 | //======================================================================= |
632 | //function : AddFilter |
633 | //purpose : |
634 | //======================================================================= |
635 | |
636 | void AIS_LocalContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
637 | { |
81bba717 |
638 | // it is checked if the filter impacts at the type of active sub-shape |
639 | // for which a filter of type has been already implemented... |
7fd59977 |
640 | |
641 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
642 | |
643 | for(;It.More();It.Next()){ |
644 | if(aFilter->ActsOn(AIS_Shape::SelectionType(It.Value()))) |
645 | if(myFilters->IsIn(myStdFilters[It.Value()])) |
646 | myFilters->Remove(myStdFilters[It.Value()]); |
647 | } |
648 | myFilters->Add(aFilter); |
649 | } |
650 | |
651 | //======================================================================= |
652 | //function : RemoveFilter |
653 | //purpose : |
654 | //======================================================================= |
655 | |
656 | void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
657 | { |
658 | if(myFilters->IsIn(aFilter)) myFilters->Remove(aFilter); |
659 | |
81bba717 |
660 | // it is checked if the filter for type standard is active. |
661 | // if yes, it is checked there are still similarities among the |
662 | // remaining filters... |
663 | // otherwise, the standard filter is restored to |
664 | // continu selecting active modes... |
7fd59977 |
665 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
666 | TopAbs_ShapeEnum SE; |
667 | for(;It.More();It.Next()){ |
668 | SE = AIS_Shape::SelectionType(It.Value()); |
669 | if(aFilter->ActsOn(SE)) |
670 | if(!HasFilters(SE)) |
671 | myFilters->Add(myStdFilters[It.Value()]); |
672 | } |
673 | } |
674 | |
675 | |
676 | |
ab943560 |
677 | Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projector)& thePrj) const |
7fd59977 |
678 | { |
ab943560 |
679 | const Handle(Select3D_Projector)& aCurPrj = myMainVS->Projector(); |
680 | if (aCurPrj->Perspective() != thePrj->Perspective()) |
681 | return Standard_False; |
682 | if (aCurPrj->Perspective() && aCurPrj->Focus() != thePrj->Focus()) |
683 | return Standard_False; |
684 | const gp_GTrsf& aCurTrsf = aCurPrj->Transformation(); |
685 | const gp_GTrsf& aPrjTrsf = thePrj->Transformation(); |
686 | |
687 | for (Standard_Integer i = 1; i <= 3; ++i) |
688 | { |
689 | for (Standard_Integer j = 1; j <= 3 ; ++j) |
690 | { |
691 | if (aCurTrsf.Value (i, j) != aPrjTrsf.Value (i, j)) |
692 | return Standard_False; |
7fd59977 |
693 | } |
694 | } |
ab943560 |
695 | |
7fd59977 |
696 | return Standard_True; |
697 | } |
698 | |
699 | |
700 | //======================================================================= |
701 | //function : Terminate |
702 | //purpose : |
703 | //======================================================================= |
704 | |
705 | void AIS_LocalContext::Terminate( const Standard_Boolean updateviewer ) |
706 | { |
707 | ClearDetected(); |
708 | Clear(); |
709 | myMapOfOwner.Clear(); |
710 | |
711 | mylastindex=0; |
81bba717 |
712 | // clear the selector... |
7fd59977 |
713 | myMainVS->Clear(); |
714 | myCTX->SelectionManager()->Remove(myMainVS); |
715 | |
716 | |
717 | AIS_Selection::SetCurrentSelection(mySelName.ToCString()); |
718 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
719 | Handle(Standard_Transient) Tr; |
720 | for(S->Init();S->More();S->Next()){ |
721 | Tr = S->Value(); |
722 | (*((Handle(SelectMgr_EntityOwner)*)&Tr))->State(0); |
723 | } |
724 | |
725 | |
726 | AIS_Selection::Select(); |
727 | AIS_Selection::Remove(mySelName.ToCString()); |
728 | |
729 | // CLE |
730 | // const Handle(V3d_Viewer)& Vwr = myCTX->CurrentViewer(); |
731 | Handle(V3d_Viewer) Vwr = myCTX->CurrentViewer(); |
732 | // ENDCLE |
733 | Handle(V3d_View) curV; |
734 | for(Vwr->InitActiveViews();Vwr->MoreActiveViews();Vwr->NextActiveViews()){ |
735 | curV = Vwr->ActiveView(); |
736 | Visual3d_TransientManager::ClearDraw( curV->View(), updateviewer ); |
737 | } |
738 | |
739 | |
740 | #ifdef DEB |
741 | Handle(V3d_View) BidV; |
742 | myMainVS->ClearAreas(BidV); |
743 | myMainVS->ClearSensitive(BidV); |
744 | |
745 | #endif |
746 | } |
747 | |
748 | |
749 | //======================================================================= |
750 | //function : SubIntensity |
751 | //purpose : |
752 | //======================================================================= |
753 | |
754 | void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) |
755 | { |
756 | if(!myActiveObjects.IsBound(anObject)) return; |
757 | |
758 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
759 | |
760 | if(Att->IsTemporary()) |
761 | myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); |
762 | |
763 | Att->SubIntensityOn(); |
764 | } |
765 | //======================================================================= |
766 | //function : SubIntensity |
767 | //purpose : |
768 | //======================================================================= |
769 | |
770 | void AIS_LocalContext::SubIntensityOff(const Handle(AIS_InteractiveObject)& anObject) |
771 | { |
772 | if(!myActiveObjects.IsBound(anObject)) return; |
773 | |
774 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
775 | |
776 | if(Att->IsTemporary()) |
777 | myMainPM->Unhighlight(anObject); |
778 | Att->SubIntensityOff(); |
779 | } |
780 | |
781 | |
782 | //======================================================================= |
783 | //function : Hilight |
784 | //purpose : |
785 | //======================================================================= |
786 | |
787 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) |
788 | { |
789 | if(!myActiveObjects.IsBound(anObject)){ |
790 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
791 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
792 | Standard_False, |
793 | -1,-1,HiMod); |
794 | myActiveObjects.Bind(anObject,Att); |
795 | |
796 | } |
797 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
798 | myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); |
799 | Att->SubIntensityOn(); |
800 | } |
801 | //======================================================================= |
802 | //function : Hilight |
803 | //purpose : |
804 | //======================================================================= |
805 | |
806 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, |
807 | const Quantity_NameOfColor Col) |
808 | { |
809 | if(!myActiveObjects.IsBound(anObject)){ |
810 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
811 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
812 | Standard_False, |
813 | -1,-1,HiMod); |
814 | myActiveObjects.Bind(anObject,Att); |
815 | |
816 | } |
817 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
818 | myMainPM->Color(anObject,Col,Att->HilightMode()); |
819 | Att->SubIntensityOn(); |
820 | Att->SetHilightColor(Col); |
821 | } |
822 | |
823 | //======================================================================= |
824 | //function : Unhilight |
825 | //purpose : |
826 | //======================================================================= |
827 | |
828 | void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) |
829 | { |
830 | if(!myActiveObjects.IsBound(anObject)) return; |
831 | |
81bba717 |
832 | // chieck if by hazard the object is somewhere else... |
7fd59977 |
833 | Standard_Integer Indx; |
834 | Standard_Boolean IsSomeWhereElse = |
835 | myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); |
836 | |
837 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
838 | myMainPM->Unhighlight(anObject,Att->HilightMode()); |
839 | if(Att->IsTemporary() && Att->DisplayMode()==-1) |
840 | if(!IsSomeWhereElse) |
841 | myMainPM->Erase(anObject,Att->HilightMode()); |
842 | |
843 | Att->SubIntensityOff(); |
844 | Att->SetHilightColor(Quantity_NOC_WHITE); |
845 | } |
846 | |
847 | |
848 | //======================================================================= |
849 | //function : IsIn |
850 | //purpose : |
851 | //======================================================================= |
852 | |
853 | Standard_Boolean AIS_LocalContext:: |
854 | IsIn(const Handle(AIS_InteractiveObject)& anObject) const |
855 | { |
856 | return myActiveObjects.IsBound(anObject); |
857 | } |
858 | |
859 | //======================================================================= |
860 | //function : IsHilighted |
861 | //purpose : |
862 | //======================================================================= |
863 | |
864 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject) const |
865 | { |
866 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
867 | return myActiveObjects(anObject)->IsSubIntensityOn(); |
868 | } |
869 | |
870 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, |
871 | Standard_Boolean& WithColor, |
872 | Quantity_NameOfColor& HiCol) const |
873 | { |
874 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
875 | if( myActiveObjects(anObject)->IsSubIntensityOn()){ |
876 | HiCol = myActiveObjects(anObject)->HilightColor(); |
877 | if(HiCol==Quantity_NOC_WHITE) |
878 | WithColor = Standard_True; |
879 | else |
880 | WithColor = Standard_False; |
881 | return Standard_True; |
882 | } |
883 | return Standard_False; |
884 | } |
885 | |
886 | |
887 | void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anObject, |
888 | const Standard_Integer Prior) |
889 | { |
890 | if(!myActiveObjects.IsBound(anObject)) return; |
891 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anObject); |
892 | if(STAT->DisplayMode()==-1) return; |
893 | myMainPM->SetDisplayPriority(anObject,STAT->DisplayMode(),Prior); |
894 | if(STAT->IsSubIntensityOn()) |
895 | myMainPM->SetDisplayPriority(anObject,STAT->HilightMode(),Prior); |
896 | |
897 | |
898 | } |
899 | |
7fd59977 |
900 | //======================================================================= |
901 | //function : DisplayedObjects |
902 | //purpose : |
903 | //======================================================================= |
904 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
905 | { |
906 | Standard_Integer NbDisp(0); |
907 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
908 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
909 | if(!theMap.Contains(SO)) |
910 | if(it.Value()->DisplayMode()!=-1){ |
911 | theMap.Add(SO); |
912 | NbDisp++; |
913 | } |
914 | } |
915 | return NbDisp; |
916 | } |
917 | |
918 | |
919 | //======================================================================= |
920 | //function : IsDisplayed |
921 | //purpose : |
922 | //======================================================================= |
923 | |
924 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
925 | { |
926 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
927 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
928 | } |
929 | |
930 | //======================================================================= |
931 | //function : IsDisplayed |
932 | //purpose : |
933 | //======================================================================= |
934 | |
935 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
936 | const Standard_Integer aMode) const |
937 | { |
938 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
939 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
940 | } |
941 | |
942 | //======================================================================= |
943 | //function : SelectionModes |
944 | //purpose : |
945 | //======================================================================= |
946 | |
947 | const TColStd_ListOfInteger& AIS_LocalContext:: |
948 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
949 | { |
950 | return myActiveObjects(anObject)->SelectionModes(); |
951 | } |
952 | |
953 | //======================================================================= |
954 | //function : Status |
955 | //purpose : |
956 | //======================================================================= |
957 | |
958 | TCollection_AsciiString AIS_LocalContext::Status() const |
959 | { |
960 | TCollection_AsciiString t; |
961 | return t; |
962 | } |
963 | |
964 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
965 | { |
966 | return myActiveObjects(anObject); |
967 | } |
968 | |
969 | //======================================================================= |
970 | //function : LoadContextObjects |
971 | //purpose : |
972 | //======================================================================= |
973 | |
974 | void AIS_LocalContext::LoadContextObjects() |
975 | { |
976 | AIS_ListIteratorOfListOfInteractive It; |
977 | if(myLoadDisplayed) { |
978 | AIS_ListOfInteractive LL; |
979 | myCTX->DisplayedObjects(LL,Standard_True); |
980 | Handle(AIS_LocalStatus) Att; |
981 | for (It.Initialize(LL);It.More();It.Next()){ |
982 | Att= new AIS_LocalStatus(); |
983 | Att->SetDecomposition((It.Value()->AcceptShapeDecomposition() && myAcceptStdMode)); |
984 | Att->SetTemporary(Standard_False); |
985 | Att->SetHilightMode(It.Value()->HasHilightMode()? It.Value()->HilightMode(): 0); |
986 | |
987 | myActiveObjects.Bind(It.Value(),Att); |
988 | } |
989 | } |
990 | } |
991 | |
992 | void AIS_LocalContext::UnloadContextObjects() |
993 | { |
994 | AIS_ListIteratorOfListOfInteractive It; |
995 | if(myLoadDisplayed) |
996 | { |
997 | AIS_ListOfInteractive LL; |
998 | myCTX->DisplayedObjects(LL,Standard_True); |
999 | |
1000 | for (It.Initialize(LL);It.More();It.Next()) |
1001 | { |
1002 | myActiveObjects.UnBind(It.Value()); |
1003 | } |
1004 | } |
1005 | } |
1006 | //======================================================================= |
1007 | //function : Process |
1008 | //purpose : |
1009 | //======================================================================= |
1010 | |
1011 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject, |
1012 | const Standard_Boolean WithProj) |
1013 | { |
1014 | if(!myActiveObjects.IsBound(anObject)) return; |
1015 | if(myActiveObjects(anObject)->Decomposed()) |
1016 | ActivateStandardModes(anObject,WithProj); |
1017 | else |
1018 | { |
1019 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
1020 | for(;It.More();It.Next()) |
1021 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS,WithProj); |
1022 | } |
1023 | } |
1024 | |
1025 | //======================================================================= |
1026 | //function : Process |
1027 | //purpose : |
1028 | //======================================================================= |
1029 | |
1030 | void AIS_LocalContext::Process(const Standard_Boolean WithProj) |
1031 | { |
1032 | |
1033 | myMainVS->Clear(); |
1034 | |
1035 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1036 | |
1037 | for(;It.More();It.Next()){ |
1038 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
1039 | if(It.Value()->Decomposed()) |
1040 | ActivateStandardModes(It.Key(),WithProj); |
1041 | else if( myCTX->GetAutoActivateSelection() ) |
1042 | { |
1043 | It.Value()->AddSelectionMode(0); |
1044 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS,WithProj); |
1045 | } |
1046 | } |
1047 | |
1048 | } |
1049 | |
1050 | //======================================================================= |
1051 | //function : ActivateModes |
1052 | //purpose : |
1053 | //======================================================================= |
1054 | |
1055 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject, |
1056 | const Standard_Boolean WithProj) |
1057 | { |
1058 | if(!myActiveObjects.IsBound(anObject)) return; |
1059 | |
1060 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
1061 | |
1062 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
1063 | if(LS->Decomposed()){ |
1064 | for(;itl.More();itl.Next()){ |
1065 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS,WithProj); |
1066 | LS->AddSelectionMode(itl.Value()); |
1067 | } |
1068 | } |
1069 | } |
1070 | |
1071 | |
1072 | //======================================================================= |
1073 | //function : ClearObjects |
1074 | //purpose : |
1075 | //======================================================================= |
1076 | |
1077 | void AIS_LocalContext::ClearObjects() |
1078 | { |
1079 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1080 | for(;It.More();It.Next()) |
1081 | { |
1082 | Handle(AIS_InteractiveObject) SO = |
1083 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
1084 | |
1085 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
1086 | //TColStd_ListIteratorOfListOfInteger ItL; |
81bba717 |
1087 | // if object is temporary the presentations managed by myMainPM are removed |
7fd59977 |
1088 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
1089 | |
1090 | if(TheDS != AIS_DS_Displayed){ |
1091 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
1092 | if(CurAtt->IsSubIntensityOn()&& |
1093 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
1094 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
1095 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1096 | } |
1097 | |
1098 | if(CurAtt->IsTemporary()){ |
1099 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
1100 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
1101 | } |
1102 | else { |
1103 | if (CurAtt->IsSubIntensityOn()){ |
1104 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
1105 | Standard_Integer DiMo = SO->HasDisplayMode()? |
1106 | SO->DisplayMode():myCTX->DisplayMode(); |
1107 | if(CurAtt->DisplayMode()!=-1 && |
1108 | CurAtt->DisplayMode()!= DiMo) |
1109 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1110 | } |
1111 | |
1112 | TColStd_ListIteratorOfListOfInteger ITL(CurAtt->SelectionModes()); |
1113 | for(;ITL.More();ITL.Next()) |
1114 | mySM->Deactivate(SO,ITL.Value(),myMainVS); |
1115 | |
1116 | if(CurAtt->IsTemporary()) |
1117 | mySM->Remove(SO,myMainVS); |
1118 | |
1119 | } |
1120 | ClearSelected( Standard_False ); |
1121 | myActiveObjects.Clear(); |
1122 | // myMainVS->ClearAreas();myMainVS->ClearSensitive(); |
1123 | } |
1124 | |
1125 | |
1126 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
1127 | {return !myListOfStandardMode.IsEmpty();} |
1128 | |
1129 | |
1130 | |
1131 | |
1132 | //======================================================================= |
1133 | //function : HasAlreadyFilters |
1134 | //purpose : |
1135 | //======================================================================= |
1136 | |
1137 | Standard_Boolean AIS_LocalContext:: |
1138 | HasFilters(const TopAbs_ShapeEnum aType) const |
1139 | { |
1140 | return myFilters->ActsOn(aType); |
1141 | } |
1142 | |
1143 | void AIS_LocalContext::ClearDetected() |
1144 | { |
1145 | for(Standard_Integer I=1;I<=myMapOfOwner.Extent();I++){ |
1146 | |
1147 | if(!myMapOfOwner(I).IsNull()){ |
1148 | if(myMapOfOwner(I)->IsHilighted(myMainPM)) |
1149 | myMapOfOwner(I)->Unhilight(myMainPM); |
1150 | else if (myMapOfOwner(I)->IsHilighted(myCTX->CollectorPrsMgr())) |
1151 | myMapOfOwner(I)->Unhilight(myCTX->CollectorPrsMgr()); |
1152 | |
1153 | else{ |
1154 | const Handle(SelectMgr_SelectableObject)& SO = |
1155 | myMapOfOwner.FindKey(I)->Selectable(); |
1156 | if(myActiveObjects.IsBound(SO)){ |
1157 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
1158 | |
1159 | if(Att->IsTemporary() && |
1160 | Att->DisplayMode()==-1 && |
1161 | Att->SelectionModes().IsEmpty()){ |
1162 | myMapOfOwner(I)->Clear(myMainPM); |
1163 | //myMapOfOwner(I)->Clear();//rob-jmi... |
1164 | } |
1165 | } |
1166 | } |
1167 | } |
1168 | } |
1169 | |
1170 | } |
1171 | |
1172 | void AIS_LocalContext::UpdateConversion() |
1173 | { |
1174 | myMainVS->UpdateConversion(); |
1175 | } |
1176 | |
1177 | void AIS_LocalContext::UpdateSort() |
1178 | { |
1179 | myMainVS->UpdateSort(); |
1180 | } |
1181 | |
1182 | |
1183 | |
1184 | //======================================================================= |
1185 | //function : IMMEDIATE MODE |
1186 | //purpose : |
1187 | //======================================================================= |
1188 | |
1189 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
1190 | { |
1191 | if(myMainPM->IsImmediateModeOn()){ |
1192 | myMainPM->BeginDraw(); |
1193 | return Standard_True; |
1194 | } |
1195 | return Standard_False; |
1196 | } |
1197 | |
1198 | |
1199 | Standard_Boolean AIS_LocalContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, |
1200 | const Standard_Integer aMode) |
1201 | { |
1202 | if(!myMainPM->IsImmediateModeOn()) |
1203 | return Standard_False; |
1204 | myMainPM->Add(anIObj,aMode); |
1205 | return Standard_True; |
1206 | } |
1207 | |
1208 | Standard_Boolean AIS_LocalContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, |
1209 | const Standard_Integer aMode) |
1210 | { |
1211 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1212 | myMainPM->Remove(anIObj,aMode); |
1213 | return Standard_True; |
1214 | } |
1215 | |
1216 | Standard_Boolean AIS_LocalContext::EndImmediateDraw(const Handle(V3d_View)& aView, |
1217 | const Standard_Boolean DoubleBuf) |
1218 | { |
1219 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1220 | myMainPM->EndDraw(aView,DoubleBuf); |
1221 | return Standard_True; |
1222 | } |
1223 | |
1224 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
1225 | {return myMainPM->IsImmediateModeOn();} |
1226 | |
1227 | #ifdef BUC60688 |
1228 | void AIS_LocalContext::SetSensitivity(const Standard_Real aPrecision) { |
1229 | |
1230 | myMainVS->SetSensitivity(aPrecision); |
1231 | } |
1232 | |
1233 | void AIS_LocalContext::SetSensitivity(const Standard_Integer aPrecision) { |
1234 | |
1235 | myMainVS->Set(aPrecision); |
1236 | } |
1237 | #endif |
59f45b7c |
1238 | |
1239 | //======================================================================= |
1240 | //function : SetZLayer |
1241 | //purpose : |
1242 | //======================================================================= |
1243 | |
1244 | void AIS_LocalContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, |
1245 | const Standard_Integer theLayerId) |
1246 | { |
1247 | if (!myActiveObjects.IsBound (theIObj)) |
1248 | return; |
1249 | |
1250 | const Handle(AIS_LocalStatus)& aStatus = myActiveObjects (theIObj); |
1251 | if (aStatus->DisplayMode () == -1) |
1252 | return; |
1253 | |
1254 | theIObj->SetZLayer (myMainPM, theLayerId); |
1255 | } |
1256 | |
1257 | //======================================================================= |
1258 | //function : GetZLayer |
1259 | //purpose : |
1260 | //======================================================================= |
1261 | |
1262 | Standard_Integer AIS_LocalContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const |
1263 | { |
1264 | if (!myActiveObjects.IsBound (theIObj)) |
1265 | return -1; |
1266 | |
1267 | return theIObj->GetZLayer (myMainPM); |
1268 | } |