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 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...
242 Standard_Integer NbDisp;
243 for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
244 const Handle(AIS_LocalContext)& LC = it1.Value();
245 NbDisp = LC->DisplayedObjects(theMap);
246 cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
249 Handle(AIS_InteractiveObject) curIO;
250 Handle(Standard_Transient) Tr;
251 for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
253 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
254 aListOfIO.Append(curIO);
258 //=======================================================================
259 //function : DisplayedObjects
261 //=======================================================================
263 void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
264 const Standard_Integer TheSign,
265 AIS_ListOfInteractive& aListOfIO,
266 const Standard_Boolean /*OnlyFromNeutral*/) const
268 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
271 //=======================================================================
272 //function : ErasedObjects
274 //=======================================================================
276 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const
278 ObjectsByDisplayStatus( AIS_DS_Erased, theListOfIO );
281 //=======================================================================
282 //function : ErasedObjects
284 //=======================================================================
286 void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
287 const Standard_Integer TheSign,
288 AIS_ListOfInteractive& theListOfIO) const
290 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, theListOfIO );
293 //=======================================================================
294 //function : ObjectsByDisplayStatus
296 //=======================================================================
298 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
299 AIS_ListOfInteractive& theListOfIO) const
301 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
302 for(;It.More();It.Next()){
303 if(It.Value()->GraphicStatus() == theStatus)
304 theListOfIO.Append(It.Key());
308 //=======================================================================
309 //function : ObjectsByDisplayStatus
311 //=======================================================================
313 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
314 const Standard_Integer TheSign,
315 const AIS_DisplayStatus theStatus,
316 AIS_ListOfInteractive& theListOfIO) const
318 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
319 for(;It.More();It.Next()){
320 if(It.Value()->GraphicStatus()==theStatus){
321 if(It.Key()->Type()==TheKind){
323 theListOfIO.Append(It.Key());
325 if(It.Key()->Signature()==TheSign)
326 theListOfIO.Append(It.Key());
333 //=======================================================================
334 //function : ObjectsInside
336 //=======================================================================
338 void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
339 const AIS_KindOfInteractive TheKind,
340 const Standard_Integer TheSign) const
342 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
343 if(TheKind==AIS_KOI_None && TheSign ==-1){
344 for(;It.More();It.Next()){
345 aListOfIO.Append(It.Key());
349 for(;It.More();It.Next()){
350 if(It.Key()->Type()==TheKind){
352 aListOfIO.Append(It.Key());
354 if(It.Key()->Signature()==TheSign)
355 aListOfIO.Append(It.Key());
362 //=======================================================================
365 //=======================================================================
367 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
368 const Standard_Boolean updateviewer )
370 if(anIObj.IsNull()) return;
372 Standard_Integer DispMode,HiMod,SelMode;
374 GetDefModes(anIObj,DispMode,HiMod,SelMode);
376 Handle (AIS_InteractiveContext) aThis = this;
377 if(!anIObj->HasInteractiveContext())
378 anIObj->SetContext(aThis);
380 //NO LOCAL CONTEXT OPEN
381 if(!HasOpenedContext()) {
383 // SAN : Do not return here. Perform advanced display mode analysis a bit later...
384 if(IsDisplayed(anIObj)) return;
387 // it did not yet exist
388 if(!myObjects.IsBound(anIObj)){
390 Handle(AIS_GlobalStatus) STATUS=
392 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
394 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
396 myObjects.Bind (anIObj,STATUS);
397 myMainPM->Display(anIObj,DispMode);
398 if( myIsAutoActivateSelMode )
400 if(!mgrSelector->Contains(anIObj))
401 mgrSelector->Load(anIObj);
402 mgrSelector->Activate(anIObj,SelMode,myMainSel);
405 if(updateviewer) myMainVwr->Update();
407 // it is somewhere else...
410 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
411 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
413 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
415 // SAN : erase presentations for all display modes different from <DispMode>;
416 // then make sure <DispMode> is displayed and maybe highlighted;
417 // Finally, activate selection mode <SelMode> if not yet activated.
418 TColStd_ListOfInteger aModesToRemove;
419 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
420 for(;ItL.More();ItL.Next()){
422 Standard_Integer OldMode = ItL.Value();
424 if(OldMode!=DispMode){
425 aModesToRemove.Append(OldMode);
426 if(myMainPM->IsHighlighted(anIObj,OldMode))
427 myMainPM->Unhighlight(anIObj,OldMode);
428 myMainPM->Erase(anIObj,OldMode);
432 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
433 STATUS->RemoveDisplayMode(ItL.Value());
435 if(!STATUS->IsDModeIn(DispMode))
436 STATUS->AddDisplayMode(DispMode);
438 myMainPM->Display(anIObj,DispMode);
439 if (STATUS->GraphicStatus() == AIS_DS_Erased)
441 STATUS->SetGraphicStatus(AIS_DS_Displayed);
443 if(STATUS->IsHilighted()){
444 myMainPM->Highlight(anIObj,HiMod);
446 if( myIsAutoActivateSelMode )
448 if(!mgrSelector->Contains(anIObj))
449 mgrSelector->Load(anIObj);
450 if(!mgrSelector->IsActivated(anIObj,SelMode))
451 mgrSelector->Activate(anIObj,SelMode,myMainSel);
456 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
457 myMainVwr->Viewer()->SetTransparency(Standard_True);
458 if(updateviewer) myMainVwr->Update();
461 // LOCAL CONTEXT OPEN
464 myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
466 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
467 myMainVwr->Viewer()->SetTransparency(Standard_True);
470 if(updateviewer) myMainVwr->Update();
474 //=======================================================================
477 //=======================================================================
479 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
480 const Standard_Integer aDisplayMode,
481 const Standard_Integer aSelectionMode,
482 const Standard_Boolean updateviewer,
483 const Standard_Boolean allowdecomposition)
485 if(anIObj.IsNull()) return;
487 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
489 // if no local context...
490 if(!HasOpenedContext()) {
491 // if(!anIObj->HasDisplayMode())
492 // anIObj->SetDisplayMode(aDisplayMode);
494 if(!myObjects.IsBound(anIObj)){
495 Handle(AIS_GlobalStatus) STATUS=
496 new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
497 myObjects.Bind (anIObj,STATUS);
498 myMainPM->Display(anIObj,aDisplayMode);
499 if(aSelectionMode!=-1){
500 if(!mgrSelector->Contains(anIObj))
501 mgrSelector->Load(anIObj,aSelectionMode);
502 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
504 if(updateviewer) myMainVwr->Update();
506 // anIObj->SelectionMode(aSelectionMode);
509 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
510 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
512 if(!STATUS->IsDModeIn(aDisplayMode)){
513 myMainPM->Display(anIObj,aDisplayMode);
514 STATUS->AddDisplayMode(aDisplayMode);
515 if(STATUS->IsSubIntensityOn())
516 myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
518 if(aSelectionMode!=-1){
519 STATUS->AddSelectionMode(aSelectionMode);
520 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
522 if(updateviewer) myMainVwr->Update();
528 myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
529 if(updateviewer) myMainVwr->Update();
534 //=======================================================================
537 //=======================================================================
539 void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
540 const Standard_Integer SelMode,
541 const Standard_Boolean AllowDecomposition)
543 if(anIObj.IsNull()) return;
544 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
547 if(!HasOpenedContext()) {
548 if(SelMode==-1 && !AllowDecomposition){
549 Standard_Integer DispMode,HiMod,SelModeDef;
551 GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
552 Handle(AIS_GlobalStatus) STATUS=
553 new AIS_GlobalStatus(AIS_DS_Erased,DispMode,SelModeDef);
554 myObjects.Bind (anIObj,STATUS);
558 myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
562 //=======================================================================
565 //=======================================================================
567 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
568 const Standard_Boolean updateviewer)
570 if(anIObj.IsNull()) return;
572 if ( !anIObj->IsAutoHilight() )
573 anIObj->ClearSelected();
575 if(!HasOpenedContext()){
576 EraseGlobal(anIObj,updateviewer);
580 // First it is checked if it is possible to remove in the current local context
581 // then one tries to remove in other local contexts, if they allow it...
583 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
585 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
586 for (;It.More();It.Next()){
587 if(It.Value()->AcceptErase())
589 WasInCtx |= It.Value()->Erase(anIObj);
591 WasInCtx = It.Value()->Erase(anIObj);
596 EraseGlobal(anIObj,updateviewer);
598 if(updateviewer) myMainVwr->Update();
602 //=======================================================================
603 //function : EraseAll
605 //=======================================================================
607 void AIS_InteractiveContext::EraseAll(const Standard_Boolean updateviewer)
609 if(!HasOpenedContext())
611 for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); ItM.More(); ItM.Next())
613 if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
614 Erase(ItM.Key(),Standard_False);
623 //=======================================================================
624 //function : DisplayAll
626 //=======================================================================
628 void AIS_InteractiveContext::DisplayAll(const Standard_Boolean updateviewer)
630 if(!HasOpenedContext()){
632 AIS_DisplayStatus aStatus;
634 if (!HasOpenedContext())
636 for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM (myObjects); ItM.More(); ItM.Next())
638 aStatus = ItM.Value()->GraphicStatus();
639 if (aStatus == AIS_DS_Erased)
640 Display(ItM.Key(),Standard_False);
651 //=======================================================================
652 //function : DisplaySelected
654 //=======================================================================
656 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
659 if (!HasOpenedContext())
661 Standard_Boolean found = Standard_False;
662 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
663 Handle(AIS_InteractiveObject) iObj;
664 for (sel->Init(); sel->More(); sel->Next())
666 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
667 Display(iObj,Standard_False);
668 found = Standard_True;
670 if (found && updateviewer)
678 //=======================================================================
679 //function : EraseSelected
681 //=======================================================================
683 void AIS_InteractiveContext::EraseSelected(const Standard_Boolean updateviewer)
685 if (!HasOpenedContext())
687 Standard_Boolean found = Standard_False;
688 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
689 Handle(AIS_InteractiveObject) iObj;
690 for (sel->Init();sel->More();sel->Next())
692 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
693 Erase(iObj,Standard_False);
694 found = Standard_True;
696 if(found && updateviewer)
702 //=======================================================================
705 //=======================================================================
707 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
708 const Standard_Integer WhichContext)
710 if(anIObj.IsNull()) return Standard_False;
712 if(!HasOpenedContext()) return Standard_False;
713 if(myObjects.IsBound(anIObj)) return Standard_False;
714 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
716 // Protection : if one tries to preserve a temporary object
717 // which is not in the local active context... rob 11-06-97
719 Standard_Integer IsItInLocal = myCurLocalIndex;
720 Standard_Boolean Found(Standard_False);
722 while(IsItInLocal>0 && !Found){
723 if(!myLocalContexts.IsBound(IsItInLocal))
725 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
726 Found = Standard_True;
731 if(!Found) return Standard_False;
734 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
735 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
737 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
738 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
742 if(LS->IsTemporary()){
743 Standard_Integer DM,HM,SM;
744 GetDefModes(anIObj,DM,HM,SM);
746 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
747 if(LS->DisplayMode()!= DM ){
748 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
749 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
752 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
756 // GS->SubIntensityOn();
757 myObjects.Bind(anIObj,GS);
758 mgrSelector->Load(anIObj);
759 mgrSelector->Activate(anIObj,SM,myMainSel);
761 LS->SetTemporary(Standard_False);
763 return Standard_True;
767 //=======================================================================
769 //=======================================================================
771 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const
773 if(anIObj.IsNull()) return AIS_DS_None;
775 if(myObjects.IsBound(anIObj))
776 return myObjects(anIObj)->GraphicStatus();
778 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
779 for(;ItM.More();ItM.Next()){
780 if(ItM.Value()->IsIn(anIObj))
781 return AIS_DS_Temporary;
791 //=======================================================================
792 //function : DisplayedModes
794 //=======================================================================
796 const TColStd_ListOfInteger& AIS_InteractiveContext::
797 DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const
799 return myObjects(anIObj)->DisplayedModes();
803 //=======================================================================
806 //=======================================================================
807 void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
808 const Standard_Boolean updateviewer)
811 if(anIObj.IsNull()) return;
813 if(!HasOpenedContext()){
814 ClearGlobal(anIObj,updateviewer);
818 myLocalContexts(myCurLocalIndex)->Remove(anIObj);
819 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
820 for (;It.More() ;It.Next()){
821 if(It.Value()->AcceptErase())
822 It.Value()->Remove(anIObj);
826 ClearGlobal(anIObj,updateviewer);
828 // if(updateviewer) myMainVwr->Update();
832 //=======================================================================
833 //function : RemoveAll
835 //=======================================================================
836 void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
838 AIS_ListOfInteractive aList;
839 ObjectsInside(aList);
840 AIS_ListIteratorOfListOfInteractive aListIterator;
841 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
842 Remove(aListIterator.Value(), Standard_False);
849 //=======================================================================
852 //=======================================================================
854 void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
855 const Standard_Boolean updateviewer)
857 if(anIObj.IsNull()) return;
859 if(!HasOpenedContext()){
860 ClearGlobal(anIObj,updateviewer);
865 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
866 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
867 for (;It.More() ;It.Next()){
868 if(It.Value()->AcceptErase())
869 WasInCtx = It.Value()->Remove(anIObj);
873 ClearGlobal(anIObj,updateviewer);
875 if(updateviewer) myMainVwr->Update();
882 //=======================================================================
883 //function : ClearPrs
885 //=======================================================================
887 void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
888 const Standard_Integer aMode,
889 const Standard_Boolean updateviewer)
891 if(anIObj.IsNull()) return;
893 if(!HasOpenedContext()){
894 ClearGlobalPrs(anIObj,aMode,updateviewer);
898 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
899 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
900 for (;It.More() ;It.Next()){
901 if(It.Value()->AcceptErase())
902 WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
905 ClearGlobalPrs(anIObj,aMode,updateviewer);
907 if(updateviewer) myMainVwr->Update();
912 //=======================================================================
915 //=======================================================================
917 void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
918 const Standard_Boolean updateviewer)
920 if(anIObj.IsNull()) return;
922 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
923 if (!HasOpenedContext())
925 if(!myObjects.IsBound(anIObj)) return;
928 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
929 // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
930 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
933 STATUS->SetHilightStatus (Standard_True);
935 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
937 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
938 myMainPM->Highlight (anIObj, aHilightMode);
943 myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
946 if(updateviewer) myMainVwr->Update();
948 //=======================================================================
951 //=======================================================================
953 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
954 const Quantity_NameOfColor aCol,
955 const Standard_Boolean updateviewer)
957 if(anIObj.IsNull()) return;
959 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
961 if (!HasOpenedContext())
963 if(!myObjects.IsBound(anIObj)) return;
965 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
966 STATUS->SetHilightStatus (Standard_True);
968 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
970 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
971 myMainPM->Color (anIObj, aCol, aHilightMode);
972 STATUS->SetHilightColor (aCol);
977 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
979 if(updateviewer) myMainVwr->Update();
982 //=======================================================================
983 //function : Unhilight
985 //=======================================================================
987 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
989 if(anIObj.IsNull()) return;
991 if (!HasOpenedContext())
993 if(!myObjects.IsBound(anIObj)) return;
995 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
996 STATUS->SetHilightStatus (Standard_False);
997 STATUS->SetHilightColor(Quantity_NOC_WHITE);
999 if (STATUS->GraphicStatus() == AIS_DS_Displayed)
1001 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
1002 myMainPM->Unhighlight (anIObj, aHilightMode);
1007 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
1009 if(updateviewer) myMainVwr->Update();
1012 //=======================================================================
1013 //function : IsHilighted
1015 //=======================================================================
1017 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1019 if(anIObj.IsNull()) return Standard_False;
1021 if (!HasOpenedContext()){
1022 if(!myObjects.IsBound(anIObj))
1023 return Standard_False;
1024 return myObjects(anIObj)->IsHilighted();
1026 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1027 for(;ItM.More();ItM.Next()){
1028 if(ItM.Value()->IsHilighted(anIObj))
1029 return Standard_True;
1031 return Standard_False;
1034 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1035 Standard_Boolean& WithColor,
1036 Quantity_NameOfColor& TheHiCol) const
1038 if(!HasOpenedContext()){
1039 if(myObjects.IsBound(anIObj)){
1040 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1041 if(STAT->IsHilighted()){
1042 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1043 WithColor=Standard_True;
1044 TheHiCol = STAT->HilightColor();
1047 WithColor = Standard_False;
1048 return Standard_True;
1051 return Standard_False;
1053 Standard_Integer MaxIndex = HighestIndex();
1054 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1055 if(myLocalContexts.IsBound(i)){
1056 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1057 return Standard_True;
1061 return Standard_False;
1066 //=======================================================================
1067 //function : IsDisplayed
1069 //=======================================================================
1071 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1073 if(anIObj.IsNull()) return Standard_False;
1076 if(myObjects.IsBound(anIObj))
1077 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1078 return Standard_True;
1080 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1081 for(;ItM.More();ItM.Next()){
1082 if(ItM.Value()->IsDisplayed(anIObj))
1083 return Standard_True;
1085 return Standard_False;
1089 //=======================================================================
1090 //function : IsDisplayed
1092 //=======================================================================
1094 Standard_Boolean AIS_InteractiveContext::
1095 IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
1096 const Standard_Integer aMode) const
1098 if(anIObj.IsNull()) return Standard_False;
1099 if(myObjects.IsBound(anIObj)) {
1100 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
1101 myObjects(anIObj)->IsDModeIn(aMode))
1102 return Standard_True;
1105 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1106 for(;ItM.More();ItM.Next()){
1107 if(ItM.Value()->IsDisplayed(anIObj,aMode))
1108 return Standard_True;
1110 return Standard_False;
1114 //=======================================================================
1115 //function : DisplayPriority
1117 //=======================================================================
1119 Standard_Integer AIS_InteractiveContext::
1120 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const
1122 if(anIObj.IsNull()) return -1;
1124 if (myObjects.IsBound(anIObj))
1126 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1127 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
1129 Standard_Integer aDispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
1130 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
1131 return myMainPM->DisplayPriority (anIObj, aDispMode);
1136 //=======================================================================
1137 //function : SetDisplayPriority
1139 //=======================================================================
1141 void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
1142 const Standard_Integer aPriority)
1146 if(!anIObj->HasInteractiveContext())
1147 anIObj->SetContext(this);
1148 if(myObjects.IsBound(anIObj))
1150 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1152 if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
1154 Standard_Integer aDisplayMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
1155 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
1156 myMainPM->SetDisplayPriority (anIObj, aDisplayMode, aPriority);
1159 else if (HasOpenedContext())
1161 myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);
1165 //=======================================================================
1166 //function : Redisplay
1168 //=======================================================================
1170 void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
1171 const Standard_Boolean updateviewer,
1172 const Standard_Boolean allmodes)
1174 if(AISDebugModeOn()){
1175 cout<<"===>AIS_InteractiveContext::Redisplay de :";
1176 cout<<anIObj->DynamicType()->Name()<<endl;
1179 RecomputePrsOnly(anIObj,updateviewer,allmodes);
1180 RecomputeSelectionOnly(anIObj);
1183 //=======================================================================
1184 //function : Redisplay
1186 //=======================================================================
1188 void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
1189 const Standard_Integer /*Sign*/,
1190 const Standard_Boolean updateviewer)
1192 Standard_Boolean found_viewer(Standard_False);
1194 for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
1196 // const Handle(AIS_InteractiveObject)& IO = It.Key();
1197 Handle(AIS_InteractiveObject) IO = It.Key();
1199 if(IO->Type()== KOI){
1201 // Standard_Boolean good = (Sign==-1)? Standard_True :
1202 // ((IO->Signature()==Sign)? Standard_True:Standard_False);
1204 Redisplay(IO,Standard_False);
1205 if (It.Value()->GraphicStatus() == AIS_DS_Displayed)
1207 found_viewer = Standard_True;
1212 if(updateviewer && found_viewer)
1214 myMainVwr->Update();
1219 //=======================================================================
1220 //function : RecomputePrsOnly
1222 //=======================================================================
1224 void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
1225 const Standard_Boolean updateviewer,
1226 const Standard_Boolean allmodes)
1228 if(anIObj.IsNull()) return;
1229 anIObj->Update(allmodes);
1236 if (HasOpenedContext() ||
1237 (myObjects.IsBound(anIObj) && myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed))
1239 myMainVwr->Update();
1242 //=======================================================================
1243 //function : RecomputeSelectionOnly
1245 //=======================================================================
1246 void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj)
1248 if(anIObj.IsNull()) return;
1249 mgrSelector->RecomputeSelection(anIObj);
1253 TColStd_ListOfInteger LI;
1254 TColStd_ListIteratorOfListOfInteger Lit;
1255 ActivatedModes(anIObj,LI);
1256 if(!HasOpenedContext()){
1257 if(!myObjects.IsBound(anIObj)) return;
1259 if (myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
1261 for(Lit.Initialize(LI);Lit.More();Lit.Next())
1263 mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
1269 //=======================================================================
1272 //=======================================================================
1273 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1274 const Standard_Boolean theUpdateViewer)
1276 if (theIObj.IsNull())
1281 TColStd_ListOfInteger aListOfFlaggedPrsModes;
1282 theIObj->ToBeUpdated (aListOfFlaggedPrsModes);
1284 TColStd_ListIteratorOfListOfInteger aPrsModesIt (aListOfFlaggedPrsModes);
1285 for ( ; aPrsModesIt.More(); aPrsModesIt.Next())
1287 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1290 mgrSelector->Update(theIObj);
1292 if (theUpdateViewer)
1294 if (!myObjects.IsBound (theIObj))
1299 switch (myObjects (theIObj)->GraphicStatus())
1301 case AIS_DS_Displayed:
1302 case AIS_DS_Temporary:
1303 myMainVwr->Update();
1311 //=======================================================================
1312 //function : SetLocation
1314 //=======================================================================
1316 void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
1317 const TopLoc_Location& aLoc)
1319 if(anIObj.IsNull()) return;
1322 if(anIObj->HasLocation() && aLoc.IsIdentity()){
1323 anIObj->ResetLocation();
1324 mgrSelector->Update(anIObj,Standard_False);
1327 if(aLoc.IsIdentity()) return ;
1329 // first reset the previous location to properly clean everything...
1330 if(anIObj->HasLocation())
1331 anIObj->ResetLocation();
1334 anIObj->SetLocation(aLoc);
1336 if(!HasOpenedContext())
1337 mgrSelector->Update(anIObj,Standard_False);
1341 // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1342 Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1344 mgrSelector->Update(anIObj,tempSel,Standard_False);
1347 //=======================================================================
1348 //function : ResetLocation
1350 //=======================================================================
1351 void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
1353 if(anIObj.IsNull()) return;
1355 anIObj->ResetLocation();
1356 mgrSelector->Update(anIObj,Standard_False);
1359 //=======================================================================
1360 //function : HasLocation
1362 //=======================================================================
1364 Standard_Boolean AIS_InteractiveContext::
1365 HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
1367 if(anIObj.IsNull()) return Standard_False;
1369 return anIObj->HasLocation();
1372 const TopLoc_Location& AIS_InteractiveContext::
1373 Location(const Handle(AIS_InteractiveObject)& anIObj) const
1375 return anIObj->Location();
1378 //=======================================================================
1379 //function : SetDeviationCoefficient
1381 //=======================================================================
1383 void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
1385 myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
1387 //=======================================================================
1388 //function : SetDeviationAngle
1390 //=======================================================================
1392 void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
1394 myDefaultDrawer->SetDeviationCoefficient(anAngle);
1397 //=======================================================================
1398 //function : DeviationAngle
1399 //purpose : Gets deviationAngle
1400 //=======================================================================
1402 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1404 //return M_PI/180.0e0 ;
1405 return myDefaultDrawer->DeviationAngle();
1408 //=======================================================================
1409 //function : DeviationCoefficient
1411 //=======================================================================
1413 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1415 return myDefaultDrawer->DeviationCoefficient();
1417 //=======================================================================
1418 //function : SetHLRDeviationCoefficient
1420 //=======================================================================
1422 void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
1424 myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
1427 //=======================================================================
1428 //function : HLRDeviationCoefficient
1430 //=======================================================================
1432 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1434 return myDefaultDrawer->HLRDeviationCoefficient();
1437 //=======================================================================
1438 //function : SetHLRAngle
1440 //=======================================================================
1442 void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
1444 myDefaultDrawer->SetHLRAngle(anAngle);
1447 //=======================================================================
1448 //function : SetHLRAngleAndDeviation
1449 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1450 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1451 // of myDefaultDrawer
1452 //=======================================================================
1454 void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
1457 Standard_Real OutAngl,OutDefl;
1458 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1460 myDefaultDrawer->SetHLRAngle(OutAngl);
1461 myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
1465 //=======================================================================
1466 //function : HLRAngle
1468 //=======================================================================
1470 Standard_Real AIS_InteractiveContext::HLRAngle() const
1472 return myDefaultDrawer->HLRAngle();
1475 //=======================================================================
1476 //function : SetDisplayMode
1478 //=======================================================================
1480 void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
1481 const Standard_Boolean updateviewer)
1483 if(aMode==myDisplayMode) return;
1484 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
1486 for(;It.More();It.Next()){
1488 // const Handle(AIS_InteractiveObject)& anObj = It.Key();
1489 Handle(AIS_InteractiveObject) anObj = It.Key();
1491 Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
1492 anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) ||
1493 anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) );
1495 if ((!anObj->HasDisplayMode()) && Processed)
1497 if(anObj->AcceptDisplayMode(aMode)){
1499 // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
1500 Handle(AIS_GlobalStatus) STATUS = It.Value();
1502 if(STATUS->IsDModeIn(myDisplayMode))
1503 STATUS->RemoveDisplayMode(myDisplayMode);
1505 STATUS->AddDisplayMode(aMode);
1507 if(STATUS->GraphicStatus()== AIS_DS_Displayed){
1508 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1509 myMainPM->Display(anObj, aMode);
1510 if(STATUS->IsSubIntensityOn())
1511 myMainPM->Color(anObj,mySubIntensity,aMode);
1513 // myDisplayMode = aMode;
1518 myDisplayMode = aMode;
1519 if(updateviewer) myMainVwr->Update();
1522 //=======================================================================
1523 //function : SetDisplayMode
1525 //=======================================================================
1527 void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1528 const Standard_Integer aMode,
1529 const Standard_Boolean updateviewer)
1532 if(!anIObj->HasInteractiveContext())
1533 anIObj->SetContext(this);
1534 if(!HasOpenedContext()){
1536 if(!myObjects.IsBound(anIObj))
1537 anIObj->SetDisplayMode(aMode);
1538 else if( anIObj->AcceptDisplayMode(aMode) )
1541 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1542 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1544 // SAN : erase presentations for all display modes different from <aMode>
1545 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1546 TColStd_ListOfInteger aModesToRemove;
1547 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
1548 for(;ItL.More();ItL.Next()){
1550 Standard_Integer OldMode = ItL.Value();
1553 aModesToRemove.Append(OldMode);
1554 if(myMainPM->IsHighlighted(anIObj,OldMode))
1555 myMainPM->Unhighlight(anIObj,OldMode);
1556 myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
1560 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
1561 STATUS->RemoveDisplayMode(ItL.Value());
1563 if(!STATUS->IsDModeIn(aMode))
1564 STATUS->AddDisplayMode(aMode);
1566 myMainPM->Display(anIObj,aMode);
1567 Standard_Integer DM,HM,SM;
1568 GetDefModes(anIObj,DM,HM,SM);
1569 if(STATUS->IsHilighted()){
1570 myMainPM->Highlight(anIObj,HM);
1572 if(STATUS->IsSubIntensityOn()){
1573 myMainPM->Color(anIObj,mySubIntensity,aMode);
1575 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
1576 myMainVwr->Viewer()->SetTransparency(Standard_True);
1578 if(updateviewer) myMainVwr->Update();
1580 anIObj->SetDisplayMode(aMode);
1585 //=======================================================================
1586 //function : UnsetDisplayMode
1588 //=======================================================================
1590 void AIS_InteractiveContext::
1591 UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1592 const Standard_Boolean updateviewer)
1594 if(anIObj.IsNull()) return ;
1595 if(!anIObj->HasDisplayMode()) return;
1597 if(!myObjects.IsBound(anIObj))
1598 anIObj->UnsetDisplayMode();
1601 Standard_Integer OldMode = anIObj->DisplayMode();
1602 if(myDisplayMode==OldMode) return;
1603 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1604 STATUS->RemoveDisplayMode(OldMode);
1605 if(!STATUS->IsDModeIn(myDisplayMode))
1606 STATUS->AddDisplayMode(myDisplayMode);
1607 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1608 if(myMainPM->IsHighlighted(anIObj,OldMode))
1609 myMainPM->Unhighlight(anIObj,OldMode);
1610 myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
1611 myMainPM->Display(anIObj,myDisplayMode);
1612 Standard_Integer DM,HM,SM;
1613 GetDefModes(anIObj,DM,HM,SM);
1614 if(STATUS->IsHilighted()){
1615 myMainPM->Highlight(anIObj,HM);
1617 if(STATUS->IsSubIntensityOn()){
1618 myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
1620 if(updateviewer) myMainVwr->Update();
1622 anIObj->UnsetDisplayMode();
1627 //=======================================================================
1628 //function : SetCurrentFacingModel
1630 //=======================================================================
1632 void AIS_InteractiveContext::SetCurrentFacingModel(
1633 const Handle(AIS_InteractiveObject)& anIObj,
1634 const Aspect_TypeOfFacingModel aModel)
1636 if ( !anIObj.IsNull () )
1637 anIObj->SetCurrentFacingModel(aModel);
1640 //=======================================================================
1641 //function : SetColor
1643 //=======================================================================
1645 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1646 const Quantity_NameOfColor aColor,
1647 const Standard_Boolean updateviewer)
1649 SetColor(anIObj,Quantity_Color(aColor),updateviewer);
1652 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1653 const Quantity_Color &aColor,
1654 const Standard_Boolean updateviewer)
1656 if(anIObj.IsNull()) return ;
1658 if(!anIObj->HasInteractiveContext())
1659 anIObj->SetContext(this);
1660 anIObj->SetColor(aColor);
1661 if(anIObj->RecomputeEveryPrs())
1662 anIObj->Redisplay();
1665 Standard_Integer NbDisp=0;
1666 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1667 for (;ITI.More();ITI.Next())
1669 anIObj->Update(ITI.Value(),Standard_False);
1672 anIObj->SetRecomputeOk();
1674 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1681 // if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
1682 // Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
1683 // Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
1685 // gp_Dir D =Tr->Component()->XDirection();
1686 // gp_Pnt O = Tr->Component()->Location();
1687 // gp_Vec V(D);V*=Lx/5.;
1688 // T.SetRotation(gp_Ax1(O,D),M_PI/6.);
1689 // T.SetTranslationPart(V);
1690 // TopLoc_Location L,IncLoc(T);
1692 // for(Standard_Integer I=1;I<90;I++){
1693 // if(anIObj->HasLocation())
1694 // L = anIObj->Location() * IncLoc;
1697 // SetLocation(anIObj,L);
1698 // UpdateCurrentViewer();
1700 // for(I=1;I<90;I++){
1701 // L = anIObj->Location() /IncLoc;
1702 // SetLocation(anIObj,L);
1703 // UpdateCurrentViewer();
1705 // ResetLocation(anIObj);
1708 if(updateviewer) UpdateCurrentViewer();
1711 //=======================================================================
1712 //function : SetDeviationCoefficient
1714 //=======================================================================
1716 void AIS_InteractiveContext::SetDeviationCoefficient(
1717 const Handle(AIS_InteractiveObject)& anIObj,
1718 const Standard_Real aCoefficient,
1719 const Standard_Boolean updateviewer)
1721 // cout<<" Coefficient:"<< aCoefficient <<endl;
1722 if(anIObj.IsNull()) return ;
1724 if(!anIObj->HasInteractiveContext())
1725 anIObj->SetContext(this);
1727 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1728 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
1729 if(anIObj->Signature()!=0) return;
1730 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
1734 if(anIObj->RecomputeEveryPrs())
1735 anIObj->Redisplay();
1738 Standard_Integer NbDisp=0;
1739 TColStd_ListOfInteger LL;
1740 anIObj->ToBeUpdated(LL);
1741 TColStd_ListIteratorOfListOfInteger ITI(LL);
1742 for (;ITI.More();ITI.Next())
1744 anIObj->Update(ITI.Value(),Standard_False);
1747 anIObj->SetRecomputeOk();
1749 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1752 if(updateviewer) UpdateCurrentViewer();
1755 //=======================================================================
1756 //function : SetHLRDeviationCoefficient
1758 //=======================================================================
1760 void AIS_InteractiveContext::SetHLRDeviationCoefficient(
1761 const Handle(AIS_InteractiveObject)& anIObj,
1762 const Standard_Real aCoefficient,
1763 const Standard_Boolean updateviewer)
1765 // cout<<" HLRCoefficient:"<< aCoefficient <<endl;
1766 if(anIObj.IsNull()) return ;
1768 if(!anIObj->HasInteractiveContext())
1769 anIObj->SetContext(this);
1770 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1771 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
1772 if(anIObj->Signature()!=0) return;
1773 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
1777 if(anIObj->RecomputeEveryPrs())
1778 anIObj->Redisplay();
1781 Standard_Integer NbDisp=0;
1783 TColStd_ListOfInteger LL;
1784 anIObj->ToBeUpdated(LL);
1785 TColStd_ListIteratorOfListOfInteger ITI(LL);
1786 for (;ITI.More();ITI.Next())
1788 anIObj->Update(ITI.Value(),Standard_False);
1791 anIObj->SetRecomputeOk();
1793 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1796 if(updateviewer) UpdateCurrentViewer();
1800 //=======================================================================
1801 //function : SetDeviationAngle
1803 //=======================================================================
1805 void AIS_InteractiveContext::SetDeviationAngle(
1806 const Handle(AIS_InteractiveObject)& anIObj,
1807 const Standard_Real anAngle,
1808 const Standard_Boolean updateviewer)
1810 // cout<<" Angle:"<< anAngle <<endl;
1811 if(anIObj.IsNull()) return ;
1813 if(!anIObj->HasInteractiveContext())
1814 anIObj->SetContext(this);
1815 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1816 if(anIObj->Type()!=AIS_KOI_Shape) return;
1817 if(anIObj->Signature()!=0) return;
1818 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
1821 if(anIObj->RecomputeEveryPrs())
1822 anIObj->Redisplay();
1825 Standard_Integer NbDisp=0;
1826 TColStd_ListOfInteger LL;
1827 anIObj->ToBeUpdated(LL);
1828 TColStd_ListIteratorOfListOfInteger ITI(LL);
1829 for (;ITI.More();ITI.Next())
1831 anIObj->Update(ITI.Value(),Standard_False);
1834 anIObj->SetRecomputeOk();
1836 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1839 if(updateviewer) UpdateCurrentViewer();
1841 //=======================================================================
1842 //function : SetDeviationAngle
1844 //=======================================================================
1846 void AIS_InteractiveContext::SetAngleAndDeviation(
1847 const Handle(AIS_InteractiveObject)& anIObj,
1848 const Standard_Real anAngle,
1849 const Standard_Boolean updateviewer)
1851 // cout<<" Angle:"<< anAngle <<endl;
1852 if(anIObj.IsNull()) return ;
1853 // Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
1854 if(!anIObj->HasInteractiveContext())
1855 anIObj->SetContext(this);
1857 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1858 if(anIObj->Type()!=AIS_KOI_Shape) return;
1859 if(anIObj->Signature()!=0) return;
1860 (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
1863 if(anIObj->RecomputeEveryPrs())
1864 anIObj->Redisplay();
1866 Update(anIObj,updateviewer);
1869 //=======================================================================
1870 //function : SetDeviationAngle
1872 //=======================================================================
1874 void AIS_InteractiveContext::SetHLRAngleAndDeviation(
1875 const Handle(AIS_InteractiveObject)& anIObj,
1876 const Standard_Real anAngle,
1877 const Standard_Boolean updateviewer)
1879 // cout<<" Angle:"<< anAngle <<endl;
1881 if(anIObj.IsNull()) return ;
1882 if(!anIObj->HasInteractiveContext())
1883 anIObj->SetContext(this);
1885 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1886 if(anIObj->Type()!=AIS_KOI_Shape) return;
1887 if(anIObj->Signature()!=0) return;
1888 (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
1891 if(anIObj->RecomputeEveryPrs())
1892 anIObj->Redisplay();
1895 Standard_Integer NbDisp=0;
1897 TColStd_ListOfInteger LL;
1898 anIObj->ToBeUpdated(LL);
1899 TColStd_ListIteratorOfListOfInteger ITI(LL);
1900 for (;ITI.More();ITI.Next())
1902 anIObj->Update(ITI.Value(),Standard_False);
1905 anIObj->SetRecomputeOk();
1907 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1910 if(updateviewer) UpdateCurrentViewer();
1913 //=======================================================================
1914 //function : SetHLRDeviationAngle
1916 //=======================================================================
1918 void AIS_InteractiveContext::SetHLRDeviationAngle(
1919 const Handle(AIS_InteractiveObject)& anIObj,
1920 const Standard_Real anAngle,
1921 const Standard_Boolean updateviewer)
1923 // cout<<" HLRAngle:"<< anAngle <<endl;
1924 if(anIObj.IsNull()) return ;
1926 if(!anIObj->HasInteractiveContext())
1927 anIObj->SetContext(this);
1928 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1929 if( anIObj->Type()!=AIS_KOI_Shape) return;
1930 if(anIObj->Signature()!=0) return;
1931 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
1934 if(anIObj->RecomputeEveryPrs())
1935 anIObj->Redisplay();
1938 Standard_Integer NbDisp=0;
1939 TColStd_ListOfInteger LL;
1940 anIObj->ToBeUpdated(LL);
1941 TColStd_ListIteratorOfListOfInteger ITI(LL);
1942 for (;ITI.More();ITI.Next())
1944 anIObj->Update(ITI.Value(),Standard_False);
1947 anIObj->SetRecomputeOk();
1949 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1952 if(updateviewer) UpdateCurrentViewer();
1955 //=======================================================================
1956 //function : UnsetColor
1958 //=======================================================================
1960 void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
1961 const Standard_Boolean updateviewer)
1963 if(anIObj.IsNull()) return ;
1964 anIObj->UnsetColor();
1965 if(anIObj->RecomputeEveryPrs())
1966 anIObj->Redisplay();
1969 Standard_Integer NbDisp =0;
1970 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1971 for (;ITI.More();ITI.Next())
1973 anIObj->Update(ITI.Value(),Standard_False);
1977 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1979 anIObj->SetRecomputeOk();
1982 UpdateCurrentViewer();
1985 //=======================================================================
1986 //function : HasColor
1988 //=======================================================================
1990 Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const
1992 return anIObj->HasColor();
1996 //=======================================================================
1999 //=======================================================================
2001 Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const
2003 return anIObj->Color();
2006 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
2007 Quantity_Color &aColor) const
2009 anIObj->Color(aColor);
2012 //=======================================================================
2015 //=======================================================================
2017 Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const
2019 return anIObj->Width();
2022 //=======================================================================
2023 //function : SetWidth
2025 //=======================================================================
2027 void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2028 const Standard_Real aValue,
2029 const Standard_Boolean updateviewer)
2031 if(anIObj.IsNull()) return ;
2033 if(!anIObj->HasInteractiveContext())
2034 anIObj->SetContext(this);
2035 anIObj->SetWidth(aValue);
2036 if(anIObj->RecomputeEveryPrs())
2037 anIObj->Redisplay();
2040 Standard_Integer NbDisp=0;
2041 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2042 for (;ITI.More();ITI.Next())
2044 anIObj->Update(ITI.Value(),Standard_False);
2048 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2050 anIObj->SetRecomputeOk();
2053 UpdateCurrentViewer();
2056 //=======================================================================
2057 //function : UnsetWidth
2059 //=======================================================================
2061 void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2062 const Standard_Boolean updateviewer)
2064 if(anIObj.IsNull()) return ;
2065 anIObj->UnsetWidth();
2066 if(anIObj->RecomputeEveryPrs())
2067 anIObj->Redisplay();
2070 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2071 for (;ITI.More();ITI.Next())
2073 anIObj->Update(ITI.Value(),Standard_False);
2075 anIObj->SetRecomputeOk();
2078 UpdateCurrentViewer();
2081 //=======================================================================
2082 //function : SetMaterial
2084 //=======================================================================
2086 void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2088 const Graphic3d_NameOfMaterial aName,
2089 // const Graphic3d_NameOfPhysicalMaterial aName,
2090 const Standard_Boolean updateviewer)
2092 if(!anIObj->HasInteractiveContext())
2093 anIObj->SetContext(this);
2094 anIObj->SetMaterial(aName);
2095 if(anIObj->RecomputeEveryPrs())
2096 anIObj->Redisplay();
2099 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2100 for (;ITI.More();ITI.Next())
2102 anIObj->Update(ITI.Value(),Standard_False);
2104 anIObj->SetRecomputeOk();
2107 UpdateCurrentViewer();
2111 //=======================================================================
2112 //function : UnsetMaterial
2114 //=======================================================================
2116 void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2117 const Standard_Boolean updateviewer)
2119 if(anIObj.IsNull()) return ;
2120 anIObj->UnsetMaterial();
2121 if(anIObj->RecomputeEveryPrs())
2122 anIObj->Redisplay();
2125 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2126 for (;ITI.More();ITI.Next())
2128 anIObj->Update(ITI.Value(),Standard_False);
2130 anIObj->SetRecomputeOk();
2133 UpdateCurrentViewer();
2136 //=======================================================================
2137 //function : SetTransparency
2139 //=======================================================================
2141 void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2142 const Standard_Real aValue,
2143 const Standard_Boolean updateviewer)
2145 if(anIObj.IsNull()) return ;
2146 if(!anIObj->HasInteractiveContext())
2147 anIObj->SetContext(this);
2149 #ifdef BUC60577 //right optimization
2150 if(!anIObj->IsTransparent() && aValue<=0.05) return;
2152 // if(!anIObj->IsTransparent() && aValue<=0.05) return;
2155 UnsetTransparency(anIObj,updateviewer);
2159 if(!myMainVwr->Viewer()->Transparency())
2160 myMainVwr->Viewer()->SetTransparency(Standard_True);
2161 anIObj->SetTransparency(aValue);
2162 if(anIObj->RecomputeEveryPrs())
2163 anIObj->Redisplay();
2166 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2167 for (;ITI.More();ITI.Next())
2169 anIObj->Update(ITI.Value(),Standard_False);
2171 anIObj->SetRecomputeOk();
2174 UpdateCurrentViewer();
2177 //=======================================================================
2178 //function : UnsetTransparency
2180 //=======================================================================
2182 void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2183 const Standard_Boolean updateviewer)
2185 if(anIObj.IsNull()) return ;
2186 anIObj->UnsetTransparency();
2187 if(anIObj->RecomputeEveryPrs())
2188 anIObj->Redisplay();
2191 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2192 for (;ITI.More();ITI.Next())
2194 anIObj->Update(ITI.Value(),Standard_False);
2196 anIObj->SetRecomputeOk();
2199 // To Unset transparency in the viewer, if no other object is transparent ...(Speed)
2200 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
2201 Standard_Boolean FoundTransp(Standard_False);
2202 for(;It.More() && !FoundTransp ;It.Next()){
2203 if(It.Key()->IsTransparent())
2204 FoundTransp = Standard_True;
2207 myMainVwr->Viewer()->SetTransparency(Standard_False);
2211 UpdateCurrentViewer();
2214 //=======================================================================
2215 //function : SetSelectedAspect
2217 //=======================================================================
2218 void AIS_InteractiveContext::SetSelectedAspect(
2219 const Handle(Prs3d_BasicAspect)& anAspect,
2220 const Standard_Boolean globalChange,
2221 const Standard_Boolean updateViewer)
2223 if( !HasOpenedContext() ) {
2224 Standard_Boolean found = Standard_False;
2225 Handle(AIS_Selection) sel =
2226 AIS_Selection::Selection(myCurrentName.ToCString());
2227 Handle(AIS_InteractiveObject) object;
2228 for( sel->Init() ; sel->More() ; sel->Next()) {
2229 found = Standard_True;
2230 object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
2231 object->SetAspect(anAspect,globalChange);
2233 if( found && updateViewer) {
2234 myMainVwr->Update();
2239 //=======================================================================
2240 //function : SetLocalAttributes
2242 //=======================================================================
2244 void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2245 const Handle(AIS_Drawer)& aDrawer,
2246 const Standard_Boolean updateviewer)
2248 if(anIObj.IsNull()) return ;
2249 if(!anIObj->HasInteractiveContext())
2250 anIObj->SetContext(this);
2251 anIObj->SetAttributes(aDrawer);
2252 Update(anIObj,updateviewer);
2256 //=======================================================================
2257 //function : UnsetLocalAttributes
2259 //=======================================================================
2260 void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2261 const Standard_Boolean updateviewer)
2263 if(anIObj.IsNull()) return ;
2264 if(!anIObj->HasInteractiveContext())
2265 anIObj->SetContext(this);
2266 anIObj->UnsetAttributes();
2267 Update(anIObj,updateviewer);
2271 //=======================================================================
2274 //=======================================================================
2276 void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const
2280 if(anIObj.IsNull()) return ;
2281 if(myObjects.IsBound(anIObj)){
2282 astatus += "\t ____________________________________________";
2283 astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2284 const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
2285 switch(ST->GraphicStatus()){
2286 case AIS_DS_Displayed:
2288 astatus +="\t| -->Displayed\n";
2293 astatus +="\t| -->Erased\n";
2299 astatus += "\t| Active Display Modes in the MainViewer :\n";
2300 TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
2301 for(;ItL.More();ItL.Next()){
2302 astatus += "\t|\t Mode ";
2303 astatus += TCollection_AsciiString(ItL.Value());
2306 if(IsCurrent(anIObj)) astatus +="\t| Current\n";
2307 if(IsSelected(anIObj)) astatus +="\t| Selected\n";
2309 astatus += "\t| Active Selection Modes in the MainViewer :\n";
2310 for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
2311 astatus += "\t\t Mode ";
2312 astatus += TCollection_AsciiString(ItL.Value());
2315 astatus += "\t ____________________________________________";
2321 //=======================================================================
2322 //function : GetDefModes
2324 //=======================================================================
2326 void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
2327 Standard_Integer& DispMode,
2328 Standard_Integer& HiMode,
2329 Standard_Integer& SelMode) const
2331 if(anIObj.IsNull()) return ;
2332 DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
2333 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
2335 HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
2337 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
2339 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
2344 //=======================================================================
2345 //function : EraseGlobal
2347 //=======================================================================
2349 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2350 const Standard_Boolean updateviewer)
2352 if(anIObj.IsNull()) return ;
2353 if(!myObjects.IsBound(anIObj)) return;
2356 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2357 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2359 Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2360 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
2362 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2363 for(;ItL.More();ItL.Next()){
2364 if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2365 myMainPM->Unhighlight(anIObj,ItL.Value());
2366 myMainPM->SetVisibility (anIObj, ItL.Value(), Standard_False);
2368 if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
2369 myMainPM->SetVisibility (anIObj, Dmode, Standard_False);
2371 for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
2372 mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
2373 if(updateviewer) myMainVwr->Update();
2375 STATUS->SetGraphicStatus(AIS_DS_Erased);
2379 //=======================================================================
2380 //function : ClearGlobal
2382 //=======================================================================
2384 void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2385 const Standard_Boolean updateviewer)
2387 if(anIObj.IsNull()) return ;
2388 if(!myObjects.IsBound(anIObj)) return;
2390 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2391 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2393 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2394 for(;ItL.More();ItL.Next()){
2395 if(STATUS->IsHilighted()){
2396 if(IsCurrent(anIObj))
2398 AddOrRemoveCurrentObject( anIObj, updateviewer );
2400 AddOrRemoveCurrentObject(anIObj);
2402 else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2403 myMainPM->Unhighlight(anIObj,ItL.Value());
2405 myMainPM->Erase(anIObj,ItL.Value());
2406 myMainPM->Clear(anIObj,ItL.Value());
2407 if(anIObj->HasHilightMode()){
2408 Standard_Integer im = anIObj->HilightMode();
2409 myMainPM->Unhighlight(anIObj,im);
2410 myMainPM->Erase(anIObj,im);
2415 //Object removes from Detected sequence
2416 Standard_Integer i = 1;
2417 for(i = 1; i < myAISDetectedSeq.Length(); i++)
2419 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2420 if( !anObj.IsNull() && anObj != anIObj )
2421 myAISDetectedSeq.Remove( i );
2424 if(myLastinMain == anIObj)
2425 myLastinMain.Nullify();
2427 if(myLastPicked == anIObj)
2428 myLastPicked.Nullify();
2430 // OCC21671: Remove IO from the selection manager in any case
2431 // to avoid memory leaks
2432 mgrSelector->Remove(anIObj);
2434 if (updateviewer && (STATUS->GraphicStatus() == AIS_DS_Displayed))
2436 myMainVwr->Update();
2439 myObjects.UnBind(anIObj);
2443 //=======================================================================
2444 //function : ClearGlobalPrs
2446 //=======================================================================
2448 void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj,
2449 const Standard_Integer aMode,
2450 const Standard_Boolean updateviewer)
2452 if(anIObj.IsNull()) return ;
2453 if(!myObjects.IsBound(anIObj)) return;
2454 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2456 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2457 if(STATUS->IsDModeIn(aMode)){
2458 if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
2459 myMainPM->Unhighlight(anIObj,aMode);
2461 myMainPM->Erase(anIObj,aMode);
2462 myMainPM->Clear(anIObj,aMode);
2466 if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
2467 myMainVwr->Update();
2470 //=======================================================================
2471 //function : DrawHiddenLine
2473 //=======================================================================
2475 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
2477 return myDefaultDrawer->DrawHiddenLine();
2480 //=======================================================================
2481 //function : EnableDrawHiddenLine
2483 //=======================================================================
2485 void AIS_InteractiveContext::EnableDrawHiddenLine () const {
2486 myDefaultDrawer->EnableDrawHiddenLine();
2489 //=======================================================================
2490 //function : DisableDrawHiddenLine
2492 //=======================================================================
2494 void AIS_InteractiveContext::DisableDrawHiddenLine () const {
2495 myDefaultDrawer->DisableDrawHiddenLine();
2498 //=======================================================================
2499 //function : HiddenLineAspect
2501 //=======================================================================
2503 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const {
2504 return myDefaultDrawer->HiddenLineAspect();
2507 //=======================================================================
2508 //function : SetHiddenLineAspect
2510 //=======================================================================
2512 void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
2513 myDefaultDrawer->SetHiddenLineAspect(anAspect);
2516 //=======================================================================
2517 //function : SetIsoNumber
2519 //=======================================================================
2521 void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
2525 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2528 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2531 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2532 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2537 //=======================================================================
2538 //function : IsoNumber
2540 //=======================================================================
2542 Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
2547 return myDefaultDrawer->UIsoAspect()->Number();
2549 return myDefaultDrawer->VIsoAspect()->Number();
2551 return (myDefaultDrawer->UIsoAspect()->Number()==
2552 myDefaultDrawer->VIsoAspect()->Number()) ?
2553 myDefaultDrawer->UIsoAspect()->Number(): -1;
2558 //=======================================================================
2559 //function : IsoOnPlane
2561 //=======================================================================
2563 void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
2565 myDefaultDrawer->SetIsoOnPlane(SwitchOn);
2568 //=======================================================================
2569 //function : IsoOnPlane
2571 //=======================================================================
2573 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2575 return myDefaultDrawer->IsoOnPlane();
2578 //=======================================================================
2579 //function : SetSelectionMode
2581 //=======================================================================
2583 void AIS_InteractiveContext::SetSelectionMode(const Handle(AIS_InteractiveObject)&, const Standard_Integer )
2587 //=======================================================================
2588 //function : UnsetSelectionMode
2590 //=======================================================================
2592 void AIS_InteractiveContext::UnsetSelectionMode(const Handle(AIS_InteractiveObject)&)
2596 //=======================================================================
2597 //function : SetSensitivityMode
2599 //=======================================================================
2601 void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
2603 if( HasOpenedContext() )
2604 myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
2606 myMainSel->SetSensitivityMode(aMode);
2610 //=======================================================================
2611 //function : SensitivityMode
2613 //=======================================================================
2615 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
2617 if( HasOpenedContext() )
2618 return myLocalContexts(myCurLocalIndex)->SensitivityMode();
2619 return myMainSel->SensitivityMode();
2622 //=======================================================================
2623 //function : SetSensitivity
2625 //=======================================================================
2627 void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
2629 if( HasOpenedContext() )
2630 myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
2632 myMainSel->SetSensitivity(aPrecision);
2636 //=======================================================================
2637 //function : Sensitivity
2639 //=======================================================================
2641 Standard_Real AIS_InteractiveContext::Sensitivity() const {
2643 if( HasOpenedContext() )
2644 return myLocalContexts(myCurLocalIndex)->Sensitivity();
2645 return myMainSel->Sensitivity();
2648 //=======================================================================
2649 //function : SetPixelTolerance
2651 //=======================================================================
2653 void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
2655 if( HasOpenedContext() )
2656 myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
2658 myMainSel->SetPixelTolerance(aPrecision);
2662 //=======================================================================
2663 //function : PixelTolerance
2665 //=======================================================================
2667 Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
2669 if( HasOpenedContext() )
2670 return myLocalContexts(myCurLocalIndex)->PixelTolerance();
2671 return myMainSel->PixelTolerance();
2674 //=======================================================================
2675 //function : IsInLocal
2677 //=======================================================================
2679 Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle(AIS_InteractiveObject)& anIObj,
2680 Standard_Integer& TheIndex) const
2682 if(anIObj.IsNull()) return Standard_False;
2683 // if it exists at neutral point 0 index is returned
2684 if(myObjects.IsBound(anIObj)) {
2686 return Standard_False;
2688 for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
2689 if(myLocalContexts.IsBound(I)){
2690 if(myLocalContexts(I)->IsIn(anIObj)){
2692 return Standard_True;
2698 return Standard_False;
2701 //=======================================================================
2702 //function : InitAttributes
2704 //=======================================================================
2706 void AIS_InteractiveContext::InitAttributes()
2709 mgrSelector->Add(myMainSel);
2710 myCurrentName = AIS_Context_NewCurName();
2711 mySelectionName = AIS_Context_NewSelName();
2713 AIS_Selection::CreateSelection(mySelectionName.ToCString());
2714 AIS_Selection::CreateSelection(myCurrentName.ToCString());
2717 myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
2718 Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
2719 myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
2721 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2722 Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
2723 HLA->SetColor(Quantity_NOC_GRAY20);
2725 HLA->SetTypeOfLine(Aspect_TOL_DASH);
2727 // tolerance to 4 pixels...
2728 SetPixelTolerance();
2730 // Customizing the drawer for trihedrons and planes...
2732 Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
2733 Standard_Real aLength(100.);
2734 DA->SetAxisLength(aLength,aLength,aLength);
2735 Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
2736 DA->FirstAxisAspect()->SetColor(col);
2737 DA->SecondAxisAspect()->SetColor(col);
2738 DA->ThirdAxisAspect()->SetColor(col);
2740 Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
2742 PA->SetPlaneLength(aLength,aLength);
2743 PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
2749 //=======================================================================
2750 //function : TrihedronSize
2752 //=======================================================================
2753 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2755 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2757 //=======================================================================
2758 //function : SetTrihedronSize
2760 //=======================================================================
2761 void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
2763 myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
2764 Redisplay(AIS_KOI_Datum,3,Standard_False);
2765 Redisplay(AIS_KOI_Datum,4,Standard_True);
2770 //=======================================================================
2771 //function : SetPlaneSize
2773 //=======================================================================
2774 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
2775 const Standard_Real aValY,
2776 const Standard_Boolean /*updateviewer*/)
2778 myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
2779 Redisplay(AIS_KOI_Datum,7);
2782 //=======================================================================
2783 //function : SetPlaneSize
2785 //=======================================================================
2787 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
2788 const Standard_Boolean updateviewer)
2790 SetPlaneSize(aVal,aVal,updateviewer);
2793 //=======================================================================
2794 //function : PlaneSize
2796 //=======================================================================
2798 Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
2800 LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2801 LY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2802 return (Abs(LX-LY)<=Precision::Confusion());
2807 //=======================================================================
2810 //=======================================================================
2811 void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
2813 myIsAutoActivateSelMode = Auto;
2816 //=======================================================================
2819 //=======================================================================
2820 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2822 return myIsAutoActivateSelMode;
2825 //=======================================================================
2826 //function : SetZLayer
2828 //=======================================================================
2830 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2831 const Standard_Integer theLayerId)
2833 if (theIObj.IsNull ())
2836 if (myObjects.IsBound (theIObj))
2838 if (myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed || myObjects (theIObj)->GraphicStatus() == AIS_DS_Erased)
2840 theIObj->SetZLayer (myMainPM, theLayerId);
2843 else if (HasOpenedContext ())
2845 myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
2849 //=======================================================================
2850 //function : GetZLayer
2852 //=======================================================================
2854 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2856 if (theIObj.IsNull ())
2859 if (myObjects.IsBound (theIObj))
2861 return theIObj->GetZLayer (myMainPM);
2863 else if (HasOpenedContext ())
2865 return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);