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