1 // Created on: 1997-01-17
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
23 #define BUC60577 //GG_101099 Enable to compute correctly
24 // transparency with more than one object in the view.
26 #define GER61351 //GG_171199 Enable to set an object RGB color
27 // instead a restricted object NameOfColor.
29 #define G003 //EUG_26/01/00 Degenerate support (G003)
31 #define IMP140200 //GG Add SetSelectedAspect() method.
33 #define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
34 // method, compute only authorized presentation.
36 #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods.
38 #define BUC60722 //GG 04/09/00 Always enable viewer update when erasing something
40 #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
42 #define OCC172 //SAV clear static map before destroying context.
44 #define OCC204 //SAV 26/02/02 : pass <updateviewer> flag to
45 // AddOrRemoveCurrentObject method from ClearGlobal.
47 #define OCC4373 //SAN 10/11/03 : improve display mode management in
48 // Display( IO, updateviewer ) and
49 // SetDisplayMode( IO, mode, updateviewer ) methods
51 #include <AIS_InteractiveContext.ixx>
53 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
54 #include <TColStd_ListIteratorOfListOfInteger.hxx>
55 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
56 #include <AIS_LocalContext.hxx>
57 #include <AIS_LocalStatus.hxx>
58 #include <Precision.hxx>
59 #include <AIS_Selection.hxx>
60 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
61 #include <AIS_ConnectedShape.hxx>
62 #include <AIS_MultipleConnectedShape.hxx>
63 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
64 #include <AIS_GlobalStatus.hxx>
65 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
66 #include <PrsMgr_ModedPresentation.hxx>
67 #include <Visual3d_ViewManager.hxx>
68 #include <Prs3d_ShadingAspect.hxx>
69 #include <AIS_Shape.hxx>
70 #include <Graphic3d_AspectFillArea3d.hxx>
71 #include <HLRBRep.hxx>
72 #include <Prs3d_IsoAspect.hxx>
73 #include <Prs3d_DatumAspect.hxx>
74 #include <Prs3d_PlaneAspect.hxx>
75 #include <PrsMgr_PresentableObject.hxx>
76 #include <Standard_Atomic.hxx>
77 #include <UnitsAPI.hxx>
79 #include <AIS_Trihedron.hxx>
80 #include <Geom_Axis2Placement.hxx>
81 #include <OSD_Environment.hxx>
83 #include <AIS_ListIteratorOfListOfInteractive.hxx>
85 // In the method GetDefModes() the returned value of the selection mode
86 // is always equal to 0 if it is -1.
89 // The local context is closed the method ::ResetOriginalState() sets the selection mode equal to 0
90 // in spite of the selection mode of the interactive object in Natural Point.
93 // An interactive Object being erased in the main viewer and put into collector should have the same selection mode.
94 // It impacts the performance!
97 static Standard_Boolean AISDebugModeOn()
99 // static OSD_Environment aisdb("AISDEBUGMODE");
100 // return !aisdb.Value().IsEmpty();
101 static Standard_Integer isDebugMode(-1);
102 if (isDebugMode < 0) {
104 OSD_Environment aisdb("AISDEBUGMODE");
105 if (aisdb.Value().IsEmpty())
108 return (isDebugMode != 0);
113 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
114 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
116 static TCollection_AsciiString AIS_Context_NewSelName()
118 return TCollection_AsciiString ("AIS_SelContext_")
119 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
122 static TCollection_AsciiString AIS_Context_NewCurName()
124 return TCollection_AsciiString ("AIS_CurContext_")
125 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
129 //=======================================================================
130 //function : AIS_InteractiveContext
132 //=======================================================================
134 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
135 mgrSelector(new SelectMgr_SelectionManager()),
136 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
137 myMainVwr(MainViewer),
138 myMainSel(new StdSelect_ViewerSelector3d()),
139 myIsCollClosed(Standard_True),
140 myToHilightSelected( Standard_False ),
141 myFilters(new SelectMgr_OrFilter()),
142 myDefaultDrawer(new Prs3d_Drawer()),
143 myDefaultColor(Quantity_NOC_GOLDENROD),
144 myHilightColor(Quantity_NOC_CYAN1),
145 mySelectionColor(Quantity_NOC_GRAY80),
146 myPreselectionColor(Quantity_NOC_GREEN),
147 mySubIntensity(Quantity_NOC_GRAY40),
153 myIsAutoActivateSelMode( Standard_True )
159 //=======================================================================
160 //function : AIS_InteractiveContext
162 //=======================================================================
164 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer,
165 const Handle(V3d_Viewer)& Collector):
166 mgrSelector(new SelectMgr_SelectionManager()),
167 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
168 myMainVwr(MainViewer),
169 myMainSel(new StdSelect_ViewerSelector3d()),
170 myCollectorPM(new PrsMgr_PresentationManager3d(Collector->Viewer())),
171 myCollectorVwr(Collector),
172 myCollectorSel(new StdSelect_ViewerSelector3d()),
173 myIsCollClosed(Standard_False),
174 myToHilightSelected( Standard_False ),
175 myFilters(new SelectMgr_OrFilter()),
176 myDefaultDrawer(new Prs3d_Drawer()),
177 myDefaultColor(Quantity_NOC_GOLDENROD),
178 myHilightColor(Quantity_NOC_CYAN1),
179 mySelectionColor(Quantity_NOC_GRAY80),
180 myPreselectionColor(Quantity_NOC_GREEN),
181 mySubIntensity(Quantity_NOC_GRAY40),
187 myIsAutoActivateSelMode( Standard_True )
190 mgrSelector->Add(myCollectorSel);
194 void AIS_InteractiveContext::Delete() const
197 // to avoid an exception
198 if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
199 AIS_Selection::Remove( mySelectionName.ToCString() );
201 // to avoid an exception
202 if ( AIS_Selection::Find( myCurrentName.ToCString() ) )
203 AIS_Selection::Remove( myCurrentName.ToCString() );
205 // let's remove one reference explicitly. this operation's supposed to
206 // be performed when mgrSelector will be destroyed but anyway...
207 mgrSelector->Remove( myMainSel );
209 MMgt_TShared::Delete();
212 //=======================================================================
213 //function : AIS_SelectionName
215 //=======================================================================
216 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
218 if(!HasOpenedContext())
219 return mySelectionName;
220 return myLocalContexts(myCurLocalIndex)->SelectionName();
226 //=======================================================================
227 //function : UpdateCurrentViewer
229 //=======================================================================
231 void AIS_InteractiveContext::UpdateCurrentViewer()
233 if (!myMainVwr.IsNull())
237 void AIS_InteractiveContext::OpenCollector()
239 myIsCollClosed =Standard_True;
240 // to be completed....
245 //=======================================================================
246 //function : DomainOfMainViewer
248 //=======================================================================
250 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
252 return myMainVwr->Domain();
256 //=======================================================================
257 //function : DisplayedObjects
259 //=======================================================================
261 void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
262 const Standard_Boolean OnlyFromNeutral) const
265 cout<<"AIS_IC::DisplayedObjects"<<endl;
268 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
269 if(!HasOpenedContext() || OnlyFromNeutral){
270 for(;It.More();It.Next()){
271 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
272 aListOfIO.Append(It.Key());
276 TColStd_MapOfTransient theMap;
278 for(;It.More();It.Next()){
279 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
280 theMap.Add(It.Key());
283 cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl;
286 //parse all local contexts...
287 Standard_Integer NbDisp;
288 for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
289 const Handle(AIS_LocalContext)& LC = it1.Value();
290 NbDisp = LC->DisplayedObjects(theMap);
292 cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
296 Handle(AIS_InteractiveObject) curIO;
297 Handle(Standard_Transient) Tr;
298 for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
300 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
301 aListOfIO.Append(curIO);
305 //=======================================================================
306 //function : DisplayedObjects
308 //=======================================================================
310 void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
311 const Standard_Integer TheSign,
312 AIS_ListOfInteractive& aListOfIO,
313 const Standard_Boolean /*OnlyFromNeutral*/) const
315 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
318 //=======================================================================
319 //function : UpdateCollector
321 //=======================================================================
323 void AIS_InteractiveContext::UpdateCollector()
325 if (!myCollectorVwr.IsNull())
326 myCollectorVwr->Update();
329 //=======================================================================
330 //function : DomainOfCollector
332 //=======================================================================
334 Standard_CString AIS_InteractiveContext::DomainOfCollector() const
336 if(myCollectorVwr.IsNull()) return "";
337 return myCollectorVwr->Domain();
340 //=======================================================================
341 //function : ObjectsInCollector
343 //=======================================================================
345 void AIS_InteractiveContext::ObjectsInCollector(AIS_ListOfInteractive& aListOfIO) const
347 ObjectsByDisplayStatus( AIS_DS_Erased, aListOfIO );
350 //=======================================================================
351 //function : ObjectsInCollector
353 //=======================================================================
355 void AIS_InteractiveContext::ObjectsInCollector(const AIS_KindOfInteractive TheKind,
356 const Standard_Integer TheSign,
357 AIS_ListOfInteractive& aListOfIO) const
359 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, aListOfIO );
362 //=======================================================================
363 //function : ErasedObjects
365 //=======================================================================
367 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const
369 ObjectsByDisplayStatus( AIS_DS_FullErased, theListOfIO );
372 //=======================================================================
373 //function : ErasedObjects
375 //=======================================================================
377 void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
378 const Standard_Integer TheSign,
379 AIS_ListOfInteractive& theListOfIO) const
381 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_FullErased, theListOfIO );
384 //=======================================================================
385 //function : ObjectsByDisplayStatus
387 //=======================================================================
389 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
390 AIS_ListOfInteractive& theListOfIO) const
392 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
393 for(;It.More();It.Next()){
394 if(It.Value()->GraphicStatus() == theStatus)
395 theListOfIO.Append(It.Key());
399 //=======================================================================
400 //function : ObjectsByDisplayStatus
402 //=======================================================================
404 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
405 const Standard_Integer TheSign,
406 const AIS_DisplayStatus theStatus,
407 AIS_ListOfInteractive& theListOfIO) const
409 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
410 for(;It.More();It.Next()){
411 if(It.Value()->GraphicStatus()==theStatus){
412 if(It.Key()->Type()==TheKind){
414 theListOfIO.Append(It.Key());
416 if(It.Key()->Signature()==TheSign)
417 theListOfIO.Append(It.Key());
424 //=======================================================================
425 //function : ObjectsInside
427 //=======================================================================
429 void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
430 const AIS_KindOfInteractive TheKind,
431 const Standard_Integer TheSign) const
433 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
434 if(TheKind==AIS_KOI_None && TheSign ==-1){
435 for(;It.More();It.Next()){
436 aListOfIO.Append(It.Key());
440 for(;It.More();It.Next()){
441 if(It.Key()->Type()==TheKind){
443 aListOfIO.Append(It.Key());
445 if(It.Key()->Signature()==TheSign)
446 aListOfIO.Append(It.Key());
453 //=======================================================================
456 //=======================================================================
458 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
459 const Standard_Boolean updateviewer )
461 if(anIObj.IsNull()) return;
463 Standard_Integer DispMode,HiMod,SelMode;
465 GetDefModes(anIObj,DispMode,HiMod,SelMode);
467 Handle (AIS_InteractiveContext) aThis = this;
468 if(!anIObj->HasInteractiveContext())
469 anIObj->SetContext(aThis);
471 //NO LOCAL CONTEXT OPEN
472 if(!HasOpenedContext()) {
474 // SAN : Do not return here. Perform advanced display mode analysis a bit later...
475 if(IsDisplayed(anIObj)) return;
477 Standard_Boolean updcol = Standard_False;
479 // it did not yet exist
480 if(!myObjects.IsBound(anIObj)){
482 Handle(AIS_GlobalStatus) STATUS=
484 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
486 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
488 myObjects.Bind (anIObj,STATUS);
489 myMainPM->Display(anIObj,DispMode);
490 if( myIsAutoActivateSelMode )
492 if(!mgrSelector->Contains(anIObj))
493 mgrSelector->Load(anIObj);
494 mgrSelector->Activate(anIObj,SelMode,myMainSel);
497 if(updateviewer) myMainVwr->Update();
499 // it is somewhere else...
502 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
503 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
505 switch (STATUS->GraphicStatus()){
507 if(STATUS->IsHilighted())
508 myCollectorPM->Unhighlight(anIObj,HiMod);
509 myCollectorPM->Erase(anIObj,HiMod);
510 mgrSelector->Deactivate(anIObj,myCollectorSel);
511 updcol = updateviewer;
512 }// attention the break is not set on purpose...
513 case AIS_DS_FullErased:{
514 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
515 for (;ItL.More();ItL.Next()){
516 myMainPM->Display(anIObj,ItL.Value());
517 if(STATUS->IsSubIntensityOn())
518 myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
520 if( myIsAutoActivateSelMode )
521 for (ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
522 mgrSelector->Activate(anIObj,ItL.Value(),myMainSel);
523 STATUS->SetGraphicStatus(AIS_DS_Displayed);
524 if(STATUS->IsHilighted())
525 myMainPM->Highlight(anIObj,HiMod);
529 // SAN : erase presentations for all display modes different from <DispMode>;
530 // then make sure <DispMode> is displayed and maybe highlighted;
531 // Finally, activate selection mode <SelMode> if not yet activated.
532 case AIS_DS_Displayed:{
533 TColStd_ListOfInteger aModesToRemove;
534 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
535 for(;ItL.More();ItL.Next()){
537 Standard_Integer OldMode = ItL.Value();
539 if(OldMode!=DispMode){
540 aModesToRemove.Append(OldMode);
541 if(myMainPM->IsHighlighted(anIObj,OldMode))
542 myMainPM->Unhighlight(anIObj,OldMode);
543 myMainPM->Erase(anIObj,OldMode);
547 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
548 STATUS->RemoveDisplayMode(ItL.Value());
550 if(!STATUS->IsDModeIn(DispMode))
551 STATUS->AddDisplayMode(DispMode);
553 myMainPM->Display(anIObj,DispMode);
554 if(STATUS->IsHilighted()){
555 myMainPM->Highlight(anIObj,HiMod);
557 if( myIsAutoActivateSelMode )
559 if(!mgrSelector->Contains(anIObj))
560 mgrSelector->Load(anIObj);
561 if(!mgrSelector->IsActivated(anIObj,SelMode))
562 mgrSelector->Activate(anIObj,SelMode,myMainSel);
573 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
574 myMainVwr->Viewer()->SetTransparency(Standard_True);
575 if(updateviewer) myMainVwr->Update();
576 if(updcol && !myCollectorVwr.IsNull()) myCollectorVwr->Update();
579 // LOCAL CONTEXT OPEN
582 myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
584 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
585 myMainVwr->Viewer()->SetTransparency(Standard_True);
588 if(updateviewer) myMainVwr->Update();
592 //=======================================================================
595 //=======================================================================
597 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
598 const Standard_Integer aDisplayMode,
599 const Standard_Integer aSelectionMode,
600 const Standard_Boolean updateviewer,
601 const Standard_Boolean allowdecomposition)
603 if(anIObj.IsNull()) return;
605 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
607 // if no local context...
608 if(!HasOpenedContext()) {
609 // if(!anIObj->HasDisplayMode())
610 // anIObj->SetDisplayMode(aDisplayMode);
612 if(!myObjects.IsBound(anIObj)){
613 Handle(AIS_GlobalStatus) STATUS=
614 new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
615 myObjects.Bind (anIObj,STATUS);
616 myMainPM->Display(anIObj,aDisplayMode);
617 if(aSelectionMode!=-1){
618 if(!mgrSelector->Contains(anIObj))
619 mgrSelector->Load(anIObj,aSelectionMode);
620 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
622 if(updateviewer) myMainVwr->Update();
624 // anIObj->SelectionMode(aSelectionMode);
627 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
628 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
630 if(!STATUS->IsDModeIn(aDisplayMode)){
631 myMainPM->Display(anIObj,aDisplayMode);
632 STATUS->AddDisplayMode(aDisplayMode);
633 if(STATUS->IsSubIntensityOn())
634 myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
636 if(aSelectionMode!=-1){
637 STATUS->AddSelectionMode(aSelectionMode);
638 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
640 if(updateviewer) myMainVwr->Update();
646 myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
647 if(updateviewer) myMainVwr->Update();
652 //=======================================================================
655 //=======================================================================
657 void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
658 const Standard_Integer SelMode,
659 const Standard_Boolean AllowDecomposition)
661 if(anIObj.IsNull()) return;
662 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
665 if(!HasOpenedContext()) {
666 if(SelMode==-1 && !AllowDecomposition){
667 Standard_Integer DispMode,HiMod,SelModeDef;
669 GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
670 Handle(AIS_GlobalStatus) STATUS=
671 new AIS_GlobalStatus(AIS_DS_FullErased,DispMode,SelModeDef);
672 myObjects.Bind (anIObj,STATUS);
676 myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
680 //=======================================================================
683 //=======================================================================
685 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
686 const Standard_Boolean updateviewer,
687 const Standard_Boolean PutInCollector)
689 if(anIObj.IsNull()) return;
691 if ( !anIObj->IsAutoHilight() )
692 anIObj->ClearSelected();
694 if(!HasOpenedContext()){
695 EraseGlobal(anIObj,updateviewer,PutInCollector);
699 // First it is checked if it is possible to remove in the current local context
700 // then one tries to remove in other local contexts, if they allow it...
702 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
704 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
705 for (;It.More();It.Next()){
706 if(It.Value()->AcceptErase())
708 WasInCtx |= It.Value()->Erase(anIObj);
710 WasInCtx = It.Value()->Erase(anIObj);
715 EraseGlobal(anIObj,updateviewer,PutInCollector);
717 if(updateviewer) myMainVwr->Update();
720 //=======================================================================
723 //=======================================================================
725 void AIS_InteractiveContext::EraseMode(const Handle(AIS_InteractiveObject)& anIObj,
726 const Standard_Integer aMode,
727 const Standard_Boolean /*updateviewer*/)
729 if(anIObj.IsNull()) return;
731 if(!myObjects.IsBound(anIObj)) return;
733 if(anIObj->HasDisplayMode()){
734 if(anIObj->DisplayMode()==aMode) return;
736 else if(myDisplayMode==aMode) return;
738 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
739 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
741 if(STATUS->GraphicStatus()!=AIS_DS_Displayed) return;
744 // if(STATUS->IsDModeIn(aMode)) {}
749 //=======================================================================
750 //function : EraseAll
752 //=======================================================================
754 void AIS_InteractiveContext::EraseAll(const Standard_Boolean PutInCollector,
755 const Standard_Boolean updateviewer)
757 if(!HasOpenedContext()){
758 AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
760 for(;ItM.More();ItM.Next()){
761 if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
762 Erase(ItM.Key(),Standard_False,PutInCollector);
766 if (PutInCollector && !myCollectorVwr.IsNull())
767 myCollectorVwr->Update();
773 //=======================================================================
774 //function : DisplayAll
776 //=======================================================================
778 void AIS_InteractiveContext::DisplayAll(const Standard_Boolean OnlyFromCollector,
779 const Standard_Boolean updateviewer)
781 if(!HasOpenedContext()){
782 Standard_Boolean FoundInCollector(Standard_False);
783 AIS_DisplayStatus aDStatus = OnlyFromCollector ? AIS_DS_Erased : AIS_DS_FullErased,TheStatus;
785 if(!HasOpenedContext()){
786 AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
788 for(;ItM.More();ItM.Next()){
789 TheStatus = ItM.Value()->GraphicStatus();
790 if(TheStatus == aDStatus)
791 Display(ItM.Key(),Standard_False);
792 if(TheStatus == AIS_DS_Erased)
793 FoundInCollector = Standard_True;
797 if(FoundInCollector && !myCollectorVwr.IsNull())
798 myCollectorVwr->Update();
805 //=======================================================================
806 //function : DisplaySelected
808 //=======================================================================
810 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
813 if(!HasOpenedContext()){
814 Standard_Boolean found = Standard_False;
815 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
816 Handle(AIS_InteractiveObject) iObj;
817 for (sel->Init();sel->More();sel->Next()) {
818 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
819 Display(iObj,Standard_False);
820 found = Standard_True;
822 if(found && updateviewer) {
824 if(!(myIsCollClosed && myCollectorVwr.IsNull()))
826 myCollectorVwr->Update();
832 //=======================================================================
833 //function : EraseSelected
835 //=======================================================================
837 void AIS_InteractiveContext::EraseSelected(const Standard_Boolean PutInCollector,
838 const Standard_Boolean updateviewer)
841 if(!HasOpenedContext()){
842 Standard_Boolean found = Standard_False;
843 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
844 Handle(AIS_InteractiveObject) iObj;
845 for(sel->Init();sel->More();sel->Next()) {
846 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
847 Erase(iObj,Standard_False,PutInCollector);
848 found = Standard_True;
850 if(found && updateviewer) {
852 if(PutInCollector && !myCollectorVwr.IsNull())
853 myCollectorVwr->Update();
857 //=======================================================================
860 //=======================================================================
862 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
863 const Standard_Integer WhichContext)
865 if(anIObj.IsNull()) return Standard_False;
867 if(!HasOpenedContext()) return Standard_False;
868 if(myObjects.IsBound(anIObj)) return Standard_False;
869 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
871 // Protection : if one tries to preserve a temporary object
872 // which is not in the local active context... rob 11-06-97
874 Standard_Integer IsItInLocal = myCurLocalIndex;
875 Standard_Boolean Found(Standard_False);
877 while(IsItInLocal>0 && !Found){
878 if(!myLocalContexts.IsBound(IsItInLocal))
880 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
881 Found = Standard_True;
886 if(!Found) return Standard_False;
889 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
890 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
892 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
893 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
897 if(LS->IsTemporary()){
898 Standard_Integer DM,HM,SM;
899 GetDefModes(anIObj,DM,HM,SM);
901 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
902 if(LS->DisplayMode()!= DM ){
903 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
904 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
907 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
911 // GS->SubIntensityOn();
912 myObjects.Bind(anIObj,GS);
913 mgrSelector->Load(anIObj);
914 mgrSelector->Activate(anIObj,SM,myMainSel);
916 LS->SetTemporary(Standard_False);
918 return Standard_True;
922 //=======================================================================
924 //=======================================================================
926 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const
928 if(anIObj.IsNull()) return AIS_DS_None;
930 if(myObjects.IsBound(anIObj))
931 return myObjects(anIObj)->GraphicStatus();
933 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
934 for(;ItM.More();ItM.Next()){
935 if(ItM.Value()->IsIn(anIObj))
936 return AIS_DS_Temporary;
946 //=======================================================================
947 //function : DisplayedModes
949 //=======================================================================
951 const TColStd_ListOfInteger& AIS_InteractiveContext::
952 DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const
954 return myObjects(anIObj)->DisplayedModes();
958 //=======================================================================
961 //=======================================================================
962 void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
963 const Standard_Boolean updateviewer)
966 if(anIObj.IsNull()) return;
968 if(!HasOpenedContext()){
969 ClearGlobal(anIObj,updateviewer);
973 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
974 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
975 for (;It.More() ;It.Next()){
976 if(It.Value()->AcceptErase())
977 WasInCtx = It.Value()->Remove(anIObj);
981 ClearGlobal(anIObj,updateviewer);
983 // if(updateviewer) myMainVwr->Update();
987 //=======================================================================
988 //function : RemoveAll
990 //=======================================================================
991 void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
993 AIS_ListOfInteractive aList;
994 ObjectsInside(aList);
995 AIS_ListIteratorOfListOfInteractive aListIterator;
996 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
997 Remove(aListIterator.Value(), Standard_False);
1001 myMainVwr->Update();
1004 //=======================================================================
1007 //=======================================================================
1009 void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
1010 const Standard_Boolean updateviewer)
1012 if(anIObj.IsNull()) return;
1014 if(!HasOpenedContext()){
1015 ClearGlobal(anIObj,updateviewer);
1020 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
1021 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
1022 for (;It.More() ;It.Next()){
1023 if(It.Value()->AcceptErase())
1024 WasInCtx = It.Value()->Remove(anIObj);
1028 ClearGlobal(anIObj,updateviewer);
1030 if(updateviewer) myMainVwr->Update();
1037 //=======================================================================
1038 //function : ClearPrs
1040 //=======================================================================
1042 void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
1043 const Standard_Integer aMode,
1044 const Standard_Boolean updateviewer)
1046 if(anIObj.IsNull()) return;
1048 if(!HasOpenedContext()){
1049 ClearGlobalPrs(anIObj,aMode,updateviewer);
1053 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
1054 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
1055 for (;It.More() ;It.Next()){
1056 if(It.Value()->AcceptErase())
1057 WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
1060 ClearGlobalPrs(anIObj,aMode,updateviewer);
1062 if(updateviewer) myMainVwr->Update();
1067 //=======================================================================
1068 //function : Hilight
1070 //=======================================================================
1072 void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
1073 const Standard_Boolean updateviewer)
1075 if(anIObj.IsNull()) return;
1077 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1078 if (!HasOpenedContext())
1080 if(!myObjects.IsBound(anIObj)) return;
1083 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1084 // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
1085 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1088 STATUS->SetHilightStatus (Standard_True);
1090 switch(STATUS->GraphicStatus()){
1091 case AIS_DS_Displayed:
1093 Standard_Integer DispMode,HiMode,SelMode;
1094 GetDefModes(anIObj,DispMode,HiMode,SelMode);
1095 // if(!STATUS->IsDModeIn(HiMode)){
1096 // myMainPM->Display(anIObj,HiMode);
1098 myMainPM->Highlight(anIObj,HiMode);
1099 if(updateviewer) myMainVwr->Update();
1104 Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1105 myCollectorPM->Highlight(anIObj,HiMode);
1106 if(updateviewer) myCollectorVwr->Update();
1114 myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
1115 if(updateviewer) myMainVwr->Update();
1117 //=======================================================================
1118 //function : Hilight
1120 //=======================================================================
1122 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
1123 const Quantity_NameOfColor aCol,
1124 const Standard_Boolean updateviewer)
1126 if(anIObj.IsNull()) return;
1128 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1130 if (!HasOpenedContext())
1132 if(!myObjects.IsBound(anIObj)) return;
1134 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1135 STATUS->SetHilightStatus (Standard_True);
1137 switch(STATUS->GraphicStatus()){
1138 case AIS_DS_Displayed:
1140 Standard_Integer DispMode,HiMode,SelMode;
1141 GetDefModes(anIObj,DispMode,HiMode,SelMode);
1142 // if(!STATUS->IsDModeIn(HiMode)){
1143 // myMainPM->Display(anIObj,HiMode);
1145 myMainPM->Color(anIObj,aCol,HiMode);
1146 STATUS->SetHilightColor(aCol);
1147 if(updateviewer) myMainVwr->Update();
1152 Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1153 myCollectorPM->Color(anIObj,aCol,HiMode);
1154 if(updateviewer) myCollectorVwr->Update();
1162 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
1163 if(updateviewer) myMainVwr->Update();
1166 //=======================================================================
1167 //function : Unhilight
1169 //=======================================================================
1171 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
1173 if(anIObj.IsNull()) return;
1175 if (!HasOpenedContext())
1177 if(!myObjects.IsBound(anIObj)) return;
1179 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1180 STATUS->SetHilightStatus (Standard_False);
1181 STATUS->SetHilightColor(Quantity_NOC_WHITE);
1183 switch(STATUS->GraphicStatus()){
1184 case AIS_DS_Displayed:
1186 Standard_Integer DispMode,HiMode,SelMode;
1187 GetDefModes(anIObj,DispMode,HiMode,SelMode);
1188 myMainPM->Unhighlight(anIObj,HiMode);
1189 // if(!STATUS->IsDModeIn(HiMode))
1190 // myMainPM->Erase(anIObj,HiMode);
1191 if(updateviewer) myMainVwr->Update();
1196 Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1197 myCollectorPM->Unhighlight(anIObj,HiMode);
1198 if(updateviewer) myCollectorVwr->Update();
1206 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
1207 if(updateviewer) myMainVwr->Update();
1210 //=======================================================================
1211 //function : IsHilighted
1213 //=======================================================================
1215 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1217 if(anIObj.IsNull()) return Standard_False;
1219 if (!HasOpenedContext()){
1220 if(!myObjects.IsBound(anIObj))
1221 return Standard_False;
1222 return myObjects(anIObj)->IsHilighted();
1224 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1225 for(;ItM.More();ItM.Next()){
1226 if(ItM.Value()->IsHilighted(anIObj))
1227 return Standard_True;
1229 return Standard_False;
1232 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1233 Standard_Boolean& WithColor,
1234 Quantity_NameOfColor& TheHiCol) const
1236 if(!HasOpenedContext()){
1237 if(myObjects.IsBound(anIObj)){
1238 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1239 if(STAT->IsHilighted()){
1240 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1241 WithColor=Standard_True;
1242 TheHiCol = STAT->HilightColor();
1245 WithColor = Standard_False;
1246 return Standard_True;
1249 return Standard_False;
1251 Standard_Integer MaxIndex = HighestIndex();
1252 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1253 if(myLocalContexts.IsBound(i)){
1254 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1255 return Standard_True;
1259 return Standard_False;
1264 //=======================================================================
1265 //function : IsDisplayed
1267 //=======================================================================
1269 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1271 if(anIObj.IsNull()) return Standard_False;
1274 if(myObjects.IsBound(anIObj))
1275 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1276 return Standard_True;
1278 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1279 for(;ItM.More();ItM.Next()){
1280 if(ItM.Value()->IsDisplayed(anIObj))
1281 return Standard_True;
1283 return Standard_False;
1286 //=======================================================================
1287 //function : IsDisplayed
1289 //=======================================================================
1291 Standard_Boolean AIS_InteractiveContext::IsInCollector(const Handle(AIS_InteractiveObject)& anIObj) const
1293 if(anIObj.IsNull()) return Standard_False;
1296 if(myObjects.IsBound(anIObj))
1297 return (myObjects(anIObj)->GraphicStatus()==AIS_DS_Erased);
1298 return Standard_False;
1302 //=======================================================================
1303 //function : IsDisplayed
1305 //=======================================================================
1307 Standard_Boolean AIS_InteractiveContext::
1308 IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
1309 const Standard_Integer aMode) const
1311 if(anIObj.IsNull()) return Standard_False;
1312 if(myObjects.IsBound(anIObj)) {
1313 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
1314 myObjects(anIObj)->IsDModeIn(aMode))
1315 return Standard_True;
1318 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1319 for(;ItM.More();ItM.Next()){
1320 if(ItM.Value()->IsDisplayed(anIObj,aMode))
1321 return Standard_True;
1323 return Standard_False;
1327 //=======================================================================
1328 //function : DisplayPriority
1330 //=======================================================================
1332 Standard_Integer AIS_InteractiveContext::
1333 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const
1335 if(anIObj.IsNull()) return -1;
1336 if(myObjects.IsBound(anIObj)){
1338 // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
1339 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1341 Standard_Integer DM,HM,SM ;
1342 GetDefModes(anIObj,DM,HM,SM);
1343 switch(STATUS->GraphicStatus()){
1344 case AIS_DS_Displayed:
1346 return myMainPM->DisplayPriority(anIObj,DM);
1350 return myCollectorPM->DisplayPriority(anIObj,HM);
1358 //=======================================================================
1359 //function : SetDisplayPriority
1361 //=======================================================================
1363 void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
1364 const Standard_Integer aPriority)
1368 if(!anIObj->HasInteractiveContext())
1369 anIObj->SetContext(this);
1370 if(myObjects.IsBound(anIObj)){
1372 // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
1373 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1375 Standard_Integer DM,HM,SM ;
1376 GetDefModes(anIObj,DM,HM,SM);
1377 switch(STATUS->GraphicStatus()){
1378 case AIS_DS_Displayed:
1380 myMainPM->SetDisplayPriority(anIObj,DM,aPriority);
1385 myCollectorPM->SetDisplayPriority(anIObj,HM,aPriority);
1392 else if (HasOpenedContext())
1393 {myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);}
1396 //=======================================================================
1397 //function : Redisplay
1399 //=======================================================================
1401 void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
1402 const Standard_Boolean updateviewer,
1403 const Standard_Boolean allmodes)
1405 if(AISDebugModeOn()){
1406 cout<<"===>AIS_InteractiveContext::Redisplay de :";
1407 cout<<anIObj->DynamicType()->Name()<<endl;
1410 RecomputePrsOnly(anIObj,updateviewer,allmodes);
1411 RecomputeSelectionOnly(anIObj);
1414 //=======================================================================
1415 //function : Redisplay
1417 //=======================================================================
1419 void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
1420 const Standard_Integer /*Sign*/,
1421 const Standard_Boolean updateviewer)
1423 Standard_Boolean found_viewer(Standard_False),found_coll(Standard_False);
1425 for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
1427 // const Handle(AIS_InteractiveObject)& IO = It.Key();
1428 Handle(AIS_InteractiveObject) IO = It.Key();
1430 if(IO->Type()== KOI){
1432 // Standard_Boolean good = (Sign==-1)? Standard_True :
1433 // ((IO->Signature()==Sign)? Standard_True:Standard_False);
1435 Redisplay(IO,Standard_False);
1436 switch(It.Value()->GraphicStatus()){
1437 case AIS_DS_Displayed:
1438 found_viewer = Standard_True;
1441 found_coll = Standard_True;
1451 myMainVwr->Update();
1453 myCollectorVwr->Update();
1458 //=======================================================================
1459 //function : RecomputePrsOnly
1461 //=======================================================================
1463 void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
1464 const Standard_Boolean updateviewer,
1465 const Standard_Boolean allmodes)
1467 if(anIObj.IsNull()) return;
1468 anIObj->Update(allmodes);
1471 if(HasOpenedContext())
1472 myMainVwr->Update();
1474 if(myObjects.IsBound(anIObj)){
1475 switch(myObjects(anIObj)->GraphicStatus()){
1476 case AIS_DS_Displayed:
1477 myMainVwr->Update();
1481 if(!myCollectorVwr.IsNull())
1482 myCollectorVwr->Update();
1491 //=======================================================================
1492 //function : RecomputeSelectionOnly
1494 //=======================================================================
1495 void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj)
1497 if(anIObj.IsNull()) return;
1498 mgrSelector->RecomputeSelection(anIObj);
1502 TColStd_ListOfInteger LI;
1503 TColStd_ListIteratorOfListOfInteger Lit;
1504 ActivatedModes(anIObj,LI);
1505 if(!HasOpenedContext()){
1506 if(!myObjects.IsBound(anIObj)) return;
1507 switch(myObjects(anIObj)->GraphicStatus())
1509 case AIS_DS_Displayed:
1511 for(Lit.Initialize(LI);Lit.More();Lit.Next())
1512 mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
1517 for(Lit.Initialize(LI);Lit.More();Lit.Next())
1518 mgrSelector->Activate(anIObj,Lit.Value(),myCollectorSel);
1528 //=======================================================================
1531 //=======================================================================
1533 void AIS_InteractiveContext::Update(const Handle(AIS_InteractiveObject)& anIObj,
1534 const Standard_Boolean updateviewer)
1536 if(anIObj.IsNull()) return;
1540 TColStd_ListOfInteger LL;
1541 anIObj->ToBeUpdated(LL);
1542 TColStd_ListIteratorOfListOfInteger ITI(LL);
1543 Standard_Boolean wasupdated(Standard_False);
1545 for (;ITI.More();ITI.Next()){
1546 anIObj->Update(ITI.Value(),Standard_False);
1547 wasupdated = Standard_True;
1551 mgrSelector->Update(anIObj);
1554 if(!myObjects.IsBound(anIObj)) return;
1555 switch(myObjects(anIObj)->GraphicStatus()){
1556 case AIS_DS_Displayed:
1557 case AIS_DS_Temporary:
1558 myMainVwr->Update();
1561 myCollectorVwr->Update();
1571 //=======================================================================
1572 //function : SetLocation
1574 //=======================================================================
1576 void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
1577 const TopLoc_Location& aLoc)
1579 if(anIObj.IsNull()) return;
1582 if(anIObj->HasLocation() && aLoc.IsIdentity()){
1583 anIObj->ResetLocation();
1584 mgrSelector->Update(anIObj,Standard_False);
1587 if(aLoc.IsIdentity()) return ;
1589 // first reset the previous location to properly clean everything...
1590 if(anIObj->HasLocation())
1591 anIObj->ResetLocation();
1594 anIObj->SetLocation(aLoc);
1596 if(!HasOpenedContext())
1597 mgrSelector->Update(anIObj,Standard_False);
1601 // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1602 Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1604 mgrSelector->Update(anIObj,tempSel,Standard_False);
1607 //=======================================================================
1608 //function : ResetLocation
1610 //=======================================================================
1611 void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
1613 if(anIObj.IsNull()) return;
1615 anIObj->ResetLocation();
1616 mgrSelector->Update(anIObj,Standard_False);
1619 //=======================================================================
1620 //function : HasLocation
1622 //=======================================================================
1624 Standard_Boolean AIS_InteractiveContext::
1625 HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
1627 if(anIObj.IsNull()) return Standard_False;
1629 return anIObj->HasLocation();
1632 const TopLoc_Location& AIS_InteractiveContext::
1633 Location(const Handle(AIS_InteractiveObject)& anIObj) const
1635 return anIObj->Location();
1638 //=======================================================================
1639 //function : SetDeviationCoefficient
1641 //=======================================================================
1643 void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
1645 myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
1647 //=======================================================================
1648 //function : SetDeviationAngle
1650 //=======================================================================
1652 void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
1654 myDefaultDrawer->SetDeviationCoefficient(anAngle);
1657 //=======================================================================
1658 //function : DeviationAngle
1659 //purpose : Gets deviationAngle
1660 //=======================================================================
1662 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1664 return M_PI/180.0e0 ;
1665 // return myDefaultDrawer->DeviationAngle();
1668 //=======================================================================
1669 //function : DeviationCoefficient
1671 //=======================================================================
1673 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1675 return myDefaultDrawer->DeviationCoefficient();
1677 //=======================================================================
1678 //function : SetHLRDeviationCoefficient
1680 //=======================================================================
1682 void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
1684 myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
1687 //=======================================================================
1688 //function : HLRDeviationCoefficient
1690 //=======================================================================
1692 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1694 return myDefaultDrawer->HLRDeviationCoefficient();
1697 //=======================================================================
1698 //function : SetHLRAngle
1700 //=======================================================================
1702 void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
1704 myDefaultDrawer->SetHLRAngle(anAngle);
1707 //=======================================================================
1708 //function : SetHLRAngleAndDeviation
1709 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1710 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1711 // of myDefaultDrawer
1712 //=======================================================================
1714 void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
1717 Standard_Real OutAngl,OutDefl;
1718 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1720 myDefaultDrawer->SetHLRAngle(OutAngl);
1721 myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
1725 //=======================================================================
1726 //function : HLRAngle
1728 //=======================================================================
1730 Standard_Real AIS_InteractiveContext::HLRAngle() const
1732 return myDefaultDrawer->HLRAngle();
1735 //=======================================================================
1736 //function : SetDisplayMode
1738 //=======================================================================
1740 void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
1741 const Standard_Boolean updateviewer)
1743 if(aMode==myDisplayMode) return;
1744 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
1746 for(;It.More();It.Next()){
1748 // const Handle(AIS_InteractiveObject)& anObj = It.Key();
1749 Handle(AIS_InteractiveObject) anObj = It.Key();
1751 Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
1752 anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) ||
1753 anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) );
1755 if ((!anObj->HasDisplayMode()) && Processed)
1757 if(anObj->AcceptDisplayMode(aMode)){
1759 // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
1760 Handle(AIS_GlobalStatus) STATUS = It.Value();
1762 if(STATUS->IsDModeIn(myDisplayMode))
1763 STATUS->RemoveDisplayMode(myDisplayMode);
1765 STATUS->AddDisplayMode(aMode);
1767 if(STATUS->GraphicStatus()== AIS_DS_Displayed){
1768 myMainPM->Erase(anObj, myDisplayMode);
1769 myMainPM->Display(anObj, aMode);
1770 if(STATUS->IsSubIntensityOn())
1771 myMainPM->Color(anObj,mySubIntensity,aMode);
1773 // myDisplayMode = aMode;
1778 myDisplayMode = aMode;
1779 if(updateviewer) myMainVwr->Update();
1782 //=======================================================================
1783 //function : SetDisplayMode
1785 //=======================================================================
1787 void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1788 const Standard_Integer aMode,
1789 const Standard_Boolean updateviewer)
1792 if(!anIObj->HasInteractiveContext())
1793 anIObj->SetContext(this);
1794 if(!HasOpenedContext()){
1796 if(!myObjects.IsBound(anIObj))
1797 anIObj->SetDisplayMode(aMode);
1799 else if( anIObj->AcceptDisplayMode(aMode) )
1805 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1806 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1809 // the interactive object has no mode : OldMode = Mode Session
1810 // already has a mode : OldMode = old mode Propre
1812 Standard_Integer OldMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode(): myDisplayMode;
1814 if(STATUS->IsDModeIn(OldMode))
1815 STATUS->RemoveDisplayMode(OldMode);
1816 STATUS->AddDisplayMode(aMode);
1818 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1819 if(aMode!=OldMode ){
1820 if(myMainPM->IsHighlighted(anIObj,OldMode))
1821 myMainPM->Unhighlight(anIObj,OldMode);
1823 myMainPM->Erase(anIObj,OldMode);
1825 // SAN : erase presentations for all display modes different from <aMode>
1826 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1827 TColStd_ListOfInteger aModesToRemove;
1828 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
1829 for(;ItL.More();ItL.Next()){
1831 Standard_Integer OldMode = ItL.Value();
1834 aModesToRemove.Append(OldMode);
1835 if(myMainPM->IsHighlighted(anIObj,OldMode))
1836 myMainPM->Unhighlight(anIObj,OldMode);
1837 myMainPM->Erase(anIObj,OldMode);
1841 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
1842 STATUS->RemoveDisplayMode(ItL.Value());
1844 if(!STATUS->IsDModeIn(aMode))
1845 STATUS->AddDisplayMode(aMode);
1848 myMainPM->Display(anIObj,aMode);
1849 Standard_Integer DM,HM,SM;
1850 GetDefModes(anIObj,DM,HM,SM);
1851 if(STATUS->IsHilighted()){
1852 myMainPM->Highlight(anIObj,HM);
1854 if(STATUS->IsSubIntensityOn()){
1855 myMainPM->Color(anIObj,mySubIntensity,aMode);
1857 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
1858 myMainVwr->Viewer()->SetTransparency(Standard_True);
1860 if(updateviewer) myMainVwr->Update();
1865 anIObj->SetDisplayMode(aMode);
1870 //=======================================================================
1871 //function : UnsetDisplayMode
1873 //=======================================================================
1875 void AIS_InteractiveContext::
1876 UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1877 const Standard_Boolean updateviewer)
1879 if(anIObj.IsNull()) return ;
1880 if(!anIObj->HasDisplayMode()) return;
1882 if(!myObjects.IsBound(anIObj))
1883 anIObj->UnsetDisplayMode();
1886 Standard_Integer OldMode = anIObj->DisplayMode();
1887 if(myDisplayMode==OldMode) return;
1888 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1889 STATUS->RemoveDisplayMode(OldMode);
1890 if(!STATUS->IsDModeIn(myDisplayMode))
1891 STATUS->AddDisplayMode(myDisplayMode);
1892 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1893 if(myMainPM->IsHighlighted(anIObj,OldMode))
1894 myMainPM->Unhighlight(anIObj,OldMode);
1895 myMainPM->Erase(anIObj,OldMode);
1896 myMainPM->Display(anIObj,myDisplayMode);
1897 Standard_Integer DM,HM,SM;
1898 GetDefModes(anIObj,DM,HM,SM);
1899 if(STATUS->IsHilighted()){
1900 myMainPM->Highlight(anIObj,HM);
1902 if(STATUS->IsSubIntensityOn()){
1903 myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
1905 if(updateviewer) myMainVwr->Update();
1907 anIObj->UnsetDisplayMode();
1912 //=======================================================================
1913 //function : SetCurrentFacingModel
1915 //=======================================================================
1918 void AIS_InteractiveContext::SetCurrentFacingModel(
1919 const Handle(AIS_InteractiveObject)& anIObj,
1920 const Aspect_TypeOfFacingModel aModel) {
1921 if ( !anIObj.IsNull () ) {
1922 anIObj->SetCurrentFacingModel(aModel);
1927 //=======================================================================
1928 //function : SetColor
1930 //=======================================================================
1932 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1933 const Quantity_NameOfColor aColor,
1934 const Standard_Boolean updateviewer)
1937 SetColor(anIObj,Quantity_Color(aColor),updateviewer);
1940 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1941 const Quantity_Color &aColor,
1942 const Standard_Boolean updateviewer)
1945 if(anIObj.IsNull()) return ;
1947 if(!anIObj->HasInteractiveContext())
1948 anIObj->SetContext(this);
1949 anIObj->SetColor(aColor);
1950 if(anIObj->RecomputeEveryPrs())
1951 anIObj->Redisplay();
1954 Standard_Integer NbDisp=0;
1955 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1956 for (;ITI.More();ITI.Next())
1958 anIObj->Update(ITI.Value(),Standard_False);
1961 anIObj->SetRecomputeOk();
1963 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1970 // if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
1971 // Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
1972 // Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
1974 // gp_Dir D =Tr->Component()->XDirection();
1975 // gp_Pnt O = Tr->Component()->Location();
1976 // gp_Vec V(D);V*=Lx/5.;
1977 // T.SetRotation(gp_Ax1(O,D),M_PI/6.);
1978 // T.SetTranslationPart(V);
1979 // TopLoc_Location L,IncLoc(T);
1981 // for(Standard_Integer I=1;I<90;I++){
1982 // if(anIObj->HasLocation())
1983 // L = anIObj->Location() * IncLoc;
1986 // SetLocation(anIObj,L);
1987 // UpdateCurrentViewer();
1989 // for(I=1;I<90;I++){
1990 // L = anIObj->Location() /IncLoc;
1991 // SetLocation(anIObj,L);
1992 // UpdateCurrentViewer();
1994 // ResetLocation(anIObj);
1997 if(updateviewer) UpdateCurrentViewer();
2000 //=======================================================================
2001 //function : SetDeviationCoefficient
2003 //=======================================================================
2005 void AIS_InteractiveContext::SetDeviationCoefficient(
2006 const Handle(AIS_InteractiveObject)& anIObj,
2007 const Standard_Real aCoefficient,
2008 const Standard_Boolean updateviewer)
2010 // cout<<" Coefficient:"<< aCoefficient <<endl;
2011 if(anIObj.IsNull()) return ;
2013 if(!anIObj->HasInteractiveContext())
2014 anIObj->SetContext(this);
2016 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2017 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
2018 if(anIObj->Signature()!=0) return;
2019 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
2023 if(anIObj->RecomputeEveryPrs())
2024 anIObj->Redisplay();
2027 Standard_Integer NbDisp=0;
2028 TColStd_ListOfInteger LL;
2029 anIObj->ToBeUpdated(LL);
2030 TColStd_ListIteratorOfListOfInteger ITI(LL);
2031 for (;ITI.More();ITI.Next())
2033 anIObj->Update(ITI.Value(),Standard_False);
2036 anIObj->SetRecomputeOk();
2038 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2041 if(updateviewer) UpdateCurrentViewer();
2044 //=======================================================================
2045 //function : SetHLRDeviationCoefficient
2047 //=======================================================================
2049 void AIS_InteractiveContext::SetHLRDeviationCoefficient(
2050 const Handle(AIS_InteractiveObject)& anIObj,
2051 const Standard_Real aCoefficient,
2052 const Standard_Boolean updateviewer)
2054 // cout<<" HLRCoefficient:"<< aCoefficient <<endl;
2055 if(anIObj.IsNull()) return ;
2057 if(!anIObj->HasInteractiveContext())
2058 anIObj->SetContext(this);
2059 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2060 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
2061 if(anIObj->Signature()!=0) return;
2062 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
2066 if(anIObj->RecomputeEveryPrs())
2067 anIObj->Redisplay();
2070 Standard_Integer NbDisp=0;
2072 TColStd_ListOfInteger LL;
2073 anIObj->ToBeUpdated(LL);
2074 TColStd_ListIteratorOfListOfInteger ITI(LL);
2075 for (;ITI.More();ITI.Next())
2077 anIObj->Update(ITI.Value(),Standard_False);
2080 anIObj->SetRecomputeOk();
2082 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2085 if(updateviewer) UpdateCurrentViewer();
2089 //=======================================================================
2090 //function : SetDeviationAngle
2092 //=======================================================================
2094 void AIS_InteractiveContext::SetDeviationAngle(
2095 const Handle(AIS_InteractiveObject)& anIObj,
2096 const Standard_Real anAngle,
2097 const Standard_Boolean updateviewer)
2099 // cout<<" Angle:"<< anAngle <<endl;
2100 if(anIObj.IsNull()) return ;
2102 if(!anIObj->HasInteractiveContext())
2103 anIObj->SetContext(this);
2104 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2105 if(anIObj->Type()!=AIS_KOI_Shape) return;
2106 if(anIObj->Signature()!=0) return;
2107 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
2110 if(anIObj->RecomputeEveryPrs())
2111 anIObj->Redisplay();
2114 Standard_Integer NbDisp=0;
2115 TColStd_ListOfInteger LL;
2116 anIObj->ToBeUpdated(LL);
2117 TColStd_ListIteratorOfListOfInteger ITI(LL);
2118 for (;ITI.More();ITI.Next())
2120 anIObj->Update(ITI.Value(),Standard_False);
2123 anIObj->SetRecomputeOk();
2125 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2128 if(updateviewer) UpdateCurrentViewer();
2130 //=======================================================================
2131 //function : SetDeviationAngle
2133 //=======================================================================
2135 void AIS_InteractiveContext::SetAngleAndDeviation(
2136 const Handle(AIS_InteractiveObject)& anIObj,
2137 const Standard_Real anAngle,
2138 const Standard_Boolean updateviewer)
2140 // cout<<" Angle:"<< anAngle <<endl;
2141 if(anIObj.IsNull()) return ;
2142 // Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
2143 if(!anIObj->HasInteractiveContext())
2144 anIObj->SetContext(this);
2146 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2147 if(anIObj->Type()!=AIS_KOI_Shape) return;
2148 if(anIObj->Signature()!=0) return;
2149 (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
2152 if(anIObj->RecomputeEveryPrs())
2153 anIObj->Redisplay();
2155 Update(anIObj,updateviewer);
2158 //=======================================================================
2159 //function : SetDeviationAngle
2161 //=======================================================================
2163 void AIS_InteractiveContext::SetHLRAngleAndDeviation(
2164 const Handle(AIS_InteractiveObject)& anIObj,
2165 const Standard_Real anAngle,
2166 const Standard_Boolean updateviewer)
2168 // cout<<" Angle:"<< anAngle <<endl;
2170 if(anIObj.IsNull()) return ;
2171 if(!anIObj->HasInteractiveContext())
2172 anIObj->SetContext(this);
2174 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2175 if(anIObj->Type()!=AIS_KOI_Shape) return;
2176 if(anIObj->Signature()!=0) return;
2177 (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
2180 if(anIObj->RecomputeEveryPrs())
2181 anIObj->Redisplay();
2184 Standard_Integer NbDisp=0;
2186 TColStd_ListOfInteger LL;
2187 anIObj->ToBeUpdated(LL);
2188 TColStd_ListIteratorOfListOfInteger ITI(LL);
2189 for (;ITI.More();ITI.Next())
2191 anIObj->Update(ITI.Value(),Standard_False);
2194 anIObj->SetRecomputeOk();
2196 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2199 if(updateviewer) UpdateCurrentViewer();
2202 //=======================================================================
2203 //function : SetHLRDeviationAngle
2205 //=======================================================================
2207 void AIS_InteractiveContext::SetHLRDeviationAngle(
2208 const Handle(AIS_InteractiveObject)& anIObj,
2209 const Standard_Real anAngle,
2210 const Standard_Boolean updateviewer)
2212 // cout<<" HLRAngle:"<< anAngle <<endl;
2213 if(anIObj.IsNull()) return ;
2215 if(!anIObj->HasInteractiveContext())
2216 anIObj->SetContext(this);
2217 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2218 if( anIObj->Type()!=AIS_KOI_Shape) return;
2219 if(anIObj->Signature()!=0) return;
2220 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
2223 if(anIObj->RecomputeEveryPrs())
2224 anIObj->Redisplay();
2227 Standard_Integer NbDisp=0;
2228 TColStd_ListOfInteger LL;
2229 anIObj->ToBeUpdated(LL);
2230 TColStd_ListIteratorOfListOfInteger ITI(LL);
2231 for (;ITI.More();ITI.Next())
2233 anIObj->Update(ITI.Value(),Standard_False);
2236 anIObj->SetRecomputeOk();
2238 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2241 if(updateviewer) UpdateCurrentViewer();
2244 //=======================================================================
2245 //function : UnsetColor
2247 //=======================================================================
2249 void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
2250 const Standard_Boolean updateviewer)
2252 if(anIObj.IsNull()) return ;
2253 anIObj->UnsetColor();
2254 if(anIObj->RecomputeEveryPrs())
2255 anIObj->Redisplay();
2258 Standard_Integer NbDisp =0;
2259 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2260 for (;ITI.More();ITI.Next())
2262 anIObj->Update(ITI.Value(),Standard_False);
2266 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2268 anIObj->SetRecomputeOk();
2271 UpdateCurrentViewer();
2274 //=======================================================================
2275 //function : HasColor
2277 //=======================================================================
2279 Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const
2281 return anIObj->HasColor();
2285 //=======================================================================
2288 //=======================================================================
2290 Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const
2292 return anIObj->Color();
2296 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
2297 Quantity_Color &aColor) const
2299 anIObj->Color(aColor);
2303 //=======================================================================
2306 //=======================================================================
2308 Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const
2310 return anIObj->Width();
2313 //=======================================================================
2314 //function : SetWidth
2316 //=======================================================================
2318 void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2319 const Standard_Real aValue,
2320 const Standard_Boolean updateviewer)
2322 if(anIObj.IsNull()) return ;
2324 if(!anIObj->HasInteractiveContext())
2325 anIObj->SetContext(this);
2326 anIObj->SetWidth(aValue);
2327 if(anIObj->RecomputeEveryPrs())
2328 anIObj->Redisplay();
2331 Standard_Integer NbDisp=0;
2332 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2333 for (;ITI.More();ITI.Next())
2335 anIObj->Update(ITI.Value(),Standard_False);
2339 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2341 anIObj->SetRecomputeOk();
2344 UpdateCurrentViewer();
2347 //=======================================================================
2348 //function : UnsetWidth
2350 //=======================================================================
2352 void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2353 const Standard_Boolean updateviewer)
2355 if(anIObj.IsNull()) return ;
2356 anIObj->UnsetWidth();
2357 if(anIObj->RecomputeEveryPrs())
2358 anIObj->Redisplay();
2361 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2362 for (;ITI.More();ITI.Next())
2364 anIObj->Update(ITI.Value(),Standard_False);
2366 anIObj->SetRecomputeOk();
2369 UpdateCurrentViewer();
2372 //=======================================================================
2373 //function : SetMaterial
2375 //=======================================================================
2377 void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2379 const Graphic3d_NameOfMaterial aName,
2380 // const Graphic3d_NameOfPhysicalMaterial aName,
2381 const Standard_Boolean updateviewer)
2383 if(!anIObj->HasInteractiveContext())
2384 anIObj->SetContext(this);
2385 anIObj->SetMaterial(aName);
2386 if(anIObj->RecomputeEveryPrs())
2387 anIObj->Redisplay();
2390 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2391 for (;ITI.More();ITI.Next())
2393 anIObj->Update(ITI.Value(),Standard_False);
2395 anIObj->SetRecomputeOk();
2398 UpdateCurrentViewer();
2402 //=======================================================================
2403 //function : UnsetMaterial
2405 //=======================================================================
2407 void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2408 const Standard_Boolean updateviewer)
2410 if(anIObj.IsNull()) return ;
2411 anIObj->UnsetMaterial();
2412 if(anIObj->RecomputeEveryPrs())
2413 anIObj->Redisplay();
2416 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2417 for (;ITI.More();ITI.Next())
2419 anIObj->Update(ITI.Value(),Standard_False);
2421 anIObj->SetRecomputeOk();
2424 UpdateCurrentViewer();
2427 //=======================================================================
2428 //function : SetTransparency
2430 //=======================================================================
2432 void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2433 const Standard_Real aValue,
2434 const Standard_Boolean updateviewer)
2436 if(anIObj.IsNull()) return ;
2437 if(!anIObj->HasInteractiveContext())
2438 anIObj->SetContext(this);
2440 #ifdef BUC60577 //right optimization
2441 if(!anIObj->IsTransparent() && aValue<=0.05) return;
2443 // if(!anIObj->IsTransparent() && aValue<=0.05) return;
2446 UnsetTransparency(anIObj,updateviewer);
2450 if(!myMainVwr->Viewer()->Transparency())
2451 myMainVwr->Viewer()->SetTransparency(Standard_True);
2452 anIObj->SetTransparency(aValue);
2453 if(anIObj->RecomputeEveryPrs())
2454 anIObj->Redisplay();
2457 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2458 for (;ITI.More();ITI.Next())
2460 anIObj->Update(ITI.Value(),Standard_False);
2462 anIObj->SetRecomputeOk();
2465 UpdateCurrentViewer();
2468 //=======================================================================
2469 //function : UnsetTransparency
2471 //=======================================================================
2473 void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2474 const Standard_Boolean updateviewer)
2476 if(anIObj.IsNull()) return ;
2477 anIObj->UnsetTransparency();
2478 if(anIObj->RecomputeEveryPrs())
2479 anIObj->Redisplay();
2482 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2483 for (;ITI.More();ITI.Next())
2485 anIObj->Update(ITI.Value(),Standard_False);
2487 anIObj->SetRecomputeOk();
2490 // To Unset transparency in the viewer, if no other object is transparent ...(Speed)
2491 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
2492 Standard_Boolean FoundTransp(Standard_False);
2493 for(;It.More() && !FoundTransp ;It.Next()){
2494 if(It.Key()->IsTransparent())
2495 FoundTransp = Standard_True;
2498 myMainVwr->Viewer()->SetTransparency(Standard_False);
2502 UpdateCurrentViewer();
2505 //=======================================================================
2506 //function : SetDegenerateModel
2508 //=======================================================================
2511 void AIS_InteractiveContext :: SetDegenerateModel (
2512 const Handle( AIS_InteractiveObject )& anObject,
2513 const Aspect_TypeOfDegenerateModel aModel,
2514 const Quantity_Ratio aRatio
2516 if ( !anObject.IsNull () ) {
2517 if ( !anObject -> HasInteractiveContext () )
2518 anObject -> SetContext ( this );
2519 anObject->SetDegenerateModel(aModel,aRatio);
2522 } // end AIS_InteractiveContext :: SetDegenerateModel
2524 void AIS_InteractiveContext :: SetDegenerateModel (
2525 const Aspect_TypeOfDegenerateModel aModel,
2526 const Quantity_Ratio aRatio
2529 AIS_DataMapIteratorOfDataMapOfIOStatus it ( myObjects );
2531 while ( it.More () ) {
2533 Handle( AIS_InteractiveObject ) obj = it.Key ();
2535 obj->SetDegenerateModel(aModel,aRatio);
2541 } // end AIS_InteractiveContext :: SetDegenerateModel
2545 //=======================================================================
2546 //function : SetSelectedAspect
2548 //=======================================================================
2549 void AIS_InteractiveContext::SetSelectedAspect(
2550 const Handle(Prs3d_BasicAspect)& anAspect,
2551 const Standard_Boolean globalChange,
2552 const Standard_Boolean updateViewer) {
2553 if( !HasOpenedContext() ) {
2554 Standard_Boolean found = Standard_False;
2555 Handle(AIS_Selection) sel =
2556 AIS_Selection::Selection(myCurrentName.ToCString());
2557 Handle(AIS_InteractiveObject) object;
2558 for( sel->Init() ; sel->More() ; sel->Next()) {
2559 found = Standard_True;
2560 object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
2561 object->SetAspect(anAspect,globalChange);
2563 if( found && updateViewer) {
2564 myMainVwr->Update();
2565 if( !(myIsCollClosed && myCollectorVwr.IsNull()) )
2566 myCollectorVwr->Update();
2572 //=======================================================================
2573 //function : SetLocalAttributes
2575 //=======================================================================
2577 void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2578 const Handle(AIS_Drawer)& aDrawer,
2579 const Standard_Boolean updateviewer)
2581 if(anIObj.IsNull()) return ;
2582 if(!anIObj->HasInteractiveContext())
2583 anIObj->SetContext(this);
2584 anIObj->SetAttributes(aDrawer);
2585 Update(anIObj,updateviewer);
2589 //=======================================================================
2590 //function : UnsetLocalAttributes
2592 //=======================================================================
2593 void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2594 const Standard_Boolean updateviewer)
2596 if(anIObj.IsNull()) return ;
2597 if(!anIObj->HasInteractiveContext())
2598 anIObj->SetContext(this);
2599 anIObj->UnsetAttributes();
2600 Update(anIObj,updateviewer);
2604 //=======================================================================
2607 //=======================================================================
2609 void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const
2613 if(anIObj.IsNull()) return ;
2614 if(myObjects.IsBound(anIObj)){
2615 astatus += "\t ____________________________________________";
2616 astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2617 const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
2618 switch(ST->GraphicStatus()){
2619 case AIS_DS_Displayed:
2621 astatus +="\t| -->Displayed\n";
2626 astatus +="\t| -->Erased\n";
2629 case AIS_DS_FullErased:
2631 astatus +="\t| -->Full Erased\n";
2637 astatus += "\t| Active Display Modes in the MainViewer :\n";
2638 TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
2639 for(;ItL.More();ItL.Next()){
2640 astatus += "\t|\t Mode ";
2641 astatus += TCollection_AsciiString(ItL.Value());
2644 if(IsCurrent(anIObj)) astatus +="\t| Current\n";
2645 if(IsSelected(anIObj)) astatus +="\t| Selected\n";
2647 astatus += "\t| Active Selection Modes in the MainViewer :\n";
2648 for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
2649 astatus += "\t\t Mode ";
2650 astatus += TCollection_AsciiString(ItL.Value());
2653 astatus += "\t ____________________________________________";
2659 //=======================================================================
2660 //function : GetDefModes
2662 //=======================================================================
2664 void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
2665 Standard_Integer& DispMode,
2666 Standard_Integer& HiMode,
2667 Standard_Integer& SelMode) const
2669 if(anIObj.IsNull()) return ;
2670 DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
2671 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
2673 HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
2675 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
2677 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
2682 //=======================================================================
2683 //function : EraseGlobal
2685 //=======================================================================
2687 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2688 const Standard_Boolean updateviewer,
2689 const Standard_Boolean PutInCollector)
2691 if(anIObj.IsNull()) return ;
2692 if(!myObjects.IsBound(anIObj)) return;
2695 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2696 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2698 Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2699 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
2701 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2702 for(;ItL.More();ItL.Next()){
2703 if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2704 myMainPM->Unhighlight(anIObj,ItL.Value());
2705 myMainPM->Erase(anIObj,ItL.Value());
2707 if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
2708 myMainPM->Erase(anIObj,Dmode);
2710 for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
2711 mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
2712 if(updateviewer) myMainVwr->Update();
2714 if(PutInCollector && !myCollectorPM.IsNull()){
2715 myCollectorPM->Display(anIObj,Dmode);
2717 Standard_Integer SMode = anIObj->SelectionMode();
2718 mgrSelector->Activate(anIObj,SMode,myCollectorSel);
2720 mgrSelector->Activate(anIObj,0,myCollectorSel);
2722 if(STATUS->IsHilighted())
2723 myCollectorPM->Highlight(anIObj,Dmode);
2724 STATUS->SetGraphicStatus(AIS_DS_Erased);
2725 if(updateviewer) myCollectorVwr->Update();
2728 STATUS->SetGraphicStatus(AIS_DS_FullErased);
2732 //=======================================================================
2733 //function : ClearGlobal
2735 //=======================================================================
2737 void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2738 const Standard_Boolean updateviewer)
2740 if(anIObj.IsNull()) return ;
2741 if(!myObjects.IsBound(anIObj)) return;
2743 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2744 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2746 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2747 for(;ItL.More();ItL.Next()){
2748 if(STATUS->IsHilighted()){
2749 if(IsCurrent(anIObj))
2751 AddOrRemoveCurrentObject( anIObj, updateviewer );
2753 AddOrRemoveCurrentObject(anIObj);
2755 else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2756 myMainPM->Unhighlight(anIObj,ItL.Value());
2758 myMainPM->Erase(anIObj,ItL.Value());
2759 myMainPM->Clear(anIObj,ItL.Value());
2760 if(anIObj->HasHilightMode()){
2761 Standard_Integer im = anIObj->HilightMode();
2762 myMainPM->Unhighlight(anIObj,im);
2763 myMainPM->Erase(anIObj,im);
2768 //Object removes from Detected sequence
2769 Standard_Integer i = 1;
2770 for(i = 1; i < myAISDetectedSeq.Length(); i++)
2772 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2773 if( !anObj.IsNull() && anObj != anIObj )
2774 myAISDetectedSeq.Remove( i );
2777 if(myLastinMain == anIObj)
2778 myLastinMain.Nullify();
2779 if(myLastinColl == anIObj)
2780 myLastinColl.Nullify();
2782 if(myLastPicked == anIObj)
2783 myLastPicked.Nullify();
2785 // OCC21671: Remove IO from the selection manager in any case
2786 // to avoid memory leaks
2787 mgrSelector->Remove(anIObj);
2789 switch(STATUS->GraphicStatus()){
2792 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2793 if(STATUS->IsHilighted()){
2794 myCollectorPM->Unhighlight(anIObj,DM);
2796 myCollectorPM->Erase(anIObj,DM);
2797 myCollectorPM->Clear(anIObj,DM);
2798 if(updateviewer) myCollectorVwr->Update();
2801 case AIS_DS_Displayed:
2803 if(updateviewer) myMainVwr->Update();
2809 myObjects.UnBind(anIObj);
2813 //=======================================================================
2814 //function : ClearGlobalPrs
2816 //=======================================================================
2818 void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj,
2819 const Standard_Integer aMode,
2820 const Standard_Boolean updateviewer)
2822 if(anIObj.IsNull()) return ;
2823 if(!myObjects.IsBound(anIObj)) return;
2824 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2826 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2827 if(STATUS->IsDModeIn(aMode)){
2828 if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
2829 myMainPM->Unhighlight(anIObj,aMode);
2831 myMainPM->Erase(anIObj,aMode);
2832 myMainPM->Clear(anIObj,aMode);
2835 if(STATUS->GraphicStatus()== AIS_DS_Erased)
2838 if(STATUS->IsHilighted())
2839 myCollectorPM->Unhighlight(anIObj,aMode);
2840 myCollectorPM->Erase(anIObj,DM);
2841 myCollectorPM->Clear(anIObj,DM);
2843 if(updateviewer) myCollectorVwr->Update();
2845 else if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
2846 myMainVwr->Update();
2849 //=======================================================================
2850 //function : DrawHiddenLine
2852 //=======================================================================
2854 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
2856 return myDefaultDrawer->DrawHiddenLine();
2859 //=======================================================================
2860 //function : EnableDrawHiddenLine
2862 //=======================================================================
2864 void AIS_InteractiveContext::EnableDrawHiddenLine () const {
2865 myDefaultDrawer->EnableDrawHiddenLine();
2868 //=======================================================================
2869 //function : DisableDrawHiddenLine
2871 //=======================================================================
2873 void AIS_InteractiveContext::DisableDrawHiddenLine () const {
2874 myDefaultDrawer->DisableDrawHiddenLine();
2877 //=======================================================================
2878 //function : HiddenLineAspect
2880 //=======================================================================
2882 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const {
2883 return myDefaultDrawer->HiddenLineAspect();
2886 //=======================================================================
2887 //function : SetHiddenLineAspect
2889 //=======================================================================
2891 void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
2892 myDefaultDrawer->SetHiddenLineAspect(anAspect);
2895 //=======================================================================
2896 //function : SetIsoNumber
2898 //=======================================================================
2900 void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
2904 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2907 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2910 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2911 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2916 //=======================================================================
2917 //function : IsoNumber
2919 //=======================================================================
2921 Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
2926 return myDefaultDrawer->UIsoAspect()->Number();
2928 return myDefaultDrawer->VIsoAspect()->Number();
2930 return (myDefaultDrawer->UIsoAspect()->Number()==
2931 myDefaultDrawer->VIsoAspect()->Number()) ?
2932 myDefaultDrawer->UIsoAspect()->Number(): -1;
2937 //=======================================================================
2938 //function : IsoOnPlane
2940 //=======================================================================
2942 void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
2944 myDefaultDrawer->SetIsoOnPlane(SwitchOn);
2947 //=======================================================================
2948 //function : IsoOnPlane
2950 //=======================================================================
2952 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2954 return myDefaultDrawer->IsoOnPlane();
2957 //=======================================================================
2958 //function : SetSelectionMode
2960 //=======================================================================
2962 void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject&, const Standard_Integer )
2966 //=======================================================================
2967 //function : UnsetSelectionMode
2969 //=======================================================================
2971 void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObject&)
2975 //=======================================================================
2976 //function : SetSensitivityMode
2978 //=======================================================================
2980 void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
2982 if( HasOpenedContext() )
2983 myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
2985 myMainSel->SetSensitivityMode(aMode);
2986 if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivityMode(aMode);
2990 //=======================================================================
2991 //function : SensitivityMode
2993 //=======================================================================
2995 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
2997 if( HasOpenedContext() )
2998 return myLocalContexts(myCurLocalIndex)->SensitivityMode();
2999 return myMainSel->SensitivityMode();
3002 //=======================================================================
3003 //function : SetSensitivity
3005 //=======================================================================
3007 void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
3009 if( HasOpenedContext() )
3010 myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
3012 myMainSel->SetSensitivity(aPrecision);
3013 if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivity(aPrecision);
3017 //=======================================================================
3018 //function : Sensitivity
3020 //=======================================================================
3022 Standard_Real AIS_InteractiveContext::Sensitivity() const {
3024 if( HasOpenedContext() )
3025 return myLocalContexts(myCurLocalIndex)->Sensitivity();
3026 return myMainSel->Sensitivity();
3029 //=======================================================================
3030 //function : SetPixelTolerance
3032 //=======================================================================
3034 void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
3036 if( HasOpenedContext() )
3037 myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
3039 myMainSel->SetPixelTolerance(aPrecision);
3040 if( !myCollectorSel.IsNull() ) myCollectorSel->SetPixelTolerance(aPrecision);
3044 //=======================================================================
3045 //function : PixelTolerance
3047 //=======================================================================
3049 Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
3051 if( HasOpenedContext() )
3052 return myLocalContexts(myCurLocalIndex)->PixelTolerance();
3053 return myMainSel->PixelTolerance();
3056 //=======================================================================
3057 //function : IsInLocal
3059 //=======================================================================
3061 Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle_AIS_InteractiveObject& anIObj,
3062 Standard_Integer& TheIndex) const
3064 if(anIObj.IsNull()) return Standard_False;
3065 // if it exists at neutral point 0 index is returned
3066 if(myObjects.IsBound(anIObj)) {
3068 return Standard_False;
3070 for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
3071 if(myLocalContexts.IsBound(I)){
3072 if(myLocalContexts(I)->IsIn(anIObj)){
3074 return Standard_True;
3080 return Standard_False;
3083 //=======================================================================
3084 //function : InitAttributes
3086 //=======================================================================
3088 void AIS_InteractiveContext::InitAttributes()
3091 mgrSelector->Add(myMainSel);
3092 myCurrentName = AIS_Context_NewCurName();
3093 mySelectionName = AIS_Context_NewSelName();
3095 AIS_Selection::CreateSelection(mySelectionName.ToCString());
3096 AIS_Selection::CreateSelection(myCurrentName.ToCString());
3099 myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
3100 Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
3101 myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
3103 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
3104 Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
3105 HLA->SetColor(Quantity_NOC_GRAY20);
3107 HLA->SetTypeOfLine(Aspect_TOL_DASH);
3109 // tolerance to 4 pixels...
3110 SetPixelTolerance();
3112 // Customizing the drawer for trihedrons and planes...
3114 Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
3115 Standard_Real aLength(100.);
3116 DA->SetAxisLength(aLength,aLength,aLength);
3117 Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
3118 DA->FirstAxisAspect()->SetColor(col);
3119 DA->SecondAxisAspect()->SetColor(col);
3120 DA->ThirdAxisAspect()->SetColor(col);
3122 Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
3124 PA->SetPlaneLength(aLength,aLength);
3125 PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
3131 //=======================================================================
3132 //function : TrihedronSize
3134 //=======================================================================
3135 Standard_Real AIS_InteractiveContext::TrihedronSize() const
3137 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
3139 //=======================================================================
3140 //function : SetTrihedronSize
3142 //=======================================================================
3143 void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
3145 myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
3146 Redisplay(AIS_KOI_Datum,3,Standard_False);
3147 Redisplay(AIS_KOI_Datum,4,Standard_True);
3152 //=======================================================================
3153 //function : SetPlaneSize
3155 //=======================================================================
3156 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
3157 const Standard_Real aValY,
3158 const Standard_Boolean /*updateviewer*/)
3160 myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
3161 Redisplay(AIS_KOI_Datum,7);
3164 //=======================================================================
3165 //function : SetPlaneSize
3167 //=======================================================================
3169 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
3170 const Standard_Boolean updateviewer)
3172 SetPlaneSize(aVal,aVal,updateviewer);
3175 //=======================================================================
3176 //function : PlaneSize
3178 //=======================================================================
3180 Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
3182 LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
3183 LY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
3184 return (Abs(LX-LY)<=Precision::Confusion());
3189 //=======================================================================
3192 //=======================================================================
3193 void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
3195 myIsAutoActivateSelMode = Auto;
3198 //=======================================================================
3201 //=======================================================================
3202 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
3204 return myIsAutoActivateSelMode;
3207 //=======================================================================
3208 //function : SetZLayer
3210 //=======================================================================
3212 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
3213 const Standard_Integer theLayerId)
3215 if (theIObj.IsNull ())
3218 if (myObjects.IsBound (theIObj))
3220 switch (myObjects (theIObj)->GraphicStatus ())
3222 case AIS_DS_Displayed:
3224 theIObj->SetZLayer (myMainPM, theLayerId);
3229 theIObj->SetZLayer (myCollectorPM, theLayerId);
3236 else if (HasOpenedContext ())
3238 myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
3242 //=======================================================================
3243 //function : GetZLayer
3245 //=======================================================================
3247 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
3249 if (theIObj.IsNull ())
3252 if (myObjects.IsBound (theIObj))
3254 return theIObj->GetZLayer (myMainPM);
3256 else if (HasOpenedContext ())
3258 return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);