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