7fd59977 |
1 | // File: AIS_InteractiveContext_2.cxx |
2 | // Created: Wed Jan 29 10:55:05 1997 |
3 | // Author: Robert COUBLANC |
4 | // <rob@robox.paris1.matra-dtv.fr> |
5 | |
6 | #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods |
7 | |
8 | #include <AIS_InteractiveContext.jxx> |
9 | |
10 | #include <AIS_LocalContext.hxx> |
11 | |
12 | #include <AIS_GlobalStatus.hxx> |
13 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
14 | |
15 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> |
16 | #include <AIS_DataMapIteratorOfDataMapOfILC.hxx> |
17 | #include <Graphic3d_StructureManager.hxx> |
18 | #include <Graphic3d_Structure.hxx> |
19 | #include <Graphic3d_MapOfStructure.hxx> |
20 | #include <Graphic3d_MapIteratorOfMapOfStructure.hxx> |
21 | #include <AIS_Selection.hxx> |
22 | |
7fd59977 |
23 | //======================================================================= |
24 | //function : OpenLocalContext |
25 | //purpose : |
26 | //======================================================================= |
27 | |
28 | Standard_Integer AIS_InteractiveContext:: |
29 | OpenLocalContext(const Standard_Boolean UseDisplayedObjects, |
30 | const Standard_Boolean AllowShapeDecomposition, |
31 | const Standard_Boolean AcceptEraseOfTemporary, |
32 | const Standard_Boolean /*BothViewers*/) |
33 | { |
34 | |
35 | // on dehilighte les eventuelles entitees detectees juste avant l'ouverture |
36 | // du contexte... |
37 | if(!IsCurrent(myLastPicked)){ |
38 | if(!myLastPicked.IsNull()){ |
39 | Standard_Integer HiMod = myLastPicked->HasHilightMode()?myLastPicked->HilightMode():0; |
40 | myMainPM->Unhighlight(myLastPicked,HiMod); |
41 | }} |
42 | |
43 | if(!mylastmoveview.IsNull()){ |
44 | if(myCurLocalIndex>0) |
45 | myLocalContexts(myCurLocalIndex)->UnhilightLastDetected(mylastmoveview); |
46 | } |
47 | |
48 | // on met a 0 les entites liees a la selection dynamique au point neutre. |
49 | |
50 | myLastinMain.Nullify(); |
51 | myLastinColl.Nullify(); |
52 | myLastPicked.Nullify(); |
53 | myWasLastMain = Standard_True; |
54 | |
55 | |
56 | |
57 | Standard_Integer untilnow = myCurLocalIndex; |
58 | |
59 | myCurLocalIndex = HighestIndex() + 1; |
60 | |
61 | Handle(AIS_LocalContext) NewLocal= new AIS_LocalContext(this,myCurLocalIndex, |
62 | UseDisplayedObjects, |
63 | AllowShapeDecomposition, |
64 | AcceptEraseOfTemporary); |
4952a30a |
65 | NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 0) |
66 | ? myLocalContexts (untilnow)->MainSelector()->Projector() |
67 | : myMainSel->Projector()); |
68 | |
7fd59977 |
69 | NewLocal->MainSelector()->UpdateConversion(); |
7fd59977 |
70 | |
4952a30a |
71 | myLocalContexts.Bind(myCurLocalIndex,NewLocal); |
7fd59977 |
72 | |
73 | #ifdef DEB |
74 | cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl; |
75 | if(UseDisplayedObjects){ |
76 | cout<<"\t\tObjects from Neutral Point loaded"<<endl; |
77 | if(AllowShapeDecomposition) |
78 | cout<<"\t\tDecomposition Authorized for Loaded Shapes"<<endl; |
79 | else |
80 | cout<<"\t\tNo Decomposition Authorized for Loaded Shapes"<<endl; |
81 | } |
82 | else |
83 | cout<<"\t\tNo Objects Were Loaded "<<endl; |
84 | #endif |
85 | return myCurLocalIndex; |
7fd59977 |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : CloseLocalContext |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index, |
94 | const Standard_Boolean updateviewer) |
95 | { |
96 | |
97 | Standard_Boolean debugmode(Standard_False); |
98 | #ifdef DEB |
99 | debugmode = Standard_True; |
100 | #endif |
101 | |
102 | Standard_Integer GoodIndex = (Index ==-1) ? myCurLocalIndex : Index; |
103 | |
104 | if(debugmode) cout<<"Call to CloseLocalContext - Index "<<GoodIndex<<endl; |
105 | if(!HasOpenedContext()){ |
106 | if(debugmode) cout<<"\t But No Local Context is opened"<<endl; |
107 | return; |
108 | } |
109 | if(!myLocalContexts.IsBound(GoodIndex)) { |
110 | if(debugmode) cout<<" Attempt to Close a non-existent Local Context"<<endl; |
111 | return; |
112 | } |
113 | |
114 | // On va fermer le seul contexte local ouvert... |
115 | if(myLocalContexts.Extent()==1 && GoodIndex == myCurLocalIndex){ |
116 | |
117 | Standard_Boolean updateproj = !(myLocalContexts(myCurLocalIndex)->HasSameProjector(myMainSel->Projector())); |
118 | myLocalContexts(myCurLocalIndex)->Terminate( updateviewer ); |
119 | myLocalContexts.UnBind(myCurLocalIndex); |
120 | myCurLocalIndex = 0; |
121 | |
122 | ResetOriginalState(Standard_False); |
123 | if(updateproj) |
124 | myMainSel->UpdateConversion(); |
125 | else{ |
126 | myMainSel->ReactivateProjector(); |
127 | myMainSel->UpdateSort(); |
128 | } |
129 | if(debugmode) |
130 | cout<<"No More Opened Local Context "<<endl; |
131 | } |
132 | |
133 | // Sinon on aura encore un contexte local d'ouvert apres la fermeture du courant |
134 | else{ |
135 | Handle(StdSelect_ViewerSelector3d) VS = myLocalContexts(GoodIndex)->MainSelector(); |
136 | myLocalContexts(GoodIndex)->Terminate(); |
137 | myLocalContexts.UnBind(GoodIndex); |
138 | // on ferme le courant... |
139 | if(GoodIndex==myCurLocalIndex){ |
140 | myCurLocalIndex = HighestIndex(); |
141 | const Handle(AIS_LocalContext)& LocCtx = myLocalContexts(myCurLocalIndex); |
142 | if(LocCtx->HasSameProjector(VS->Projector())){ |
143 | LocCtx->MainSelector()->ReactivateProjector(); |
144 | } |
145 | else |
146 | LocCtx->MainSelector()->UpdateConversion(); |
147 | } |
148 | else if(debugmode) |
149 | cout<<"a No Current Local Context WasClosed"<<endl; |
150 | |
151 | if(debugmode) cout<<"Index Of CurrentLocalContext:"<<myCurLocalIndex<<endl; |
152 | |
153 | } |
154 | |
155 | |
156 | if(updateviewer) myMainVwr->Update(); |
157 | } |
158 | |
159 | //======================================================================= |
160 | //function : CloseAllContexts |
161 | //purpose : |
162 | //======================================================================= |
163 | |
164 | void AIS_InteractiveContext::CloseAllContexts(const Standard_Boolean updateviewer) |
165 | { |
166 | |
167 | while(!myLocalContexts.IsEmpty()){ |
168 | CloseLocalContext(myCurLocalIndex,Standard_False); |
169 | } |
170 | |
171 | ResetOriginalState(Standard_False); |
172 | |
173 | myMainSel->UpdateSort(); |
174 | if(!myIsCollClosed && !myCollectorSel.IsNull()) |
175 | myCollectorSel->UpdateSort(); |
176 | if(updateviewer) myMainVwr->Update(); |
177 | } |
178 | |
179 | //======================================================================= |
180 | //function : IndexOfCurrentLocal |
181 | //purpose : |
182 | //======================================================================= |
183 | |
184 | Standard_Integer AIS_InteractiveContext::IndexOfCurrentLocal() const |
185 | { |
186 | return myCurLocalIndex; |
187 | } |
188 | |
189 | //======================================================================= |
190 | //function : ClearLocalContext |
191 | //purpose : |
192 | //======================================================================= |
193 | |
194 | void AIS_InteractiveContext::ClearLocalContext(const AIS_ClearMode aMode) |
195 | { |
196 | if (!HasOpenedContext()) return; |
197 | myLocalContexts(myCurLocalIndex)->Clear(aMode); |
198 | |
199 | } |
200 | |
201 | //======================================================================= |
202 | //function : HighestIndex |
203 | //purpose : |
204 | //======================================================================= |
205 | |
206 | Standard_Integer AIS_InteractiveContext::HighestIndex() const |
207 | { |
208 | AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); |
209 | Standard_Integer HiInd = 0; |
210 | for(;It.More();It.Next()) |
211 | HiInd = (It.Key()>HiInd) ? It.Key() : HiInd; |
212 | return HiInd; |
213 | |
214 | } |
215 | |
216 | |
217 | //======================================================================= |
218 | //function : Activate |
219 | //purpose : |
220 | //======================================================================= |
221 | |
222 | void AIS_InteractiveContext:: |
223 | Activate(const Handle(AIS_InteractiveObject)& anIObj, |
224 | const Standard_Integer aMode) |
225 | { |
226 | if(!HasOpenedContext()){ |
227 | if(!myObjects.IsBound(anIObj)) return; |
228 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
229 | if(STAT->GraphicStatus()==AIS_DS_Displayed) |
230 | mgrSelector->Activate(anIObj,aMode,myMainSel); |
231 | STAT ->AddSelectionMode(aMode); |
232 | } |
233 | else{ |
234 | myLocalContexts(myCurLocalIndex)->ActivateMode(anIObj,aMode); |
235 | } |
236 | } |
237 | |
238 | //======================================================================= |
239 | //function : LocalSelector |
240 | //purpose : |
241 | //======================================================================= |
242 | Handle( StdSelect_ViewerSelector3d ) AIS_InteractiveContext::LocalSelector() const |
243 | { |
244 | if( !HasOpenedContext() ) |
245 | return Handle( StdSelect_ViewerSelector3d )(); |
246 | else |
247 | return myLocalContexts( myCurLocalIndex )->MainSelector(); |
248 | } |
249 | |
250 | |
251 | //======================================================================= |
252 | //function : DeActivate |
253 | //purpose : |
254 | //======================================================================= |
255 | void AIS_InteractiveContext:: |
256 | Deactivate(const Handle(AIS_InteractiveObject)& anIObj) |
257 | { |
258 | if(!HasOpenedContext()){ |
259 | if(!myObjects.IsBound(anIObj)) return; |
4952a30a |
260 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
261 | for(ItL.Initialize(myObjects(anIObj)->SelectionModes()); |
262 | ItL.More(); |
263 | ItL.Next()){ |
264 | if(myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed) |
265 | mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel); |
266 | } |
267 | myObjects(anIObj)->ClearSelectionModes(); |
268 | } |
269 | else{ |
270 | const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex); |
271 | LC->Deactivate(anIObj); |
272 | } |
273 | } |
274 | |
275 | //======================================================================= |
276 | //function : Deactivate |
277 | //purpose : |
278 | //======================================================================= |
279 | |
280 | void AIS_InteractiveContext::Deactivate(const Handle(AIS_InteractiveObject)& anIObj, |
281 | const Standard_Integer aMode) |
282 | { |
283 | if(!HasOpenedContext()){ |
284 | if(!myObjects.IsBound(anIObj)) return; |
285 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
286 | |
287 | if(STAT->GraphicStatus() == AIS_DS_Displayed) |
288 | mgrSelector->Deactivate(anIObj,aMode,myMainSel); |
289 | STAT->RemoveSelectionMode(aMode); |
290 | } |
291 | else{ |
292 | myLocalContexts(myCurLocalIndex)->DeactivateMode(anIObj,aMode); |
293 | } |
294 | } |
295 | |
296 | //======================================================================= |
297 | //function : ActivatedModes |
298 | //purpose : |
299 | //======================================================================= |
300 | |
301 | void AIS_InteractiveContext:: |
302 | ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj, |
303 | TColStd_ListOfInteger& theList) const |
304 | { |
4952a30a |
305 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
306 | if(!HasOpenedContext()){ |
307 | if(myObjects.IsBound(anIObj)){ |
7fd59977 |
308 | for(ItL.Initialize(myObjects(anIObj)->SelectionModes()); |
309 | ItL.More(); |
310 | ItL.Next()) |
311 | theList.Append(ItL.Value()); |
312 | |
313 | } |
314 | } |
315 | else{ |
316 | if(myLocalContexts(myCurLocalIndex)->IsIn(anIObj)){ |
317 | for(ItL.Initialize(myLocalContexts(myCurLocalIndex)->SelectionModes(anIObj)); |
318 | ItL.More(); |
319 | ItL.Next()) |
320 | theList.Append(ItL.Value()); |
321 | } |
322 | } |
323 | } |
324 | |
325 | //======================================================================= |
326 | //function : SetShapeDecomposition |
327 | //purpose : |
328 | //======================================================================= |
329 | |
330 | void AIS_InteractiveContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& anIObj, |
331 | const Standard_Boolean StdModeSensitive) |
332 | { |
333 | if(!HasOpenedContext()) return; |
334 | myLocalContexts(myCurLocalIndex)->SetShapeDecomposition(anIObj,StdModeSensitive); |
335 | } |
336 | |
337 | //======================================================================= |
338 | //function : SetTemporaryAttributes |
339 | //purpose : |
340 | //======================================================================= |
341 | |
342 | void AIS_InteractiveContext:: |
343 | SetTemporaryAttributes(const Handle(AIS_InteractiveObject)& /*anObj*/, |
344 | const Handle(Prs3d_Drawer)& /*aDrawer*/, |
345 | const Standard_Boolean /*updateviewer*/) |
346 | { |
347 | } |
348 | |
349 | //======================================================================= |
350 | //function : SubIntensityOn |
351 | //purpose : |
352 | //======================================================================= |
353 | void AIS_InteractiveContext:: |
354 | SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj, |
355 | const Standard_Boolean updateviewer) |
356 | { |
357 | if(!HasOpenedContext()){ |
358 | if(!myObjects.IsBound(anIObj)) |
359 | return; |
360 | const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj); |
361 | if(GB->IsSubIntensityOn()) |
362 | return; |
363 | GB->SubIntensityOn(); |
364 | Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False); |
365 | |
366 | for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){ |
367 | if(GB->GraphicStatus()==AIS_DS_Displayed){ |
368 | myMainPM->Color(anIObj,mySubIntensity,It.Value()); |
369 | UpdMain = Standard_True;} |
370 | else if(GB->GraphicStatus()==AIS_DS_Erased){ |
371 | myCollectorPM->Color(anIObj,mySubIntensity,It.Value()); |
372 | UpdColl=Standard_True; |
373 | } |
374 | } |
375 | if(updateviewer){ |
376 | if(UpdMain) |
377 | myMainVwr->Update(); |
378 | if(UpdColl) |
379 | myCollectorVwr->Update(); |
380 | } |
381 | } |
382 | else { |
383 | if(myObjects.IsBound(anIObj)){ |
384 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
385 | STAT->SubIntensityOn(); |
4952a30a |
386 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
387 | for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) |
388 | myMainPM->Color(anIObj,mySubIntensity,ItL.Value()); |
389 | } |
390 | else |
391 | myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj); |
392 | |
393 | if(updateviewer) myMainVwr->Update(); |
394 | } |
395 | } |
396 | //======================================================================= |
397 | //function : SubIntensityOff |
398 | //purpose : |
399 | //======================================================================= |
400 | |
401 | void AIS_InteractiveContext:: |
402 | SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, |
403 | const Standard_Boolean updateviewer) |
404 | { |
405 | if(!HasOpenedContext()){ |
406 | if(!myObjects.IsBound(anIObj)) |
407 | return; |
408 | const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj); |
409 | if(!GB->IsSubIntensityOn()) |
410 | return; |
411 | GB->SubIntensityOff(); |
412 | Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False); |
413 | |
414 | for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){ |
415 | if(GB->GraphicStatus()!=AIS_DS_Erased){ |
416 | myMainPM->Unhighlight(anIObj,It.Value()); |
417 | UpdMain = Standard_True;} |
418 | else { |
419 | myCollectorPM->Unhighlight(anIObj,It.Value()); |
420 | UpdColl=Standard_True; |
421 | } |
422 | } |
423 | |
424 | Standard_Integer DM,HM,SM; |
425 | GetDefModes(anIObj,DM,HM,SM); |
426 | if(AIS_Selection::IsSelected(anIObj)) |
427 | myMainPM->Highlight(anIObj,HM); |
428 | |
429 | if(updateviewer){ |
430 | if(UpdMain) |
431 | myMainVwr->Update(); |
432 | if(UpdColl) |
433 | myCollectorVwr->Update(); |
434 | } |
435 | } |
436 | else { |
437 | if(myObjects.IsBound(anIObj)){ |
438 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
439 | STAT->SubIntensityOff(); |
4952a30a |
440 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
441 | for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) |
442 | myMainPM->Unhighlight(anIObj,ItL.Value()); |
443 | if(STAT->IsHilighted()) |
444 | Hilight(anIObj); |
445 | } |
446 | else |
447 | myLocalContexts(myCurLocalIndex)->SubIntensityOff(anIObj); |
448 | if(IsSelected(anIObj)) |
449 | Hilight(anIObj); |
450 | |
451 | if(updateviewer) myMainVwr->Update(); |
452 | } |
453 | } |
454 | |
455 | //======================================================================= |
456 | //function : SubIntensityOn |
457 | //purpose : ALL THE DISPLAYED OBJECTS HAVE SUBINTENSITY... |
458 | //======================================================================= |
459 | |
460 | void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer) |
461 | { |
462 | if(!HasOpenedContext()) return; |
463 | |
464 | AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); |
465 | TColStd_ListIteratorOfListOfInteger ItM; |
466 | for(;It.More();It.Next()){ |
467 | const Handle(AIS_GlobalStatus)& STAT = It.Value(); |
468 | if(STAT->GraphicStatus()==AIS_DS_Displayed) |
469 | { |
470 | STAT->SubIntensityOn(); |
471 | for(ItM.Initialize(STAT->DisplayedModes());ItM.More();ItM.Next()) |
472 | {myMainPM->Color(It.Key(),mySubIntensity,ItM.Value());} |
473 | } |
474 | } |
475 | if(updateviewer) myMainVwr->Update(); |
476 | } |
477 | |
478 | //======================================================================= |
479 | //function : SubIntensityOff |
480 | //purpose : |
481 | //======================================================================= |
482 | void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer) |
483 | { |
7fd59977 |
484 | if(!HasOpenedContext()) return; |
4952a30a |
485 | |
7fd59977 |
486 | AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); |
4952a30a |
487 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
488 | for(;It.More();It.Next()){ |
489 | const Handle(AIS_GlobalStatus)& STAT = It.Value(); |
490 | if(STAT->IsSubIntensityOn()) |
491 | STAT->SubIntensityOff(); |
492 | for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) |
493 | myMainPM->Unhighlight(It.Key()); |
494 | } |
4952a30a |
495 | |
7fd59977 |
496 | if(updateviewer) myMainVwr->Update(); |
497 | } |
498 | |
499 | //======================================================================= |
500 | //function : AddFilter |
501 | //purpose : |
502 | //======================================================================= |
503 | void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
504 | { |
505 | if(HasOpenedContext()) |
506 | myLocalContexts(myCurLocalIndex)->AddFilter(aFilter); |
507 | else |
508 | myFilters->Add(aFilter); |
509 | } |
510 | |
511 | //======================================================================= |
512 | //function : ActivateStandardMode |
513 | //purpose : |
514 | //======================================================================= |
515 | void AIS_InteractiveContext::ActivateStandardMode(const TopAbs_ShapeEnum aStandardActivation) |
516 | { |
517 | if(!HasOpenedContext()) return; |
518 | myLocalContexts(myCurLocalIndex)->ActivateStandardMode (aStandardActivation); |
519 | } |
520 | |
521 | //======================================================================= |
522 | //function : DeActivateStandardMode |
523 | //purpose : |
524 | //======================================================================= |
525 | void AIS_InteractiveContext::DeactivateStandardMode(const TopAbs_ShapeEnum aStandardActivation) |
526 | { |
527 | if(!HasOpenedContext()) return; |
528 | myLocalContexts(myCurLocalIndex)->DeactivateStandardMode (aStandardActivation); |
529 | } |
530 | |
531 | //======================================================================= |
532 | //function : RemoveFilter |
533 | //purpose : |
534 | //======================================================================= |
535 | void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
536 | { |
537 | if(HasOpenedContext()) |
538 | myLocalContexts(myCurLocalIndex)->RemoveFilter (aFilter); |
539 | else |
540 | myFilters->Remove(aFilter); |
541 | } |
542 | |
543 | //======================================================================= |
544 | //function : RemoveFilters |
545 | //purpose : |
546 | //======================================================================= |
547 | |
548 | void AIS_InteractiveContext::RemoveFilters() |
549 | { |
550 | if(!HasOpenedContext()) |
551 | myFilters->Clear(); |
552 | else |
553 | myLocalContexts(myCurLocalIndex)->Clear(AIS_CM_Filters); |
554 | } |
555 | |
556 | //======================================================================= |
557 | //function : ActivatedStandardModes |
558 | //purpose : |
559 | //======================================================================= |
560 | const TColStd_ListOfInteger& AIS_InteractiveContext::ActivatedStandardModes() const |
561 | { |
562 | return myLocalContexts(myCurLocalIndex)->StandardModes(); |
563 | } |
564 | |
565 | //======================================================================= |
566 | //function : Filters |
567 | //purpose : |
568 | //======================================================================= |
569 | const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const |
570 | { |
571 | if(HasOpenedContext()) |
572 | return myLocalContexts(myCurLocalIndex)->ListOfFilter(); |
573 | return myFilters->StoredFilters(); |
574 | } |
575 | |
576 | //======================================================================= |
577 | //function : DisplayActiveAreas |
578 | //purpose : |
579 | //======================================================================= |
580 | void AIS_InteractiveContext::DisplayActiveAreas(const Handle(V3d_View)& aviou) |
581 | { |
582 | if(HasOpenedContext()) |
583 | myLocalContexts(myCurLocalIndex)->DisplayAreas(aviou); |
584 | else |
585 | myMainSel->DisplayAreas(aviou); |
586 | |
587 | } |
588 | |
589 | //======================================================================= |
590 | //function : ClearActiveAreas |
591 | //purpose : |
592 | //======================================================================= |
593 | void AIS_InteractiveContext::ClearActiveAreas(const Handle(V3d_View)& aviou) |
594 | { |
595 | if(HasOpenedContext()) |
596 | myLocalContexts(myCurLocalIndex)->ClearAreas(aviou); |
597 | else |
598 | myMainSel->ClearAreas(aviou); |
599 | } |
600 | |
601 | //======================================================================= |
602 | //function : DisplayActiveSensitive |
603 | //purpose : |
604 | //======================================================================= |
605 | void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& aviou) |
606 | { |
607 | if(HasOpenedContext()) |
608 | myLocalContexts(myCurLocalIndex)->DisplaySensitive(aviou); |
609 | else |
610 | myMainSel->DisplaySensitive(aviou); |
611 | } |
612 | //======================================================================= |
613 | //function : DisplayActiveSensitive |
614 | //purpose : |
615 | //======================================================================= |
616 | |
617 | void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(AIS_InteractiveObject)& anIObj, |
618 | const Handle(V3d_View)& aviou) |
619 | { |
620 | TColStd_ListIteratorOfListOfInteger It; |
621 | Handle(StdSelect_ViewerSelector3d) VS; |
622 | if(HasOpenedContext()){ |
623 | const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex); |
624 | if(!LC->IsIn(anIObj)) return; |
625 | It.Initialize(LC->SelectionModes(anIObj)); |
626 | VS = LC->MainSelector(); |
627 | } |
628 | else{ |
629 | if(!myObjects.IsBound(anIObj)) return; |
630 | It.Initialize(myObjects(anIObj)->SelectionModes()); |
631 | VS = myMainSel; |
632 | } |
633 | |
634 | |
635 | for(;It.More();It.Next()){ |
636 | const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value()); |
637 | VS->DisplaySensitive(Sel,aviou,Standard_False); |
638 | } |
639 | |
640 | } |
641 | |
642 | //======================================================================= |
643 | //function : DisplayActiveAreas |
644 | //purpose : |
645 | //======================================================================= |
646 | |
647 | void AIS_InteractiveContext::DisplayActiveAreas(const Handle(AIS_InteractiveObject)& anIObj, |
648 | const Handle(V3d_View)& aviou) |
649 | { |
650 | TColStd_ListIteratorOfListOfInteger It; |
651 | Handle(StdSelect_ViewerSelector3d) VS; |
652 | if(HasOpenedContext()){ |
653 | const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex); |
654 | if(!LC->IsIn(anIObj)) return; |
655 | It.Initialize(LC->SelectionModes(anIObj)); |
656 | VS = LC->MainSelector(); |
657 | } |
658 | else{ |
659 | if(!myObjects.IsBound(anIObj)) return; |
660 | It.Initialize(myObjects(anIObj)->SelectionModes()); |
661 | VS = myMainSel; |
662 | } |
663 | |
664 | |
665 | for(;It.More();It.Next()){ |
666 | const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value()); |
667 | VS->DisplayAreas(Sel,aviou,Standard_False); |
668 | } |
669 | |
670 | } |
671 | |
672 | //======================================================================= |
673 | //function : ClearActiveSensitive |
674 | //purpose : |
675 | //======================================================================= |
676 | void AIS_InteractiveContext::ClearActiveSensitive(const Handle(V3d_View)& aviou) |
677 | { |
678 | |
679 | if(HasOpenedContext()) |
680 | myLocalContexts(myCurLocalIndex)->ClearSensitive(aviou); |
681 | else |
682 | myMainSel->ClearSensitive(aviou); |
683 | } |
684 | |
685 | //======================================================================= |
686 | //function : SetAutomaticHilight |
687 | //purpose : |
688 | //======================================================================= |
689 | void AIS_InteractiveContext::SetAutomaticHilight(const Standard_Boolean aStatus) |
690 | { |
691 | |
692 | if(HasOpenedContext()) |
693 | myLocalContexts(myCurLocalIndex)->SetAutomaticHilight(aStatus); |
694 | } |
695 | |
696 | //======================================================================= |
697 | //function : AutomaticHilight |
698 | //purpose : |
699 | //======================================================================= |
700 | Standard_Boolean AIS_InteractiveContext::AutomaticHilight() const |
701 | { |
702 | if(HasOpenedContext()) |
703 | return myLocalContexts(myCurLocalIndex)->AutomaticHilight(); |
704 | return Standard_True; |
705 | } |
706 | |
707 | //======================================================================= |
708 | //function : UseDisplayedObjects |
709 | //purpose : |
710 | //======================================================================= |
711 | |
712 | void AIS_InteractiveContext::UseDisplayedObjects() |
713 | { |
714 | if(HasOpenedContext()) |
715 | myLocalContexts(myCurLocalIndex)->LoadContextObjects(); |
716 | } |
717 | |
718 | //======================================================================= |
719 | //function : NotUseDisplayedObjects |
720 | //purpose : |
721 | //======================================================================= |
722 | |
723 | void AIS_InteractiveContext::NotUseDisplayedObjects() |
724 | { |
725 | if(HasOpenedContext()) |
726 | myLocalContexts(myCurLocalIndex)->UnloadContextObjects(); |
727 | } |
728 | |
729 | |
730 | |
731 | |
732 | //======================================================================= |
733 | //function : PurgeDisplay |
734 | //purpose : |
735 | //======================================================================= |
736 | |
737 | Standard_Integer AIS_InteractiveContext::PurgeDisplay(const Standard_Boolean CollectorToo) |
738 | { |
739 | if(HasOpenedContext()) return 0; |
740 | |
741 | Standard_Integer NbStr = PurgeViewer(myMainVwr); |
742 | if(!myCollectorVwr.IsNull()) |
743 | if(CollectorToo){ |
744 | NbStr+=PurgeViewer(myCollectorVwr); |
745 | if(!IsCollectorClosed()) |
746 | myCollectorVwr->Update(); |
747 | } |
748 | myMainVwr->Update(); |
749 | return NbStr; |
750 | |
751 | } |
752 | |
753 | |
754 | //======================================================================= |
755 | //function : PurgeViewer |
756 | //purpose : |
757 | //======================================================================= |
758 | Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& Vwr) |
759 | { |
760 | const Handle(Graphic3d_StructureManager)& GSM = Vwr->Viewer(); |
761 | Standard_Integer NbCleared(0); |
762 | Graphic3d_MapOfStructure SOS; |
763 | GSM->DisplayedStructures(SOS); |
764 | |
765 | Handle(Graphic3d_Structure) G; |
766 | for(Graphic3d_MapIteratorOfMapOfStructure It(SOS); It.More();It.Next()){ |
767 | G = It.Key(); |
768 | Standard_Address Add = G->Owner(); |
769 | if(Add==NULL){ |
770 | G->Erase(); |
771 | G->Clear();// ca veut dire qu'elle n'est pas reference comme une presentation d'un InterfactiveObject... |
772 | NbCleared++; |
773 | } |
774 | Handle(AIS_InteractiveObject) IO = (AIS_InteractiveObject*)Add; |
775 | if(!myObjects.IsBound(IO)){ |
776 | G->Erase(); |
777 | NbCleared++; |
778 | } |
779 | } |
780 | return NbCleared; |
781 | } |
782 | |
783 | |
784 | //======================================================================= |
785 | //function : IsImmediateModeOn |
786 | //purpose : |
787 | //======================================================================= |
788 | Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const |
789 | { |
790 | if(!HasOpenedContext()) return Standard_False; |
791 | return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn(); |
792 | } |
793 | |
794 | Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw() |
795 | { |
796 | if(HasOpenedContext()) |
797 | return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw(); |
798 | return Standard_False; |
799 | } |
800 | |
801 | //======================================================================= |
802 | //function : ImmediateAdd |
803 | //purpose : |
804 | //======================================================================= |
805 | |
806 | Standard_Boolean AIS_InteractiveContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, |
807 | const Standard_Integer AMode) |
808 | { |
809 | if(HasOpenedContext()){ |
810 | return myLocalContexts(myCurLocalIndex)->ImmediateAdd(anIObj,AMode);} |
811 | return Standard_False; |
812 | } |
813 | |
814 | //======================================================================= |
815 | //function : ImmediateRemove |
816 | //purpose : |
817 | //======================================================================= |
818 | |
819 | Standard_Boolean AIS_InteractiveContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, |
820 | const Standard_Integer aMode) |
821 | { |
822 | if(HasOpenedContext()) |
823 | return myLocalContexts(myCurLocalIndex)->ImmediateRemove(anIObj,aMode); |
824 | return Standard_False; |
825 | } |
826 | |
827 | //======================================================================= |
828 | //function : EndImmediateDraw |
829 | //purpose : |
830 | //======================================================================= |
831 | |
832 | Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Handle(V3d_View)& aView, |
833 | const Standard_Boolean DoubleBuf) |
834 | { |
835 | if(HasOpenedContext()) |
836 | return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(aView,DoubleBuf); |
837 | return Standard_False; |
838 | |
839 | } |
840 | |
841 | //======================================================================= |
842 | //function : EndImmediateDraw |
843 | //purpose : |
844 | //======================================================================= |
845 | |
846 | Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Standard_Boolean DoubleBuf) |
847 | { |
848 | if(HasOpenedContext()){ |
849 | Handle(V3d_View) V ; |
850 | myMainVwr->InitActiveViews(); |
851 | if(myMainVwr->MoreActiveViews()){ |
852 | V = myMainVwr->ActiveView(); |
853 | |
854 | return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(V,DoubleBuf); |
855 | } |
856 | } |
857 | return Standard_False; |
858 | |
859 | } |
860 | |
861 | |
862 | //======================================================================= |
863 | //function : ResetOriginalState |
864 | //purpose : |
865 | //======================================================================= |
866 | |
867 | void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updateviewer) |
868 | { |
869 | Standard_Boolean upd_main(Standard_False),upd_col(Standard_False); |
870 | TColStd_ListIteratorOfListOfInteger itl; |
4952a30a |
871 | |
7fd59977 |
872 | for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){ |
873 | const Handle(AIS_InteractiveObject)& iobj = it.Key(); |
874 | const Handle(AIS_GlobalStatus)& STAT = it.Value(); |
875 | switch(STAT->GraphicStatus()){ |
876 | case AIS_DS_Displayed:{ |
877 | upd_main = Standard_True; |
878 | |
879 | // partie display... |
880 | for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next()) |
881 | myMainPM->Display(iobj,itl.Value()); |
882 | if(STAT->IsHilighted()){ |
883 | if(STAT->HilightColor()!=Quantity_NOC_WHITE) |
884 | HilightWithColor(iobj,STAT->HilightColor(),Standard_False); |
885 | else |
886 | Hilight(iobj,Standard_False); |
887 | } |
888 | //partie selection |
889 | for(itl.Initialize(STAT->SelectionModes());itl.More();itl.Next()){ |
890 | if(itl.Value()!=-1) |
891 | mgrSelector->Activate(iobj,itl.Value(),myMainSel); |
892 | } |
893 | break; |
894 | } |
895 | case AIS_DS_Erased:{ |
896 | upd_col = Standard_True; |
897 | EraseGlobal(iobj,Standard_False,Standard_True); |
898 | break; |
899 | } |
900 | case AIS_DS_FullErased:{ |
901 | EraseGlobal(iobj,Standard_False,Standard_False); |
902 | break; |
903 | } |
904 | default: |
905 | break; |
906 | } |
907 | } |
908 | if(updateviewer){ |
909 | if(upd_main) |
910 | myMainVwr->Update(); |
911 | if(upd_col) |
912 | myCollectorVwr->Update(); |
913 | } |
914 | } |
915 | |
916 | #ifdef IMP051001 |
917 | //======================================================================= |
918 | //function : SetZDetection |
919 | //purpose : |
920 | //======================================================================= |
921 | void AIS_InteractiveContext::SetZDetection(const Standard_Boolean aStatus) |
922 | { |
923 | myZDetectionFlag = aStatus; |
924 | } |
925 | |
926 | //======================================================================= |
927 | //function : ZDetection |
928 | //purpose : |
929 | //======================================================================= |
930 | Standard_Boolean AIS_InteractiveContext::ZDetection() const |
931 | { |
932 | return myZDetectionFlag; |
933 | } |
934 | #endif |