1 // Created on: 1997-01-29
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
24 #include <AIS_InteractiveContext.jxx>
26 #include <AIS_LocalContext.hxx>
28 #include <AIS_GlobalStatus.hxx>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
31 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
32 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
33 #include <Graphic3d_StructureManager.hxx>
34 #include <Graphic3d_Structure.hxx>
35 #include <Graphic3d_MapOfStructure.hxx>
36 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
37 #include <AIS_Selection.hxx>
39 //=======================================================================
40 //function : OpenLocalContext
42 //=======================================================================
44 Standard_Integer AIS_InteractiveContext::
45 OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
46 const Standard_Boolean AllowShapeDecomposition,
47 const Standard_Boolean AcceptEraseOfTemporary,
48 const Standard_Boolean /*BothViewers*/)
51 // the entities eventually detected just before the context was opened are unhighlighted...
52 if(!IsCurrent(myLastPicked)){
53 if(!myLastPicked.IsNull()){
54 Standard_Integer HiMod = myLastPicked->HasHilightMode()?myLastPicked->HilightMode():0;
55 myMainPM->Unhighlight(myLastPicked,HiMod);
58 if(!mylastmoveview.IsNull()){
60 myLocalContexts(myCurLocalIndex)->UnhilightLastDetected(mylastmoveview);
63 // entities connected to dynamic selection at neutral point are set to 0.
65 myLastinMain.Nullify();
66 myLastinColl.Nullify();
67 myLastPicked.Nullify();
68 myWasLastMain = Standard_True;
72 Standard_Integer untilnow = myCurLocalIndex;
74 myCurLocalIndex = HighestIndex() + 1;
76 Handle(AIS_LocalContext) NewLocal= new AIS_LocalContext(this,myCurLocalIndex,
78 AllowShapeDecomposition,
79 AcceptEraseOfTemporary);
80 NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 0)
81 ? myLocalContexts (untilnow)->MainSelector()->Projector()
82 : myMainSel->Projector());
84 NewLocal->MainSelector()->UpdateConversion();
86 myLocalContexts.Bind(myCurLocalIndex,NewLocal);
89 cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
90 if(UseDisplayedObjects){
91 cout<<"\t\tObjects from Neutral Point loaded"<<endl;
92 if(AllowShapeDecomposition)
93 cout<<"\t\tDecomposition Authorized for Loaded Shapes"<<endl;
95 cout<<"\t\tNo Decomposition Authorized for Loaded Shapes"<<endl;
98 cout<<"\t\tNo Objects Were Loaded "<<endl;
100 return myCurLocalIndex;
103 //=======================================================================
104 //function : CloseLocalContext
106 //=======================================================================
108 void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index,
109 const Standard_Boolean updateviewer)
112 Standard_Boolean debugmode(Standard_False);
114 debugmode = Standard_True;
117 Standard_Integer GoodIndex = (Index ==-1) ? myCurLocalIndex : Index;
119 if(debugmode) cout<<"Call to CloseLocalContext - Index "<<GoodIndex<<endl;
120 if(!HasOpenedContext()){
121 if(debugmode) cout<<"\t But No Local Context is opened"<<endl;
124 if(!myLocalContexts.IsBound(GoodIndex)) {
125 if(debugmode) cout<<" Attempt to Close a non-existent Local Context"<<endl;
129 // the only open local context is closed...
130 if(myLocalContexts.Extent()==1 && GoodIndex == myCurLocalIndex){
132 Standard_Boolean updateproj = !(myLocalContexts(myCurLocalIndex)->HasSameProjector(myMainSel->Projector()));
133 myLocalContexts(myCurLocalIndex)->Terminate( updateviewer );
134 myLocalContexts.UnBind(myCurLocalIndex);
137 ResetOriginalState(Standard_False);
139 myMainSel->UpdateConversion();
141 myMainSel->ReactivateProjector();
142 myMainSel->UpdateSort();
145 cout<<"No More Opened Local Context "<<endl;
148 // Otherwise the local context will be still open after the current is closed
150 Handle(StdSelect_ViewerSelector3d) VS = myLocalContexts(GoodIndex)->MainSelector();
151 myLocalContexts(GoodIndex)->Terminate();
152 myLocalContexts.UnBind(GoodIndex);
153 // the current is closed...
154 if(GoodIndex==myCurLocalIndex){
155 myCurLocalIndex = HighestIndex();
156 const Handle(AIS_LocalContext)& LocCtx = myLocalContexts(myCurLocalIndex);
157 if(LocCtx->HasSameProjector(VS->Projector())){
158 LocCtx->MainSelector()->ReactivateProjector();
161 LocCtx->MainSelector()->UpdateConversion();
164 cout<<"a No Current Local Context WasClosed"<<endl;
166 if(debugmode) cout<<"Index Of CurrentLocalContext:"<<myCurLocalIndex<<endl;
171 if(updateviewer) myMainVwr->Update();
174 //=======================================================================
175 //function : CloseAllContexts
177 //=======================================================================
179 void AIS_InteractiveContext::CloseAllContexts(const Standard_Boolean updateviewer)
182 while(!myLocalContexts.IsEmpty()){
183 CloseLocalContext(myCurLocalIndex,Standard_False);
186 ResetOriginalState(Standard_False);
188 myMainSel->UpdateSort();
189 if(!myIsCollClosed && !myCollectorSel.IsNull())
190 myCollectorSel->UpdateSort();
191 if(updateviewer) myMainVwr->Update();
194 //=======================================================================
195 //function : IndexOfCurrentLocal
197 //=======================================================================
199 Standard_Integer AIS_InteractiveContext::IndexOfCurrentLocal() const
201 return myCurLocalIndex;
204 //=======================================================================
205 //function : ClearLocalContext
207 //=======================================================================
209 void AIS_InteractiveContext::ClearLocalContext(const AIS_ClearMode aMode)
211 if (!HasOpenedContext()) return;
212 myLocalContexts(myCurLocalIndex)->Clear(aMode);
216 //=======================================================================
217 //function : HighestIndex
219 //=======================================================================
221 Standard_Integer AIS_InteractiveContext::HighestIndex() const
223 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
224 Standard_Integer HiInd = 0;
225 for(;It.More();It.Next())
226 HiInd = (It.Key()>HiInd) ? It.Key() : HiInd;
232 //=======================================================================
233 //function : Activate
235 //=======================================================================
237 void AIS_InteractiveContext::
238 Activate(const Handle(AIS_InteractiveObject)& anIObj,
239 const Standard_Integer aMode)
241 if(!HasOpenedContext()){
242 if(!myObjects.IsBound(anIObj)) return;
243 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
244 if(STAT->GraphicStatus()==AIS_DS_Displayed)
245 mgrSelector->Activate(anIObj,aMode,myMainSel);
246 STAT ->AddSelectionMode(aMode);
249 myLocalContexts(myCurLocalIndex)->ActivateMode(anIObj,aMode);
253 //=======================================================================
254 //function : LocalSelector
256 //=======================================================================
257 Handle( StdSelect_ViewerSelector3d ) AIS_InteractiveContext::LocalSelector() const
259 if( !HasOpenedContext() )
260 return Handle( StdSelect_ViewerSelector3d )();
262 return myLocalContexts( myCurLocalIndex )->MainSelector();
266 //=======================================================================
267 //function : DeActivate
269 //=======================================================================
270 void AIS_InteractiveContext::
271 Deactivate(const Handle(AIS_InteractiveObject)& anIObj)
273 if(!HasOpenedContext()){
274 if(!myObjects.IsBound(anIObj)) return;
275 TColStd_ListIteratorOfListOfInteger ItL;
276 for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
279 if(myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
280 mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
282 myObjects(anIObj)->ClearSelectionModes();
285 const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
286 LC->Deactivate(anIObj);
290 //=======================================================================
291 //function : Deactivate
293 //=======================================================================
295 void AIS_InteractiveContext::Deactivate(const Handle(AIS_InteractiveObject)& anIObj,
296 const Standard_Integer aMode)
298 if(!HasOpenedContext()){
299 if(!myObjects.IsBound(anIObj)) return;
300 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
302 if(STAT->GraphicStatus() == AIS_DS_Displayed)
303 mgrSelector->Deactivate(anIObj,aMode,myMainSel);
304 STAT->RemoveSelectionMode(aMode);
307 myLocalContexts(myCurLocalIndex)->DeactivateMode(anIObj,aMode);
311 //=======================================================================
312 //function : ActivatedModes
314 //=======================================================================
316 void AIS_InteractiveContext::
317 ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj,
318 TColStd_ListOfInteger& theList) const
320 TColStd_ListIteratorOfListOfInteger ItL;
321 if(!HasOpenedContext()){
322 if(myObjects.IsBound(anIObj)){
323 for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
326 theList.Append(ItL.Value());
331 if(myLocalContexts(myCurLocalIndex)->IsIn(anIObj)){
332 for(ItL.Initialize(myLocalContexts(myCurLocalIndex)->SelectionModes(anIObj));
335 theList.Append(ItL.Value());
340 //=======================================================================
341 //function : SetShapeDecomposition
343 //=======================================================================
345 void AIS_InteractiveContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& anIObj,
346 const Standard_Boolean StdModeSensitive)
348 if(!HasOpenedContext()) return;
349 myLocalContexts(myCurLocalIndex)->SetShapeDecomposition(anIObj,StdModeSensitive);
352 //=======================================================================
353 //function : SetTemporaryAttributes
355 //=======================================================================
357 void AIS_InteractiveContext::
358 SetTemporaryAttributes(const Handle(AIS_InteractiveObject)& /*anObj*/,
359 const Handle(Prs3d_Drawer)& /*aDrawer*/,
360 const Standard_Boolean /*updateviewer*/)
364 //=======================================================================
365 //function : SubIntensityOn
367 //=======================================================================
368 void AIS_InteractiveContext::
369 SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
370 const Standard_Boolean updateviewer)
372 if(!HasOpenedContext()){
373 if(!myObjects.IsBound(anIObj))
375 const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj);
376 if(GB->IsSubIntensityOn())
378 GB->SubIntensityOn();
379 Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False);
381 for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){
382 if(GB->GraphicStatus()==AIS_DS_Displayed){
383 myMainPM->Color(anIObj,mySubIntensity,It.Value());
384 UpdMain = Standard_True;}
385 else if(GB->GraphicStatus()==AIS_DS_Erased){
386 myCollectorPM->Color(anIObj,mySubIntensity,It.Value());
387 UpdColl=Standard_True;
394 myCollectorVwr->Update();
398 if(myObjects.IsBound(anIObj)){
399 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
400 STAT->SubIntensityOn();
401 TColStd_ListIteratorOfListOfInteger ItL;
402 for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
403 myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
406 myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj);
408 if(updateviewer) myMainVwr->Update();
411 //=======================================================================
412 //function : SubIntensityOff
414 //=======================================================================
416 void AIS_InteractiveContext::
417 SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
418 const Standard_Boolean updateviewer)
420 if(!HasOpenedContext()){
421 if(!myObjects.IsBound(anIObj))
423 const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj);
424 if(!GB->IsSubIntensityOn())
426 GB->SubIntensityOff();
427 Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False);
429 for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){
430 if(GB->GraphicStatus()!=AIS_DS_Erased){
431 myMainPM->Unhighlight(anIObj,It.Value());
432 UpdMain = Standard_True;}
434 myCollectorPM->Unhighlight(anIObj,It.Value());
435 UpdColl=Standard_True;
439 Standard_Integer DM,HM,SM;
440 GetDefModes(anIObj,DM,HM,SM);
441 if(AIS_Selection::IsSelected(anIObj))
442 myMainPM->Highlight(anIObj,HM);
448 myCollectorVwr->Update();
452 if(myObjects.IsBound(anIObj)){
453 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
454 STAT->SubIntensityOff();
455 TColStd_ListIteratorOfListOfInteger ItL;
456 for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
457 myMainPM->Unhighlight(anIObj,ItL.Value());
458 if(STAT->IsHilighted())
462 myLocalContexts(myCurLocalIndex)->SubIntensityOff(anIObj);
463 if(IsSelected(anIObj))
466 if(updateviewer) myMainVwr->Update();
470 //=======================================================================
471 //function : SubIntensityOn
472 //purpose : ALL THE DISPLAYED OBJECTS HAVE SUBINTENSITY...
473 //=======================================================================
475 void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer)
477 if(!HasOpenedContext()) return;
479 AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
480 TColStd_ListIteratorOfListOfInteger ItM;
481 for(;It.More();It.Next()){
482 const Handle(AIS_GlobalStatus)& STAT = It.Value();
483 if(STAT->GraphicStatus()==AIS_DS_Displayed)
485 STAT->SubIntensityOn();
486 for(ItM.Initialize(STAT->DisplayedModes());ItM.More();ItM.Next())
487 {myMainPM->Color(It.Key(),mySubIntensity,ItM.Value());}
490 if(updateviewer) myMainVwr->Update();
493 //=======================================================================
494 //function : SubIntensityOff
496 //=======================================================================
497 void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer)
499 if(!HasOpenedContext()) return;
501 AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
502 TColStd_ListIteratorOfListOfInteger ItL;
503 for(;It.More();It.Next()){
504 const Handle(AIS_GlobalStatus)& STAT = It.Value();
505 if(STAT->IsSubIntensityOn())
506 STAT->SubIntensityOff();
507 for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
508 myMainPM->Unhighlight(It.Key());
511 if(updateviewer) myMainVwr->Update();
514 //=======================================================================
515 //function : AddFilter
517 //=======================================================================
518 void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter)
520 if(HasOpenedContext())
521 myLocalContexts(myCurLocalIndex)->AddFilter(aFilter);
523 myFilters->Add(aFilter);
526 //=======================================================================
527 //function : ActivateStandardMode
529 //=======================================================================
530 void AIS_InteractiveContext::ActivateStandardMode(const TopAbs_ShapeEnum aStandardActivation)
532 if(!HasOpenedContext()) return;
533 myLocalContexts(myCurLocalIndex)->ActivateStandardMode (aStandardActivation);
536 //=======================================================================
537 //function : DeActivateStandardMode
539 //=======================================================================
540 void AIS_InteractiveContext::DeactivateStandardMode(const TopAbs_ShapeEnum aStandardActivation)
542 if(!HasOpenedContext()) return;
543 myLocalContexts(myCurLocalIndex)->DeactivateStandardMode (aStandardActivation);
546 //=======================================================================
547 //function : RemoveFilter
549 //=======================================================================
550 void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
552 if(HasOpenedContext())
553 myLocalContexts(myCurLocalIndex)->RemoveFilter (aFilter);
555 myFilters->Remove(aFilter);
558 //=======================================================================
559 //function : RemoveFilters
561 //=======================================================================
563 void AIS_InteractiveContext::RemoveFilters()
565 if(!HasOpenedContext())
568 myLocalContexts(myCurLocalIndex)->Clear(AIS_CM_Filters);
571 //=======================================================================
572 //function : ActivatedStandardModes
574 //=======================================================================
575 const TColStd_ListOfInteger& AIS_InteractiveContext::ActivatedStandardModes() const
577 return myLocalContexts(myCurLocalIndex)->StandardModes();
580 //=======================================================================
583 //=======================================================================
584 const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const
586 if(HasOpenedContext())
587 return myLocalContexts(myCurLocalIndex)->ListOfFilter();
588 return myFilters->StoredFilters();
591 //=======================================================================
592 //function : DisplayActiveAreas
594 //=======================================================================
595 void AIS_InteractiveContext::DisplayActiveAreas(const Handle(V3d_View)& aviou)
597 if(HasOpenedContext())
598 myLocalContexts(myCurLocalIndex)->DisplayAreas(aviou);
600 myMainSel->DisplayAreas(aviou);
604 //=======================================================================
605 //function : ClearActiveAreas
607 //=======================================================================
608 void AIS_InteractiveContext::ClearActiveAreas(const Handle(V3d_View)& aviou)
610 if(HasOpenedContext())
611 myLocalContexts(myCurLocalIndex)->ClearAreas(aviou);
613 myMainSel->ClearAreas(aviou);
616 //=======================================================================
617 //function : DisplayActiveSensitive
619 //=======================================================================
620 void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& aviou)
622 if(HasOpenedContext())
623 myLocalContexts(myCurLocalIndex)->DisplaySensitive(aviou);
625 myMainSel->DisplaySensitive(aviou);
627 //=======================================================================
628 //function : DisplayActiveSensitive
630 //=======================================================================
632 void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(AIS_InteractiveObject)& anIObj,
633 const Handle(V3d_View)& aviou)
635 TColStd_ListIteratorOfListOfInteger It;
636 Handle(StdSelect_ViewerSelector3d) VS;
637 if(HasOpenedContext()){
638 const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
639 if(!LC->IsIn(anIObj)) return;
640 It.Initialize(LC->SelectionModes(anIObj));
641 VS = LC->MainSelector();
644 if(!myObjects.IsBound(anIObj)) return;
645 It.Initialize(myObjects(anIObj)->SelectionModes());
650 for(;It.More();It.Next()){
651 const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value());
652 VS->DisplaySensitive(Sel,aviou,Standard_False);
657 //=======================================================================
658 //function : DisplayActiveAreas
660 //=======================================================================
662 void AIS_InteractiveContext::DisplayActiveAreas(const Handle(AIS_InteractiveObject)& anIObj,
663 const Handle(V3d_View)& aviou)
665 TColStd_ListIteratorOfListOfInteger It;
666 Handle(StdSelect_ViewerSelector3d) VS;
667 if(HasOpenedContext()){
668 const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
669 if(!LC->IsIn(anIObj)) return;
670 It.Initialize(LC->SelectionModes(anIObj));
671 VS = LC->MainSelector();
674 if(!myObjects.IsBound(anIObj)) return;
675 It.Initialize(myObjects(anIObj)->SelectionModes());
680 for(;It.More();It.Next()){
681 const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value());
682 VS->DisplayAreas(Sel,aviou,Standard_False);
687 //=======================================================================
688 //function : ClearActiveSensitive
690 //=======================================================================
691 void AIS_InteractiveContext::ClearActiveSensitive(const Handle(V3d_View)& aviou)
694 if(HasOpenedContext())
695 myLocalContexts(myCurLocalIndex)->ClearSensitive(aviou);
697 myMainSel->ClearSensitive(aviou);
700 //=======================================================================
701 //function : SetAutomaticHilight
703 //=======================================================================
704 void AIS_InteractiveContext::SetAutomaticHilight(const Standard_Boolean aStatus)
707 if(HasOpenedContext())
708 myLocalContexts(myCurLocalIndex)->SetAutomaticHilight(aStatus);
711 //=======================================================================
712 //function : AutomaticHilight
714 //=======================================================================
715 Standard_Boolean AIS_InteractiveContext::AutomaticHilight() const
717 if(HasOpenedContext())
718 return myLocalContexts(myCurLocalIndex)->AutomaticHilight();
719 return Standard_True;
722 //=======================================================================
723 //function : UseDisplayedObjects
725 //=======================================================================
727 void AIS_InteractiveContext::UseDisplayedObjects()
729 if(HasOpenedContext())
730 myLocalContexts(myCurLocalIndex)->LoadContextObjects();
733 //=======================================================================
734 //function : NotUseDisplayedObjects
736 //=======================================================================
738 void AIS_InteractiveContext::NotUseDisplayedObjects()
740 if(HasOpenedContext())
741 myLocalContexts(myCurLocalIndex)->UnloadContextObjects();
747 //=======================================================================
748 //function : PurgeDisplay
750 //=======================================================================
752 Standard_Integer AIS_InteractiveContext::PurgeDisplay(const Standard_Boolean CollectorToo)
754 if(HasOpenedContext()) return 0;
756 Standard_Integer NbStr = PurgeViewer(myMainVwr);
757 if(!myCollectorVwr.IsNull())
759 NbStr+=PurgeViewer(myCollectorVwr);
760 if(!IsCollectorClosed())
761 myCollectorVwr->Update();
769 //=======================================================================
770 //function : PurgeViewer
772 //=======================================================================
773 Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& Vwr)
775 const Handle(Graphic3d_StructureManager)& GSM = Vwr->Viewer();
776 Standard_Integer NbCleared(0);
777 Graphic3d_MapOfStructure SOS;
778 GSM->DisplayedStructures(SOS);
780 Handle(Graphic3d_Structure) G;
781 for(Graphic3d_MapIteratorOfMapOfStructure It(SOS); It.More();It.Next()){
783 Standard_Address Add = G->Owner();
786 G->Clear();// it means that it is not referenced as a presentation of InterfactiveObject...
789 Handle(AIS_InteractiveObject) IO = (AIS_InteractiveObject*)Add;
790 if(!myObjects.IsBound(IO)){
799 //=======================================================================
800 //function : IsImmediateModeOn
802 //=======================================================================
803 Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const
805 if(!HasOpenedContext()) return Standard_False;
806 return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn();
809 Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
811 if(HasOpenedContext())
812 return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw();
813 return Standard_False;
816 //=======================================================================
817 //function : ImmediateAdd
819 //=======================================================================
821 Standard_Boolean AIS_InteractiveContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj,
822 const Standard_Integer AMode)
824 if(HasOpenedContext()){
825 return myLocalContexts(myCurLocalIndex)->ImmediateAdd(anIObj,AMode);}
826 return Standard_False;
829 //=======================================================================
830 //function : ImmediateRemove
832 //=======================================================================
834 Standard_Boolean AIS_InteractiveContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj,
835 const Standard_Integer aMode)
837 if(HasOpenedContext())
838 return myLocalContexts(myCurLocalIndex)->ImmediateRemove(anIObj,aMode);
839 return Standard_False;
842 //=======================================================================
843 //function : EndImmediateDraw
845 //=======================================================================
847 Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Handle(V3d_View)& aView,
848 const Standard_Boolean DoubleBuf)
850 if(HasOpenedContext())
851 return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(aView,DoubleBuf);
852 return Standard_False;
856 //=======================================================================
857 //function : EndImmediateDraw
859 //=======================================================================
861 Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Standard_Boolean DoubleBuf)
863 if(HasOpenedContext()){
865 myMainVwr->InitActiveViews();
866 if(myMainVwr->MoreActiveViews()){
867 V = myMainVwr->ActiveView();
869 return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(V,DoubleBuf);
872 return Standard_False;
877 //=======================================================================
878 //function : ResetOriginalState
880 //=======================================================================
882 void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updateviewer)
884 Standard_Boolean upd_main(Standard_False),upd_col(Standard_False);
885 TColStd_ListIteratorOfListOfInteger itl;
887 for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){
888 const Handle(AIS_InteractiveObject)& iobj = it.Key();
889 const Handle(AIS_GlobalStatus)& STAT = it.Value();
890 switch(STAT->GraphicStatus()){
891 case AIS_DS_Displayed:{
892 upd_main = Standard_True;
895 for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next())
896 myMainPM->Display(iobj,itl.Value());
897 if(STAT->IsHilighted()){
898 if(STAT->HilightColor()!=Quantity_NOC_WHITE)
899 HilightWithColor(iobj,STAT->HilightColor(),Standard_False);
901 Hilight(iobj,Standard_False);
904 for(itl.Initialize(STAT->SelectionModes());itl.More();itl.Next()){
906 mgrSelector->Activate(iobj,itl.Value(),myMainSel);
911 upd_col = Standard_True;
912 EraseGlobal(iobj,Standard_False,Standard_True);
915 case AIS_DS_FullErased:{
916 EraseGlobal(iobj,Standard_False,Standard_False);
927 myCollectorVwr->Update();
932 //=======================================================================
933 //function : SetZDetection
935 //=======================================================================
936 void AIS_InteractiveContext::SetZDetection(const Standard_Boolean aStatus)
938 myZDetectionFlag = aStatus;
941 //=======================================================================
942 //function : ZDetection
944 //=======================================================================
945 Standard_Boolean AIS_InteractiveContext::ZDetection() const
947 return myZDetectionFlag;