1 // Created on: 1997-01-17
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
19 #define BUC60577 //GG_101099 Enable to compute correctly
20 // transparency with more than one object in the view.
22 #define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
23 // method, compute only authorized presentation.
25 #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods.
27 #define BUC60722 //GG 04/09/00 Always enable viewer update when erasing something
29 #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
31 #define OCC172 //SAV clear static map before destroying context.
33 #define OCC204 //SAV 26/02/02 : pass <updateviewer> flag to
34 // AddOrRemoveCurrentObject method from ClearGlobal.
36 #define OCC4373 //SAN 10/11/03 : improve display mode management in
37 // Display( IO, updateviewer ) and
38 // SetDisplayMode( IO, mode, updateviewer ) methods
40 #include <AIS_InteractiveContext.ixx>
42 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
43 #include <TColStd_ListIteratorOfListOfInteger.hxx>
44 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
45 #include <AIS_LocalContext.hxx>
46 #include <AIS_LocalStatus.hxx>
47 #include <Precision.hxx>
48 #include <AIS_Selection.hxx>
49 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
50 #include <AIS_ConnectedShape.hxx>
51 #include <AIS_MultipleConnectedShape.hxx>
52 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
53 #include <AIS_GlobalStatus.hxx>
54 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
55 #include <PrsMgr_ModedPresentation.hxx>
56 #include <Visual3d_ViewManager.hxx>
57 #include <Prs3d_ShadingAspect.hxx>
58 #include <AIS_Shape.hxx>
59 #include <Graphic3d_AspectFillArea3d.hxx>
60 #include <HLRBRep.hxx>
61 #include <Prs3d_IsoAspect.hxx>
62 #include <Prs3d_DatumAspect.hxx>
63 #include <Prs3d_PlaneAspect.hxx>
64 #include <PrsMgr_PresentableObject.hxx>
65 #include <Standard_Atomic.hxx>
66 #include <UnitsAPI.hxx>
68 #include <AIS_Trihedron.hxx>
69 #include <Geom_Axis2Placement.hxx>
70 #include <OSD_Environment.hxx>
72 #include <AIS_ListIteratorOfListOfInteractive.hxx>
74 // In the method GetDefModes() the returned value of the selection mode
75 // is always equal to 0 if it is -1.
78 // The local context is closed the method ::ResetOriginalState() sets the selection mode equal to 0
79 // in spite of the selection mode of the interactive object in Natural Point.
82 static Standard_Boolean AISDebugModeOn()
84 // static OSD_Environment aisdb("AISDEBUGMODE");
85 // return !aisdb.Value().IsEmpty();
86 static Standard_Integer isDebugMode(-1);
87 if (isDebugMode < 0) {
89 OSD_Environment aisdb("AISDEBUGMODE");
90 if (aisdb.Value().IsEmpty())
93 return (isDebugMode != 0);
98 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
99 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
101 static TCollection_AsciiString AIS_Context_NewSelName()
103 return TCollection_AsciiString ("AIS_SelContext_")
104 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
107 static TCollection_AsciiString AIS_Context_NewCurName()
109 return TCollection_AsciiString ("AIS_CurContext_")
110 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
114 //=======================================================================
115 //function : AIS_InteractiveContext
117 //=======================================================================
119 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
120 mgrSelector(new SelectMgr_SelectionManager()),
121 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
122 myMainVwr(MainViewer),
123 myMainSel(new StdSelect_ViewerSelector3d()),
124 myToHilightSelected( Standard_False ),
125 myFilters(new SelectMgr_OrFilter()),
126 myDefaultDrawer(new Prs3d_Drawer()),
127 myDefaultColor(Quantity_NOC_GOLDENROD),
128 myHilightColor(Quantity_NOC_CYAN1),
129 mySelectionColor(Quantity_NOC_GRAY80),
130 myPreselectionColor(Quantity_NOC_GREEN),
131 mySubIntensity(Quantity_NOC_GRAY40),
137 myIsAutoActivateSelMode( Standard_True )
142 void AIS_InteractiveContext::Delete() const
144 //Clear the static current selection. Else the memory
146 AIS_Selection::ClearCurrentSelection();
148 // to avoid an exception
149 if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
150 AIS_Selection::Remove( mySelectionName.ToCString() );
152 // to avoid an exception
153 if ( AIS_Selection::Find( myCurrentName.ToCString() ) )
154 AIS_Selection::Remove( myCurrentName.ToCString() );
156 // let's remove one reference explicitly. this operation's supposed to
157 // be performed when mgrSelector will be destroyed but anyway...
158 mgrSelector->Remove( myMainSel );
160 AIS_ListOfInteractive aList;
162 AIS_DataMapIteratorOfDataMapOfIOStatus anIt(myObjects);
163 Handle(AIS_InteractiveContext) aNullContext;
164 for(; anIt.More() ; anIt.Next())
166 Handle(AIS_InteractiveObject) anObj = anIt.Key();
167 anObj->SetContext(aNullContext);
170 MMgt_TShared::Delete();
173 //=======================================================================
174 //function : AIS_SelectionName
176 //=======================================================================
177 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
179 if(!HasOpenedContext())
180 return mySelectionName;
181 return myLocalContexts(myCurLocalIndex)->SelectionName();
187 //=======================================================================
188 //function : UpdateCurrentViewer
190 //=======================================================================
192 void AIS_InteractiveContext::UpdateCurrentViewer()
194 if (!myMainVwr.IsNull())
199 //=======================================================================
200 //function : DomainOfMainViewer
202 //=======================================================================
204 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
206 return myMainVwr->Domain();
210 //=======================================================================
211 //function : DisplayedObjects
213 //=======================================================================
215 void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
216 const Standard_Boolean OnlyFromNeutral) const
219 cout<<"AIS_IC::DisplayedObjects"<<endl;
222 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
223 if(!HasOpenedContext() || OnlyFromNeutral){
224 for(;It.More();It.Next()){
225 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
226 aListOfIO.Append(It.Key());
230 TColStd_MapOfTransient theMap;
232 for(;It.More();It.Next()){
233 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
234 theMap.Add(It.Key());
237 cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl;
240 //parse all local contexts...
241 Standard_Integer NbDisp;
242 for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
243 const Handle(AIS_LocalContext)& LC = it1.Value();
244 NbDisp = LC->DisplayedObjects(theMap);
246 cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
250 Handle(AIS_InteractiveObject) curIO;
251 Handle(Standard_Transient) Tr;
252 for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
254 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
255 aListOfIO.Append(curIO);
259 //=======================================================================
260 //function : DisplayedObjects
262 //=======================================================================
264 void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
265 const Standard_Integer TheSign,
266 AIS_ListOfInteractive& aListOfIO,
267 const Standard_Boolean /*OnlyFromNeutral*/) const
269 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
272 //=======================================================================
273 //function : ErasedObjects
275 //=======================================================================
277 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const
279 ObjectsByDisplayStatus( AIS_DS_Erased, theListOfIO );
282 //=======================================================================
283 //function : ErasedObjects
285 //=======================================================================
287 void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
288 const Standard_Integer TheSign,
289 AIS_ListOfInteractive& theListOfIO) const
291 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, theListOfIO );
294 //=======================================================================
295 //function : ObjectsByDisplayStatus
297 //=======================================================================
299 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
300 AIS_ListOfInteractive& theListOfIO) const
302 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
303 for(;It.More();It.Next()){
304 if(It.Value()->GraphicStatus() == theStatus)
305 theListOfIO.Append(It.Key());
309 //=======================================================================
310 //function : ObjectsByDisplayStatus
312 //=======================================================================
314 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
315 const Standard_Integer TheSign,
316 const AIS_DisplayStatus theStatus,
317 AIS_ListOfInteractive& theListOfIO) const
319 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
320 for(;It.More();It.Next()){
321 if(It.Value()->GraphicStatus()==theStatus){
322 if(It.Key()->Type()==TheKind){
324 theListOfIO.Append(It.Key());
326 if(It.Key()->Signature()==TheSign)
327 theListOfIO.Append(It.Key());
334 //=======================================================================
335 //function : ObjectsInside
337 //=======================================================================
339 void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
340 const AIS_KindOfInteractive TheKind,
341 const Standard_Integer TheSign) const
343 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
344 if(TheKind==AIS_KOI_None && TheSign ==-1){
345 for(;It.More();It.Next()){
346 aListOfIO.Append(It.Key());
350 for(;It.More();It.Next()){
351 if(It.Key()->Type()==TheKind){
353 aListOfIO.Append(It.Key());
355 if(It.Key()->Signature()==TheSign)
356 aListOfIO.Append(It.Key());
363 //=======================================================================
366 //=======================================================================
368 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
369 const Standard_Boolean updateviewer )
371 if(anIObj.IsNull()) return;
373 Standard_Integer DispMode,HiMod,SelMode;
375 GetDefModes(anIObj,DispMode,HiMod,SelMode);
377 Handle (AIS_InteractiveContext) aThis = this;
378 if(!anIObj->HasInteractiveContext())
379 anIObj->SetContext(aThis);
381 //NO LOCAL CONTEXT OPEN
382 if(!HasOpenedContext()) {
384 // SAN : Do not return here. Perform advanced display mode analysis a bit later...
385 if(IsDisplayed(anIObj)) return;
388 // it did not yet exist
389 if(!myObjects.IsBound(anIObj)){
391 Handle(AIS_GlobalStatus) STATUS=
393 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
395 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
397 myObjects.Bind (anIObj,STATUS);
398 myMainPM->Display(anIObj,DispMode);
399 if( myIsAutoActivateSelMode )
401 if(!mgrSelector->Contains(anIObj))
402 mgrSelector->Load(anIObj);
403 mgrSelector->Activate(anIObj,SelMode,myMainSel);
406 if(updateviewer) myMainVwr->Update();
408 // it is somewhere else...
411 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
412 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
414 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
416 // SAN : erase presentations for all display modes different from <DispMode>;
417 // then make sure <DispMode> is displayed and maybe highlighted;
418 // Finally, activate selection mode <SelMode> if not yet activated.
419 TColStd_ListOfInteger aModesToRemove;
420 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
421 for(;ItL.More();ItL.Next()){
423 Standard_Integer OldMode = ItL.Value();
425 if(OldMode!=DispMode){
426 aModesToRemove.Append(OldMode);
427 if(myMainPM->IsHighlighted(anIObj,OldMode))
428 myMainPM->Unhighlight(anIObj,OldMode);
429 myMainPM->Erase(anIObj,OldMode);
433 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
434 STATUS->RemoveDisplayMode(ItL.Value());
436 if(!STATUS->IsDModeIn(DispMode))
437 STATUS->AddDisplayMode(DispMode);
439 myMainPM->Display(anIObj,DispMode);
440 if (STATUS->GraphicStatus() == AIS_DS_Erased)
442 STATUS->SetGraphicStatus(AIS_DS_Displayed);
444 if(STATUS->IsHilighted()){
445 myMainPM->Highlight(anIObj,HiMod);
447 if( myIsAutoActivateSelMode )
449 if(!mgrSelector->Contains(anIObj))
450 mgrSelector->Load(anIObj);
451 if(!mgrSelector->IsActivated(anIObj,SelMode))
452 mgrSelector->Activate(anIObj,SelMode,myMainSel);
457 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
458 myMainVwr->Viewer()->SetTransparency(Standard_True);
459 if(updateviewer) myMainVwr->Update();
462 // LOCAL CONTEXT OPEN
465 myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
467 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
468 myMainVwr->Viewer()->SetTransparency(Standard_True);
471 if(updateviewer) myMainVwr->Update();
475 //=======================================================================
478 //=======================================================================
480 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
481 const Standard_Integer aDisplayMode,
482 const Standard_Integer aSelectionMode,
483 const Standard_Boolean updateviewer,
484 const Standard_Boolean allowdecomposition)
486 if(anIObj.IsNull()) return;
488 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
490 // if no local context...
491 if(!HasOpenedContext()) {
492 // if(!anIObj->HasDisplayMode())
493 // anIObj->SetDisplayMode(aDisplayMode);
495 if(!myObjects.IsBound(anIObj)){
496 Handle(AIS_GlobalStatus) STATUS=
497 new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
498 myObjects.Bind (anIObj,STATUS);
499 myMainPM->Display(anIObj,aDisplayMode);
500 if(aSelectionMode!=-1){
501 if(!mgrSelector->Contains(anIObj))
502 mgrSelector->Load(anIObj,aSelectionMode);
503 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
505 if(updateviewer) myMainVwr->Update();
507 // anIObj->SelectionMode(aSelectionMode);
510 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
511 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
513 if(!STATUS->IsDModeIn(aDisplayMode)){
514 myMainPM->Display(anIObj,aDisplayMode);
515 STATUS->AddDisplayMode(aDisplayMode);
516 if(STATUS->IsSubIntensityOn())
517 myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
519 if(aSelectionMode!=-1){
520 STATUS->AddSelectionMode(aSelectionMode);
521 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
523 if(updateviewer) myMainVwr->Update();
529 myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
530 if(updateviewer) myMainVwr->Update();
535 //=======================================================================
538 //=======================================================================
540 void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
541 const Standard_Integer SelMode,
542 const Standard_Boolean AllowDecomposition)
544 if(anIObj.IsNull()) return;
545 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
548 if(!HasOpenedContext()) {
549 if(SelMode==-1 && !AllowDecomposition){
550 Standard_Integer DispMode,HiMod,SelModeDef;
552 GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
553 Handle(AIS_GlobalStatus) STATUS=
554 new AIS_GlobalStatus(AIS_DS_Erased,DispMode,SelModeDef);
555 myObjects.Bind (anIObj,STATUS);
559 myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
563 //=======================================================================
566 //=======================================================================
568 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
569 const Standard_Boolean updateviewer)
571 if(anIObj.IsNull()) return;
573 if ( !anIObj->IsAutoHilight() )
574 anIObj->ClearSelected();
576 if(!HasOpenedContext()){
577 EraseGlobal(anIObj,updateviewer);
581 // First it is checked if it is possible to remove in the current local context
582 // then one tries to remove in other local contexts, if they allow it...
584 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
586 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
587 for (;It.More();It.Next()){
588 if(It.Value()->AcceptErase())
590 WasInCtx |= It.Value()->Erase(anIObj);
592 WasInCtx = It.Value()->Erase(anIObj);
597 EraseGlobal(anIObj,updateviewer);
599 if(updateviewer) myMainVwr->Update();
603 //=======================================================================
604 //function : EraseAll
606 //=======================================================================
608 void AIS_InteractiveContext::EraseAll(const Standard_Boolean updateviewer)
610 if(!HasOpenedContext())
612 for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); ItM.More(); ItM.Next())
614 if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
615 Erase(ItM.Key(),Standard_False);
624 //=======================================================================
625 //function : DisplayAll
627 //=======================================================================
629 void AIS_InteractiveContext::DisplayAll(const Standard_Boolean updateviewer)
631 if(!HasOpenedContext()){
633 AIS_DisplayStatus aStatus;
635 if (!HasOpenedContext())
637 for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM (myObjects); ItM.More(); ItM.Next())
639 aStatus = ItM.Value()->GraphicStatus();
640 if (aStatus == AIS_DS_Erased)
641 Display(ItM.Key(),Standard_False);
652 //=======================================================================
653 //function : DisplaySelected
655 //=======================================================================
657 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
660 if (!HasOpenedContext())
662 Standard_Boolean found = Standard_False;
663 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
664 Handle(AIS_InteractiveObject) iObj;
665 for (sel->Init(); sel->More(); sel->Next())
667 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
668 Display(iObj,Standard_False);
669 found = Standard_True;
671 if (found && updateviewer)
679 //=======================================================================
680 //function : EraseSelected
682 //=======================================================================
684 void AIS_InteractiveContext::EraseSelected(const Standard_Boolean updateviewer)
686 if (!HasOpenedContext())
688 Standard_Boolean found = Standard_False;
689 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
690 Handle(AIS_InteractiveObject) iObj;
691 for (sel->Init();sel->More();sel->Next())
693 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
694 Erase(iObj,Standard_False);
695 found = Standard_True;
697 if(found && updateviewer)
703 //=======================================================================
706 //=======================================================================
708 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
709 const Standard_Integer WhichContext)
711 if(anIObj.IsNull()) return Standard_False;
713 if(!HasOpenedContext()) return Standard_False;
714 if(myObjects.IsBound(anIObj)) return Standard_False;
715 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
717 // Protection : if one tries to preserve a temporary object
718 // which is not in the local active context... rob 11-06-97
720 Standard_Integer IsItInLocal = myCurLocalIndex;
721 Standard_Boolean Found(Standard_False);
723 while(IsItInLocal>0 && !Found){
724 if(!myLocalContexts.IsBound(IsItInLocal))
726 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
727 Found = Standard_True;
732 if(!Found) return Standard_False;
735 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
736 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
738 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
739 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
743 if(LS->IsTemporary()){
744 Standard_Integer DM,HM,SM;
745 GetDefModes(anIObj,DM,HM,SM);
747 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
748 if(LS->DisplayMode()!= DM ){
749 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
750 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
753 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
757 // GS->SubIntensityOn();
758 myObjects.Bind(anIObj,GS);
759 mgrSelector->Load(anIObj);
760 mgrSelector->Activate(anIObj,SM,myMainSel);
762 LS->SetTemporary(Standard_False);
764 return Standard_True;
768 //=======================================================================
770 //=======================================================================
772 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const
774 if(anIObj.IsNull()) return AIS_DS_None;
776 if(myObjects.IsBound(anIObj))
777 return myObjects(anIObj)->GraphicStatus();
779 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
780 for(;ItM.More();ItM.Next()){
781 if(ItM.Value()->IsIn(anIObj))
782 return AIS_DS_Temporary;
792 //=======================================================================
793 //function : DisplayedModes
795 //=======================================================================
797 const TColStd_ListOfInteger& AIS_InteractiveContext::
798 DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const
800 return myObjects(anIObj)->DisplayedModes();
804 //=======================================================================
807 //=======================================================================
808 void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
809 const Standard_Boolean updateviewer)
812 if(anIObj.IsNull()) return;
814 if(!HasOpenedContext()){
815 ClearGlobal(anIObj,updateviewer);
819 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
820 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
821 for (;It.More() ;It.Next()){
822 if(It.Value()->AcceptErase())
823 WasInCtx = It.Value()->Remove(anIObj);
827 ClearGlobal(anIObj,updateviewer);
829 // if(updateviewer) myMainVwr->Update();
833 //=======================================================================
834 //function : RemoveAll
836 //=======================================================================
837 void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
839 AIS_ListOfInteractive aList;
840 ObjectsInside(aList);
841 AIS_ListIteratorOfListOfInteractive aListIterator;
842 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
843 Remove(aListIterator.Value(), Standard_False);
850 //=======================================================================
853 //=======================================================================
855 void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
856 const Standard_Boolean updateviewer)
858 if(anIObj.IsNull()) return;
860 if(!HasOpenedContext()){
861 ClearGlobal(anIObj,updateviewer);
866 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
867 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
868 for (;It.More() ;It.Next()){
869 if(It.Value()->AcceptErase())
870 WasInCtx = It.Value()->Remove(anIObj);
874 ClearGlobal(anIObj,updateviewer);
876 if(updateviewer) myMainVwr->Update();
883 //=======================================================================
884 //function : ClearPrs
886 //=======================================================================
888 void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
889 const Standard_Integer aMode,
890 const Standard_Boolean updateviewer)
892 if(anIObj.IsNull()) return;
894 if(!HasOpenedContext()){
895 ClearGlobalPrs(anIObj,aMode,updateviewer);
899 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
900 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
901 for (;It.More() ;It.Next()){
902 if(It.Value()->AcceptErase())
903 WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
906 ClearGlobalPrs(anIObj,aMode,updateviewer);
908 if(updateviewer) myMainVwr->Update();
913 //=======================================================================
916 //=======================================================================
918 void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
919 const Standard_Boolean updateviewer)
921 if(anIObj.IsNull()) return;
923 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
924 if (!HasOpenedContext())
926 if(!myObjects.IsBound(anIObj)) return;
929 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
930 // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
931 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
934 STATUS->SetHilightStatus (Standard_True);
936 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
938 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
939 myMainPM->Highlight (anIObj, aHilightMode);
944 myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
947 if(updateviewer) myMainVwr->Update();
949 //=======================================================================
952 //=======================================================================
954 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
955 const Quantity_NameOfColor aCol,
956 const Standard_Boolean updateviewer)
958 if(anIObj.IsNull()) return;
960 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
962 if (!HasOpenedContext())
964 if(!myObjects.IsBound(anIObj)) return;
966 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
967 STATUS->SetHilightStatus (Standard_True);
969 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
971 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
972 myMainPM->Color (anIObj, aCol, aHilightMode);
973 STATUS->SetHilightColor (aCol);
978 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
980 if(updateviewer) myMainVwr->Update();
983 //=======================================================================
984 //function : Unhilight
986 //=======================================================================
988 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
990 if(anIObj.IsNull()) return;
992 if (!HasOpenedContext())
994 if(!myObjects.IsBound(anIObj)) return;
996 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
997 STATUS->SetHilightStatus (Standard_False);
998 STATUS->SetHilightColor(Quantity_NOC_WHITE);
1000 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
1002 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
1003 myMainPM->Unhighlight (anIObj, aHilightMode);
1008 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
1010 if(updateviewer) myMainVwr->Update();
1013 //=======================================================================
1014 //function : IsHilighted
1016 //=======================================================================
1018 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1020 if(anIObj.IsNull()) return Standard_False;
1022 if (!HasOpenedContext()){
1023 if(!myObjects.IsBound(anIObj))
1024 return Standard_False;
1025 return myObjects(anIObj)->IsHilighted();
1027 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1028 for(;ItM.More();ItM.Next()){
1029 if(ItM.Value()->IsHilighted(anIObj))
1030 return Standard_True;
1032 return Standard_False;
1035 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1036 Standard_Boolean& WithColor,
1037 Quantity_NameOfColor& TheHiCol) const
1039 if(!HasOpenedContext()){
1040 if(myObjects.IsBound(anIObj)){
1041 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1042 if(STAT->IsHilighted()){
1043 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1044 WithColor=Standard_True;
1045 TheHiCol = STAT->HilightColor();
1048 WithColor = Standard_False;
1049 return Standard_True;
1052 return Standard_False;
1054 Standard_Integer MaxIndex = HighestIndex();
1055 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1056 if(myLocalContexts.IsBound(i)){
1057 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1058 return Standard_True;
1062 return Standard_False;
1067 //=======================================================================
1068 //function : IsDisplayed
1070 //=======================================================================
1072 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1074 if(anIObj.IsNull()) return Standard_False;
1077 if(myObjects.IsBound(anIObj))
1078 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1079 return Standard_True;
1081 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1082 for(;ItM.More();ItM.Next()){
1083 if(ItM.Value()->IsDisplayed(anIObj))
1084 return Standard_True;
1086 return Standard_False;
1090 //=======================================================================
1091 //function : IsDisplayed
1093 //=======================================================================
1095 Standard_Boolean AIS_InteractiveContext::
1096 IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
1097 const Standard_Integer aMode) const
1099 if(anIObj.IsNull()) return Standard_False;
1100 if(myObjects.IsBound(anIObj)) {
1101 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
1102 myObjects(anIObj)->IsDModeIn(aMode))
1103 return Standard_True;
1106 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1107 for(;ItM.More();ItM.Next()){
1108 if(ItM.Value()->IsDisplayed(anIObj,aMode))
1109 return Standard_True;
1111 return Standard_False;
1115 //=======================================================================
1116 //function : DisplayPriority
1118 //=======================================================================
1120 Standard_Integer AIS_InteractiveContext::
1121 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const
1123 if(anIObj.IsNull()) return -1;
1125 if (myObjects.IsBound(anIObj))
1127 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1128 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
1130 Standard_Integer aDispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
1131 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
1132 return myMainPM->DisplayPriority (anIObj, aDispMode);
1137 //=======================================================================
1138 //function : SetDisplayPriority
1140 //=======================================================================
1142 void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
1143 const Standard_Integer aPriority)
1147 if(!anIObj->HasInteractiveContext())
1148 anIObj->SetContext(this);
1149 if(myObjects.IsBound(anIObj))
1151 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1153 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
1155 Standard_Integer aDisplayMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
1156 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
1157 myMainPM->SetDisplayPriority (anIObj, aDisplayMode, aPriority);
1160 else if (HasOpenedContext())
1162 myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);
1166 //=======================================================================
1167 //function : Redisplay
1169 //=======================================================================
1171 void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
1172 const Standard_Boolean updateviewer,
1173 const Standard_Boolean allmodes)
1175 if(AISDebugModeOn()){
1176 cout<<"===>AIS_InteractiveContext::Redisplay de :";
1177 cout<<anIObj->DynamicType()->Name()<<endl;
1180 RecomputePrsOnly(anIObj,updateviewer,allmodes);
1181 RecomputeSelectionOnly(anIObj);
1184 //=======================================================================
1185 //function : Redisplay
1187 //=======================================================================
1189 void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
1190 const Standard_Integer /*Sign*/,
1191 const Standard_Boolean updateviewer)
1193 Standard_Boolean found_viewer(Standard_False);
1195 for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
1197 // const Handle(AIS_InteractiveObject)& IO = It.Key();
1198 Handle(AIS_InteractiveObject) IO = It.Key();
1200 if(IO->Type()== KOI){
1202 // Standard_Boolean good = (Sign==-1)? Standard_True :
1203 // ((IO->Signature()==Sign)? Standard_True:Standard_False);
1205 Redisplay(IO,Standard_False);
1206 if (It.Value()->GraphicStatus() == AIS_DS_Displayed)
1208 found_viewer = Standard_True;
1213 if(updateviewer && found_viewer)
1215 myMainVwr->Update();
1220 //=======================================================================
1221 //function : RecomputePrsOnly
1223 //=======================================================================
1225 void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
1226 const Standard_Boolean updateviewer,
1227 const Standard_Boolean allmodes)
1229 if(anIObj.IsNull()) return;
1230 anIObj->Update(allmodes);
1237 if (HasOpenedContext() ||
1238 (myObjects.IsBound(anIObj) && myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed))
1240 myMainVwr->Update();
1243 //=======================================================================
1244 //function : RecomputeSelectionOnly
1246 //=======================================================================
1247 void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj)
1249 if(anIObj.IsNull()) return;
1250 mgrSelector->RecomputeSelection(anIObj);
1254 TColStd_ListOfInteger LI;
1255 TColStd_ListIteratorOfListOfInteger Lit;
1256 ActivatedModes(anIObj,LI);
1257 if(!HasOpenedContext()){
1258 if(!myObjects.IsBound(anIObj)) return;
1260 if (myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
1262 for(Lit.Initialize(LI);Lit.More();Lit.Next())
1264 mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
1270 //=======================================================================
1273 //=======================================================================
1275 void AIS_InteractiveContext::Update(const Handle(AIS_InteractiveObject)& anIObj,
1276 const Standard_Boolean updateviewer)
1278 if(anIObj.IsNull()) return;
1282 TColStd_ListOfInteger LL;
1283 anIObj->ToBeUpdated(LL);
1284 TColStd_ListIteratorOfListOfInteger ITI(LL);
1285 Standard_Boolean wasupdated(Standard_False);
1287 for (;ITI.More();ITI.Next()){
1288 anIObj->Update(ITI.Value(),Standard_False);
1289 wasupdated = Standard_True;
1293 mgrSelector->Update(anIObj);
1296 if(!myObjects.IsBound(anIObj)) return;
1297 switch(myObjects(anIObj)->GraphicStatus()){
1298 case AIS_DS_Displayed:
1299 case AIS_DS_Temporary:
1300 myMainVwr->Update();
1310 //=======================================================================
1311 //function : SetLocation
1313 //=======================================================================
1315 void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
1316 const TopLoc_Location& aLoc)
1318 if(anIObj.IsNull()) return;
1321 if(anIObj->HasLocation() && aLoc.IsIdentity()){
1322 anIObj->ResetLocation();
1323 mgrSelector->Update(anIObj,Standard_False);
1326 if(aLoc.IsIdentity()) return ;
1328 // first reset the previous location to properly clean everything...
1329 if(anIObj->HasLocation())
1330 anIObj->ResetLocation();
1333 anIObj->SetLocation(aLoc);
1335 if(!HasOpenedContext())
1336 mgrSelector->Update(anIObj,Standard_False);
1340 // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1341 Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1343 mgrSelector->Update(anIObj,tempSel,Standard_False);
1346 //=======================================================================
1347 //function : ResetLocation
1349 //=======================================================================
1350 void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
1352 if(anIObj.IsNull()) return;
1354 anIObj->ResetLocation();
1355 mgrSelector->Update(anIObj,Standard_False);
1358 //=======================================================================
1359 //function : HasLocation
1361 //=======================================================================
1363 Standard_Boolean AIS_InteractiveContext::
1364 HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
1366 if(anIObj.IsNull()) return Standard_False;
1368 return anIObj->HasLocation();
1371 const TopLoc_Location& AIS_InteractiveContext::
1372 Location(const Handle(AIS_InteractiveObject)& anIObj) const
1374 return anIObj->Location();
1377 //=======================================================================
1378 //function : SetDeviationCoefficient
1380 //=======================================================================
1382 void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
1384 myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
1386 //=======================================================================
1387 //function : SetDeviationAngle
1389 //=======================================================================
1391 void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
1393 myDefaultDrawer->SetDeviationCoefficient(anAngle);
1396 //=======================================================================
1397 //function : DeviationAngle
1398 //purpose : Gets deviationAngle
1399 //=======================================================================
1401 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1403 //return M_PI/180.0e0 ;
1404 return myDefaultDrawer->DeviationAngle();
1407 //=======================================================================
1408 //function : DeviationCoefficient
1410 //=======================================================================
1412 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1414 return myDefaultDrawer->DeviationCoefficient();
1416 //=======================================================================
1417 //function : SetHLRDeviationCoefficient
1419 //=======================================================================
1421 void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
1423 myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
1426 //=======================================================================
1427 //function : HLRDeviationCoefficient
1429 //=======================================================================
1431 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1433 return myDefaultDrawer->HLRDeviationCoefficient();
1436 //=======================================================================
1437 //function : SetHLRAngle
1439 //=======================================================================
1441 void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
1443 myDefaultDrawer->SetHLRAngle(anAngle);
1446 //=======================================================================
1447 //function : SetHLRAngleAndDeviation
1448 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1449 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1450 // of myDefaultDrawer
1451 //=======================================================================
1453 void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
1456 Standard_Real OutAngl,OutDefl;
1457 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1459 myDefaultDrawer->SetHLRAngle(OutAngl);
1460 myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
1464 //=======================================================================
1465 //function : HLRAngle
1467 //=======================================================================
1469 Standard_Real AIS_InteractiveContext::HLRAngle() const
1471 return myDefaultDrawer->HLRAngle();
1474 //=======================================================================
1475 //function : SetDisplayMode
1477 //=======================================================================
1479 void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
1480 const Standard_Boolean updateviewer)
1482 if(aMode==myDisplayMode) return;
1483 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
1485 for(;It.More();It.Next()){
1487 // const Handle(AIS_InteractiveObject)& anObj = It.Key();
1488 Handle(AIS_InteractiveObject) anObj = It.Key();
1490 Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
1491 anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) ||
1492 anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) );
1494 if ((!anObj->HasDisplayMode()) && Processed)
1496 if(anObj->AcceptDisplayMode(aMode)){
1498 // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
1499 Handle(AIS_GlobalStatus) STATUS = It.Value();
1501 if(STATUS->IsDModeIn(myDisplayMode))
1502 STATUS->RemoveDisplayMode(myDisplayMode);
1504 STATUS->AddDisplayMode(aMode);
1506 if(STATUS->GraphicStatus()== AIS_DS_Displayed){
1507 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1508 myMainPM->Display(anObj, aMode);
1509 if(STATUS->IsSubIntensityOn())
1510 myMainPM->Color(anObj,mySubIntensity,aMode);
1512 // myDisplayMode = aMode;
1517 myDisplayMode = aMode;
1518 if(updateviewer) myMainVwr->Update();
1521 //=======================================================================
1522 //function : SetDisplayMode
1524 //=======================================================================
1526 void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1527 const Standard_Integer aMode,
1528 const Standard_Boolean updateviewer)
1531 if(!anIObj->HasInteractiveContext())
1532 anIObj->SetContext(this);
1533 if(!HasOpenedContext()){
1535 if(!myObjects.IsBound(anIObj))
1536 anIObj->SetDisplayMode(aMode);
1537 else if( anIObj->AcceptDisplayMode(aMode) )
1540 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1541 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1543 // SAN : erase presentations for all display modes different from <aMode>
1544 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1545 TColStd_ListOfInteger aModesToRemove;
1546 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
1547 for(;ItL.More();ItL.Next()){
1549 Standard_Integer OldMode = ItL.Value();
1552 aModesToRemove.Append(OldMode);
1553 if(myMainPM->IsHighlighted(anIObj,OldMode))
1554 myMainPM->Unhighlight(anIObj,OldMode);
1555 myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
1559 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
1560 STATUS->RemoveDisplayMode(ItL.Value());
1562 if(!STATUS->IsDModeIn(aMode))
1563 STATUS->AddDisplayMode(aMode);
1565 myMainPM->Display(anIObj,aMode);
1566 Standard_Integer DM,HM,SM;
1567 GetDefModes(anIObj,DM,HM,SM);
1568 if(STATUS->IsHilighted()){
1569 myMainPM->Highlight(anIObj,HM);
1571 if(STATUS->IsSubIntensityOn()){
1572 myMainPM->Color(anIObj,mySubIntensity,aMode);
1574 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
1575 myMainVwr->Viewer()->SetTransparency(Standard_True);
1577 if(updateviewer) myMainVwr->Update();
1579 anIObj->SetDisplayMode(aMode);
1584 //=======================================================================
1585 //function : UnsetDisplayMode
1587 //=======================================================================
1589 void AIS_InteractiveContext::
1590 UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1591 const Standard_Boolean updateviewer)
1593 if(anIObj.IsNull()) return ;
1594 if(!anIObj->HasDisplayMode()) return;
1596 if(!myObjects.IsBound(anIObj))
1597 anIObj->UnsetDisplayMode();
1600 Standard_Integer OldMode = anIObj->DisplayMode();
1601 if(myDisplayMode==OldMode) return;
1602 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1603 STATUS->RemoveDisplayMode(OldMode);
1604 if(!STATUS->IsDModeIn(myDisplayMode))
1605 STATUS->AddDisplayMode(myDisplayMode);
1606 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1607 if(myMainPM->IsHighlighted(anIObj,OldMode))
1608 myMainPM->Unhighlight(anIObj,OldMode);
1609 myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
1610 myMainPM->Display(anIObj,myDisplayMode);
1611 Standard_Integer DM,HM,SM;
1612 GetDefModes(anIObj,DM,HM,SM);
1613 if(STATUS->IsHilighted()){
1614 myMainPM->Highlight(anIObj,HM);
1616 if(STATUS->IsSubIntensityOn()){
1617 myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
1619 if(updateviewer) myMainVwr->Update();
1621 anIObj->UnsetDisplayMode();
1626 //=======================================================================
1627 //function : SetCurrentFacingModel
1629 //=======================================================================
1631 void AIS_InteractiveContext::SetCurrentFacingModel(
1632 const Handle(AIS_InteractiveObject)& anIObj,
1633 const Aspect_TypeOfFacingModel aModel)
1635 if ( !anIObj.IsNull () )
1636 anIObj->SetCurrentFacingModel(aModel);
1639 //=======================================================================
1640 //function : SetColor
1642 //=======================================================================
1644 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1645 const Quantity_NameOfColor aColor,
1646 const Standard_Boolean updateviewer)
1648 SetColor(anIObj,Quantity_Color(aColor),updateviewer);
1651 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1652 const Quantity_Color &aColor,
1653 const Standard_Boolean updateviewer)
1655 if(anIObj.IsNull()) return ;
1657 if(!anIObj->HasInteractiveContext())
1658 anIObj->SetContext(this);
1659 anIObj->SetColor(aColor);
1660 if(anIObj->RecomputeEveryPrs())
1661 anIObj->Redisplay();
1664 Standard_Integer NbDisp=0;
1665 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1666 for (;ITI.More();ITI.Next())
1668 anIObj->Update(ITI.Value(),Standard_False);
1671 anIObj->SetRecomputeOk();
1673 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1680 // if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
1681 // Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
1682 // Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
1684 // gp_Dir D =Tr->Component()->XDirection();
1685 // gp_Pnt O = Tr->Component()->Location();
1686 // gp_Vec V(D);V*=Lx/5.;
1687 // T.SetRotation(gp_Ax1(O,D),M_PI/6.);
1688 // T.SetTranslationPart(V);
1689 // TopLoc_Location L,IncLoc(T);
1691 // for(Standard_Integer I=1;I<90;I++){
1692 // if(anIObj->HasLocation())
1693 // L = anIObj->Location() * IncLoc;
1696 // SetLocation(anIObj,L);
1697 // UpdateCurrentViewer();
1699 // for(I=1;I<90;I++){
1700 // L = anIObj->Location() /IncLoc;
1701 // SetLocation(anIObj,L);
1702 // UpdateCurrentViewer();
1704 // ResetLocation(anIObj);
1707 if(updateviewer) UpdateCurrentViewer();
1710 //=======================================================================
1711 //function : SetDeviationCoefficient
1713 //=======================================================================
1715 void AIS_InteractiveContext::SetDeviationCoefficient(
1716 const Handle(AIS_InteractiveObject)& anIObj,
1717 const Standard_Real aCoefficient,
1718 const Standard_Boolean updateviewer)
1720 // cout<<" Coefficient:"<< aCoefficient <<endl;
1721 if(anIObj.IsNull()) return ;
1723 if(!anIObj->HasInteractiveContext())
1724 anIObj->SetContext(this);
1726 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1727 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
1728 if(anIObj->Signature()!=0) return;
1729 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
1733 if(anIObj->RecomputeEveryPrs())
1734 anIObj->Redisplay();
1737 Standard_Integer NbDisp=0;
1738 TColStd_ListOfInteger LL;
1739 anIObj->ToBeUpdated(LL);
1740 TColStd_ListIteratorOfListOfInteger ITI(LL);
1741 for (;ITI.More();ITI.Next())
1743 anIObj->Update(ITI.Value(),Standard_False);
1746 anIObj->SetRecomputeOk();
1748 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1751 if(updateviewer) UpdateCurrentViewer();
1754 //=======================================================================
1755 //function : SetHLRDeviationCoefficient
1757 //=======================================================================
1759 void AIS_InteractiveContext::SetHLRDeviationCoefficient(
1760 const Handle(AIS_InteractiveObject)& anIObj,
1761 const Standard_Real aCoefficient,
1762 const Standard_Boolean updateviewer)
1764 // cout<<" HLRCoefficient:"<< aCoefficient <<endl;
1765 if(anIObj.IsNull()) return ;
1767 if(!anIObj->HasInteractiveContext())
1768 anIObj->SetContext(this);
1769 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1770 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
1771 if(anIObj->Signature()!=0) return;
1772 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
1776 if(anIObj->RecomputeEveryPrs())
1777 anIObj->Redisplay();
1780 Standard_Integer NbDisp=0;
1782 TColStd_ListOfInteger LL;
1783 anIObj->ToBeUpdated(LL);
1784 TColStd_ListIteratorOfListOfInteger ITI(LL);
1785 for (;ITI.More();ITI.Next())
1787 anIObj->Update(ITI.Value(),Standard_False);
1790 anIObj->SetRecomputeOk();
1792 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1795 if(updateviewer) UpdateCurrentViewer();
1799 //=======================================================================
1800 //function : SetDeviationAngle
1802 //=======================================================================
1804 void AIS_InteractiveContext::SetDeviationAngle(
1805 const Handle(AIS_InteractiveObject)& anIObj,
1806 const Standard_Real anAngle,
1807 const Standard_Boolean updateviewer)
1809 // cout<<" Angle:"<< anAngle <<endl;
1810 if(anIObj.IsNull()) return ;
1812 if(!anIObj->HasInteractiveContext())
1813 anIObj->SetContext(this);
1814 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1815 if(anIObj->Type()!=AIS_KOI_Shape) return;
1816 if(anIObj->Signature()!=0) return;
1817 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
1820 if(anIObj->RecomputeEveryPrs())
1821 anIObj->Redisplay();
1824 Standard_Integer NbDisp=0;
1825 TColStd_ListOfInteger LL;
1826 anIObj->ToBeUpdated(LL);
1827 TColStd_ListIteratorOfListOfInteger ITI(LL);
1828 for (;ITI.More();ITI.Next())
1830 anIObj->Update(ITI.Value(),Standard_False);
1833 anIObj->SetRecomputeOk();
1835 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1838 if(updateviewer) UpdateCurrentViewer();
1840 //=======================================================================
1841 //function : SetDeviationAngle
1843 //=======================================================================
1845 void AIS_InteractiveContext::SetAngleAndDeviation(
1846 const Handle(AIS_InteractiveObject)& anIObj,
1847 const Standard_Real anAngle,
1848 const Standard_Boolean updateviewer)
1850 // cout<<" Angle:"<< anAngle <<endl;
1851 if(anIObj.IsNull()) return ;
1852 // Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
1853 if(!anIObj->HasInteractiveContext())
1854 anIObj->SetContext(this);
1856 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1857 if(anIObj->Type()!=AIS_KOI_Shape) return;
1858 if(anIObj->Signature()!=0) return;
1859 (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
1862 if(anIObj->RecomputeEveryPrs())
1863 anIObj->Redisplay();
1865 Update(anIObj,updateviewer);
1868 //=======================================================================
1869 //function : SetDeviationAngle
1871 //=======================================================================
1873 void AIS_InteractiveContext::SetHLRAngleAndDeviation(
1874 const Handle(AIS_InteractiveObject)& anIObj,
1875 const Standard_Real anAngle,
1876 const Standard_Boolean updateviewer)
1878 // cout<<" Angle:"<< anAngle <<endl;
1880 if(anIObj.IsNull()) return ;
1881 if(!anIObj->HasInteractiveContext())
1882 anIObj->SetContext(this);
1884 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1885 if(anIObj->Type()!=AIS_KOI_Shape) return;
1886 if(anIObj->Signature()!=0) return;
1887 (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
1890 if(anIObj->RecomputeEveryPrs())
1891 anIObj->Redisplay();
1894 Standard_Integer NbDisp=0;
1896 TColStd_ListOfInteger LL;
1897 anIObj->ToBeUpdated(LL);
1898 TColStd_ListIteratorOfListOfInteger ITI(LL);
1899 for (;ITI.More();ITI.Next())
1901 anIObj->Update(ITI.Value(),Standard_False);
1904 anIObj->SetRecomputeOk();
1906 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1909 if(updateviewer) UpdateCurrentViewer();
1912 //=======================================================================
1913 //function : SetHLRDeviationAngle
1915 //=======================================================================
1917 void AIS_InteractiveContext::SetHLRDeviationAngle(
1918 const Handle(AIS_InteractiveObject)& anIObj,
1919 const Standard_Real anAngle,
1920 const Standard_Boolean updateviewer)
1922 // cout<<" HLRAngle:"<< anAngle <<endl;
1923 if(anIObj.IsNull()) return ;
1925 if(!anIObj->HasInteractiveContext())
1926 anIObj->SetContext(this);
1927 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1928 if( anIObj->Type()!=AIS_KOI_Shape) return;
1929 if(anIObj->Signature()!=0) return;
1930 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
1933 if(anIObj->RecomputeEveryPrs())
1934 anIObj->Redisplay();
1937 Standard_Integer NbDisp=0;
1938 TColStd_ListOfInteger LL;
1939 anIObj->ToBeUpdated(LL);
1940 TColStd_ListIteratorOfListOfInteger ITI(LL);
1941 for (;ITI.More();ITI.Next())
1943 anIObj->Update(ITI.Value(),Standard_False);
1946 anIObj->SetRecomputeOk();
1948 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1951 if(updateviewer) UpdateCurrentViewer();
1954 //=======================================================================
1955 //function : UnsetColor
1957 //=======================================================================
1959 void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
1960 const Standard_Boolean updateviewer)
1962 if(anIObj.IsNull()) return ;
1963 anIObj->UnsetColor();
1964 if(anIObj->RecomputeEveryPrs())
1965 anIObj->Redisplay();
1968 Standard_Integer NbDisp =0;
1969 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1970 for (;ITI.More();ITI.Next())
1972 anIObj->Update(ITI.Value(),Standard_False);
1976 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1978 anIObj->SetRecomputeOk();
1981 UpdateCurrentViewer();
1984 //=======================================================================
1985 //function : HasColor
1987 //=======================================================================
1989 Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const
1991 return anIObj->HasColor();
1995 //=======================================================================
1998 //=======================================================================
2000 Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const
2002 return anIObj->Color();
2005 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
2006 Quantity_Color &aColor) const
2008 anIObj->Color(aColor);
2011 //=======================================================================
2014 //=======================================================================
2016 Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const
2018 return anIObj->Width();
2021 //=======================================================================
2022 //function : SetWidth
2024 //=======================================================================
2026 void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2027 const Standard_Real aValue,
2028 const Standard_Boolean updateviewer)
2030 if(anIObj.IsNull()) return ;
2032 if(!anIObj->HasInteractiveContext())
2033 anIObj->SetContext(this);
2034 anIObj->SetWidth(aValue);
2035 if(anIObj->RecomputeEveryPrs())
2036 anIObj->Redisplay();
2039 Standard_Integer NbDisp=0;
2040 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2041 for (;ITI.More();ITI.Next())
2043 anIObj->Update(ITI.Value(),Standard_False);
2047 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2049 anIObj->SetRecomputeOk();
2052 UpdateCurrentViewer();
2055 //=======================================================================
2056 //function : UnsetWidth
2058 //=======================================================================
2060 void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2061 const Standard_Boolean updateviewer)
2063 if(anIObj.IsNull()) return ;
2064 anIObj->UnsetWidth();
2065 if(anIObj->RecomputeEveryPrs())
2066 anIObj->Redisplay();
2069 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2070 for (;ITI.More();ITI.Next())
2072 anIObj->Update(ITI.Value(),Standard_False);
2074 anIObj->SetRecomputeOk();
2077 UpdateCurrentViewer();
2080 //=======================================================================
2081 //function : SetMaterial
2083 //=======================================================================
2085 void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2087 const Graphic3d_NameOfMaterial aName,
2088 // const Graphic3d_NameOfPhysicalMaterial aName,
2089 const Standard_Boolean updateviewer)
2091 if(!anIObj->HasInteractiveContext())
2092 anIObj->SetContext(this);
2093 anIObj->SetMaterial(aName);
2094 if(anIObj->RecomputeEveryPrs())
2095 anIObj->Redisplay();
2098 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2099 for (;ITI.More();ITI.Next())
2101 anIObj->Update(ITI.Value(),Standard_False);
2103 anIObj->SetRecomputeOk();
2106 UpdateCurrentViewer();
2110 //=======================================================================
2111 //function : UnsetMaterial
2113 //=======================================================================
2115 void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2116 const Standard_Boolean updateviewer)
2118 if(anIObj.IsNull()) return ;
2119 anIObj->UnsetMaterial();
2120 if(anIObj->RecomputeEveryPrs())
2121 anIObj->Redisplay();
2124 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2125 for (;ITI.More();ITI.Next())
2127 anIObj->Update(ITI.Value(),Standard_False);
2129 anIObj->SetRecomputeOk();
2132 UpdateCurrentViewer();
2135 //=======================================================================
2136 //function : SetTransparency
2138 //=======================================================================
2140 void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2141 const Standard_Real aValue,
2142 const Standard_Boolean updateviewer)
2144 if(anIObj.IsNull()) return ;
2145 if(!anIObj->HasInteractiveContext())
2146 anIObj->SetContext(this);
2148 #ifdef BUC60577 //right optimization
2149 if(!anIObj->IsTransparent() && aValue<=0.05) return;
2151 // if(!anIObj->IsTransparent() && aValue<=0.05) return;
2154 UnsetTransparency(anIObj,updateviewer);
2158 if(!myMainVwr->Viewer()->Transparency())
2159 myMainVwr->Viewer()->SetTransparency(Standard_True);
2160 anIObj->SetTransparency(aValue);
2161 if(anIObj->RecomputeEveryPrs())
2162 anIObj->Redisplay();
2165 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2166 for (;ITI.More();ITI.Next())
2168 anIObj->Update(ITI.Value(),Standard_False);
2170 anIObj->SetRecomputeOk();
2173 UpdateCurrentViewer();
2176 //=======================================================================
2177 //function : UnsetTransparency
2179 //=======================================================================
2181 void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2182 const Standard_Boolean updateviewer)
2184 if(anIObj.IsNull()) return ;
2185 anIObj->UnsetTransparency();
2186 if(anIObj->RecomputeEveryPrs())
2187 anIObj->Redisplay();
2190 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2191 for (;ITI.More();ITI.Next())
2193 anIObj->Update(ITI.Value(),Standard_False);
2195 anIObj->SetRecomputeOk();
2198 // To Unset transparency in the viewer, if no other object is transparent ...(Speed)
2199 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
2200 Standard_Boolean FoundTransp(Standard_False);
2201 for(;It.More() && !FoundTransp ;It.Next()){
2202 if(It.Key()->IsTransparent())
2203 FoundTransp = Standard_True;
2206 myMainVwr->Viewer()->SetTransparency(Standard_False);
2210 UpdateCurrentViewer();
2213 //=======================================================================
2214 //function : SetSelectedAspect
2216 //=======================================================================
2217 void AIS_InteractiveContext::SetSelectedAspect(
2218 const Handle(Prs3d_BasicAspect)& anAspect,
2219 const Standard_Boolean globalChange,
2220 const Standard_Boolean updateViewer)
2222 if( !HasOpenedContext() ) {
2223 Standard_Boolean found = Standard_False;
2224 Handle(AIS_Selection) sel =
2225 AIS_Selection::Selection(myCurrentName.ToCString());
2226 Handle(AIS_InteractiveObject) object;
2227 for( sel->Init() ; sel->More() ; sel->Next()) {
2228 found = Standard_True;
2229 object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
2230 object->SetAspect(anAspect,globalChange);
2232 if( found && updateViewer) {
2233 myMainVwr->Update();
2238 //=======================================================================
2239 //function : SetLocalAttributes
2241 //=======================================================================
2243 void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2244 const Handle(AIS_Drawer)& aDrawer,
2245 const Standard_Boolean updateviewer)
2247 if(anIObj.IsNull()) return ;
2248 if(!anIObj->HasInteractiveContext())
2249 anIObj->SetContext(this);
2250 anIObj->SetAttributes(aDrawer);
2251 Update(anIObj,updateviewer);
2255 //=======================================================================
2256 //function : UnsetLocalAttributes
2258 //=======================================================================
2259 void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2260 const Standard_Boolean updateviewer)
2262 if(anIObj.IsNull()) return ;
2263 if(!anIObj->HasInteractiveContext())
2264 anIObj->SetContext(this);
2265 anIObj->UnsetAttributes();
2266 Update(anIObj,updateviewer);
2270 //=======================================================================
2273 //=======================================================================
2275 void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const
2279 if(anIObj.IsNull()) return ;
2280 if(myObjects.IsBound(anIObj)){
2281 astatus += "\t ____________________________________________";
2282 astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2283 const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
2284 switch(ST->GraphicStatus()){
2285 case AIS_DS_Displayed:
2287 astatus +="\t| -->Displayed\n";
2292 astatus +="\t| -->Erased\n";
2298 astatus += "\t| Active Display Modes in the MainViewer :\n";
2299 TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
2300 for(;ItL.More();ItL.Next()){
2301 astatus += "\t|\t Mode ";
2302 astatus += TCollection_AsciiString(ItL.Value());
2305 if(IsCurrent(anIObj)) astatus +="\t| Current\n";
2306 if(IsSelected(anIObj)) astatus +="\t| Selected\n";
2308 astatus += "\t| Active Selection Modes in the MainViewer :\n";
2309 for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
2310 astatus += "\t\t Mode ";
2311 astatus += TCollection_AsciiString(ItL.Value());
2314 astatus += "\t ____________________________________________";
2320 //=======================================================================
2321 //function : GetDefModes
2323 //=======================================================================
2325 void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
2326 Standard_Integer& DispMode,
2327 Standard_Integer& HiMode,
2328 Standard_Integer& SelMode) const
2330 if(anIObj.IsNull()) return ;
2331 DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
2332 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
2334 HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
2336 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
2338 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
2343 //=======================================================================
2344 //function : EraseGlobal
2346 //=======================================================================
2348 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2349 const Standard_Boolean updateviewer)
2351 if(anIObj.IsNull()) return ;
2352 if(!myObjects.IsBound(anIObj)) return;
2355 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2356 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2358 Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2359 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
2361 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2362 for(;ItL.More();ItL.Next()){
2363 if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2364 myMainPM->Unhighlight(anIObj,ItL.Value());
2365 myMainPM->SetVisibility (anIObj, ItL.Value(), Standard_False);
2367 if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
2368 myMainPM->SetVisibility (anIObj, Dmode, Standard_False);
2370 for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
2371 mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
2372 if(updateviewer) myMainVwr->Update();
2374 STATUS->SetGraphicStatus(AIS_DS_Erased);
2378 //=======================================================================
2379 //function : ClearGlobal
2381 //=======================================================================
2383 void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2384 const Standard_Boolean updateviewer)
2386 if(anIObj.IsNull()) return ;
2387 if(!myObjects.IsBound(anIObj)) return;
2389 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2390 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2392 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2393 for(;ItL.More();ItL.Next()){
2394 if(STATUS->IsHilighted()){
2395 if(IsCurrent(anIObj))
2397 AddOrRemoveCurrentObject( anIObj, updateviewer );
2399 AddOrRemoveCurrentObject(anIObj);
2401 else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2402 myMainPM->Unhighlight(anIObj,ItL.Value());
2404 myMainPM->Erase(anIObj,ItL.Value());
2405 myMainPM->Clear(anIObj,ItL.Value());
2406 if(anIObj->HasHilightMode()){
2407 Standard_Integer im = anIObj->HilightMode();
2408 myMainPM->Unhighlight(anIObj,im);
2409 myMainPM->Erase(anIObj,im);
2414 //Object removes from Detected sequence
2415 Standard_Integer i = 1;
2416 for(i = 1; i < myAISDetectedSeq.Length(); i++)
2418 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2419 if( !anObj.IsNull() && anObj != anIObj )
2420 myAISDetectedSeq.Remove( i );
2423 if(myLastinMain == anIObj)
2424 myLastinMain.Nullify();
2426 if(myLastPicked == anIObj)
2427 myLastPicked.Nullify();
2429 // OCC21671: Remove IO from the selection manager in any case
2430 // to avoid memory leaks
2431 mgrSelector->Remove(anIObj);
2433 if (updateviewer && (STATUS->GraphicStatus() == AIS_DS_Displayed))
2435 myMainVwr->Update();
2438 myObjects.UnBind(anIObj);
2442 //=======================================================================
2443 //function : ClearGlobalPrs
2445 //=======================================================================
2447 void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj,
2448 const Standard_Integer aMode,
2449 const Standard_Boolean updateviewer)
2451 if(anIObj.IsNull()) return ;
2452 if(!myObjects.IsBound(anIObj)) return;
2453 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2455 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2456 if(STATUS->IsDModeIn(aMode)){
2457 if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
2458 myMainPM->Unhighlight(anIObj,aMode);
2460 myMainPM->Erase(anIObj,aMode);
2461 myMainPM->Clear(anIObj,aMode);
2465 if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
2466 myMainVwr->Update();
2469 //=======================================================================
2470 //function : DrawHiddenLine
2472 //=======================================================================
2474 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
2476 return myDefaultDrawer->DrawHiddenLine();
2479 //=======================================================================
2480 //function : EnableDrawHiddenLine
2482 //=======================================================================
2484 void AIS_InteractiveContext::EnableDrawHiddenLine () const {
2485 myDefaultDrawer->EnableDrawHiddenLine();
2488 //=======================================================================
2489 //function : DisableDrawHiddenLine
2491 //=======================================================================
2493 void AIS_InteractiveContext::DisableDrawHiddenLine () const {
2494 myDefaultDrawer->DisableDrawHiddenLine();
2497 //=======================================================================
2498 //function : HiddenLineAspect
2500 //=======================================================================
2502 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const {
2503 return myDefaultDrawer->HiddenLineAspect();
2506 //=======================================================================
2507 //function : SetHiddenLineAspect
2509 //=======================================================================
2511 void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
2512 myDefaultDrawer->SetHiddenLineAspect(anAspect);
2515 //=======================================================================
2516 //function : SetIsoNumber
2518 //=======================================================================
2520 void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
2524 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2527 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2530 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2531 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2536 //=======================================================================
2537 //function : IsoNumber
2539 //=======================================================================
2541 Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
2546 return myDefaultDrawer->UIsoAspect()->Number();
2548 return myDefaultDrawer->VIsoAspect()->Number();
2550 return (myDefaultDrawer->UIsoAspect()->Number()==
2551 myDefaultDrawer->VIsoAspect()->Number()) ?
2552 myDefaultDrawer->UIsoAspect()->Number(): -1;
2557 //=======================================================================
2558 //function : IsoOnPlane
2560 //=======================================================================
2562 void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
2564 myDefaultDrawer->SetIsoOnPlane(SwitchOn);
2567 //=======================================================================
2568 //function : IsoOnPlane
2570 //=======================================================================
2572 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2574 return myDefaultDrawer->IsoOnPlane();
2577 //=======================================================================
2578 //function : SetSelectionMode
2580 //=======================================================================
2582 void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject&, const Standard_Integer )
2586 //=======================================================================
2587 //function : UnsetSelectionMode
2589 //=======================================================================
2591 void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObject&)
2595 //=======================================================================
2596 //function : SetSensitivityMode
2598 //=======================================================================
2600 void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
2602 if( HasOpenedContext() )
2603 myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
2605 myMainSel->SetSensitivityMode(aMode);
2609 //=======================================================================
2610 //function : SensitivityMode
2612 //=======================================================================
2614 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
2616 if( HasOpenedContext() )
2617 return myLocalContexts(myCurLocalIndex)->SensitivityMode();
2618 return myMainSel->SensitivityMode();
2621 //=======================================================================
2622 //function : SetSensitivity
2624 //=======================================================================
2626 void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
2628 if( HasOpenedContext() )
2629 myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
2631 myMainSel->SetSensitivity(aPrecision);
2635 //=======================================================================
2636 //function : Sensitivity
2638 //=======================================================================
2640 Standard_Real AIS_InteractiveContext::Sensitivity() const {
2642 if( HasOpenedContext() )
2643 return myLocalContexts(myCurLocalIndex)->Sensitivity();
2644 return myMainSel->Sensitivity();
2647 //=======================================================================
2648 //function : SetPixelTolerance
2650 //=======================================================================
2652 void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
2654 if( HasOpenedContext() )
2655 myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
2657 myMainSel->SetPixelTolerance(aPrecision);
2661 //=======================================================================
2662 //function : PixelTolerance
2664 //=======================================================================
2666 Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
2668 if( HasOpenedContext() )
2669 return myLocalContexts(myCurLocalIndex)->PixelTolerance();
2670 return myMainSel->PixelTolerance();
2673 //=======================================================================
2674 //function : IsInLocal
2676 //=======================================================================
2678 Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle_AIS_InteractiveObject& anIObj,
2679 Standard_Integer& TheIndex) const
2681 if(anIObj.IsNull()) return Standard_False;
2682 // if it exists at neutral point 0 index is returned
2683 if(myObjects.IsBound(anIObj)) {
2685 return Standard_False;
2687 for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
2688 if(myLocalContexts.IsBound(I)){
2689 if(myLocalContexts(I)->IsIn(anIObj)){
2691 return Standard_True;
2697 return Standard_False;
2700 //=======================================================================
2701 //function : InitAttributes
2703 //=======================================================================
2705 void AIS_InteractiveContext::InitAttributes()
2708 mgrSelector->Add(myMainSel);
2709 myCurrentName = AIS_Context_NewCurName();
2710 mySelectionName = AIS_Context_NewSelName();
2712 AIS_Selection::CreateSelection(mySelectionName.ToCString());
2713 AIS_Selection::CreateSelection(myCurrentName.ToCString());
2716 myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
2717 Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
2718 myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
2720 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2721 Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
2722 HLA->SetColor(Quantity_NOC_GRAY20);
2724 HLA->SetTypeOfLine(Aspect_TOL_DASH);
2726 // tolerance to 4 pixels...
2727 SetPixelTolerance();
2729 // Customizing the drawer for trihedrons and planes...
2731 Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
2732 Standard_Real aLength(100.);
2733 DA->SetAxisLength(aLength,aLength,aLength);
2734 Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
2735 DA->FirstAxisAspect()->SetColor(col);
2736 DA->SecondAxisAspect()->SetColor(col);
2737 DA->ThirdAxisAspect()->SetColor(col);
2739 Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
2741 PA->SetPlaneLength(aLength,aLength);
2742 PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
2748 //=======================================================================
2749 //function : TrihedronSize
2751 //=======================================================================
2752 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2754 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2756 //=======================================================================
2757 //function : SetTrihedronSize
2759 //=======================================================================
2760 void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
2762 myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
2763 Redisplay(AIS_KOI_Datum,3,Standard_False);
2764 Redisplay(AIS_KOI_Datum,4,Standard_True);
2769 //=======================================================================
2770 //function : SetPlaneSize
2772 //=======================================================================
2773 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
2774 const Standard_Real aValY,
2775 const Standard_Boolean /*updateviewer*/)
2777 myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
2778 Redisplay(AIS_KOI_Datum,7);
2781 //=======================================================================
2782 //function : SetPlaneSize
2784 //=======================================================================
2786 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
2787 const Standard_Boolean updateviewer)
2789 SetPlaneSize(aVal,aVal,updateviewer);
2792 //=======================================================================
2793 //function : PlaneSize
2795 //=======================================================================
2797 Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
2799 LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2800 LY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2801 return (Abs(LX-LY)<=Precision::Confusion());
2806 //=======================================================================
2809 //=======================================================================
2810 void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
2812 myIsAutoActivateSelMode = Auto;
2815 //=======================================================================
2818 //=======================================================================
2819 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2821 return myIsAutoActivateSelMode;
2824 //=======================================================================
2825 //function : SetZLayer
2827 //=======================================================================
2829 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2830 const Standard_Integer theLayerId)
2832 if (theIObj.IsNull ())
2835 if (myObjects.IsBound (theIObj))
2837 if (myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed || myObjects (theIObj)->GraphicStatus() == AIS_DS_Erased)
2839 theIObj->SetZLayer (myMainPM, theLayerId);
2842 else if (HasOpenedContext ())
2844 myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
2848 //=======================================================================
2849 //function : GetZLayer
2851 //=======================================================================
2853 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2855 if (theIObj.IsNull ())
2858 if (myObjects.IsBound (theIObj))
2860 return theIObj->GetZLayer (myMainPM);
2862 else if (HasOpenedContext ())
2864 return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);