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 under
9 // the terms of the GNU Lesser General Public License 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 BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
20 // method, compute only authorized presentation.
22 #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods.
24 #define BUC60722 //GG 04/09/00 Always enable viewer update when erasing something
26 #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
28 #define OCC172 //SAV clear static map before destroying context.
30 #define OCC204 //SAV 26/02/02 : pass <updateviewer> flag to
31 // AddOrRemoveCurrentObject method from ClearGlobal.
33 #define OCC4373 //SAN 10/11/03 : improve display mode management in
34 // Display( IO, updateviewer ) and
35 // SetDisplayMode( IO, mode, updateviewer ) methods
37 #include <AIS_InteractiveContext.ixx>
39 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
40 #include <TColStd_ListIteratorOfListOfInteger.hxx>
41 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
42 #include <AIS_LocalContext.hxx>
43 #include <AIS_LocalStatus.hxx>
44 #include <Precision.hxx>
45 #include <AIS_Selection.hxx>
46 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
47 #include <AIS_ConnectedInteractive.hxx>
48 #include <AIS_MultipleConnectedInteractive.hxx>
49 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
50 #include <AIS_GlobalStatus.hxx>
51 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
52 #include <PrsMgr_ModedPresentation.hxx>
53 #include <Visual3d_ViewManager.hxx>
54 #include <Prs3d_ShadingAspect.hxx>
55 #include <AIS_Shape.hxx>
56 #include <Graphic3d_AspectFillArea3d.hxx>
57 #include <HLRBRep.hxx>
58 #include <Prs3d_IsoAspect.hxx>
59 #include <Prs3d_DatumAspect.hxx>
60 #include <Prs3d_PlaneAspect.hxx>
61 #include <PrsMgr_PresentableObject.hxx>
62 #include <Standard_Atomic.hxx>
63 #include <UnitsAPI.hxx>
65 #include <AIS_Trihedron.hxx>
66 #include <Geom_Axis2Placement.hxx>
67 #include <OSD_Environment.hxx>
69 #include <AIS_ListIteratorOfListOfInteractive.hxx>
71 // In the method GetDefModes() the returned value of the selection mode
72 // is always equal to 0 if it is -1.
75 // The local context is closed the method ::ResetOriginalState() sets the selection mode equal to 0
76 // in spite of the selection mode of the interactive object in Natural Point.
79 static Standard_Boolean AISDebugModeOn()
81 // static OSD_Environment aisdb("AISDEBUGMODE");
82 // return !aisdb.Value().IsEmpty();
83 static Standard_Integer isDebugMode(-1);
84 if (isDebugMode < 0) {
86 OSD_Environment aisdb("AISDEBUGMODE");
87 if (aisdb.Value().IsEmpty())
90 return (isDebugMode != 0);
95 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
96 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
98 static TCollection_AsciiString AIS_Context_NewSelName()
100 return TCollection_AsciiString ("AIS_SelContext_")
101 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
104 static TCollection_AsciiString AIS_Context_NewCurName()
106 return TCollection_AsciiString ("AIS_CurContext_")
107 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
111 //=======================================================================
112 //function : AIS_InteractiveContext
114 //=======================================================================
116 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
117 mgrSelector(new SelectMgr_SelectionManager()),
118 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
119 myMainVwr(MainViewer),
120 myMainSel(new StdSelect_ViewerSelector3d()),
121 myToHilightSelected( Standard_True ),
122 myFilters(new SelectMgr_OrFilter()),
123 myDefaultDrawer(new Prs3d_Drawer()),
124 myDefaultColor(Quantity_NOC_GOLDENROD),
125 myHilightColor(Quantity_NOC_CYAN1),
126 mySelectionColor(Quantity_NOC_GRAY80),
127 myPreselectionColor(Quantity_NOC_GREEN),
128 mySubIntensity(Quantity_NOC_GRAY40),
134 myIsAutoActivateSelMode( Standard_True )
139 void AIS_InteractiveContext::Delete() const
141 //Clear the static current selection. Else the memory
143 AIS_Selection::ClearCurrentSelection();
145 // to avoid an exception
146 if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
147 AIS_Selection::Remove( mySelectionName.ToCString() );
149 // to avoid an exception
150 if ( AIS_Selection::Find( myCurrentName.ToCString() ) )
151 AIS_Selection::Remove( myCurrentName.ToCString() );
153 // let's remove one reference explicitly. this operation's supposed to
154 // be performed when mgrSelector will be destroyed but anyway...
155 mgrSelector->Remove( myMainSel );
157 AIS_ListOfInteractive aList;
159 AIS_DataMapIteratorOfDataMapOfIOStatus anIt(myObjects);
160 Handle(AIS_InteractiveContext) aNullContext;
161 for(; anIt.More() ; anIt.Next())
163 Handle(AIS_InteractiveObject) anObj = anIt.Key();
164 anObj->SetContext(aNullContext);
167 MMgt_TShared::Delete();
170 //=======================================================================
171 //function : AIS_SelectionName
173 //=======================================================================
174 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
176 if(!HasOpenedContext())
177 return mySelectionName;
178 return myLocalContexts(myCurLocalIndex)->SelectionName();
184 //=======================================================================
185 //function : UpdateCurrentViewer
187 //=======================================================================
189 void AIS_InteractiveContext::UpdateCurrentViewer()
191 if (!myMainVwr.IsNull())
196 //=======================================================================
197 //function : DomainOfMainViewer
199 //=======================================================================
201 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
203 return myMainVwr->Domain();
207 //=======================================================================
208 //function : DisplayedObjects
210 //=======================================================================
212 void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
213 const Standard_Boolean OnlyFromNeutral) const
216 cout<<"AIS_IC::DisplayedObjects"<<endl;
219 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
220 if(!HasOpenedContext() || OnlyFromNeutral){
221 for(;It.More();It.Next()){
222 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
223 aListOfIO.Append(It.Key());
227 TColStd_MapOfTransient theMap;
229 for(;It.More();It.Next()){
230 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
231 theMap.Add(It.Key());
234 //parse all local contexts...
236 cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl;
237 Standard_Integer NbDisp;
238 for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
239 const Handle(AIS_LocalContext)& LC = it1.Value();
240 NbDisp = LC->DisplayedObjects(theMap);
241 cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
244 Handle(AIS_InteractiveObject) curIO;
245 Handle(Standard_Transient) Tr;
246 for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
248 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
249 aListOfIO.Append(curIO);
253 //=======================================================================
254 //function : DisplayedObjects
256 //=======================================================================
258 void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
259 const Standard_Integer TheSign,
260 AIS_ListOfInteractive& aListOfIO,
261 const Standard_Boolean /*OnlyFromNeutral*/) const
263 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
266 //=======================================================================
267 //function : ErasedObjects
269 //=======================================================================
271 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const
273 ObjectsByDisplayStatus( AIS_DS_Erased, theListOfIO );
276 //=======================================================================
277 //function : ErasedObjects
279 //=======================================================================
281 void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
282 const Standard_Integer TheSign,
283 AIS_ListOfInteractive& theListOfIO) const
285 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, theListOfIO );
288 //=======================================================================
289 //function : ObjectsByDisplayStatus
291 //=======================================================================
293 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
294 AIS_ListOfInteractive& theListOfIO) const
296 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
297 for(;It.More();It.Next()){
298 if(It.Value()->GraphicStatus() == theStatus)
299 theListOfIO.Append(It.Key());
303 //=======================================================================
304 //function : ObjectsByDisplayStatus
306 //=======================================================================
308 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
309 const Standard_Integer TheSign,
310 const AIS_DisplayStatus theStatus,
311 AIS_ListOfInteractive& theListOfIO) const
313 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
314 for(;It.More();It.Next()){
315 if(It.Value()->GraphicStatus()==theStatus){
316 if(It.Key()->Type()==TheKind){
318 theListOfIO.Append(It.Key());
320 if(It.Key()->Signature()==TheSign)
321 theListOfIO.Append(It.Key());
328 //=======================================================================
329 //function : ObjectsInside
331 //=======================================================================
333 void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
334 const AIS_KindOfInteractive TheKind,
335 const Standard_Integer TheSign) const
337 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
338 if(TheKind==AIS_KOI_None && TheSign ==-1){
339 for(;It.More();It.Next()){
340 aListOfIO.Append(It.Key());
344 for(;It.More();It.Next()){
345 if(It.Key()->Type()==TheKind){
347 aListOfIO.Append(It.Key());
349 if(It.Key()->Signature()==TheSign)
350 aListOfIO.Append(It.Key());
357 //=======================================================================
360 //=======================================================================
362 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
363 const Standard_Boolean updateviewer )
365 if(anIObj.IsNull()) return;
367 Standard_Integer DispMode,HiMod,SelMode;
369 GetDefModes(anIObj,DispMode,HiMod,SelMode);
371 Handle (AIS_InteractiveContext) aThis = this;
372 if(!anIObj->HasInteractiveContext())
373 anIObj->SetContext(aThis);
375 //NO LOCAL CONTEXT OPEN
376 if(!HasOpenedContext()) {
378 // SAN : Do not return here. Perform advanced display mode analysis a bit later...
379 if(IsDisplayed(anIObj)) return;
382 // it did not yet exist
383 if(!myObjects.IsBound(anIObj)){
385 Handle(AIS_GlobalStatus) STATUS=
387 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
389 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
391 myObjects.Bind (anIObj,STATUS);
392 myMainPM->Display(anIObj,DispMode);
393 if( myIsAutoActivateSelMode )
395 if(!mgrSelector->Contains(anIObj))
396 mgrSelector->Load(anIObj);
397 mgrSelector->Activate(anIObj,SelMode,myMainSel);
400 if(updateviewer) myMainVwr->Update();
402 // it is somewhere else...
405 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
406 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
408 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
410 // SAN : erase presentations for all display modes different from <DispMode>;
411 // then make sure <DispMode> is displayed and maybe highlighted;
412 // Finally, activate selection mode <SelMode> if not yet activated.
413 TColStd_ListOfInteger aModesToRemove;
414 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
415 for(;ItL.More();ItL.Next()){
417 Standard_Integer OldMode = ItL.Value();
419 if(OldMode!=DispMode){
420 aModesToRemove.Append(OldMode);
421 if(myMainPM->IsHighlighted(anIObj,OldMode))
422 myMainPM->Unhighlight(anIObj,OldMode);
423 myMainPM->Erase(anIObj,OldMode);
427 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
428 STATUS->RemoveDisplayMode(ItL.Value());
430 if(!STATUS->IsDModeIn(DispMode))
431 STATUS->AddDisplayMode(DispMode);
433 myMainPM->Display(anIObj,DispMode);
434 if (STATUS->GraphicStatus() == AIS_DS_Erased)
436 STATUS->SetGraphicStatus(AIS_DS_Displayed);
438 if(STATUS->IsHilighted()){
439 myMainPM->Highlight(anIObj,HiMod);
441 if( myIsAutoActivateSelMode )
443 if(!mgrSelector->Contains(anIObj))
444 mgrSelector->Load(anIObj);
445 if(!mgrSelector->IsActivated(anIObj,SelMode))
446 mgrSelector->Activate(anIObj,SelMode,myMainSel);
451 if(updateviewer) myMainVwr->Update();
454 // LOCAL CONTEXT OPEN
457 myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
459 if(updateviewer) myMainVwr->Update();
463 //=======================================================================
466 //=======================================================================
468 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
469 const Standard_Integer aDisplayMode,
470 const Standard_Integer aSelectionMode,
471 const Standard_Boolean updateviewer,
472 const Standard_Boolean allowdecomposition)
474 if(anIObj.IsNull()) return;
476 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
478 // if no local context...
479 if(!HasOpenedContext()) {
480 // if(!anIObj->HasDisplayMode())
481 // anIObj->SetDisplayMode(aDisplayMode);
483 if(!myObjects.IsBound(anIObj)){
484 Handle(AIS_GlobalStatus) STATUS=
485 new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
486 myObjects.Bind (anIObj,STATUS);
487 myMainPM->Display(anIObj,aDisplayMode);
488 if(aSelectionMode!=-1){
489 if(!mgrSelector->Contains(anIObj))
490 mgrSelector->Load(anIObj,aSelectionMode);
491 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
493 if(updateviewer) myMainVwr->Update();
495 // anIObj->SelectionMode(aSelectionMode);
498 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
499 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
501 if(!STATUS->IsDModeIn(aDisplayMode)){
502 myMainPM->Display(anIObj,aDisplayMode);
503 STATUS->AddDisplayMode(aDisplayMode);
504 if(STATUS->IsSubIntensityOn())
505 myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
507 if(aSelectionMode!=-1){
508 STATUS->AddSelectionMode(aSelectionMode);
509 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
511 if(updateviewer) myMainVwr->Update();
517 myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
518 if(updateviewer) myMainVwr->Update();
523 //=======================================================================
526 //=======================================================================
528 void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
529 const Standard_Integer SelMode,
530 const Standard_Boolean AllowDecomposition)
532 if(anIObj.IsNull()) return;
533 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
536 if(!HasOpenedContext()) {
537 if(SelMode==-1 && !AllowDecomposition){
538 Standard_Integer DispMode,HiMod,SelModeDef;
540 GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
541 Handle(AIS_GlobalStatus) STATUS=
542 new AIS_GlobalStatus(AIS_DS_Erased,DispMode,SelModeDef);
543 myObjects.Bind (anIObj,STATUS);
547 myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
551 //=======================================================================
554 //=======================================================================
556 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
557 const Standard_Boolean updateviewer)
559 if(anIObj.IsNull()) return;
561 if ( !anIObj->IsAutoHilight() )
562 anIObj->ClearSelected();
564 if(!HasOpenedContext()){
565 EraseGlobal(anIObj,updateviewer);
569 // First it is checked if it is possible to remove in the current local context
570 // then one tries to remove in other local contexts, if they allow it...
572 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
574 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
575 for (;It.More();It.Next()){
576 if(It.Value()->AcceptErase())
578 WasInCtx |= It.Value()->Erase(anIObj);
580 WasInCtx = It.Value()->Erase(anIObj);
585 EraseGlobal(anIObj,updateviewer);
587 if(updateviewer) myMainVwr->Update();
591 //=======================================================================
592 //function : EraseAll
594 //=======================================================================
596 void AIS_InteractiveContext::EraseAll(const Standard_Boolean updateviewer)
598 if(!HasOpenedContext())
600 for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); ItM.More(); ItM.Next())
602 if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
603 Erase(ItM.Key(),Standard_False);
612 //=======================================================================
613 //function : DisplayAll
615 //=======================================================================
617 void AIS_InteractiveContext::DisplayAll(const Standard_Boolean updateviewer)
619 if(!HasOpenedContext()){
621 AIS_DisplayStatus aStatus;
623 if (!HasOpenedContext())
625 for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM (myObjects); ItM.More(); ItM.Next())
627 aStatus = ItM.Value()->GraphicStatus();
628 if (aStatus == AIS_DS_Erased)
629 Display(ItM.Key(),Standard_False);
640 //=======================================================================
641 //function : DisplaySelected
643 //=======================================================================
645 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
648 if (!HasOpenedContext())
650 Standard_Boolean found = Standard_False;
651 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
652 Handle(AIS_InteractiveObject) iObj;
653 for (sel->Init(); sel->More(); sel->Next())
655 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
656 Display(iObj,Standard_False);
657 found = Standard_True;
659 if (found && updateviewer)
667 //=======================================================================
668 //function : EraseSelected
670 //=======================================================================
672 void AIS_InteractiveContext::EraseSelected(const Standard_Boolean updateviewer)
674 if (!HasOpenedContext())
676 Standard_Boolean found = Standard_False;
677 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
678 Handle(AIS_InteractiveObject) iObj;
679 for (sel->Init();sel->More();sel->Next())
681 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
682 Erase(iObj,Standard_False);
683 found = Standard_True;
685 if(found && updateviewer)
691 //=======================================================================
694 //=======================================================================
696 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
697 const Standard_Integer WhichContext)
699 if(anIObj.IsNull()) return Standard_False;
701 if(!HasOpenedContext()) return Standard_False;
702 if(myObjects.IsBound(anIObj)) return Standard_False;
703 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
705 // Protection : if one tries to preserve a temporary object
706 // which is not in the local active context... rob 11-06-97
708 Standard_Integer IsItInLocal = myCurLocalIndex;
709 Standard_Boolean Found(Standard_False);
711 while(IsItInLocal>0 && !Found){
712 if(!myLocalContexts.IsBound(IsItInLocal))
714 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
715 Found = Standard_True;
720 if(!Found) return Standard_False;
723 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
724 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
726 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
727 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
731 if(LS->IsTemporary()){
732 Standard_Integer DM,HM,SM;
733 GetDefModes(anIObj,DM,HM,SM);
735 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
736 if(LS->DisplayMode()!= DM ){
737 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
738 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
741 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
745 // GS->SubIntensityOn();
746 myObjects.Bind(anIObj,GS);
747 mgrSelector->Load(anIObj);
748 mgrSelector->Activate(anIObj,SM,myMainSel);
750 LS->SetTemporary(Standard_False);
752 return Standard_True;
756 //=======================================================================
758 //=======================================================================
760 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const
762 if(anIObj.IsNull()) return AIS_DS_None;
764 if(myObjects.IsBound(anIObj))
765 return myObjects(anIObj)->GraphicStatus();
767 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
768 for(;ItM.More();ItM.Next()){
769 if(ItM.Value()->IsIn(anIObj))
770 return AIS_DS_Temporary;
780 //=======================================================================
781 //function : DisplayedModes
783 //=======================================================================
785 const TColStd_ListOfInteger& AIS_InteractiveContext::
786 DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const
788 return myObjects(anIObj)->DisplayedModes();
792 //=======================================================================
795 //=======================================================================
796 void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
797 const Standard_Boolean updateviewer)
800 if(anIObj.IsNull()) return;
802 if(!HasOpenedContext()){
803 ClearGlobal(anIObj,updateviewer);
807 myLocalContexts(myCurLocalIndex)->Remove(anIObj);
808 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
809 for (;It.More() ;It.Next()){
810 if(It.Value()->AcceptErase())
811 It.Value()->Remove(anIObj);
815 ClearGlobal(anIObj,updateviewer);
817 // if(updateviewer) myMainVwr->Update();
821 //=======================================================================
822 //function : RemoveAll
824 //=======================================================================
825 void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
827 AIS_ListOfInteractive aList;
828 ObjectsInside(aList);
829 AIS_ListIteratorOfListOfInteractive aListIterator;
830 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
831 Remove(aListIterator.Value(), Standard_False);
838 //=======================================================================
841 //=======================================================================
843 void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
844 const Standard_Boolean updateviewer)
846 if(anIObj.IsNull()) return;
848 if(!HasOpenedContext()){
849 ClearGlobal(anIObj,updateviewer);
854 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
855 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
856 for (;It.More() ;It.Next()){
857 if(It.Value()->AcceptErase())
858 WasInCtx = It.Value()->Remove(anIObj);
862 ClearGlobal(anIObj,updateviewer);
864 if(updateviewer) myMainVwr->Update();
871 //=======================================================================
872 //function : ClearPrs
874 //=======================================================================
876 void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
877 const Standard_Integer aMode,
878 const Standard_Boolean updateviewer)
880 if(anIObj.IsNull()) return;
882 if(!HasOpenedContext()){
883 ClearGlobalPrs(anIObj,aMode,updateviewer);
887 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
888 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
889 for (;It.More() ;It.Next()){
890 if(It.Value()->AcceptErase())
891 WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
894 ClearGlobalPrs(anIObj,aMode,updateviewer);
896 if(updateviewer) myMainVwr->Update();
901 //=======================================================================
904 //=======================================================================
906 void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
907 const Standard_Boolean updateviewer)
909 if(anIObj.IsNull()) return;
911 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
912 if (!HasOpenedContext())
914 if(!myObjects.IsBound(anIObj)) return;
917 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
918 // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
919 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
922 STATUS->SetHilightStatus (Standard_True);
924 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
926 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
927 myMainPM->Highlight (anIObj, aHilightMode);
932 myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
935 if(updateviewer) myMainVwr->Update();
937 //=======================================================================
940 //=======================================================================
942 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
943 const Quantity_NameOfColor aCol,
944 const Standard_Boolean updateviewer)
946 if(anIObj.IsNull()) return;
948 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
950 if (!HasOpenedContext())
952 if(!myObjects.IsBound(anIObj)) return;
954 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
955 STATUS->SetHilightStatus (Standard_True);
957 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
959 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
960 myMainPM->Color (anIObj, aCol, aHilightMode);
961 STATUS->SetHilightColor (aCol);
966 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
968 if(updateviewer) myMainVwr->Update();
971 //=======================================================================
972 //function : Unhilight
974 //=======================================================================
976 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
978 if(anIObj.IsNull()) return;
980 if (!HasOpenedContext())
982 if(!myObjects.IsBound(anIObj)) return;
984 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
985 STATUS->SetHilightStatus (Standard_False);
986 STATUS->SetHilightColor(Quantity_NOC_WHITE);
988 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
990 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
991 myMainPM->Unhighlight (anIObj, aHilightMode);
996 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
998 if(updateviewer) myMainVwr->Update();
1001 //=======================================================================
1002 //function : IsHilighted
1004 //=======================================================================
1006 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1008 if(anIObj.IsNull()) return Standard_False;
1010 if (!HasOpenedContext()){
1011 if(!myObjects.IsBound(anIObj))
1012 return Standard_False;
1013 return myObjects(anIObj)->IsHilighted();
1015 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1016 for(;ItM.More();ItM.Next()){
1017 if(ItM.Value()->IsHilighted(anIObj))
1018 return Standard_True;
1020 return Standard_False;
1023 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1024 Standard_Boolean& WithColor,
1025 Quantity_NameOfColor& TheHiCol) const
1027 if(!HasOpenedContext()){
1028 if(myObjects.IsBound(anIObj)){
1029 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1030 if(STAT->IsHilighted()){
1031 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1032 WithColor=Standard_True;
1033 TheHiCol = STAT->HilightColor();
1036 WithColor = Standard_False;
1037 return Standard_True;
1040 return Standard_False;
1042 Standard_Integer MaxIndex = HighestIndex();
1043 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1044 if(myLocalContexts.IsBound(i)){
1045 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1046 return Standard_True;
1050 return Standard_False;
1055 //=======================================================================
1056 //function : IsDisplayed
1058 //=======================================================================
1060 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1062 if(anIObj.IsNull()) return Standard_False;
1065 if(myObjects.IsBound(anIObj))
1066 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1067 return Standard_True;
1069 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1070 for(;ItM.More();ItM.Next()){
1071 if(ItM.Value()->IsDisplayed(anIObj))
1072 return Standard_True;
1074 return Standard_False;
1078 //=======================================================================
1079 //function : IsDisplayed
1081 //=======================================================================
1083 Standard_Boolean AIS_InteractiveContext::
1084 IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
1085 const Standard_Integer aMode) const
1087 if(anIObj.IsNull()) return Standard_False;
1088 if(myObjects.IsBound(anIObj)) {
1089 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
1090 myObjects(anIObj)->IsDModeIn(aMode))
1091 return Standard_True;
1094 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1095 for(;ItM.More();ItM.Next()){
1096 if(ItM.Value()->IsDisplayed(anIObj,aMode))
1097 return Standard_True;
1099 return Standard_False;
1103 //=======================================================================
1104 //function : DisplayPriority
1106 //=======================================================================
1108 Standard_Integer AIS_InteractiveContext::
1109 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const
1111 if(anIObj.IsNull()) return -1;
1113 if (myObjects.IsBound(anIObj))
1115 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1116 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
1118 Standard_Integer aDispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
1119 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
1120 return myMainPM->DisplayPriority (anIObj, aDispMode);
1125 //=======================================================================
1126 //function : SetDisplayPriority
1128 //=======================================================================
1130 void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
1131 const Standard_Integer aPriority)
1135 if(!anIObj->HasInteractiveContext())
1136 anIObj->SetContext(this);
1137 if(myObjects.IsBound(anIObj))
1139 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1141 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
1143 Standard_Integer aDisplayMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
1144 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
1145 myMainPM->SetDisplayPriority (anIObj, aDisplayMode, aPriority);
1148 else if (HasOpenedContext())
1150 myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);
1154 //=======================================================================
1155 //function : Redisplay
1157 //=======================================================================
1159 void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
1160 const Standard_Boolean updateviewer,
1161 const Standard_Boolean allmodes)
1163 if(AISDebugModeOn()){
1164 cout<<"===>AIS_InteractiveContext::Redisplay de :";
1165 cout<<anIObj->DynamicType()->Name()<<endl;
1168 RecomputePrsOnly(anIObj,updateviewer,allmodes);
1169 RecomputeSelectionOnly(anIObj);
1172 //=======================================================================
1173 //function : Redisplay
1175 //=======================================================================
1177 void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
1178 const Standard_Integer /*Sign*/,
1179 const Standard_Boolean updateviewer)
1181 Standard_Boolean found_viewer(Standard_False);
1183 for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
1185 // const Handle(AIS_InteractiveObject)& IO = It.Key();
1186 Handle(AIS_InteractiveObject) IO = It.Key();
1188 if(IO->Type()== KOI){
1190 // Standard_Boolean good = (Sign==-1)? Standard_True :
1191 // ((IO->Signature()==Sign)? Standard_True:Standard_False);
1193 Redisplay(IO,Standard_False);
1194 if (It.Value()->GraphicStatus() == AIS_DS_Displayed)
1196 found_viewer = Standard_True;
1201 if(updateviewer && found_viewer)
1203 myMainVwr->Update();
1208 //=======================================================================
1209 //function : RecomputePrsOnly
1211 //=======================================================================
1213 void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
1214 const Standard_Boolean updateviewer,
1215 const Standard_Boolean allmodes)
1217 if(anIObj.IsNull()) return;
1218 anIObj->Update(allmodes);
1225 if (HasOpenedContext() ||
1226 (myObjects.IsBound(anIObj) && myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed))
1228 myMainVwr->Update();
1231 //=======================================================================
1232 //function : RecomputeSelectionOnly
1234 //=======================================================================
1235 void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
1242 mgrSelector->RecomputeSelection (theIO);
1244 if (HasOpenedContext())
1246 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1248 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
1253 if (!myObjects.IsBound (theIO) ||
1254 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1259 TColStd_ListOfInteger aModes;
1260 ActivatedModes (theIO, aModes);
1261 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1262 for (; aModesIter.More(); aModesIter.Next())
1264 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
1268 //=======================================================================
1271 //=======================================================================
1272 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1273 const Standard_Boolean theUpdateViewer)
1275 if (theIObj.IsNull())
1280 TColStd_ListOfInteger aListOfFlaggedPrsModes;
1281 theIObj->ToBeUpdated (aListOfFlaggedPrsModes);
1283 TColStd_ListIteratorOfListOfInteger aPrsModesIt (aListOfFlaggedPrsModes);
1284 for ( ; aPrsModesIt.More(); aPrsModesIt.Next())
1286 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1289 mgrSelector->Update(theIObj);
1291 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1293 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1296 if (theUpdateViewer)
1298 if (!myObjects.IsBound (theIObj))
1303 switch (myObjects (theIObj)->GraphicStatus())
1305 case AIS_DS_Displayed:
1306 case AIS_DS_Temporary:
1307 myMainVwr->Update();
1315 //=======================================================================
1316 //function : SetLocation
1318 //=======================================================================
1320 void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
1321 const TopLoc_Location& aLoc)
1323 if(anIObj.IsNull()) return;
1326 if(anIObj->HasTransformation() && aLoc.IsIdentity()){
1327 anIObj->ResetTransformation();
1328 mgrSelector->Update(anIObj,Standard_False);
1331 if(aLoc.IsIdentity()) return ;
1333 // first reset the previous location to properly clean everything...
1334 if(anIObj->HasTransformation())
1335 anIObj->ResetTransformation();
1338 anIObj->SetLocalTransformation (aLoc.Transformation());
1340 if(!HasOpenedContext())
1341 mgrSelector->Update(anIObj,Standard_False);
1345 // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1346 Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1348 mgrSelector->Update(anIObj,tempSel,Standard_False);
1351 //=======================================================================
1352 //function : ResetLocation
1354 //=======================================================================
1355 void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
1357 if(anIObj.IsNull()) return;
1359 anIObj->ResetTransformation();
1360 mgrSelector->Update(anIObj,Standard_False);
1363 //=======================================================================
1364 //function : HasLocation
1366 //=======================================================================
1368 Standard_Boolean AIS_InteractiveContext::
1369 HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
1371 if(anIObj.IsNull()) return Standard_False;
1373 return anIObj->HasTransformation();
1376 TopLoc_Location AIS_InteractiveContext::
1377 Location(const Handle(AIS_InteractiveObject)& anIObj) const
1379 return anIObj->Transformation();
1382 //=======================================================================
1383 //function : SetDeviationCoefficient
1385 //=======================================================================
1387 void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
1389 myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
1391 //=======================================================================
1392 //function : SetDeviationAngle
1394 //=======================================================================
1396 void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
1398 myDefaultDrawer->SetDeviationCoefficient(anAngle);
1401 //=======================================================================
1402 //function : DeviationAngle
1403 //purpose : Gets deviationAngle
1404 //=======================================================================
1406 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1408 //return M_PI/180.0e0 ;
1409 return myDefaultDrawer->DeviationAngle();
1412 //=======================================================================
1413 //function : DeviationCoefficient
1415 //=======================================================================
1417 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1419 return myDefaultDrawer->DeviationCoefficient();
1421 //=======================================================================
1422 //function : SetHLRDeviationCoefficient
1424 //=======================================================================
1426 void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
1428 myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
1431 //=======================================================================
1432 //function : HLRDeviationCoefficient
1434 //=======================================================================
1436 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1438 return myDefaultDrawer->HLRDeviationCoefficient();
1441 //=======================================================================
1442 //function : SetHLRAngle
1444 //=======================================================================
1446 void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
1448 myDefaultDrawer->SetHLRAngle(anAngle);
1451 //=======================================================================
1452 //function : SetHLRAngleAndDeviation
1453 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1454 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1455 // of myDefaultDrawer
1456 //=======================================================================
1458 void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
1461 Standard_Real OutAngl,OutDefl;
1462 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1464 myDefaultDrawer->SetHLRAngle(OutAngl);
1465 myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
1469 //=======================================================================
1470 //function : HLRAngle
1472 //=======================================================================
1474 Standard_Real AIS_InteractiveContext::HLRAngle() const
1476 return myDefaultDrawer->HLRAngle();
1479 //=======================================================================
1480 //function : SetDisplayMode
1482 //=======================================================================
1484 void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
1485 const Standard_Boolean updateviewer)
1487 if(aMode==myDisplayMode) return;
1488 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
1490 for(;It.More();It.Next()){
1492 // const Handle(AIS_InteractiveObject)& anObj = It.Key();
1493 Handle(AIS_InteractiveObject) anObj = It.Key();
1495 Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
1496 anObj->IsKind(STANDARD_TYPE(AIS_ConnectedInteractive)) ||
1497 anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedInteractive)) );
1499 if ((!anObj->HasDisplayMode()) && Processed)
1501 if(anObj->AcceptDisplayMode(aMode)){
1503 // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
1504 Handle(AIS_GlobalStatus) STATUS = It.Value();
1506 if(STATUS->IsDModeIn(myDisplayMode))
1507 STATUS->RemoveDisplayMode(myDisplayMode);
1509 STATUS->AddDisplayMode(aMode);
1511 if(STATUS->GraphicStatus()== AIS_DS_Displayed){
1512 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1513 myMainPM->Display(anObj, aMode);
1514 if(STATUS->IsSubIntensityOn())
1515 myMainPM->Color(anObj,mySubIntensity,aMode);
1517 // myDisplayMode = aMode;
1522 myDisplayMode = aMode;
1523 if(updateviewer) myMainVwr->Update();
1526 //=======================================================================
1527 //function : SetDisplayMode
1529 //=======================================================================
1531 void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1532 const Standard_Integer aMode,
1533 const Standard_Boolean updateviewer)
1536 if(!anIObj->HasInteractiveContext())
1537 anIObj->SetContext(this);
1538 if(!HasOpenedContext()){
1540 if(!myObjects.IsBound(anIObj))
1541 anIObj->SetDisplayMode(aMode);
1542 else if( anIObj->AcceptDisplayMode(aMode) )
1545 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1546 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1548 // SAN : erase presentations for all display modes different from <aMode>
1549 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1550 TColStd_ListOfInteger aModesToRemove;
1551 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
1552 for(;ItL.More();ItL.Next()){
1554 Standard_Integer OldMode = ItL.Value();
1557 aModesToRemove.Append(OldMode);
1558 if(myMainPM->IsHighlighted(anIObj,OldMode))
1559 myMainPM->Unhighlight(anIObj,OldMode);
1560 myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
1564 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
1565 STATUS->RemoveDisplayMode(ItL.Value());
1567 if(!STATUS->IsDModeIn(aMode))
1568 STATUS->AddDisplayMode(aMode);
1570 myMainPM->Display(anIObj,aMode);
1571 Standard_Integer DM,HM,SM;
1572 GetDefModes(anIObj,DM,HM,SM);
1573 if(STATUS->IsHilighted()){
1574 myMainPM->Highlight(anIObj,HM);
1576 if(STATUS->IsSubIntensityOn()){
1577 myMainPM->Color(anIObj,mySubIntensity,aMode);
1580 if(updateviewer) myMainVwr->Update();
1582 anIObj->SetDisplayMode(aMode);
1587 //=======================================================================
1588 //function : UnsetDisplayMode
1590 //=======================================================================
1592 void AIS_InteractiveContext::
1593 UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1594 const Standard_Boolean updateviewer)
1596 if(anIObj.IsNull()) return ;
1597 if(!anIObj->HasDisplayMode()) return;
1599 if(!myObjects.IsBound(anIObj))
1600 anIObj->UnsetDisplayMode();
1603 Standard_Integer OldMode = anIObj->DisplayMode();
1604 if(myDisplayMode==OldMode) return;
1605 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1606 STATUS->RemoveDisplayMode(OldMode);
1607 if(!STATUS->IsDModeIn(myDisplayMode))
1608 STATUS->AddDisplayMode(myDisplayMode);
1609 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1610 if(myMainPM->IsHighlighted(anIObj,OldMode))
1611 myMainPM->Unhighlight(anIObj,OldMode);
1612 myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
1613 myMainPM->Display(anIObj,myDisplayMode);
1614 Standard_Integer DM,HM,SM;
1615 GetDefModes(anIObj,DM,HM,SM);
1616 if(STATUS->IsHilighted()){
1617 myMainPM->Highlight(anIObj,HM);
1619 if(STATUS->IsSubIntensityOn()){
1620 myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
1622 if(updateviewer) myMainVwr->Update();
1624 anIObj->UnsetDisplayMode();
1629 //=======================================================================
1630 //function : SetCurrentFacingModel
1632 //=======================================================================
1634 void AIS_InteractiveContext::SetCurrentFacingModel(
1635 const Handle(AIS_InteractiveObject)& anIObj,
1636 const Aspect_TypeOfFacingModel aModel)
1638 if ( !anIObj.IsNull () )
1639 anIObj->SetCurrentFacingModel(aModel);
1642 //=======================================================================
1643 //function : SetColor
1645 //=======================================================================
1647 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1648 const Quantity_NameOfColor aColor,
1649 const Standard_Boolean updateviewer)
1651 SetColor(anIObj,Quantity_Color(aColor),updateviewer);
1654 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1655 const Quantity_Color &aColor,
1656 const Standard_Boolean updateviewer)
1658 if(anIObj.IsNull()) return ;
1660 if(!anIObj->HasInteractiveContext())
1661 anIObj->SetContext(this);
1662 anIObj->SetColor(aColor);
1663 if(anIObj->RecomputeEveryPrs())
1664 anIObj->Redisplay();
1667 Standard_Integer NbDisp=0;
1668 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1669 for (;ITI.More();ITI.Next())
1671 anIObj->Update(ITI.Value(),Standard_False);
1674 anIObj->SetRecomputeOk();
1676 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1683 // if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
1684 // Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
1685 // Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
1687 // gp_Dir D =Tr->Component()->XDirection();
1688 // gp_Pnt O = Tr->Component()->Location();
1689 // gp_Vec V(D);V*=Lx/5.;
1690 // T.SetRotation(gp_Ax1(O,D),M_PI/6.);
1691 // T.SetTranslationPart(V);
1692 // TopLoc_Location L,IncLoc(T);
1694 // for(Standard_Integer I=1;I<90;I++){
1695 // if(anIObj->HasLocation())
1696 // L = anIObj->Location() * IncLoc;
1699 // SetLocation(anIObj,L);
1700 // UpdateCurrentViewer();
1702 // for(I=1;I<90;I++){
1703 // L = anIObj->Location() /IncLoc;
1704 // SetLocation(anIObj,L);
1705 // UpdateCurrentViewer();
1707 // ResetLocation(anIObj);
1710 if(updateviewer) UpdateCurrentViewer();
1713 //=======================================================================
1714 //function : SetDeviationCoefficient
1716 //=======================================================================
1718 void AIS_InteractiveContext::SetDeviationCoefficient(
1719 const Handle(AIS_InteractiveObject)& anIObj,
1720 const Standard_Real aCoefficient,
1721 const Standard_Boolean updateviewer)
1723 // cout<<" Coefficient:"<< aCoefficient <<endl;
1724 if(anIObj.IsNull()) return ;
1726 if(!anIObj->HasInteractiveContext())
1727 anIObj->SetContext(this);
1729 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1730 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
1731 if(anIObj->Signature()!=0) return;
1732 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
1736 if(anIObj->RecomputeEveryPrs())
1737 anIObj->Redisplay();
1740 Standard_Integer NbDisp=0;
1741 TColStd_ListOfInteger LL;
1742 anIObj->ToBeUpdated(LL);
1743 TColStd_ListIteratorOfListOfInteger ITI(LL);
1744 for (;ITI.More();ITI.Next())
1746 anIObj->Update(ITI.Value(),Standard_False);
1749 anIObj->SetRecomputeOk();
1751 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1754 if(updateviewer) UpdateCurrentViewer();
1757 //=======================================================================
1758 //function : SetHLRDeviationCoefficient
1760 //=======================================================================
1762 void AIS_InteractiveContext::SetHLRDeviationCoefficient(
1763 const Handle(AIS_InteractiveObject)& anIObj,
1764 const Standard_Real aCoefficient,
1765 const Standard_Boolean updateviewer)
1767 // cout<<" HLRCoefficient:"<< aCoefficient <<endl;
1768 if(anIObj.IsNull()) return ;
1770 if(!anIObj->HasInteractiveContext())
1771 anIObj->SetContext(this);
1772 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1773 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
1774 if(anIObj->Signature()!=0) return;
1775 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
1779 if(anIObj->RecomputeEveryPrs())
1780 anIObj->Redisplay();
1783 Standard_Integer NbDisp=0;
1785 TColStd_ListOfInteger LL;
1786 anIObj->ToBeUpdated(LL);
1787 TColStd_ListIteratorOfListOfInteger ITI(LL);
1788 for (;ITI.More();ITI.Next())
1790 anIObj->Update(ITI.Value(),Standard_False);
1793 anIObj->SetRecomputeOk();
1795 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1798 if(updateviewer) UpdateCurrentViewer();
1802 //=======================================================================
1803 //function : SetDeviationAngle
1805 //=======================================================================
1807 void AIS_InteractiveContext::SetDeviationAngle(
1808 const Handle(AIS_InteractiveObject)& anIObj,
1809 const Standard_Real anAngle,
1810 const Standard_Boolean updateviewer)
1812 // cout<<" Angle:"<< anAngle <<endl;
1813 if(anIObj.IsNull()) return ;
1815 if(!anIObj->HasInteractiveContext())
1816 anIObj->SetContext(this);
1817 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1818 if(anIObj->Type()!=AIS_KOI_Shape) return;
1819 if(anIObj->Signature()!=0) return;
1820 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
1823 if(anIObj->RecomputeEveryPrs())
1824 anIObj->Redisplay();
1827 Standard_Integer NbDisp=0;
1828 TColStd_ListOfInteger LL;
1829 anIObj->ToBeUpdated(LL);
1830 TColStd_ListIteratorOfListOfInteger ITI(LL);
1831 for (;ITI.More();ITI.Next())
1833 anIObj->Update(ITI.Value(),Standard_False);
1836 anIObj->SetRecomputeOk();
1838 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1841 if(updateviewer) UpdateCurrentViewer();
1843 //=======================================================================
1844 //function : SetDeviationAngle
1846 //=======================================================================
1848 void AIS_InteractiveContext::SetAngleAndDeviation(
1849 const Handle(AIS_InteractiveObject)& anIObj,
1850 const Standard_Real anAngle,
1851 const Standard_Boolean updateviewer)
1853 // cout<<" Angle:"<< anAngle <<endl;
1854 if(anIObj.IsNull()) return ;
1855 // Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
1856 if(!anIObj->HasInteractiveContext())
1857 anIObj->SetContext(this);
1859 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1860 if(anIObj->Type()!=AIS_KOI_Shape) return;
1861 if(anIObj->Signature()!=0) return;
1862 (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
1865 if(anIObj->RecomputeEveryPrs())
1866 anIObj->Redisplay();
1868 Update(anIObj,updateviewer);
1871 //=======================================================================
1872 //function : SetDeviationAngle
1874 //=======================================================================
1876 void AIS_InteractiveContext::SetHLRAngleAndDeviation(
1877 const Handle(AIS_InteractiveObject)& anIObj,
1878 const Standard_Real anAngle,
1879 const Standard_Boolean updateviewer)
1881 // cout<<" Angle:"<< anAngle <<endl;
1883 if(anIObj.IsNull()) return ;
1884 if(!anIObj->HasInteractiveContext())
1885 anIObj->SetContext(this);
1887 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1888 if(anIObj->Type()!=AIS_KOI_Shape) return;
1889 if(anIObj->Signature()!=0) return;
1890 (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
1893 if(anIObj->RecomputeEveryPrs())
1894 anIObj->Redisplay();
1897 Standard_Integer NbDisp=0;
1899 TColStd_ListOfInteger LL;
1900 anIObj->ToBeUpdated(LL);
1901 TColStd_ListIteratorOfListOfInteger ITI(LL);
1902 for (;ITI.More();ITI.Next())
1904 anIObj->Update(ITI.Value(),Standard_False);
1907 anIObj->SetRecomputeOk();
1909 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1912 if(updateviewer) UpdateCurrentViewer();
1915 //=======================================================================
1916 //function : SetHLRDeviationAngle
1918 //=======================================================================
1920 void AIS_InteractiveContext::SetHLRDeviationAngle(
1921 const Handle(AIS_InteractiveObject)& anIObj,
1922 const Standard_Real anAngle,
1923 const Standard_Boolean updateviewer)
1925 // cout<<" HLRAngle:"<< anAngle <<endl;
1926 if(anIObj.IsNull()) return ;
1928 if(!anIObj->HasInteractiveContext())
1929 anIObj->SetContext(this);
1930 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1931 if( anIObj->Type()!=AIS_KOI_Shape) return;
1932 if(anIObj->Signature()!=0) return;
1933 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
1936 if(anIObj->RecomputeEveryPrs())
1937 anIObj->Redisplay();
1940 Standard_Integer NbDisp=0;
1941 TColStd_ListOfInteger LL;
1942 anIObj->ToBeUpdated(LL);
1943 TColStd_ListIteratorOfListOfInteger ITI(LL);
1944 for (;ITI.More();ITI.Next())
1946 anIObj->Update(ITI.Value(),Standard_False);
1949 anIObj->SetRecomputeOk();
1951 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1954 if(updateviewer) UpdateCurrentViewer();
1957 //=======================================================================
1958 //function : UnsetColor
1960 //=======================================================================
1962 void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
1963 const Standard_Boolean updateviewer)
1965 if(anIObj.IsNull()) return ;
1966 anIObj->UnsetColor();
1967 if(anIObj->RecomputeEveryPrs())
1968 anIObj->Redisplay();
1971 Standard_Integer NbDisp =0;
1972 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1973 for (;ITI.More();ITI.Next())
1975 anIObj->Update(ITI.Value(),Standard_False);
1979 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1981 anIObj->SetRecomputeOk();
1984 UpdateCurrentViewer();
1987 //=======================================================================
1988 //function : HasColor
1990 //=======================================================================
1992 Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const
1994 return anIObj->HasColor();
1998 //=======================================================================
2001 //=======================================================================
2003 Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const
2005 return anIObj->Color();
2008 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
2009 Quantity_Color &aColor) const
2011 anIObj->Color(aColor);
2014 //=======================================================================
2017 //=======================================================================
2019 Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const
2021 return anIObj->Width();
2024 //=======================================================================
2025 //function : SetWidth
2027 //=======================================================================
2029 void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2030 const Standard_Real aValue,
2031 const Standard_Boolean updateviewer)
2033 if(anIObj.IsNull()) return ;
2035 if(!anIObj->HasInteractiveContext())
2036 anIObj->SetContext(this);
2037 anIObj->SetWidth(aValue);
2038 if(anIObj->RecomputeEveryPrs())
2039 anIObj->Redisplay();
2042 Standard_Integer NbDisp=0;
2043 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2044 for (;ITI.More();ITI.Next())
2046 anIObj->Update(ITI.Value(),Standard_False);
2050 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2052 anIObj->SetRecomputeOk();
2055 UpdateCurrentViewer();
2058 //=======================================================================
2059 //function : UnsetWidth
2061 //=======================================================================
2063 void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2064 const Standard_Boolean updateviewer)
2066 if(anIObj.IsNull()) return ;
2067 anIObj->UnsetWidth();
2068 if(anIObj->RecomputeEveryPrs())
2069 anIObj->Redisplay();
2072 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2073 for (;ITI.More();ITI.Next())
2075 anIObj->Update(ITI.Value(),Standard_False);
2077 anIObj->SetRecomputeOk();
2080 UpdateCurrentViewer();
2083 //=======================================================================
2084 //function : SetMaterial
2086 //=======================================================================
2088 void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2090 const Graphic3d_NameOfMaterial aName,
2091 // const Graphic3d_NameOfPhysicalMaterial aName,
2092 const Standard_Boolean updateviewer)
2094 if(!anIObj->HasInteractiveContext())
2095 anIObj->SetContext(this);
2096 anIObj->SetMaterial(aName);
2097 if(anIObj->RecomputeEveryPrs())
2098 anIObj->Redisplay();
2101 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2102 for (;ITI.More();ITI.Next())
2104 anIObj->Update(ITI.Value(),Standard_False);
2106 anIObj->SetRecomputeOk();
2109 UpdateCurrentViewer();
2113 //=======================================================================
2114 //function : UnsetMaterial
2116 //=======================================================================
2118 void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2119 const Standard_Boolean updateviewer)
2121 if(anIObj.IsNull()) return ;
2122 anIObj->UnsetMaterial();
2123 if(anIObj->RecomputeEveryPrs())
2124 anIObj->Redisplay();
2127 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2128 for (;ITI.More();ITI.Next())
2130 anIObj->Update(ITI.Value(),Standard_False);
2132 anIObj->SetRecomputeOk();
2135 UpdateCurrentViewer();
2138 //=======================================================================
2139 //function : SetTransparency
2141 //=======================================================================
2143 void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2144 const Standard_Real aValue,
2145 const Standard_Boolean updateviewer)
2147 if(anIObj.IsNull()) return ;
2148 if(!anIObj->HasInteractiveContext())
2149 anIObj->SetContext(this);
2151 if (!anIObj->IsTransparent()
2158 UnsetTransparency(anIObj,updateviewer);
2162 anIObj->SetTransparency(aValue);
2163 if(anIObj->RecomputeEveryPrs())
2164 anIObj->Redisplay();
2167 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2168 for (;ITI.More();ITI.Next())
2170 anIObj->Update(ITI.Value(),Standard_False);
2172 anIObj->SetRecomputeOk();
2175 UpdateCurrentViewer();
2178 //=======================================================================
2179 //function : UnsetTransparency
2181 //=======================================================================
2183 void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2184 const Standard_Boolean updateviewer)
2186 if(anIObj.IsNull()) return ;
2187 anIObj->UnsetTransparency();
2188 if(anIObj->RecomputeEveryPrs())
2189 anIObj->Redisplay();
2192 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2193 for (;ITI.More();ITI.Next())
2195 anIObj->Update(ITI.Value(),Standard_False);
2197 anIObj->SetRecomputeOk();
2201 UpdateCurrentViewer();
2204 //=======================================================================
2205 //function : SetSelectedAspect
2207 //=======================================================================
2208 void AIS_InteractiveContext::SetSelectedAspect(
2209 const Handle(Prs3d_BasicAspect)& anAspect,
2210 const Standard_Boolean globalChange,
2211 const Standard_Boolean updateViewer)
2213 if( !HasOpenedContext() ) {
2214 Standard_Boolean found = Standard_False;
2215 Handle(AIS_Selection) sel =
2216 AIS_Selection::Selection(myCurrentName.ToCString());
2217 Handle(AIS_InteractiveObject) object;
2218 for( sel->Init() ; sel->More() ; sel->Next()) {
2219 found = Standard_True;
2220 object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
2221 object->SetAspect(anAspect,globalChange);
2223 if( found && updateViewer) {
2224 myMainVwr->Update();
2229 //=======================================================================
2230 //function : SetLocalAttributes
2232 //=======================================================================
2234 void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2235 const Handle(AIS_Drawer)& aDrawer,
2236 const Standard_Boolean updateviewer)
2238 if(anIObj.IsNull()) return ;
2239 if(!anIObj->HasInteractiveContext())
2240 anIObj->SetContext(this);
2241 anIObj->SetAttributes(aDrawer);
2242 Update(anIObj,updateviewer);
2246 //=======================================================================
2247 //function : UnsetLocalAttributes
2249 //=======================================================================
2250 void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2251 const Standard_Boolean updateviewer)
2253 if(anIObj.IsNull()) return ;
2254 if(!anIObj->HasInteractiveContext())
2255 anIObj->SetContext(this);
2256 anIObj->UnsetAttributes();
2257 Update(anIObj,updateviewer);
2261 //=======================================================================
2264 //=======================================================================
2266 void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const
2270 if(anIObj.IsNull()) return ;
2271 if(myObjects.IsBound(anIObj)){
2272 astatus += "\t ____________________________________________";
2273 astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2274 const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
2275 switch(ST->GraphicStatus()){
2276 case AIS_DS_Displayed:
2278 astatus +="\t| -->Displayed\n";
2283 astatus +="\t| -->Erased\n";
2289 astatus += "\t| Active Display Modes in the MainViewer :\n";
2290 TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
2291 for(;ItL.More();ItL.Next()){
2292 astatus += "\t|\t Mode ";
2293 astatus += TCollection_AsciiString(ItL.Value());
2296 if(IsCurrent(anIObj)) astatus +="\t| Current\n";
2297 if(IsSelected(anIObj)) astatus +="\t| Selected\n";
2299 astatus += "\t| Active Selection Modes in the MainViewer :\n";
2300 for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
2301 astatus += "\t\t Mode ";
2302 astatus += TCollection_AsciiString(ItL.Value());
2305 astatus += "\t ____________________________________________";
2311 //=======================================================================
2312 //function : GetDefModes
2314 //=======================================================================
2316 void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
2317 Standard_Integer& DispMode,
2318 Standard_Integer& HiMode,
2319 Standard_Integer& SelMode) const
2321 if(anIObj.IsNull()) return ;
2322 DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
2323 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
2325 HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
2327 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
2329 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
2334 //=======================================================================
2335 //function : EraseGlobal
2337 //=======================================================================
2339 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2340 const Standard_Boolean updateviewer)
2342 if(anIObj.IsNull()) return ;
2343 if(!myObjects.IsBound(anIObj)) return;
2346 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2347 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2349 Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2350 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
2352 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2353 for(;ItL.More();ItL.Next()){
2354 if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2355 myMainPM->Unhighlight(anIObj,ItL.Value());
2356 myMainPM->SetVisibility (anIObj, ItL.Value(), Standard_False);
2358 if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
2359 myMainPM->SetVisibility (anIObj, Dmode, Standard_False);
2361 for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
2362 mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
2363 if(updateviewer) myMainVwr->Update();
2365 STATUS->SetGraphicStatus(AIS_DS_Erased);
2369 //=======================================================================
2370 //function : ClearGlobal
2372 //=======================================================================
2374 void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2375 const Standard_Boolean updateviewer)
2377 if(anIObj.IsNull()) return ;
2378 if(!myObjects.IsBound(anIObj)) return;
2380 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2381 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2383 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2384 for(;ItL.More();ItL.Next()){
2385 if(STATUS->IsHilighted()){
2386 if(IsCurrent(anIObj))
2388 AddOrRemoveCurrentObject( anIObj, updateviewer );
2390 AddOrRemoveCurrentObject(anIObj);
2392 else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2393 myMainPM->Unhighlight(anIObj,ItL.Value());
2395 myMainPM->Erase(anIObj,ItL.Value());
2396 myMainPM->Clear(anIObj,ItL.Value());
2397 if(anIObj->HasHilightMode()){
2398 Standard_Integer im = anIObj->HilightMode();
2399 myMainPM->Unhighlight(anIObj,im);
2400 myMainPM->Erase(anIObj,im);
2405 //Object removes from Detected sequence
2406 Standard_Integer i = 1;
2407 for(i = 1; i < myAISDetectedSeq.Length(); i++)
2409 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2410 if( !anObj.IsNull() && anObj != anIObj )
2411 myAISDetectedSeq.Remove( i );
2414 if(myLastinMain == anIObj)
2415 myLastinMain.Nullify();
2417 if(myLastPicked == anIObj)
2418 myLastPicked.Nullify();
2420 // OCC21671: Remove IO from the selection manager in any case
2421 // to avoid memory leaks
2422 mgrSelector->Remove(anIObj);
2424 if (updateviewer && (STATUS->GraphicStatus() == AIS_DS_Displayed))
2426 myMainVwr->Update();
2429 myObjects.UnBind(anIObj);
2433 //=======================================================================
2434 //function : ClearGlobalPrs
2436 //=======================================================================
2438 void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj,
2439 const Standard_Integer aMode,
2440 const Standard_Boolean updateviewer)
2442 if(anIObj.IsNull()) return ;
2443 if(!myObjects.IsBound(anIObj)) return;
2444 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2446 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2447 if(STATUS->IsDModeIn(aMode)){
2448 if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
2449 myMainPM->Unhighlight(anIObj,aMode);
2451 myMainPM->Erase(anIObj,aMode);
2452 myMainPM->Clear(anIObj,aMode);
2456 if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
2457 myMainVwr->Update();
2460 //=======================================================================
2461 //function : DrawHiddenLine
2463 //=======================================================================
2465 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
2467 return myDefaultDrawer->DrawHiddenLine();
2470 //=======================================================================
2471 //function : EnableDrawHiddenLine
2473 //=======================================================================
2475 void AIS_InteractiveContext::EnableDrawHiddenLine () const {
2476 myDefaultDrawer->EnableDrawHiddenLine();
2479 //=======================================================================
2480 //function : DisableDrawHiddenLine
2482 //=======================================================================
2484 void AIS_InteractiveContext::DisableDrawHiddenLine () const {
2485 myDefaultDrawer->DisableDrawHiddenLine();
2488 //=======================================================================
2489 //function : HiddenLineAspect
2491 //=======================================================================
2493 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const {
2494 return myDefaultDrawer->HiddenLineAspect();
2497 //=======================================================================
2498 //function : SetHiddenLineAspect
2500 //=======================================================================
2502 void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
2503 myDefaultDrawer->SetHiddenLineAspect(anAspect);
2506 //=======================================================================
2507 //function : SetIsoNumber
2509 //=======================================================================
2511 void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
2515 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2518 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2521 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2522 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2527 //=======================================================================
2528 //function : IsoNumber
2530 //=======================================================================
2532 Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
2537 return myDefaultDrawer->UIsoAspect()->Number();
2539 return myDefaultDrawer->VIsoAspect()->Number();
2541 return (myDefaultDrawer->UIsoAspect()->Number()==
2542 myDefaultDrawer->VIsoAspect()->Number()) ?
2543 myDefaultDrawer->UIsoAspect()->Number(): -1;
2548 //=======================================================================
2549 //function : IsoOnPlane
2551 //=======================================================================
2553 void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
2555 myDefaultDrawer->SetIsoOnPlane(SwitchOn);
2558 //=======================================================================
2559 //function : IsoOnPlane
2561 //=======================================================================
2563 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2565 return myDefaultDrawer->IsoOnPlane();
2568 //=======================================================================
2569 //function : SetSelectionMode
2571 //=======================================================================
2573 void AIS_InteractiveContext::SetSelectionMode(const Handle(AIS_InteractiveObject)&, const Standard_Integer )
2577 //=======================================================================
2578 //function : UnsetSelectionMode
2580 //=======================================================================
2582 void AIS_InteractiveContext::UnsetSelectionMode(const Handle(AIS_InteractiveObject)&)
2586 //=======================================================================
2587 //function : SetSensitivityMode
2589 //=======================================================================
2591 void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
2593 if( HasOpenedContext() )
2594 myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
2596 myMainSel->SetSensitivityMode(aMode);
2600 //=======================================================================
2601 //function : SensitivityMode
2603 //=======================================================================
2605 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
2607 if( HasOpenedContext() )
2608 return myLocalContexts(myCurLocalIndex)->SensitivityMode();
2609 return myMainSel->SensitivityMode();
2612 //=======================================================================
2613 //function : SetSensitivity
2615 //=======================================================================
2617 void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
2619 if( HasOpenedContext() )
2620 myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
2622 myMainSel->SetSensitivity(aPrecision);
2626 //=======================================================================
2627 //function : Sensitivity
2629 //=======================================================================
2631 Standard_Real AIS_InteractiveContext::Sensitivity() const {
2633 if( HasOpenedContext() )
2634 return myLocalContexts(myCurLocalIndex)->Sensitivity();
2635 return myMainSel->Sensitivity();
2638 //=======================================================================
2639 //function : SetPixelTolerance
2641 //=======================================================================
2643 void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
2645 if( HasOpenedContext() )
2646 myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
2648 myMainSel->SetPixelTolerance(aPrecision);
2652 //=======================================================================
2653 //function : PixelTolerance
2655 //=======================================================================
2657 Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
2659 if( HasOpenedContext() )
2660 return myLocalContexts(myCurLocalIndex)->PixelTolerance();
2661 return myMainSel->PixelTolerance();
2664 //=======================================================================
2665 //function : IsInLocal
2667 //=======================================================================
2669 Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle(AIS_InteractiveObject)& anIObj,
2670 Standard_Integer& TheIndex) const
2672 if(anIObj.IsNull()) return Standard_False;
2673 // if it exists at neutral point 0 index is returned
2674 if(myObjects.IsBound(anIObj)) {
2676 return Standard_False;
2678 for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
2679 if(myLocalContexts.IsBound(I)){
2680 if(myLocalContexts(I)->IsIn(anIObj)){
2682 return Standard_True;
2688 return Standard_False;
2691 //=======================================================================
2692 //function : InitAttributes
2694 //=======================================================================
2696 void AIS_InteractiveContext::InitAttributes()
2699 mgrSelector->Add(myMainSel);
2700 myCurrentName = AIS_Context_NewCurName();
2701 mySelectionName = AIS_Context_NewSelName();
2703 AIS_Selection::CreateSelection(mySelectionName.ToCString());
2704 AIS_Selection::CreateSelection(myCurrentName.ToCString());
2707 myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
2708 Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
2709 myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
2711 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2712 Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
2713 HLA->SetColor(Quantity_NOC_GRAY20);
2715 HLA->SetTypeOfLine(Aspect_TOL_DASH);
2717 // tolerance to 4 pixels...
2718 SetPixelTolerance();
2720 // Customizing the drawer for trihedrons and planes...
2722 Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
2723 Standard_Real aLength(100.);
2724 DA->SetAxisLength(aLength,aLength,aLength);
2725 Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
2726 DA->FirstAxisAspect()->SetColor(col);
2727 DA->SecondAxisAspect()->SetColor(col);
2728 DA->ThirdAxisAspect()->SetColor(col);
2730 Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
2732 PA->SetPlaneLength(aLength,aLength);
2733 PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
2739 //=======================================================================
2740 //function : TrihedronSize
2742 //=======================================================================
2743 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2745 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2747 //=======================================================================
2748 //function : SetTrihedronSize
2750 //=======================================================================
2751 void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
2753 myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
2754 Redisplay(AIS_KOI_Datum,3,Standard_False);
2755 Redisplay(AIS_KOI_Datum,4,Standard_True);
2760 //=======================================================================
2761 //function : SetPlaneSize
2763 //=======================================================================
2764 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
2765 const Standard_Real aValY,
2766 const Standard_Boolean /*updateviewer*/)
2768 myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
2769 Redisplay(AIS_KOI_Datum,7);
2772 //=======================================================================
2773 //function : SetPlaneSize
2775 //=======================================================================
2777 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
2778 const Standard_Boolean updateviewer)
2780 SetPlaneSize(aVal,aVal,updateviewer);
2783 //=======================================================================
2784 //function : PlaneSize
2786 //=======================================================================
2788 Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
2790 LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2791 LY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2792 return (Abs(LX-LY)<=Precision::Confusion());
2797 //=======================================================================
2800 //=======================================================================
2801 void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
2803 myIsAutoActivateSelMode = Auto;
2806 //=======================================================================
2809 //=======================================================================
2810 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2812 return myIsAutoActivateSelMode;
2815 //=======================================================================
2816 //function : SetZLayer
2818 //=======================================================================
2820 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2821 const Standard_Integer theLayerId)
2823 if (theIObj.IsNull ())
2826 if (myObjects.IsBound (theIObj))
2828 if (myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed || myObjects (theIObj)->GraphicStatus() == AIS_DS_Erased)
2830 theIObj->SetZLayer (myMainPM, theLayerId);
2833 else if (HasOpenedContext ())
2835 myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
2839 //=======================================================================
2840 //function : GetZLayer
2842 //=======================================================================
2844 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2846 if (theIObj.IsNull ())
2849 if (myObjects.IsBound (theIObj))
2851 return theIObj->GetZLayer (myMainPM);
2853 else if (HasOpenedContext ())
2855 return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);