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 //GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor.
28 #define G003 //EUG_26/01/00 Degenerate support (G003)
30 //IMP140200 //GG Add SetSelectedAspect() method.
32 #define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
33 // method, compute only authorized presentation.
35 #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods.
37 #define BUC60722 //GG 04/09/00 Always enable viewer update when erasing something
39 #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
41 #define OCC172 //SAV clear static map before destroying context.
43 #define OCC204 //SAV 26/02/02 : pass <updateviewer> flag to
44 // AddOrRemoveCurrentObject method from ClearGlobal.
46 #define OCC4373 //SAN 10/11/03 : improve display mode management in
47 // Display( IO, updateviewer ) and
48 // SetDisplayMode( IO, mode, updateviewer ) methods
50 #include <AIS_InteractiveContext.ixx>
52 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
53 #include <TColStd_ListIteratorOfListOfInteger.hxx>
54 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
55 #include <AIS_LocalContext.hxx>
56 #include <AIS_LocalStatus.hxx>
57 #include <Precision.hxx>
58 #include <AIS_Selection.hxx>
59 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
60 #include <AIS_ConnectedShape.hxx>
61 #include <AIS_MultipleConnectedShape.hxx>
62 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
63 #include <AIS_GlobalStatus.hxx>
64 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
65 #include <PrsMgr_ModedPresentation.hxx>
66 #include <Visual3d_ViewManager.hxx>
67 #include <Prs3d_ShadingAspect.hxx>
68 #include <AIS_Shape.hxx>
69 #include <Graphic3d_AspectFillArea3d.hxx>
70 #include <HLRBRep.hxx>
71 #include <Prs3d_IsoAspect.hxx>
72 #include <Prs3d_DatumAspect.hxx>
73 #include <Prs3d_PlaneAspect.hxx>
74 #include <PrsMgr_PresentableObject.hxx>
75 #include <Standard_Atomic.hxx>
76 #include <UnitsAPI.hxx>
78 #include <AIS_Trihedron.hxx>
79 #include <Geom_Axis2Placement.hxx>
80 #include <OSD_Environment.hxx>
82 #include <AIS_ListIteratorOfListOfInteractive.hxx>
84 // In the method GetDefModes() the returned value of the selection mode
85 // is always equal to 0 if it is -1.
88 // The local context is closed the method ::ResetOriginalState() sets the selection mode equal to 0
89 // in spite of the selection mode of the interactive object in Natural Point.
92 // An interactive Object being erased in the main viewer and put into collector should have the same selection mode.
93 // It impacts the performance!
96 static Standard_Boolean AISDebugModeOn()
98 // static OSD_Environment aisdb("AISDEBUGMODE");
99 // return !aisdb.Value().IsEmpty();
100 static Standard_Integer isDebugMode(-1);
101 if (isDebugMode < 0) {
103 OSD_Environment aisdb("AISDEBUGMODE");
104 if (aisdb.Value().IsEmpty())
107 return (isDebugMode != 0);
112 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
113 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
115 static TCollection_AsciiString AIS_Context_NewSelName()
117 return TCollection_AsciiString ("AIS_SelContext_")
118 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
121 static TCollection_AsciiString AIS_Context_NewCurName()
123 return TCollection_AsciiString ("AIS_CurContext_")
124 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
128 //=======================================================================
129 //function : AIS_InteractiveContext
131 //=======================================================================
133 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
134 mgrSelector(new SelectMgr_SelectionManager()),
135 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
136 myMainVwr(MainViewer),
137 myMainSel(new StdSelect_ViewerSelector3d()),
138 myIsCollClosed(Standard_True),
139 myToHilightSelected( Standard_False ),
140 myFilters(new SelectMgr_OrFilter()),
141 myDefaultDrawer(new Prs3d_Drawer()),
142 myDefaultColor(Quantity_NOC_GOLDENROD),
143 myHilightColor(Quantity_NOC_CYAN1),
144 mySelectionColor(Quantity_NOC_GRAY80),
145 myPreselectionColor(Quantity_NOC_GREEN),
146 mySubIntensity(Quantity_NOC_GRAY40),
152 myIsAutoActivateSelMode( Standard_True )
158 //=======================================================================
159 //function : AIS_InteractiveContext
161 //=======================================================================
163 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer,
164 const Handle(V3d_Viewer)& Collector):
165 mgrSelector(new SelectMgr_SelectionManager()),
166 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
167 myMainVwr(MainViewer),
168 myMainSel(new StdSelect_ViewerSelector3d()),
169 myCollectorPM(new PrsMgr_PresentationManager3d(Collector->Viewer())),
170 myCollectorVwr(Collector),
171 myCollectorSel(new StdSelect_ViewerSelector3d()),
172 myIsCollClosed(Standard_False),
173 myToHilightSelected( Standard_False ),
174 myFilters(new SelectMgr_OrFilter()),
175 myDefaultDrawer(new Prs3d_Drawer()),
176 myDefaultColor(Quantity_NOC_GOLDENROD),
177 myHilightColor(Quantity_NOC_CYAN1),
178 mySelectionColor(Quantity_NOC_GRAY80),
179 myPreselectionColor(Quantity_NOC_GREEN),
180 mySubIntensity(Quantity_NOC_GRAY40),
186 myIsAutoActivateSelMode( Standard_True )
189 mgrSelector->Add(myCollectorSel);
193 void AIS_InteractiveContext::Delete() const
196 // to avoid an exception
197 if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
198 AIS_Selection::Remove( mySelectionName.ToCString() );
200 // to avoid an exception
201 if ( AIS_Selection::Find( myCurrentName.ToCString() ) )
202 AIS_Selection::Remove( myCurrentName.ToCString() );
204 // let's remove one reference explicitly. this operation's supposed to
205 // be performed when mgrSelector will be destroyed but anyway...
206 mgrSelector->Remove( myMainSel );
208 MMgt_TShared::Delete();
211 //=======================================================================
212 //function : AIS_SelectionName
214 //=======================================================================
215 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
217 if(!HasOpenedContext())
218 return mySelectionName;
219 return myLocalContexts(myCurLocalIndex)->SelectionName();
225 //=======================================================================
226 //function : UpdateCurrentViewer
228 //=======================================================================
230 void AIS_InteractiveContext::UpdateCurrentViewer()
232 if (!myMainVwr.IsNull())
236 void AIS_InteractiveContext::OpenCollector()
238 myIsCollClosed = Standard_False;
239 // to be completed....
244 //=======================================================================
245 //function : DomainOfMainViewer
247 //=======================================================================
249 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
251 return myMainVwr->Domain();
255 //=======================================================================
256 //function : DisplayedObjects
258 //=======================================================================
260 void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
261 const Standard_Boolean OnlyFromNeutral) const
264 cout<<"AIS_IC::DisplayedObjects"<<endl;
267 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
268 if(!HasOpenedContext() || OnlyFromNeutral){
269 for(;It.More();It.Next()){
270 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
271 aListOfIO.Append(It.Key());
275 TColStd_MapOfTransient theMap;
277 for(;It.More();It.Next()){
278 if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
279 theMap.Add(It.Key());
282 cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl;
285 //parse all local contexts...
286 Standard_Integer NbDisp;
287 for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
288 const Handle(AIS_LocalContext)& LC = it1.Value();
289 NbDisp = LC->DisplayedObjects(theMap);
291 cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
295 Handle(AIS_InteractiveObject) curIO;
296 Handle(Standard_Transient) Tr;
297 for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
299 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
300 aListOfIO.Append(curIO);
304 //=======================================================================
305 //function : DisplayedObjects
307 //=======================================================================
309 void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
310 const Standard_Integer TheSign,
311 AIS_ListOfInteractive& aListOfIO,
312 const Standard_Boolean /*OnlyFromNeutral*/) const
314 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
317 //=======================================================================
318 //function : UpdateCollector
320 //=======================================================================
322 void AIS_InteractiveContext::UpdateCollector()
324 if (!myCollectorVwr.IsNull())
325 myCollectorVwr->Update();
328 //=======================================================================
329 //function : DomainOfCollector
331 //=======================================================================
333 Standard_CString AIS_InteractiveContext::DomainOfCollector() const
335 if(myCollectorVwr.IsNull()) return "";
336 return myCollectorVwr->Domain();
339 //=======================================================================
340 //function : ObjectsInCollector
342 //=======================================================================
344 void AIS_InteractiveContext::ObjectsInCollector(AIS_ListOfInteractive& aListOfIO) const
346 ObjectsByDisplayStatus( AIS_DS_Erased, aListOfIO );
349 //=======================================================================
350 //function : ObjectsInCollector
352 //=======================================================================
354 void AIS_InteractiveContext::ObjectsInCollector(const AIS_KindOfInteractive TheKind,
355 const Standard_Integer TheSign,
356 AIS_ListOfInteractive& aListOfIO) const
358 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, aListOfIO );
361 //=======================================================================
362 //function : ErasedObjects
364 //=======================================================================
366 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const
368 ObjectsByDisplayStatus( AIS_DS_FullErased, theListOfIO );
371 //=======================================================================
372 //function : ErasedObjects
374 //=======================================================================
376 void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
377 const Standard_Integer TheSign,
378 AIS_ListOfInteractive& theListOfIO) const
380 ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_FullErased, theListOfIO );
383 //=======================================================================
384 //function : ObjectsByDisplayStatus
386 //=======================================================================
388 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
389 AIS_ListOfInteractive& theListOfIO) const
391 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
392 for(;It.More();It.Next()){
393 if(It.Value()->GraphicStatus() == theStatus)
394 theListOfIO.Append(It.Key());
398 //=======================================================================
399 //function : ObjectsByDisplayStatus
401 //=======================================================================
403 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
404 const Standard_Integer TheSign,
405 const AIS_DisplayStatus theStatus,
406 AIS_ListOfInteractive& theListOfIO) const
408 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
409 for(;It.More();It.Next()){
410 if(It.Value()->GraphicStatus()==theStatus){
411 if(It.Key()->Type()==TheKind){
413 theListOfIO.Append(It.Key());
415 if(It.Key()->Signature()==TheSign)
416 theListOfIO.Append(It.Key());
423 //=======================================================================
424 //function : ObjectsInside
426 //=======================================================================
428 void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
429 const AIS_KindOfInteractive TheKind,
430 const Standard_Integer TheSign) const
432 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
433 if(TheKind==AIS_KOI_None && TheSign ==-1){
434 for(;It.More();It.Next()){
435 aListOfIO.Append(It.Key());
439 for(;It.More();It.Next()){
440 if(It.Key()->Type()==TheKind){
442 aListOfIO.Append(It.Key());
444 if(It.Key()->Signature()==TheSign)
445 aListOfIO.Append(It.Key());
452 //=======================================================================
455 //=======================================================================
457 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
458 const Standard_Boolean updateviewer )
460 if(anIObj.IsNull()) return;
462 Standard_Integer DispMode,HiMod,SelMode;
464 GetDefModes(anIObj,DispMode,HiMod,SelMode);
466 Handle (AIS_InteractiveContext) aThis = this;
467 if(!anIObj->HasInteractiveContext())
468 anIObj->SetContext(aThis);
470 //NO LOCAL CONTEXT OPEN
471 if(!HasOpenedContext()) {
473 // SAN : Do not return here. Perform advanced display mode analysis a bit later...
474 if(IsDisplayed(anIObj)) return;
476 Standard_Boolean updcol = Standard_False;
478 // it did not yet exist
479 if(!myObjects.IsBound(anIObj)){
481 Handle(AIS_GlobalStatus) STATUS=
483 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
485 new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
487 myObjects.Bind (anIObj,STATUS);
488 myMainPM->Display(anIObj,DispMode);
489 if( myIsAutoActivateSelMode )
491 if(!mgrSelector->Contains(anIObj))
492 mgrSelector->Load(anIObj);
493 mgrSelector->Activate(anIObj,SelMode,myMainSel);
496 if(updateviewer) myMainVwr->Update();
498 // it is somewhere else...
501 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
502 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
504 switch (STATUS->GraphicStatus()){
506 if(STATUS->IsHilighted())
507 myCollectorPM->Unhighlight(anIObj,HiMod);
508 myCollectorPM->Erase(anIObj,HiMod);
509 mgrSelector->Deactivate(anIObj,myCollectorSel);
510 updcol = updateviewer;
511 }// attention the break is not set on purpose...
512 case AIS_DS_FullErased:{
513 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
514 for (;ItL.More();ItL.Next()){
515 myMainPM->Display(anIObj,ItL.Value());
516 if(STATUS->IsSubIntensityOn())
517 myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
519 if( myIsAutoActivateSelMode )
520 for (ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
521 mgrSelector->Activate(anIObj,ItL.Value(),myMainSel);
522 STATUS->SetGraphicStatus(AIS_DS_Displayed);
523 if(STATUS->IsHilighted())
524 myMainPM->Highlight(anIObj,HiMod);
528 // SAN : erase presentations for all display modes different from <DispMode>;
529 // then make sure <DispMode> is displayed and maybe highlighted;
530 // Finally, activate selection mode <SelMode> if not yet activated.
531 case AIS_DS_Displayed:{
532 TColStd_ListOfInteger aModesToRemove;
533 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
534 for(;ItL.More();ItL.Next()){
536 Standard_Integer OldMode = ItL.Value();
538 if(OldMode!=DispMode){
539 aModesToRemove.Append(OldMode);
540 if(myMainPM->IsHighlighted(anIObj,OldMode))
541 myMainPM->Unhighlight(anIObj,OldMode);
542 myMainPM->Erase(anIObj,OldMode);
546 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
547 STATUS->RemoveDisplayMode(ItL.Value());
549 if(!STATUS->IsDModeIn(DispMode))
550 STATUS->AddDisplayMode(DispMode);
552 myMainPM->Display(anIObj,DispMode);
553 if(STATUS->IsHilighted()){
554 myMainPM->Highlight(anIObj,HiMod);
556 if( myIsAutoActivateSelMode )
558 if(!mgrSelector->Contains(anIObj))
559 mgrSelector->Load(anIObj);
560 if(!mgrSelector->IsActivated(anIObj,SelMode))
561 mgrSelector->Activate(anIObj,SelMode,myMainSel);
572 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
573 myMainVwr->Viewer()->SetTransparency(Standard_True);
574 if(updateviewer) myMainVwr->Update();
575 if(updcol && !myCollectorVwr.IsNull()) myCollectorVwr->Update();
578 // LOCAL CONTEXT OPEN
581 myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
583 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
584 myMainVwr->Viewer()->SetTransparency(Standard_True);
587 if(updateviewer) myMainVwr->Update();
591 //=======================================================================
594 //=======================================================================
596 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
597 const Standard_Integer aDisplayMode,
598 const Standard_Integer aSelectionMode,
599 const Standard_Boolean updateviewer,
600 const Standard_Boolean allowdecomposition)
602 if(anIObj.IsNull()) return;
604 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
606 // if no local context...
607 if(!HasOpenedContext()) {
608 // if(!anIObj->HasDisplayMode())
609 // anIObj->SetDisplayMode(aDisplayMode);
611 if(!myObjects.IsBound(anIObj)){
612 Handle(AIS_GlobalStatus) STATUS=
613 new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
614 myObjects.Bind (anIObj,STATUS);
615 myMainPM->Display(anIObj,aDisplayMode);
616 if(aSelectionMode!=-1){
617 if(!mgrSelector->Contains(anIObj))
618 mgrSelector->Load(anIObj,aSelectionMode);
619 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
621 if(updateviewer) myMainVwr->Update();
623 // anIObj->SelectionMode(aSelectionMode);
626 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
627 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
629 if(!STATUS->IsDModeIn(aDisplayMode)){
630 myMainPM->Display(anIObj,aDisplayMode);
631 STATUS->AddDisplayMode(aDisplayMode);
632 if(STATUS->IsSubIntensityOn())
633 myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
635 if(aSelectionMode!=-1){
636 STATUS->AddSelectionMode(aSelectionMode);
637 mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
639 if(updateviewer) myMainVwr->Update();
645 myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
646 if(updateviewer) myMainVwr->Update();
651 //=======================================================================
654 //=======================================================================
656 void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
657 const Standard_Integer SelMode,
658 const Standard_Boolean AllowDecomposition)
660 if(anIObj.IsNull()) return;
661 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
664 if(!HasOpenedContext()) {
665 if(SelMode==-1 && !AllowDecomposition){
666 Standard_Integer DispMode,HiMod,SelModeDef;
668 GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
669 Handle(AIS_GlobalStatus) STATUS=
670 new AIS_GlobalStatus(AIS_DS_FullErased,DispMode,SelModeDef);
671 myObjects.Bind (anIObj,STATUS);
675 myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
679 //=======================================================================
682 //=======================================================================
684 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
685 const Standard_Boolean updateviewer,
686 const Standard_Boolean PutInCollector)
688 if(anIObj.IsNull()) return;
690 if ( !anIObj->IsAutoHilight() )
691 anIObj->ClearSelected();
693 if(!HasOpenedContext()){
694 EraseGlobal(anIObj,updateviewer,PutInCollector);
698 // First it is checked if it is possible to remove in the current local context
699 // then one tries to remove in other local contexts, if they allow it...
701 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
703 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
704 for (;It.More();It.Next()){
705 if(It.Value()->AcceptErase())
707 WasInCtx |= It.Value()->Erase(anIObj);
709 WasInCtx = It.Value()->Erase(anIObj);
714 EraseGlobal(anIObj,updateviewer,PutInCollector);
716 if(updateviewer) myMainVwr->Update();
719 //=======================================================================
722 //=======================================================================
724 void AIS_InteractiveContext::EraseMode(const Handle(AIS_InteractiveObject)& anIObj,
725 const Standard_Integer aMode,
726 const Standard_Boolean /*updateviewer*/)
728 if(anIObj.IsNull()) return;
730 if(!myObjects.IsBound(anIObj)) return;
732 if(anIObj->HasDisplayMode()){
733 if(anIObj->DisplayMode()==aMode) return;
735 else if(myDisplayMode==aMode) return;
737 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
738 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
740 if(STATUS->GraphicStatus()!=AIS_DS_Displayed) return;
743 // if(STATUS->IsDModeIn(aMode)) {}
748 //=======================================================================
749 //function : EraseAll
751 //=======================================================================
753 void AIS_InteractiveContext::EraseAll(const Standard_Boolean PutInCollector,
754 const Standard_Boolean updateviewer)
756 if(!HasOpenedContext()){
757 AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
759 for(;ItM.More();ItM.Next()){
760 if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
761 Erase(ItM.Key(),Standard_False,PutInCollector);
765 if (PutInCollector && !myCollectorVwr.IsNull())
766 myCollectorVwr->Update();
772 //=======================================================================
773 //function : DisplayAll
775 //=======================================================================
777 void AIS_InteractiveContext::DisplayAll(const Standard_Boolean OnlyFromCollector,
778 const Standard_Boolean updateviewer)
780 if(!HasOpenedContext()){
781 Standard_Boolean FoundInCollector(Standard_False);
782 AIS_DisplayStatus aDStatus = OnlyFromCollector ? AIS_DS_Erased : AIS_DS_FullErased,TheStatus;
784 if(!HasOpenedContext()){
785 AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
787 for(;ItM.More();ItM.Next()){
788 TheStatus = ItM.Value()->GraphicStatus();
789 if(TheStatus == aDStatus)
790 Display(ItM.Key(),Standard_False);
791 if(TheStatus == AIS_DS_Erased)
792 FoundInCollector = Standard_True;
796 if(FoundInCollector && !myCollectorVwr.IsNull())
797 myCollectorVwr->Update();
804 //=======================================================================
805 //function : DisplaySelected
807 //=======================================================================
809 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
812 if(!HasOpenedContext()){
813 Standard_Boolean found = Standard_False;
814 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
815 Handle(AIS_InteractiveObject) iObj;
816 for (sel->Init();sel->More();sel->Next()) {
817 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
818 Display(iObj,Standard_False);
819 found = Standard_True;
821 if(found && updateviewer) {
823 if(!(myIsCollClosed && myCollectorVwr.IsNull()))
825 myCollectorVwr->Update();
831 //=======================================================================
832 //function : EraseSelected
834 //=======================================================================
836 void AIS_InteractiveContext::EraseSelected(const Standard_Boolean PutInCollector,
837 const Standard_Boolean updateviewer)
840 if(!HasOpenedContext()){
841 Standard_Boolean found = Standard_False;
842 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
843 Handle(AIS_InteractiveObject) iObj;
844 for(sel->Init();sel->More();sel->Next()) {
845 iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
846 Erase(iObj,Standard_False,PutInCollector);
847 found = Standard_True;
849 if(found && updateviewer) {
851 if(PutInCollector && !myCollectorVwr.IsNull())
852 myCollectorVwr->Update();
856 //=======================================================================
859 //=======================================================================
861 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
862 const Standard_Integer WhichContext)
864 if(anIObj.IsNull()) return Standard_False;
866 if(!HasOpenedContext()) return Standard_False;
867 if(myObjects.IsBound(anIObj)) return Standard_False;
868 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
870 // Protection : if one tries to preserve a temporary object
871 // which is not in the local active context... rob 11-06-97
873 Standard_Integer IsItInLocal = myCurLocalIndex;
874 Standard_Boolean Found(Standard_False);
876 while(IsItInLocal>0 && !Found){
877 if(!myLocalContexts.IsBound(IsItInLocal))
879 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
880 Found = Standard_True;
885 if(!Found) return Standard_False;
888 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
889 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
891 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
892 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
896 if(LS->IsTemporary()){
897 Standard_Integer DM,HM,SM;
898 GetDefModes(anIObj,DM,HM,SM);
900 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
901 if(LS->DisplayMode()!= DM ){
902 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
903 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
906 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
910 // GS->SubIntensityOn();
911 myObjects.Bind(anIObj,GS);
912 mgrSelector->Load(anIObj);
913 mgrSelector->Activate(anIObj,SM,myMainSel);
915 LS->SetTemporary(Standard_False);
917 return Standard_True;
921 //=======================================================================
923 //=======================================================================
925 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const
927 if(anIObj.IsNull()) return AIS_DS_None;
929 if(myObjects.IsBound(anIObj))
930 return myObjects(anIObj)->GraphicStatus();
932 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
933 for(;ItM.More();ItM.Next()){
934 if(ItM.Value()->IsIn(anIObj))
935 return AIS_DS_Temporary;
945 //=======================================================================
946 //function : DisplayedModes
948 //=======================================================================
950 const TColStd_ListOfInteger& AIS_InteractiveContext::
951 DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const
953 return myObjects(anIObj)->DisplayedModes();
957 //=======================================================================
960 //=======================================================================
961 void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
962 const Standard_Boolean updateviewer)
965 if(anIObj.IsNull()) return;
967 if(!HasOpenedContext()){
968 ClearGlobal(anIObj,updateviewer);
972 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
973 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
974 for (;It.More() ;It.Next()){
975 if(It.Value()->AcceptErase())
976 WasInCtx = It.Value()->Remove(anIObj);
980 ClearGlobal(anIObj,updateviewer);
982 // if(updateviewer) myMainVwr->Update();
986 //=======================================================================
987 //function : RemoveAll
989 //=======================================================================
990 void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
992 AIS_ListOfInteractive aList;
993 ObjectsInside(aList);
994 AIS_ListIteratorOfListOfInteractive aListIterator;
995 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
996 Remove(aListIterator.Value(), Standard_False);
1000 myMainVwr->Update();
1003 //=======================================================================
1006 //=======================================================================
1008 void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
1009 const Standard_Boolean updateviewer)
1011 if(anIObj.IsNull()) return;
1013 if(!HasOpenedContext()){
1014 ClearGlobal(anIObj,updateviewer);
1019 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
1020 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
1021 for (;It.More() ;It.Next()){
1022 if(It.Value()->AcceptErase())
1023 WasInCtx = It.Value()->Remove(anIObj);
1027 ClearGlobal(anIObj,updateviewer);
1029 if(updateviewer) myMainVwr->Update();
1036 //=======================================================================
1037 //function : ClearPrs
1039 //=======================================================================
1041 void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
1042 const Standard_Integer aMode,
1043 const Standard_Boolean updateviewer)
1045 if(anIObj.IsNull()) return;
1047 if(!HasOpenedContext()){
1048 ClearGlobalPrs(anIObj,aMode,updateviewer);
1052 Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
1053 AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
1054 for (;It.More() ;It.Next()){
1055 if(It.Value()->AcceptErase())
1056 WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
1059 ClearGlobalPrs(anIObj,aMode,updateviewer);
1061 if(updateviewer) myMainVwr->Update();
1066 //=======================================================================
1067 //function : Hilight
1069 //=======================================================================
1071 void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
1072 const Standard_Boolean updateviewer)
1074 if(anIObj.IsNull()) return;
1076 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1077 if (!HasOpenedContext())
1079 if(!myObjects.IsBound(anIObj)) return;
1082 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1083 // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
1084 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1087 STATUS->SetHilightStatus (Standard_True);
1089 switch(STATUS->GraphicStatus()){
1090 case AIS_DS_Displayed:
1092 Standard_Integer DispMode,HiMode,SelMode;
1093 GetDefModes(anIObj,DispMode,HiMode,SelMode);
1094 // if(!STATUS->IsDModeIn(HiMode)){
1095 // myMainPM->Display(anIObj,HiMode);
1097 myMainPM->Highlight(anIObj,HiMode);
1098 if(updateviewer) myMainVwr->Update();
1103 Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1104 myCollectorPM->Highlight(anIObj,HiMode);
1105 if(updateviewer) myCollectorVwr->Update();
1113 myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
1114 if(updateviewer) myMainVwr->Update();
1116 //=======================================================================
1117 //function : Hilight
1119 //=======================================================================
1121 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
1122 const Quantity_NameOfColor aCol,
1123 const Standard_Boolean updateviewer)
1125 if(anIObj.IsNull()) return;
1127 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1129 if (!HasOpenedContext())
1131 if(!myObjects.IsBound(anIObj)) return;
1133 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1134 STATUS->SetHilightStatus (Standard_True);
1136 switch(STATUS->GraphicStatus()){
1137 case AIS_DS_Displayed:
1139 Standard_Integer DispMode,HiMode,SelMode;
1140 GetDefModes(anIObj,DispMode,HiMode,SelMode);
1141 // if(!STATUS->IsDModeIn(HiMode)){
1142 // myMainPM->Display(anIObj,HiMode);
1144 myMainPM->Color(anIObj,aCol,HiMode);
1145 STATUS->SetHilightColor(aCol);
1146 if(updateviewer) myMainVwr->Update();
1151 Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1152 myCollectorPM->Color(anIObj,aCol,HiMode);
1153 if(updateviewer) myCollectorVwr->Update();
1161 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
1162 if(updateviewer) myMainVwr->Update();
1165 //=======================================================================
1166 //function : Unhilight
1168 //=======================================================================
1170 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
1172 if(anIObj.IsNull()) return;
1174 if (!HasOpenedContext())
1176 if(!myObjects.IsBound(anIObj)) return;
1178 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1179 STATUS->SetHilightStatus (Standard_False);
1180 STATUS->SetHilightColor(Quantity_NOC_WHITE);
1182 switch(STATUS->GraphicStatus()){
1183 case AIS_DS_Displayed:
1185 Standard_Integer DispMode,HiMode,SelMode;
1186 GetDefModes(anIObj,DispMode,HiMode,SelMode);
1187 myMainPM->Unhighlight(anIObj,HiMode);
1188 // if(!STATUS->IsDModeIn(HiMode))
1189 // myMainPM->Erase(anIObj,HiMode);
1190 if(updateviewer) myMainVwr->Update();
1195 Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1196 myCollectorPM->Unhighlight(anIObj,HiMode);
1197 if(updateviewer) myCollectorVwr->Update();
1205 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
1206 if(updateviewer) myMainVwr->Update();
1209 //=======================================================================
1210 //function : IsHilighted
1212 //=======================================================================
1214 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1216 if(anIObj.IsNull()) return Standard_False;
1218 if (!HasOpenedContext()){
1219 if(!myObjects.IsBound(anIObj))
1220 return Standard_False;
1221 return myObjects(anIObj)->IsHilighted();
1223 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1224 for(;ItM.More();ItM.Next()){
1225 if(ItM.Value()->IsHilighted(anIObj))
1226 return Standard_True;
1228 return Standard_False;
1231 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1232 Standard_Boolean& WithColor,
1233 Quantity_NameOfColor& TheHiCol) const
1235 if(!HasOpenedContext()){
1236 if(myObjects.IsBound(anIObj)){
1237 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1238 if(STAT->IsHilighted()){
1239 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1240 WithColor=Standard_True;
1241 TheHiCol = STAT->HilightColor();
1244 WithColor = Standard_False;
1245 return Standard_True;
1248 return Standard_False;
1250 Standard_Integer MaxIndex = HighestIndex();
1251 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1252 if(myLocalContexts.IsBound(i)){
1253 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1254 return Standard_True;
1258 return Standard_False;
1263 //=======================================================================
1264 //function : IsDisplayed
1266 //=======================================================================
1268 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1270 if(anIObj.IsNull()) return Standard_False;
1273 if(myObjects.IsBound(anIObj))
1274 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1275 return Standard_True;
1277 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1278 for(;ItM.More();ItM.Next()){
1279 if(ItM.Value()->IsDisplayed(anIObj))
1280 return Standard_True;
1282 return Standard_False;
1285 //=======================================================================
1286 //function : IsDisplayed
1288 //=======================================================================
1290 Standard_Boolean AIS_InteractiveContext::IsInCollector(const Handle(AIS_InteractiveObject)& anIObj) const
1292 if(anIObj.IsNull()) return Standard_False;
1295 if(myObjects.IsBound(anIObj))
1296 return (myObjects(anIObj)->GraphicStatus()==AIS_DS_Erased);
1297 return Standard_False;
1301 //=======================================================================
1302 //function : IsDisplayed
1304 //=======================================================================
1306 Standard_Boolean AIS_InteractiveContext::
1307 IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
1308 const Standard_Integer aMode) const
1310 if(anIObj.IsNull()) return Standard_False;
1311 if(myObjects.IsBound(anIObj)) {
1312 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
1313 myObjects(anIObj)->IsDModeIn(aMode))
1314 return Standard_True;
1317 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1318 for(;ItM.More();ItM.Next()){
1319 if(ItM.Value()->IsDisplayed(anIObj,aMode))
1320 return Standard_True;
1322 return Standard_False;
1326 //=======================================================================
1327 //function : DisplayPriority
1329 //=======================================================================
1331 Standard_Integer AIS_InteractiveContext::
1332 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const
1334 if(anIObj.IsNull()) return -1;
1335 if(myObjects.IsBound(anIObj)){
1337 // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
1338 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1340 Standard_Integer DM,HM,SM ;
1341 GetDefModes(anIObj,DM,HM,SM);
1342 switch(STATUS->GraphicStatus()){
1343 case AIS_DS_Displayed:
1345 return myMainPM->DisplayPriority(anIObj,DM);
1349 return myCollectorPM->DisplayPriority(anIObj,HM);
1357 //=======================================================================
1358 //function : SetDisplayPriority
1360 //=======================================================================
1362 void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
1363 const Standard_Integer aPriority)
1367 if(!anIObj->HasInteractiveContext())
1368 anIObj->SetContext(this);
1369 if(myObjects.IsBound(anIObj)){
1371 // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
1372 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1374 Standard_Integer DM,HM,SM ;
1375 GetDefModes(anIObj,DM,HM,SM);
1376 switch(STATUS->GraphicStatus()){
1377 case AIS_DS_Displayed:
1379 myMainPM->SetDisplayPriority(anIObj,DM,aPriority);
1384 myCollectorPM->SetDisplayPriority(anIObj,HM,aPriority);
1391 else if (HasOpenedContext())
1392 {myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);}
1395 //=======================================================================
1396 //function : Redisplay
1398 //=======================================================================
1400 void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
1401 const Standard_Boolean updateviewer,
1402 const Standard_Boolean allmodes)
1404 if(AISDebugModeOn()){
1405 cout<<"===>AIS_InteractiveContext::Redisplay de :";
1406 cout<<anIObj->DynamicType()->Name()<<endl;
1409 RecomputePrsOnly(anIObj,updateviewer,allmodes);
1410 RecomputeSelectionOnly(anIObj);
1413 //=======================================================================
1414 //function : Redisplay
1416 //=======================================================================
1418 void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
1419 const Standard_Integer /*Sign*/,
1420 const Standard_Boolean updateviewer)
1422 Standard_Boolean found_viewer(Standard_False),found_coll(Standard_False);
1424 for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
1426 // const Handle(AIS_InteractiveObject)& IO = It.Key();
1427 Handle(AIS_InteractiveObject) IO = It.Key();
1429 if(IO->Type()== KOI){
1431 // Standard_Boolean good = (Sign==-1)? Standard_True :
1432 // ((IO->Signature()==Sign)? Standard_True:Standard_False);
1434 Redisplay(IO,Standard_False);
1435 switch(It.Value()->GraphicStatus()){
1436 case AIS_DS_Displayed:
1437 found_viewer = Standard_True;
1440 found_coll = Standard_True;
1450 myMainVwr->Update();
1452 myCollectorVwr->Update();
1457 //=======================================================================
1458 //function : RecomputePrsOnly
1460 //=======================================================================
1462 void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
1463 const Standard_Boolean updateviewer,
1464 const Standard_Boolean allmodes)
1466 if(anIObj.IsNull()) return;
1467 anIObj->Update(allmodes);
1470 if(HasOpenedContext())
1471 myMainVwr->Update();
1473 if(myObjects.IsBound(anIObj)){
1474 switch(myObjects(anIObj)->GraphicStatus()){
1475 case AIS_DS_Displayed:
1476 myMainVwr->Update();
1480 if(!myCollectorVwr.IsNull())
1481 myCollectorVwr->Update();
1490 //=======================================================================
1491 //function : RecomputeSelectionOnly
1493 //=======================================================================
1494 void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj)
1496 if(anIObj.IsNull()) return;
1497 mgrSelector->RecomputeSelection(anIObj);
1501 TColStd_ListOfInteger LI;
1502 TColStd_ListIteratorOfListOfInteger Lit;
1503 ActivatedModes(anIObj,LI);
1504 if(!HasOpenedContext()){
1505 if(!myObjects.IsBound(anIObj)) return;
1506 switch(myObjects(anIObj)->GraphicStatus())
1508 case AIS_DS_Displayed:
1510 for(Lit.Initialize(LI);Lit.More();Lit.Next())
1511 mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
1516 for(Lit.Initialize(LI);Lit.More();Lit.Next())
1517 mgrSelector->Activate(anIObj,Lit.Value(),myCollectorSel);
1527 //=======================================================================
1530 //=======================================================================
1532 void AIS_InteractiveContext::Update(const Handle(AIS_InteractiveObject)& anIObj,
1533 const Standard_Boolean updateviewer)
1535 if(anIObj.IsNull()) return;
1539 TColStd_ListOfInteger LL;
1540 anIObj->ToBeUpdated(LL);
1541 TColStd_ListIteratorOfListOfInteger ITI(LL);
1542 Standard_Boolean wasupdated(Standard_False);
1544 for (;ITI.More();ITI.Next()){
1545 anIObj->Update(ITI.Value(),Standard_False);
1546 wasupdated = Standard_True;
1550 mgrSelector->Update(anIObj);
1553 if(!myObjects.IsBound(anIObj)) return;
1554 switch(myObjects(anIObj)->GraphicStatus()){
1555 case AIS_DS_Displayed:
1556 case AIS_DS_Temporary:
1557 myMainVwr->Update();
1560 myCollectorVwr->Update();
1570 //=======================================================================
1571 //function : SetLocation
1573 //=======================================================================
1575 void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
1576 const TopLoc_Location& aLoc)
1578 if(anIObj.IsNull()) return;
1581 if(anIObj->HasLocation() && aLoc.IsIdentity()){
1582 anIObj->ResetLocation();
1583 mgrSelector->Update(anIObj,Standard_False);
1586 if(aLoc.IsIdentity()) return ;
1588 // first reset the previous location to properly clean everything...
1589 if(anIObj->HasLocation())
1590 anIObj->ResetLocation();
1593 anIObj->SetLocation(aLoc);
1595 if(!HasOpenedContext())
1596 mgrSelector->Update(anIObj,Standard_False);
1600 // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1601 Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1603 mgrSelector->Update(anIObj,tempSel,Standard_False);
1606 //=======================================================================
1607 //function : ResetLocation
1609 //=======================================================================
1610 void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
1612 if(anIObj.IsNull()) return;
1614 anIObj->ResetLocation();
1615 mgrSelector->Update(anIObj,Standard_False);
1618 //=======================================================================
1619 //function : HasLocation
1621 //=======================================================================
1623 Standard_Boolean AIS_InteractiveContext::
1624 HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
1626 if(anIObj.IsNull()) return Standard_False;
1628 return anIObj->HasLocation();
1631 const TopLoc_Location& AIS_InteractiveContext::
1632 Location(const Handle(AIS_InteractiveObject)& anIObj) const
1634 return anIObj->Location();
1637 //=======================================================================
1638 //function : SetDeviationCoefficient
1640 //=======================================================================
1642 void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
1644 myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
1646 //=======================================================================
1647 //function : SetDeviationAngle
1649 //=======================================================================
1651 void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
1653 myDefaultDrawer->SetDeviationCoefficient(anAngle);
1656 //=======================================================================
1657 //function : DeviationAngle
1658 //purpose : Gets deviationAngle
1659 //=======================================================================
1661 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1663 //return M_PI/180.0e0 ;
1664 return myDefaultDrawer->DeviationAngle();
1667 //=======================================================================
1668 //function : DeviationCoefficient
1670 //=======================================================================
1672 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1674 return myDefaultDrawer->DeviationCoefficient();
1676 //=======================================================================
1677 //function : SetHLRDeviationCoefficient
1679 //=======================================================================
1681 void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
1683 myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
1686 //=======================================================================
1687 //function : HLRDeviationCoefficient
1689 //=======================================================================
1691 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1693 return myDefaultDrawer->HLRDeviationCoefficient();
1696 //=======================================================================
1697 //function : SetHLRAngle
1699 //=======================================================================
1701 void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
1703 myDefaultDrawer->SetHLRAngle(anAngle);
1706 //=======================================================================
1707 //function : SetHLRAngleAndDeviation
1708 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1709 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1710 // of myDefaultDrawer
1711 //=======================================================================
1713 void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
1716 Standard_Real OutAngl,OutDefl;
1717 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1719 myDefaultDrawer->SetHLRAngle(OutAngl);
1720 myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
1724 //=======================================================================
1725 //function : HLRAngle
1727 //=======================================================================
1729 Standard_Real AIS_InteractiveContext::HLRAngle() const
1731 return myDefaultDrawer->HLRAngle();
1734 //=======================================================================
1735 //function : SetDisplayMode
1737 //=======================================================================
1739 void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
1740 const Standard_Boolean updateviewer)
1742 if(aMode==myDisplayMode) return;
1743 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
1745 for(;It.More();It.Next()){
1747 // const Handle(AIS_InteractiveObject)& anObj = It.Key();
1748 Handle(AIS_InteractiveObject) anObj = It.Key();
1750 Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
1751 anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) ||
1752 anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) );
1754 if ((!anObj->HasDisplayMode()) && Processed)
1756 if(anObj->AcceptDisplayMode(aMode)){
1758 // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
1759 Handle(AIS_GlobalStatus) STATUS = It.Value();
1761 if(STATUS->IsDModeIn(myDisplayMode))
1762 STATUS->RemoveDisplayMode(myDisplayMode);
1764 STATUS->AddDisplayMode(aMode);
1766 if(STATUS->GraphicStatus()== AIS_DS_Displayed){
1767 myMainPM->Erase(anObj, myDisplayMode);
1768 myMainPM->Display(anObj, aMode);
1769 if(STATUS->IsSubIntensityOn())
1770 myMainPM->Color(anObj,mySubIntensity,aMode);
1772 // myDisplayMode = aMode;
1777 myDisplayMode = aMode;
1778 if(updateviewer) myMainVwr->Update();
1781 //=======================================================================
1782 //function : SetDisplayMode
1784 //=======================================================================
1786 void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1787 const Standard_Integer aMode,
1788 const Standard_Boolean updateviewer)
1791 if(!anIObj->HasInteractiveContext())
1792 anIObj->SetContext(this);
1793 if(!HasOpenedContext()){
1795 if(!myObjects.IsBound(anIObj))
1796 anIObj->SetDisplayMode(aMode);
1798 else if( anIObj->AcceptDisplayMode(aMode) )
1804 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1805 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1808 // the interactive object has no mode : OldMode = Mode Session
1809 // already has a mode : OldMode = old mode Propre
1811 Standard_Integer OldMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode(): myDisplayMode;
1813 if(STATUS->IsDModeIn(OldMode))
1814 STATUS->RemoveDisplayMode(OldMode);
1815 STATUS->AddDisplayMode(aMode);
1817 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1818 if(aMode!=OldMode ){
1819 if(myMainPM->IsHighlighted(anIObj,OldMode))
1820 myMainPM->Unhighlight(anIObj,OldMode);
1822 myMainPM->Erase(anIObj,OldMode);
1824 // SAN : erase presentations for all display modes different from <aMode>
1825 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1826 TColStd_ListOfInteger aModesToRemove;
1827 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
1828 for(;ItL.More();ItL.Next()){
1830 Standard_Integer OldMode = ItL.Value();
1833 aModesToRemove.Append(OldMode);
1834 if(myMainPM->IsHighlighted(anIObj,OldMode))
1835 myMainPM->Unhighlight(anIObj,OldMode);
1836 myMainPM->Erase(anIObj,OldMode);
1840 for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
1841 STATUS->RemoveDisplayMode(ItL.Value());
1843 if(!STATUS->IsDModeIn(aMode))
1844 STATUS->AddDisplayMode(aMode);
1847 myMainPM->Display(anIObj,aMode);
1848 Standard_Integer DM,HM,SM;
1849 GetDefModes(anIObj,DM,HM,SM);
1850 if(STATUS->IsHilighted()){
1851 myMainPM->Highlight(anIObj,HM);
1853 if(STATUS->IsSubIntensityOn()){
1854 myMainPM->Color(anIObj,mySubIntensity,aMode);
1856 if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
1857 myMainVwr->Viewer()->SetTransparency(Standard_True);
1859 if(updateviewer) myMainVwr->Update();
1864 anIObj->SetDisplayMode(aMode);
1869 //=======================================================================
1870 //function : UnsetDisplayMode
1872 //=======================================================================
1874 void AIS_InteractiveContext::
1875 UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1876 const Standard_Boolean updateviewer)
1878 if(anIObj.IsNull()) return ;
1879 if(!anIObj->HasDisplayMode()) return;
1881 if(!myObjects.IsBound(anIObj))
1882 anIObj->UnsetDisplayMode();
1885 Standard_Integer OldMode = anIObj->DisplayMode();
1886 if(myDisplayMode==OldMode) return;
1887 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1888 STATUS->RemoveDisplayMode(OldMode);
1889 if(!STATUS->IsDModeIn(myDisplayMode))
1890 STATUS->AddDisplayMode(myDisplayMode);
1891 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1892 if(myMainPM->IsHighlighted(anIObj,OldMode))
1893 myMainPM->Unhighlight(anIObj,OldMode);
1894 myMainPM->Erase(anIObj,OldMode);
1895 myMainPM->Display(anIObj,myDisplayMode);
1896 Standard_Integer DM,HM,SM;
1897 GetDefModes(anIObj,DM,HM,SM);
1898 if(STATUS->IsHilighted()){
1899 myMainPM->Highlight(anIObj,HM);
1901 if(STATUS->IsSubIntensityOn()){
1902 myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
1904 if(updateviewer) myMainVwr->Update();
1906 anIObj->UnsetDisplayMode();
1911 //=======================================================================
1912 //function : SetCurrentFacingModel
1914 //=======================================================================
1916 void AIS_InteractiveContext::SetCurrentFacingModel(
1917 const Handle(AIS_InteractiveObject)& anIObj,
1918 const Aspect_TypeOfFacingModel aModel)
1920 if ( !anIObj.IsNull () )
1921 anIObj->SetCurrentFacingModel(aModel);
1924 //=======================================================================
1925 //function : SetColor
1927 //=======================================================================
1929 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1930 const Quantity_NameOfColor aColor,
1931 const Standard_Boolean updateviewer)
1933 SetColor(anIObj,Quantity_Color(aColor),updateviewer);
1936 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
1937 const Quantity_Color &aColor,
1938 const Standard_Boolean updateviewer)
1940 if(anIObj.IsNull()) return ;
1942 if(!anIObj->HasInteractiveContext())
1943 anIObj->SetContext(this);
1944 anIObj->SetColor(aColor);
1945 if(anIObj->RecomputeEveryPrs())
1946 anIObj->Redisplay();
1949 Standard_Integer NbDisp=0;
1950 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1951 for (;ITI.More();ITI.Next())
1953 anIObj->Update(ITI.Value(),Standard_False);
1956 anIObj->SetRecomputeOk();
1958 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1965 // if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
1966 // Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
1967 // Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
1969 // gp_Dir D =Tr->Component()->XDirection();
1970 // gp_Pnt O = Tr->Component()->Location();
1971 // gp_Vec V(D);V*=Lx/5.;
1972 // T.SetRotation(gp_Ax1(O,D),M_PI/6.);
1973 // T.SetTranslationPart(V);
1974 // TopLoc_Location L,IncLoc(T);
1976 // for(Standard_Integer I=1;I<90;I++){
1977 // if(anIObj->HasLocation())
1978 // L = anIObj->Location() * IncLoc;
1981 // SetLocation(anIObj,L);
1982 // UpdateCurrentViewer();
1984 // for(I=1;I<90;I++){
1985 // L = anIObj->Location() /IncLoc;
1986 // SetLocation(anIObj,L);
1987 // UpdateCurrentViewer();
1989 // ResetLocation(anIObj);
1992 if(updateviewer) UpdateCurrentViewer();
1995 //=======================================================================
1996 //function : SetDeviationCoefficient
1998 //=======================================================================
2000 void AIS_InteractiveContext::SetDeviationCoefficient(
2001 const Handle(AIS_InteractiveObject)& anIObj,
2002 const Standard_Real aCoefficient,
2003 const Standard_Boolean updateviewer)
2005 // cout<<" Coefficient:"<< aCoefficient <<endl;
2006 if(anIObj.IsNull()) return ;
2008 if(!anIObj->HasInteractiveContext())
2009 anIObj->SetContext(this);
2011 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2012 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
2013 if(anIObj->Signature()!=0) return;
2014 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
2018 if(anIObj->RecomputeEveryPrs())
2019 anIObj->Redisplay();
2022 Standard_Integer NbDisp=0;
2023 TColStd_ListOfInteger LL;
2024 anIObj->ToBeUpdated(LL);
2025 TColStd_ListIteratorOfListOfInteger ITI(LL);
2026 for (;ITI.More();ITI.Next())
2028 anIObj->Update(ITI.Value(),Standard_False);
2031 anIObj->SetRecomputeOk();
2033 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2036 if(updateviewer) UpdateCurrentViewer();
2039 //=======================================================================
2040 //function : SetHLRDeviationCoefficient
2042 //=======================================================================
2044 void AIS_InteractiveContext::SetHLRDeviationCoefficient(
2045 const Handle(AIS_InteractiveObject)& anIObj,
2046 const Standard_Real aCoefficient,
2047 const Standard_Boolean updateviewer)
2049 // cout<<" HLRCoefficient:"<< aCoefficient <<endl;
2050 if(anIObj.IsNull()) return ;
2052 if(!anIObj->HasInteractiveContext())
2053 anIObj->SetContext(this);
2054 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2055 if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
2056 if(anIObj->Signature()!=0) return;
2057 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
2061 if(anIObj->RecomputeEveryPrs())
2062 anIObj->Redisplay();
2065 Standard_Integer NbDisp=0;
2067 TColStd_ListOfInteger LL;
2068 anIObj->ToBeUpdated(LL);
2069 TColStd_ListIteratorOfListOfInteger ITI(LL);
2070 for (;ITI.More();ITI.Next())
2072 anIObj->Update(ITI.Value(),Standard_False);
2075 anIObj->SetRecomputeOk();
2077 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2080 if(updateviewer) UpdateCurrentViewer();
2084 //=======================================================================
2085 //function : SetDeviationAngle
2087 //=======================================================================
2089 void AIS_InteractiveContext::SetDeviationAngle(
2090 const Handle(AIS_InteractiveObject)& anIObj,
2091 const Standard_Real anAngle,
2092 const Standard_Boolean updateviewer)
2094 // cout<<" Angle:"<< anAngle <<endl;
2095 if(anIObj.IsNull()) return ;
2097 if(!anIObj->HasInteractiveContext())
2098 anIObj->SetContext(this);
2099 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2100 if(anIObj->Type()!=AIS_KOI_Shape) return;
2101 if(anIObj->Signature()!=0) return;
2102 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
2105 if(anIObj->RecomputeEveryPrs())
2106 anIObj->Redisplay();
2109 Standard_Integer NbDisp=0;
2110 TColStd_ListOfInteger LL;
2111 anIObj->ToBeUpdated(LL);
2112 TColStd_ListIteratorOfListOfInteger ITI(LL);
2113 for (;ITI.More();ITI.Next())
2115 anIObj->Update(ITI.Value(),Standard_False);
2118 anIObj->SetRecomputeOk();
2120 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2123 if(updateviewer) UpdateCurrentViewer();
2125 //=======================================================================
2126 //function : SetDeviationAngle
2128 //=======================================================================
2130 void AIS_InteractiveContext::SetAngleAndDeviation(
2131 const Handle(AIS_InteractiveObject)& anIObj,
2132 const Standard_Real anAngle,
2133 const Standard_Boolean updateviewer)
2135 // cout<<" Angle:"<< anAngle <<endl;
2136 if(anIObj.IsNull()) return ;
2137 // Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
2138 if(!anIObj->HasInteractiveContext())
2139 anIObj->SetContext(this);
2141 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2142 if(anIObj->Type()!=AIS_KOI_Shape) return;
2143 if(anIObj->Signature()!=0) return;
2144 (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
2147 if(anIObj->RecomputeEveryPrs())
2148 anIObj->Redisplay();
2150 Update(anIObj,updateviewer);
2153 //=======================================================================
2154 //function : SetDeviationAngle
2156 //=======================================================================
2158 void AIS_InteractiveContext::SetHLRAngleAndDeviation(
2159 const Handle(AIS_InteractiveObject)& anIObj,
2160 const Standard_Real anAngle,
2161 const Standard_Boolean updateviewer)
2163 // cout<<" Angle:"<< anAngle <<endl;
2165 if(anIObj.IsNull()) return ;
2166 if(!anIObj->HasInteractiveContext())
2167 anIObj->SetContext(this);
2169 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2170 if(anIObj->Type()!=AIS_KOI_Shape) return;
2171 if(anIObj->Signature()!=0) return;
2172 (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
2175 if(anIObj->RecomputeEveryPrs())
2176 anIObj->Redisplay();
2179 Standard_Integer NbDisp=0;
2181 TColStd_ListOfInteger LL;
2182 anIObj->ToBeUpdated(LL);
2183 TColStd_ListIteratorOfListOfInteger ITI(LL);
2184 for (;ITI.More();ITI.Next())
2186 anIObj->Update(ITI.Value(),Standard_False);
2189 anIObj->SetRecomputeOk();
2191 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2194 if(updateviewer) UpdateCurrentViewer();
2197 //=======================================================================
2198 //function : SetHLRDeviationAngle
2200 //=======================================================================
2202 void AIS_InteractiveContext::SetHLRDeviationAngle(
2203 const Handle(AIS_InteractiveObject)& anIObj,
2204 const Standard_Real anAngle,
2205 const Standard_Boolean updateviewer)
2207 // cout<<" HLRAngle:"<< anAngle <<endl;
2208 if(anIObj.IsNull()) return ;
2210 if(!anIObj->HasInteractiveContext())
2211 anIObj->SetContext(this);
2212 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2213 if( anIObj->Type()!=AIS_KOI_Shape) return;
2214 if(anIObj->Signature()!=0) return;
2215 (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
2218 if(anIObj->RecomputeEveryPrs())
2219 anIObj->Redisplay();
2222 Standard_Integer NbDisp=0;
2223 TColStd_ListOfInteger LL;
2224 anIObj->ToBeUpdated(LL);
2225 TColStd_ListIteratorOfListOfInteger ITI(LL);
2226 for (;ITI.More();ITI.Next())
2228 anIObj->Update(ITI.Value(),Standard_False);
2231 anIObj->SetRecomputeOk();
2233 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2236 if(updateviewer) UpdateCurrentViewer();
2239 //=======================================================================
2240 //function : UnsetColor
2242 //=======================================================================
2244 void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
2245 const Standard_Boolean updateviewer)
2247 if(anIObj.IsNull()) return ;
2248 anIObj->UnsetColor();
2249 if(anIObj->RecomputeEveryPrs())
2250 anIObj->Redisplay();
2253 Standard_Integer NbDisp =0;
2254 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2255 for (;ITI.More();ITI.Next())
2257 anIObj->Update(ITI.Value(),Standard_False);
2261 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2263 anIObj->SetRecomputeOk();
2266 UpdateCurrentViewer();
2269 //=======================================================================
2270 //function : HasColor
2272 //=======================================================================
2274 Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const
2276 return anIObj->HasColor();
2280 //=======================================================================
2283 //=======================================================================
2285 Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const
2287 return anIObj->Color();
2290 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
2291 Quantity_Color &aColor) const
2293 anIObj->Color(aColor);
2296 //=======================================================================
2299 //=======================================================================
2301 Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const
2303 return anIObj->Width();
2306 //=======================================================================
2307 //function : SetWidth
2309 //=======================================================================
2311 void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2312 const Standard_Real aValue,
2313 const Standard_Boolean updateviewer)
2315 if(anIObj.IsNull()) return ;
2317 if(!anIObj->HasInteractiveContext())
2318 anIObj->SetContext(this);
2319 anIObj->SetWidth(aValue);
2320 if(anIObj->RecomputeEveryPrs())
2321 anIObj->Redisplay();
2324 Standard_Integer NbDisp=0;
2325 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2326 for (;ITI.More();ITI.Next())
2328 anIObj->Update(ITI.Value(),Standard_False);
2332 cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2334 anIObj->SetRecomputeOk();
2337 UpdateCurrentViewer();
2340 //=======================================================================
2341 //function : UnsetWidth
2343 //=======================================================================
2345 void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2346 const Standard_Boolean updateviewer)
2348 if(anIObj.IsNull()) return ;
2349 anIObj->UnsetWidth();
2350 if(anIObj->RecomputeEveryPrs())
2351 anIObj->Redisplay();
2354 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2355 for (;ITI.More();ITI.Next())
2357 anIObj->Update(ITI.Value(),Standard_False);
2359 anIObj->SetRecomputeOk();
2362 UpdateCurrentViewer();
2365 //=======================================================================
2366 //function : SetMaterial
2368 //=======================================================================
2370 void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2372 const Graphic3d_NameOfMaterial aName,
2373 // const Graphic3d_NameOfPhysicalMaterial aName,
2374 const Standard_Boolean updateviewer)
2376 if(!anIObj->HasInteractiveContext())
2377 anIObj->SetContext(this);
2378 anIObj->SetMaterial(aName);
2379 if(anIObj->RecomputeEveryPrs())
2380 anIObj->Redisplay();
2383 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2384 for (;ITI.More();ITI.Next())
2386 anIObj->Update(ITI.Value(),Standard_False);
2388 anIObj->SetRecomputeOk();
2391 UpdateCurrentViewer();
2395 //=======================================================================
2396 //function : UnsetMaterial
2398 //=======================================================================
2400 void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2401 const Standard_Boolean updateviewer)
2403 if(anIObj.IsNull()) return ;
2404 anIObj->UnsetMaterial();
2405 if(anIObj->RecomputeEveryPrs())
2406 anIObj->Redisplay();
2409 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2410 for (;ITI.More();ITI.Next())
2412 anIObj->Update(ITI.Value(),Standard_False);
2414 anIObj->SetRecomputeOk();
2417 UpdateCurrentViewer();
2420 //=======================================================================
2421 //function : SetTransparency
2423 //=======================================================================
2425 void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2426 const Standard_Real aValue,
2427 const Standard_Boolean updateviewer)
2429 if(anIObj.IsNull()) return ;
2430 if(!anIObj->HasInteractiveContext())
2431 anIObj->SetContext(this);
2433 #ifdef BUC60577 //right optimization
2434 if(!anIObj->IsTransparent() && aValue<=0.05) return;
2436 // if(!anIObj->IsTransparent() && aValue<=0.05) return;
2439 UnsetTransparency(anIObj,updateviewer);
2443 if(!myMainVwr->Viewer()->Transparency())
2444 myMainVwr->Viewer()->SetTransparency(Standard_True);
2445 anIObj->SetTransparency(aValue);
2446 if(anIObj->RecomputeEveryPrs())
2447 anIObj->Redisplay();
2450 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2451 for (;ITI.More();ITI.Next())
2453 anIObj->Update(ITI.Value(),Standard_False);
2455 anIObj->SetRecomputeOk();
2458 UpdateCurrentViewer();
2461 //=======================================================================
2462 //function : UnsetTransparency
2464 //=======================================================================
2466 void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2467 const Standard_Boolean updateviewer)
2469 if(anIObj.IsNull()) return ;
2470 anIObj->UnsetTransparency();
2471 if(anIObj->RecomputeEveryPrs())
2472 anIObj->Redisplay();
2475 TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2476 for (;ITI.More();ITI.Next())
2478 anIObj->Update(ITI.Value(),Standard_False);
2480 anIObj->SetRecomputeOk();
2483 // To Unset transparency in the viewer, if no other object is transparent ...(Speed)
2484 AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
2485 Standard_Boolean FoundTransp(Standard_False);
2486 for(;It.More() && !FoundTransp ;It.Next()){
2487 if(It.Key()->IsTransparent())
2488 FoundTransp = Standard_True;
2491 myMainVwr->Viewer()->SetTransparency(Standard_False);
2495 UpdateCurrentViewer();
2498 //=======================================================================
2499 //function : SetDegenerateModel
2501 //=======================================================================
2504 void AIS_InteractiveContext :: SetDegenerateModel (
2505 const Handle( AIS_InteractiveObject )& anObject,
2506 const Aspect_TypeOfDegenerateModel aModel,
2507 const Quantity_Ratio aRatio
2509 if ( !anObject.IsNull () ) {
2510 if ( !anObject -> HasInteractiveContext () )
2511 anObject -> SetContext ( this );
2512 anObject->SetDegenerateModel(aModel,aRatio);
2515 } // end AIS_InteractiveContext :: SetDegenerateModel
2517 void AIS_InteractiveContext :: SetDegenerateModel (
2518 const Aspect_TypeOfDegenerateModel aModel,
2519 const Quantity_Ratio aRatio
2522 AIS_DataMapIteratorOfDataMapOfIOStatus it ( myObjects );
2524 while ( it.More () ) {
2526 Handle( AIS_InteractiveObject ) obj = it.Key ();
2528 obj->SetDegenerateModel(aModel,aRatio);
2534 } // end AIS_InteractiveContext :: SetDegenerateModel
2537 //=======================================================================
2538 //function : SetSelectedAspect
2540 //=======================================================================
2541 void AIS_InteractiveContext::SetSelectedAspect(
2542 const Handle(Prs3d_BasicAspect)& anAspect,
2543 const Standard_Boolean globalChange,
2544 const Standard_Boolean updateViewer)
2546 if( !HasOpenedContext() ) {
2547 Standard_Boolean found = Standard_False;
2548 Handle(AIS_Selection) sel =
2549 AIS_Selection::Selection(myCurrentName.ToCString());
2550 Handle(AIS_InteractiveObject) object;
2551 for( sel->Init() ; sel->More() ; sel->Next()) {
2552 found = Standard_True;
2553 object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
2554 object->SetAspect(anAspect,globalChange);
2556 if( found && updateViewer) {
2557 myMainVwr->Update();
2558 if( !(myIsCollClosed && myCollectorVwr.IsNull()) )
2559 myCollectorVwr->Update();
2564 //=======================================================================
2565 //function : SetLocalAttributes
2567 //=======================================================================
2569 void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2570 const Handle(AIS_Drawer)& aDrawer,
2571 const Standard_Boolean updateviewer)
2573 if(anIObj.IsNull()) return ;
2574 if(!anIObj->HasInteractiveContext())
2575 anIObj->SetContext(this);
2576 anIObj->SetAttributes(aDrawer);
2577 Update(anIObj,updateviewer);
2581 //=======================================================================
2582 //function : UnsetLocalAttributes
2584 //=======================================================================
2585 void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2586 const Standard_Boolean updateviewer)
2588 if(anIObj.IsNull()) return ;
2589 if(!anIObj->HasInteractiveContext())
2590 anIObj->SetContext(this);
2591 anIObj->UnsetAttributes();
2592 Update(anIObj,updateviewer);
2596 //=======================================================================
2599 //=======================================================================
2601 void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const
2605 if(anIObj.IsNull()) return ;
2606 if(myObjects.IsBound(anIObj)){
2607 astatus += "\t ____________________________________________";
2608 astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2609 const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
2610 switch(ST->GraphicStatus()){
2611 case AIS_DS_Displayed:
2613 astatus +="\t| -->Displayed\n";
2618 astatus +="\t| -->Erased\n";
2621 case AIS_DS_FullErased:
2623 astatus +="\t| -->Full Erased\n";
2629 astatus += "\t| Active Display Modes in the MainViewer :\n";
2630 TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
2631 for(;ItL.More();ItL.Next()){
2632 astatus += "\t|\t Mode ";
2633 astatus += TCollection_AsciiString(ItL.Value());
2636 if(IsCurrent(anIObj)) astatus +="\t| Current\n";
2637 if(IsSelected(anIObj)) astatus +="\t| Selected\n";
2639 astatus += "\t| Active Selection Modes in the MainViewer :\n";
2640 for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
2641 astatus += "\t\t Mode ";
2642 astatus += TCollection_AsciiString(ItL.Value());
2645 astatus += "\t ____________________________________________";
2651 //=======================================================================
2652 //function : GetDefModes
2654 //=======================================================================
2656 void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
2657 Standard_Integer& DispMode,
2658 Standard_Integer& HiMode,
2659 Standard_Integer& SelMode) const
2661 if(anIObj.IsNull()) return ;
2662 DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
2663 (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
2665 HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
2667 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
2669 SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
2674 //=======================================================================
2675 //function : EraseGlobal
2677 //=======================================================================
2679 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2680 const Standard_Boolean updateviewer,
2681 const Standard_Boolean PutInCollector)
2683 if(anIObj.IsNull()) return ;
2684 if(!myObjects.IsBound(anIObj)) return;
2687 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2688 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2690 Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2691 if(STATUS->GraphicStatus()==AIS_DS_Displayed){
2693 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2694 for(;ItL.More();ItL.Next()){
2695 if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2696 myMainPM->Unhighlight(anIObj,ItL.Value());
2697 myMainPM->Erase(anIObj,ItL.Value());
2699 if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
2700 myMainPM->Erase(anIObj,Dmode);
2702 for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
2703 mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
2704 if(updateviewer) myMainVwr->Update();
2706 if(PutInCollector && !myCollectorPM.IsNull()){
2707 myCollectorPM->Display(anIObj,Dmode);
2709 Standard_Integer SMode = anIObj->SelectionMode();
2710 mgrSelector->Activate(anIObj,SMode,myCollectorSel);
2712 mgrSelector->Activate(anIObj,0,myCollectorSel);
2714 if(STATUS->IsHilighted())
2715 myCollectorPM->Highlight(anIObj,Dmode);
2716 STATUS->SetGraphicStatus(AIS_DS_Erased);
2717 if(updateviewer) myCollectorVwr->Update();
2720 STATUS->SetGraphicStatus(AIS_DS_FullErased);
2724 //=======================================================================
2725 //function : ClearGlobal
2727 //=======================================================================
2729 void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj,
2730 const Standard_Boolean updateviewer)
2732 if(anIObj.IsNull()) return ;
2733 if(!myObjects.IsBound(anIObj)) return;
2735 // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2736 Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2738 TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2739 for(;ItL.More();ItL.Next()){
2740 if(STATUS->IsHilighted()){
2741 if(IsCurrent(anIObj))
2743 AddOrRemoveCurrentObject( anIObj, updateviewer );
2745 AddOrRemoveCurrentObject(anIObj);
2747 else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2748 myMainPM->Unhighlight(anIObj,ItL.Value());
2750 myMainPM->Erase(anIObj,ItL.Value());
2751 myMainPM->Clear(anIObj,ItL.Value());
2752 if(anIObj->HasHilightMode()){
2753 Standard_Integer im = anIObj->HilightMode();
2754 myMainPM->Unhighlight(anIObj,im);
2755 myMainPM->Erase(anIObj,im);
2760 //Object removes from Detected sequence
2761 Standard_Integer i = 1;
2762 for(i = 1; i < myAISDetectedSeq.Length(); i++)
2764 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2765 if( !anObj.IsNull() && anObj != anIObj )
2766 myAISDetectedSeq.Remove( i );
2769 if(myLastinMain == anIObj)
2770 myLastinMain.Nullify();
2771 if(myLastinColl == anIObj)
2772 myLastinColl.Nullify();
2774 if(myLastPicked == anIObj)
2775 myLastPicked.Nullify();
2777 // OCC21671: Remove IO from the selection manager in any case
2778 // to avoid memory leaks
2779 mgrSelector->Remove(anIObj);
2781 switch(STATUS->GraphicStatus()){
2784 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2785 if(STATUS->IsHilighted()){
2786 myCollectorPM->Unhighlight(anIObj,DM);
2788 myCollectorPM->Erase(anIObj,DM);
2789 myCollectorPM->Clear(anIObj,DM);
2790 if(updateviewer) myCollectorVwr->Update();
2793 case AIS_DS_Displayed:
2795 if(updateviewer) myMainVwr->Update();
2801 myObjects.UnBind(anIObj);
2805 //=======================================================================
2806 //function : ClearGlobalPrs
2808 //=======================================================================
2810 void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj,
2811 const Standard_Integer aMode,
2812 const Standard_Boolean updateviewer)
2814 if(anIObj.IsNull()) return ;
2815 if(!myObjects.IsBound(anIObj)) return;
2816 const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2818 Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2819 if(STATUS->IsDModeIn(aMode)){
2820 if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
2821 myMainPM->Unhighlight(anIObj,aMode);
2823 myMainPM->Erase(anIObj,aMode);
2824 myMainPM->Clear(anIObj,aMode);
2827 if(STATUS->GraphicStatus()== AIS_DS_Erased)
2830 if(STATUS->IsHilighted())
2831 myCollectorPM->Unhighlight(anIObj,aMode);
2832 myCollectorPM->Erase(anIObj,DM);
2833 myCollectorPM->Clear(anIObj,DM);
2835 if(updateviewer) myCollectorVwr->Update();
2837 else if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
2838 myMainVwr->Update();
2841 //=======================================================================
2842 //function : DrawHiddenLine
2844 //=======================================================================
2846 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
2848 return myDefaultDrawer->DrawHiddenLine();
2851 //=======================================================================
2852 //function : EnableDrawHiddenLine
2854 //=======================================================================
2856 void AIS_InteractiveContext::EnableDrawHiddenLine () const {
2857 myDefaultDrawer->EnableDrawHiddenLine();
2860 //=======================================================================
2861 //function : DisableDrawHiddenLine
2863 //=======================================================================
2865 void AIS_InteractiveContext::DisableDrawHiddenLine () const {
2866 myDefaultDrawer->DisableDrawHiddenLine();
2869 //=======================================================================
2870 //function : HiddenLineAspect
2872 //=======================================================================
2874 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const {
2875 return myDefaultDrawer->HiddenLineAspect();
2878 //=======================================================================
2879 //function : SetHiddenLineAspect
2881 //=======================================================================
2883 void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
2884 myDefaultDrawer->SetHiddenLineAspect(anAspect);
2887 //=======================================================================
2888 //function : SetIsoNumber
2890 //=======================================================================
2892 void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
2896 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2899 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2902 myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2903 myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2908 //=======================================================================
2909 //function : IsoNumber
2911 //=======================================================================
2913 Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
2918 return myDefaultDrawer->UIsoAspect()->Number();
2920 return myDefaultDrawer->VIsoAspect()->Number();
2922 return (myDefaultDrawer->UIsoAspect()->Number()==
2923 myDefaultDrawer->VIsoAspect()->Number()) ?
2924 myDefaultDrawer->UIsoAspect()->Number(): -1;
2929 //=======================================================================
2930 //function : IsoOnPlane
2932 //=======================================================================
2934 void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
2936 myDefaultDrawer->SetIsoOnPlane(SwitchOn);
2939 //=======================================================================
2940 //function : IsoOnPlane
2942 //=======================================================================
2944 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2946 return myDefaultDrawer->IsoOnPlane();
2949 //=======================================================================
2950 //function : SetSelectionMode
2952 //=======================================================================
2954 void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject&, const Standard_Integer )
2958 //=======================================================================
2959 //function : UnsetSelectionMode
2961 //=======================================================================
2963 void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObject&)
2967 //=======================================================================
2968 //function : SetSensitivityMode
2970 //=======================================================================
2972 void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
2974 if( HasOpenedContext() )
2975 myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
2977 myMainSel->SetSensitivityMode(aMode);
2978 if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivityMode(aMode);
2982 //=======================================================================
2983 //function : SensitivityMode
2985 //=======================================================================
2987 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
2989 if( HasOpenedContext() )
2990 return myLocalContexts(myCurLocalIndex)->SensitivityMode();
2991 return myMainSel->SensitivityMode();
2994 //=======================================================================
2995 //function : SetSensitivity
2997 //=======================================================================
2999 void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
3001 if( HasOpenedContext() )
3002 myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
3004 myMainSel->SetSensitivity(aPrecision);
3005 if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivity(aPrecision);
3009 //=======================================================================
3010 //function : Sensitivity
3012 //=======================================================================
3014 Standard_Real AIS_InteractiveContext::Sensitivity() const {
3016 if( HasOpenedContext() )
3017 return myLocalContexts(myCurLocalIndex)->Sensitivity();
3018 return myMainSel->Sensitivity();
3021 //=======================================================================
3022 //function : SetPixelTolerance
3024 //=======================================================================
3026 void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
3028 if( HasOpenedContext() )
3029 myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
3031 myMainSel->SetPixelTolerance(aPrecision);
3032 if( !myCollectorSel.IsNull() ) myCollectorSel->SetPixelTolerance(aPrecision);
3036 //=======================================================================
3037 //function : PixelTolerance
3039 //=======================================================================
3041 Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
3043 if( HasOpenedContext() )
3044 return myLocalContexts(myCurLocalIndex)->PixelTolerance();
3045 return myMainSel->PixelTolerance();
3048 //=======================================================================
3049 //function : IsInLocal
3051 //=======================================================================
3053 Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle_AIS_InteractiveObject& anIObj,
3054 Standard_Integer& TheIndex) const
3056 if(anIObj.IsNull()) return Standard_False;
3057 // if it exists at neutral point 0 index is returned
3058 if(myObjects.IsBound(anIObj)) {
3060 return Standard_False;
3062 for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
3063 if(myLocalContexts.IsBound(I)){
3064 if(myLocalContexts(I)->IsIn(anIObj)){
3066 return Standard_True;
3072 return Standard_False;
3075 //=======================================================================
3076 //function : InitAttributes
3078 //=======================================================================
3080 void AIS_InteractiveContext::InitAttributes()
3083 mgrSelector->Add(myMainSel);
3084 myCurrentName = AIS_Context_NewCurName();
3085 mySelectionName = AIS_Context_NewSelName();
3087 AIS_Selection::CreateSelection(mySelectionName.ToCString());
3088 AIS_Selection::CreateSelection(myCurrentName.ToCString());
3091 myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
3092 Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
3093 myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
3095 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
3096 Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
3097 HLA->SetColor(Quantity_NOC_GRAY20);
3099 HLA->SetTypeOfLine(Aspect_TOL_DASH);
3101 // tolerance to 4 pixels...
3102 SetPixelTolerance();
3104 // Customizing the drawer for trihedrons and planes...
3106 Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
3107 Standard_Real aLength(100.);
3108 DA->SetAxisLength(aLength,aLength,aLength);
3109 Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
3110 DA->FirstAxisAspect()->SetColor(col);
3111 DA->SecondAxisAspect()->SetColor(col);
3112 DA->ThirdAxisAspect()->SetColor(col);
3114 Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
3116 PA->SetPlaneLength(aLength,aLength);
3117 PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
3123 //=======================================================================
3124 //function : TrihedronSize
3126 //=======================================================================
3127 Standard_Real AIS_InteractiveContext::TrihedronSize() const
3129 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
3131 //=======================================================================
3132 //function : SetTrihedronSize
3134 //=======================================================================
3135 void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
3137 myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
3138 Redisplay(AIS_KOI_Datum,3,Standard_False);
3139 Redisplay(AIS_KOI_Datum,4,Standard_True);
3144 //=======================================================================
3145 //function : SetPlaneSize
3147 //=======================================================================
3148 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
3149 const Standard_Real aValY,
3150 const Standard_Boolean /*updateviewer*/)
3152 myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
3153 Redisplay(AIS_KOI_Datum,7);
3156 //=======================================================================
3157 //function : SetPlaneSize
3159 //=======================================================================
3161 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
3162 const Standard_Boolean updateviewer)
3164 SetPlaneSize(aVal,aVal,updateviewer);
3167 //=======================================================================
3168 //function : PlaneSize
3170 //=======================================================================
3172 Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
3174 LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
3175 LY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
3176 return (Abs(LX-LY)<=Precision::Confusion());
3181 //=======================================================================
3184 //=======================================================================
3185 void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
3187 myIsAutoActivateSelMode = Auto;
3190 //=======================================================================
3193 //=======================================================================
3194 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
3196 return myIsAutoActivateSelMode;
3199 //=======================================================================
3200 //function : SetZLayer
3202 //=======================================================================
3204 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
3205 const Standard_Integer theLayerId)
3207 if (theIObj.IsNull ())
3210 if (myObjects.IsBound (theIObj))
3212 switch (myObjects (theIObj)->GraphicStatus ())
3214 case AIS_DS_Displayed:
3216 theIObj->SetZLayer (myMainPM, theLayerId);
3221 theIObj->SetZLayer (myCollectorPM, theLayerId);
3228 else if (HasOpenedContext ())
3230 myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
3234 //=======================================================================
3235 //function : GetZLayer
3237 //=======================================================================
3239 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
3241 if (theIObj.IsNull ())
3244 if (myObjects.IsBound (theIObj))
3246 return theIObj->GetZLayer (myMainPM);
3248 else if (HasOpenedContext ())
3250 return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);