0023320: The body of 'OpenCollector' function is fully equivalent to the body of...
[occt.git] / src / AIS / AIS_InteractiveContext.cxx
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
5 //
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.
10 //
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.
13 //
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.
20
21 // Modified by  XAB & Serguei Dec 97 (angle &deviation coeffts)
22
23 #define BUC60577        //GG_101099     Enable to compute correctly
24 //                      transparency with more than one object in the view.
25
26 #define GER61351        //GG_171199     Enable to set an object RGB color
27 //                              instead a restricted object NameOfColor. 
28
29 #define G003            //EUG_26/01/00 Degenerate support (G003)
30
31 #define IMP140200       //GG Add SetSelectedAspect() method.
32
33 #define BUC60632        //GG 15/03/00 Add protection on SetDisplayMode()
34 //                      method, compute only authorized presentation.
35
36 #define BUC60688        //GG 25/05/00 Add SetSensitivity() methods.
37
38 #define BUC60722  //GG 04/09/00 Always enable viewer update when erasing something
39
40 #define IMP051001       //GG Adds SetZDetected() and ZDetected() methods
41
42 #define OCC172          //SAV clear static map before destroying context.
43
44 #define OCC204          //SAV 26/02/02 : pass <updateviewer> flag to 
45 // AddOrRemoveCurrentObject method from ClearGlobal.
46
47 #define OCC4373         //SAN 10/11/03 : improve display mode management in
48 // Display( IO, updateviewer ) and 
49 // SetDisplayMode( IO, mode, updateviewer ) methods
50
51 #include <AIS_InteractiveContext.ixx>
52
53 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
54 #include <TColStd_ListIteratorOfListOfInteger.hxx>
55 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
56 #include <AIS_LocalContext.hxx>
57 #include <AIS_LocalStatus.hxx>
58 #include <Precision.hxx>
59 #include <AIS_Selection.hxx>
60 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
61 #include <AIS_ConnectedShape.hxx>
62 #include <AIS_MultipleConnectedShape.hxx>
63 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
64 #include <AIS_GlobalStatus.hxx>
65 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
66 #include <PrsMgr_ModedPresentation.hxx>
67 #include <Visual3d_ViewManager.hxx>
68 #include <Prs3d_ShadingAspect.hxx>
69 #include <AIS_Shape.hxx>
70 #include <Graphic3d_AspectFillArea3d.hxx>
71 #include <HLRBRep.hxx>
72 #include <Prs3d_IsoAspect.hxx>
73 #include <Prs3d_DatumAspect.hxx>
74 #include <Prs3d_PlaneAspect.hxx>
75 #include <PrsMgr_PresentableObject.hxx>
76 #include <Standard_Atomic.hxx>
77 #include <UnitsAPI.hxx>
78
79 #include <AIS_Trihedron.hxx>
80 #include <Geom_Axis2Placement.hxx>
81 #include <OSD_Environment.hxx>
82
83 #include <AIS_ListIteratorOfListOfInteractive.hxx>
84
85 // In the method GetDefModes() the returned value of the selection mode 
86 // is always equal to 0 if it is -1.
87 #define BUC61051
88
89 // The local context is closed the method ::ResetOriginalState() sets the selection mode equal to 0
90 // in spite of the selection mode of the interactive object in Natural Point.
91 #define OCC166
92
93 // An interactive Object being erased in the main viewer and put into collector should have the same selection mode.
94 // It impacts the performance!
95 #define OCC328
96
97 static Standard_Boolean AISDebugModeOn()
98 {
99 //  static OSD_Environment aisdb("AISDEBUGMODE");
100 //  return !aisdb.Value().IsEmpty();
101   static Standard_Integer isDebugMode(-1);
102   if (isDebugMode < 0) {
103     isDebugMode = 1;
104     OSD_Environment aisdb("AISDEBUGMODE");
105     if (aisdb.Value().IsEmpty())
106       isDebugMode = 0;
107   }
108   return (isDebugMode != 0);
109 }
110
111 namespace
112 {
113   static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
114   static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
115
116   static TCollection_AsciiString AIS_Context_NewSelName()
117   {
118     return TCollection_AsciiString ("AIS_SelContext_")
119          + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
120   }
121
122   static TCollection_AsciiString AIS_Context_NewCurName()
123   {
124     return TCollection_AsciiString ("AIS_CurContext_")
125          + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
126   }
127 };
128
129 //=======================================================================
130 //function : AIS_InteractiveContext
131 //purpose  : 
132 //=======================================================================
133
134 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
135 mgrSelector(new SelectMgr_SelectionManager()),
136 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
137 myMainVwr(MainViewer),
138 myMainSel(new StdSelect_ViewerSelector3d()),
139 myIsCollClosed(Standard_True),
140 myToHilightSelected( Standard_False ),
141 myFilters(new SelectMgr_OrFilter()),
142 myDefaultDrawer(new Prs3d_Drawer()),
143 myDefaultColor(Quantity_NOC_GOLDENROD),
144 myHilightColor(Quantity_NOC_CYAN1),
145 mySelectionColor(Quantity_NOC_GRAY80),
146 myPreselectionColor(Quantity_NOC_GREEN),
147 mySubIntensity(Quantity_NOC_GRAY40),
148 myDisplayMode(0),
149 myCurLocalIndex(0),
150 #ifdef IMP051001
151 myZDetectionFlag(0),
152 #endif
153 myIsAutoActivateSelMode( Standard_True )
154
155   InitAttributes();
156 }
157
158
159 //=======================================================================
160 //function : AIS_InteractiveContext
161 //purpose  : 
162 //=======================================================================
163
164 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer,
165                                              const Handle(V3d_Viewer)& Collector):
166 mgrSelector(new SelectMgr_SelectionManager()),
167 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
168 myMainVwr(MainViewer),
169 myMainSel(new StdSelect_ViewerSelector3d()),
170 myCollectorPM(new PrsMgr_PresentationManager3d(Collector->Viewer())),
171 myCollectorVwr(Collector),
172 myCollectorSel(new StdSelect_ViewerSelector3d()),
173 myIsCollClosed(Standard_False),
174 myToHilightSelected( Standard_False ),
175 myFilters(new SelectMgr_OrFilter()),
176 myDefaultDrawer(new Prs3d_Drawer()),
177 myDefaultColor(Quantity_NOC_GOLDENROD),
178 myHilightColor(Quantity_NOC_CYAN1),
179 mySelectionColor(Quantity_NOC_GRAY80),
180 myPreselectionColor(Quantity_NOC_GREEN),
181 mySubIntensity(Quantity_NOC_GRAY40),
182 myDisplayMode(0),
183 myCurLocalIndex(0),
184 #ifdef IMP051001
185 myZDetectionFlag(0),
186 #endif
187 myIsAutoActivateSelMode( Standard_True )
188 {
189   InitAttributes();
190   mgrSelector->Add(myCollectorSel);
191   SetPixelTolerance();
192 }
193
194 void AIS_InteractiveContext::Delete() const
195 {
196 #ifdef OCC172
197   // to avoid an exception
198   if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
199     AIS_Selection::Remove( mySelectionName.ToCString() );
200
201   // to avoid an exception
202   if ( AIS_Selection::Find( myCurrentName.ToCString() ) )
203     AIS_Selection::Remove( myCurrentName.ToCString() );
204
205   // let's remove one reference explicitly. this operation's supposed to
206   // be performed when mgrSelector will be destroyed but anyway...
207   mgrSelector->Remove( myMainSel );
208 #endif
209   MMgt_TShared::Delete();
210 }
211
212 //=======================================================================
213 //function : AIS_SelectionName
214 //purpose  : 
215 //=======================================================================
216 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const 
217 {
218   if(!HasOpenedContext())
219     return mySelectionName;
220   return myLocalContexts(myCurLocalIndex)->SelectionName();
221
222
223
224
225
226 //=======================================================================
227 //function : UpdateCurrentViewer
228 //purpose  : 
229 //=======================================================================
230
231 void AIS_InteractiveContext::UpdateCurrentViewer()
232 {
233   if (!myMainVwr.IsNull())
234     myMainVwr->Update();
235 }
236
237 void AIS_InteractiveContext::OpenCollector()
238 {
239   myIsCollClosed = Standard_False;
240   // to be completed....
241 }
242
243
244
245 //=======================================================================
246 //function : DomainOfMainViewer
247 //purpose  : 
248 //=======================================================================
249
250 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const 
251 {
252   return myMainVwr->Domain();
253   
254 }
255
256 //=======================================================================
257 //function : DisplayedObjects
258 //purpose  : 
259 //=======================================================================
260
261 void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
262                                               const Standard_Boolean OnlyFromNeutral) const 
263 {
264 #ifdef DEBUG
265   cout<<"AIS_IC::DisplayedObjects"<<endl;
266 #endif
267
268   AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
269   if(!HasOpenedContext() || OnlyFromNeutral){
270     for(;It.More();It.Next()){
271       if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
272         aListOfIO.Append(It.Key());
273     }
274   }
275   else{
276     TColStd_MapOfTransient theMap;
277     // neutral point
278     for(;It.More();It.Next()){
279       if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
280         theMap.Add(It.Key());
281     }
282 #ifdef DEBUG
283     cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl;
284 #endif
285
286     //parse all local contexts...
287     Standard_Integer NbDisp;
288     for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
289       const Handle(AIS_LocalContext)& LC = it1.Value();
290       NbDisp =  LC->DisplayedObjects(theMap);
291 #ifdef DEBUG
292       cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
293 #endif
294       
295     }
296     Handle(AIS_InteractiveObject) curIO;
297     Handle(Standard_Transient) Tr;
298       for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
299         Tr = it2.Key();
300         curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
301         aListOfIO.Append(curIO);
302       }
303     }
304 }
305 //=======================================================================
306 //function : DisplayedObjects
307 //purpose  : 
308 //=======================================================================
309
310 void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
311                                               const Standard_Integer TheSign,
312                                               AIS_ListOfInteractive& aListOfIO,
313                                               const Standard_Boolean /*OnlyFromNeutral*/) const 
314 {
315   ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
316 }
317
318 //=======================================================================
319 //function : UpdateCollector
320 //purpose  : 
321 //=======================================================================
322
323 void AIS_InteractiveContext::UpdateCollector()
324 {
325   if (!myCollectorVwr.IsNull())
326     myCollectorVwr->Update();
327 }
328
329 //=======================================================================
330 //function : DomainOfCollector
331 //purpose  : 
332 //=======================================================================
333
334 Standard_CString AIS_InteractiveContext::DomainOfCollector() const 
335 {
336   if(myCollectorVwr.IsNull()) return "";
337   return  myCollectorVwr->Domain();
338 }
339
340 //=======================================================================
341 //function : ObjectsInCollector
342 //purpose  : 
343 //=======================================================================
344
345 void AIS_InteractiveContext::ObjectsInCollector(AIS_ListOfInteractive& aListOfIO) const 
346 {
347   ObjectsByDisplayStatus( AIS_DS_Erased, aListOfIO );
348 }
349
350 //=======================================================================
351 //function : ObjectsInCollector
352 //purpose  : 
353 //=======================================================================
354
355 void AIS_InteractiveContext::ObjectsInCollector(const AIS_KindOfInteractive TheKind,
356                                                 const Standard_Integer TheSign,
357                                                 AIS_ListOfInteractive& aListOfIO) const 
358 {
359   ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, aListOfIO );
360 }
361
362 //=======================================================================
363 //function : ErasedObjects
364 //purpose  : 
365 //=======================================================================
366
367 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const 
368 {
369   ObjectsByDisplayStatus( AIS_DS_FullErased, theListOfIO );
370 }
371
372 //=======================================================================
373 //function : ErasedObjects
374 //purpose  : 
375 //=======================================================================
376
377 void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
378                                            const Standard_Integer TheSign,
379                                            AIS_ListOfInteractive& theListOfIO) const 
380 {
381   ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_FullErased, theListOfIO );
382 }
383
384 //=======================================================================
385 //function : ObjectsByDisplayStatus
386 //purpose  : 
387 //=======================================================================
388
389 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
390                                                     AIS_ListOfInteractive&  theListOfIO) const 
391 {
392   AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
393   for(;It.More();It.Next()){
394     if(It.Value()->GraphicStatus() == theStatus)
395       theListOfIO.Append(It.Key());
396   }
397 }
398
399 //=======================================================================
400 //function : ObjectsByDisplayStatus
401 //purpose  : 
402 //=======================================================================
403
404 void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
405                                                     const Standard_Integer TheSign,
406                                                     const AIS_DisplayStatus theStatus,
407                                                     AIS_ListOfInteractive& theListOfIO) const 
408 {
409   AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
410   for(;It.More();It.Next()){
411     if(It.Value()->GraphicStatus()==theStatus){
412       if(It.Key()->Type()==TheKind){
413         if(TheSign ==-1)
414           theListOfIO.Append(It.Key());
415         else{
416           if(It.Key()->Signature()==TheSign)
417             theListOfIO.Append(It.Key());
418         }
419       }
420     }
421   }
422 }
423
424 //=======================================================================
425 //function : ObjectsInside
426 //purpose  : 
427 //=======================================================================
428
429 void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
430                                            const AIS_KindOfInteractive TheKind,
431                                            const Standard_Integer TheSign) const 
432 {
433   AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
434   if(TheKind==AIS_KOI_None && TheSign ==-1){
435     for(;It.More();It.Next()){
436         aListOfIO.Append(It.Key());
437     }
438   }
439   else{
440     for(;It.More();It.Next()){
441       if(It.Key()->Type()==TheKind){
442         if(TheSign ==-1)
443           aListOfIO.Append(It.Key());
444         else{
445           if(It.Key()->Signature()==TheSign)
446             aListOfIO.Append(It.Key());
447         }
448       }
449     }
450   }
451 }
452
453 //=======================================================================
454 //function : Display
455 //purpose  : 
456 //=======================================================================
457
458 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
459                                      const Standard_Boolean updateviewer )
460 {
461   if(anIObj.IsNull()) return;
462   
463   Standard_Integer DispMode,HiMod,SelMode;
464   
465   GetDefModes(anIObj,DispMode,HiMod,SelMode);
466   
467   Handle (AIS_InteractiveContext) aThis = this;
468   if(!anIObj->HasInteractiveContext()) 
469     anIObj->SetContext(aThis);
470   
471   //NO LOCAL CONTEXT OPEN
472   if(!HasOpenedContext()) {
473 #ifndef OCC4373
474     // SAN : Do not return here. Perform advanced display mode analysis a bit later...
475     if(IsDisplayed(anIObj)) return;
476 #endif
477     Standard_Boolean updcol = Standard_False;
478     
479     // it did not yet exist
480     if(!myObjects.IsBound(anIObj)){
481       
482       Handle(AIS_GlobalStatus) STATUS= 
483 #ifdef OCC166
484         new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
485 #else
486       new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
487 #endif
488       myObjects.Bind (anIObj,STATUS);
489       myMainPM->Display(anIObj,DispMode);
490       if( myIsAutoActivateSelMode )
491       {
492         if(!mgrSelector->Contains(anIObj))
493            mgrSelector->Load(anIObj);
494         mgrSelector->Activate(anIObj,SelMode,myMainSel);
495       }
496         
497      if(updateviewer) myMainVwr->Update();
498     }
499     // it is somewhere else...
500     else {
501       // CLE
502       // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
503       Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
504       // ENDCLE
505       switch (STATUS->GraphicStatus()){
506       case AIS_DS_Erased:{
507         if(STATUS->IsHilighted())
508           myCollectorPM->Unhighlight(anIObj,HiMod);
509         myCollectorPM->Erase(anIObj,HiMod);
510         mgrSelector->Deactivate(anIObj,myCollectorSel);
511         updcol = updateviewer;
512                          }// attention the break is not set on purpose...
513       case AIS_DS_FullErased:{
514         TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
515         for (;ItL.More();ItL.Next()){
516           myMainPM->Display(anIObj,ItL.Value());
517           if(STATUS->IsSubIntensityOn())
518             myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
519         }
520         if( myIsAutoActivateSelMode )        
521             for (ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
522                 mgrSelector->Activate(anIObj,ItL.Value(),myMainSel);
523         STATUS->SetGraphicStatus(AIS_DS_Displayed);
524         if(STATUS->IsHilighted())
525           myMainPM->Highlight(anIObj,HiMod);
526         break;
527                              }
528 #ifdef OCC4373
529       // SAN : erase presentations for all display modes different from <DispMode>;
530       //       then make sure <DispMode> is displayed and maybe highlighted;
531       //       Finally, activate selection mode <SelMode> if not yet activated.
532       case AIS_DS_Displayed:{
533         TColStd_ListOfInteger aModesToRemove;
534         TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
535         for(;ItL.More();ItL.Next()){
536
537           Standard_Integer OldMode = ItL.Value();
538
539           if(OldMode!=DispMode){
540             aModesToRemove.Append(OldMode);
541             if(myMainPM->IsHighlighted(anIObj,OldMode))
542               myMainPM->Unhighlight(anIObj,OldMode);
543             myMainPM->Erase(anIObj,OldMode);
544           }
545         }
546
547         for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
548           STATUS->RemoveDisplayMode(ItL.Value());
549
550         if(!STATUS->IsDModeIn(DispMode))
551           STATUS->AddDisplayMode(DispMode);
552
553         myMainPM->Display(anIObj,DispMode);
554         if(STATUS->IsHilighted()){
555           myMainPM->Highlight(anIObj,HiMod);
556         }
557         if( myIsAutoActivateSelMode )
558         {
559            if(!mgrSelector->Contains(anIObj))
560               mgrSelector->Load(anIObj);
561            if(!mgrSelector->IsActivated(anIObj,SelMode))
562               mgrSelector->Activate(anIObj,SelMode,myMainSel);
563         }
564
565         break;
566                             }
567 #endif
568       default:
569         break;
570       }
571     } 
572     
573     if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
574       myMainVwr->Viewer()->SetTransparency(Standard_True);
575     if(updateviewer) myMainVwr->Update();
576     if(updcol && !myCollectorVwr.IsNull()) myCollectorVwr->Update();
577   }
578   
579   //  LOCAL CONTEXT OPEN
580   else
581   {
582     myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
583     
584     if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
585       myMainVwr->Viewer()->SetTransparency(Standard_True);
586     
587     
588     if(updateviewer) myMainVwr->Update();
589   }
590 }
591
592 //=======================================================================
593 //function : Display
594 //purpose  : 
595 //=======================================================================
596
597 void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
598                                     const Standard_Integer aDisplayMode, 
599                                     const Standard_Integer aSelectionMode, 
600                                     const Standard_Boolean updateviewer, 
601                                     const Standard_Boolean allowdecomposition)
602 {
603   if(anIObj.IsNull()) return;
604
605   if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
606   
607   // if no local context...
608   if(!HasOpenedContext()) {
609     //    if(!anIObj->HasDisplayMode())
610     //      anIObj->SetDisplayMode(aDisplayMode);
611   
612     if(!myObjects.IsBound(anIObj)){
613       Handle(AIS_GlobalStatus) STATUS= 
614         new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
615       myObjects.Bind (anIObj,STATUS);
616       myMainPM->Display(anIObj,aDisplayMode);
617       if(aSelectionMode!=-1){
618         if(!mgrSelector->Contains(anIObj))
619           mgrSelector->Load(anIObj,aSelectionMode);
620         mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
621       }
622       if(updateviewer) myMainVwr->Update();
623     }
624     //    anIObj->SelectionMode(aSelectionMode);
625     else{
626       // CLE
627       // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
628       Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
629       // ENDCLE
630       if(!STATUS->IsDModeIn(aDisplayMode)){
631         myMainPM->Display(anIObj,aDisplayMode);
632         STATUS->AddDisplayMode(aDisplayMode);
633         if(STATUS->IsSubIntensityOn())
634           myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
635       }
636       if(aSelectionMode!=-1){
637         STATUS->AddSelectionMode(aSelectionMode);
638         mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
639       }
640       if(updateviewer) myMainVwr->Update();
641       
642     }
643   }
644   else
645     {
646       myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
647       if(updateviewer) myMainVwr->Update();
648     }  
649 }
650
651
652 //=======================================================================
653 //function : Load
654 //purpose  : 
655 //=======================================================================
656
657 void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
658                                   const Standard_Integer SelMode,
659                                   const Standard_Boolean AllowDecomposition)
660 {
661   if(anIObj.IsNull()) return;
662   if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
663   
664
665   if(!HasOpenedContext()) {
666     if(SelMode==-1 && !AllowDecomposition){
667       Standard_Integer DispMode,HiMod,SelModeDef;
668       
669       GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
670       Handle(AIS_GlobalStatus) STATUS= 
671         new AIS_GlobalStatus(AIS_DS_FullErased,DispMode,SelModeDef);
672       myObjects.Bind (anIObj,STATUS);      
673       return;
674     }
675   }
676   myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
677 }
678
679
680 //=======================================================================
681 //function : Erase
682 //purpose  : 
683 //=======================================================================
684
685 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj, 
686                                    const Standard_Boolean updateviewer, 
687                                    const Standard_Boolean PutInCollector)
688 {
689   if(anIObj.IsNull()) return;
690   
691   if ( !anIObj->IsAutoHilight() )
692     anIObj->ClearSelected();
693   
694   if(!HasOpenedContext()){
695     EraseGlobal(anIObj,updateviewer,PutInCollector);
696   }
697   else
698     {
699       // First it is checked if it is possible to remove in the current local context
700       // then one tries to remove in other local contexts, if they allow it...
701       
702       Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
703 //      if(!WasInCtx) {
704       AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
705       for (;It.More();It.Next()){
706         if(It.Value()->AcceptErase())
707 #ifdef BUC60722
708           WasInCtx |= It.Value()->Erase(anIObj);
709 #else
710           WasInCtx = It.Value()->Erase(anIObj);
711 #endif
712       }
713       
714       if(!WasInCtx)
715         EraseGlobal(anIObj,updateviewer,PutInCollector);
716       else
717         if(updateviewer) myMainVwr->Update();
718     }
719 }
720 //=======================================================================
721 //function : Erase
722 //purpose  : 
723 //=======================================================================
724
725 void AIS_InteractiveContext::EraseMode(const Handle(AIS_InteractiveObject)& anIObj,
726                                   const Standard_Integer aMode,
727                                   const Standard_Boolean /*updateviewer*/)
728 {
729   if(anIObj.IsNull()) return;
730
731   if(!myObjects.IsBound(anIObj)) return;
732   
733   if(anIObj->HasDisplayMode()){
734     if(anIObj->DisplayMode()==aMode) return;
735   }
736   else if(myDisplayMode==aMode) return;
737   // CLE
738   // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
739   Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
740   // ENDCLE
741   if(STATUS->GraphicStatus()!=AIS_DS_Displayed) return;
742   
743   
744 //  if(STATUS->IsDModeIn(aMode)) {}
745 }
746
747
748
749 //=======================================================================
750 //function : EraseAll
751 //purpose  : 
752 //=======================================================================
753
754 void AIS_InteractiveContext::EraseAll(const Standard_Boolean PutInCollector,
755                                       const Standard_Boolean updateviewer)
756 {
757   if(!HasOpenedContext()){
758     AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
759     
760     for(;ItM.More();ItM.Next()){
761       if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
762         Erase(ItM.Key(),Standard_False,PutInCollector);
763     }
764     if(updateviewer){
765       myMainVwr->Update();
766       if (PutInCollector && !myCollectorVwr.IsNull()) 
767         myCollectorVwr->Update();
768     }
769   }
770   
771 }
772
773 //=======================================================================
774 //function : DisplayAll
775 //purpose  : 
776 //=======================================================================
777
778 void AIS_InteractiveContext::DisplayAll(const Standard_Boolean OnlyFromCollector,
779                                       const Standard_Boolean updateviewer)
780 {
781   if(!HasOpenedContext()){
782     Standard_Boolean FoundInCollector(Standard_False);
783     AIS_DisplayStatus aDStatus = OnlyFromCollector ? AIS_DS_Erased : AIS_DS_FullErased,TheStatus;
784
785     if(!HasOpenedContext()){
786       AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
787       
788       for(;ItM.More();ItM.Next()){
789         TheStatus = ItM.Value()->GraphicStatus();
790         if(TheStatus == aDStatus)
791           Display(ItM.Key(),Standard_False);
792         if(TheStatus == AIS_DS_Erased)
793           FoundInCollector = Standard_True;
794       }
795       if(updateviewer){
796         myMainVwr->Update();
797         if(FoundInCollector && !myCollectorVwr.IsNull())
798           myCollectorVwr->Update();
799       }
800     }
801   }
802   
803 }
804
805 //=======================================================================
806 //function : DisplaySelected
807 //purpose  : 
808 //=======================================================================
809
810 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
811 {
812   
813   if(!HasOpenedContext()){
814     Standard_Boolean found = Standard_False;
815     Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
816     Handle(AIS_InteractiveObject) iObj;
817     for (sel->Init();sel->More();sel->Next()) {
818       iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
819       Display(iObj,Standard_False);
820       found = Standard_True;
821     }
822     if(found && updateviewer) {
823       myMainVwr->Update();
824       if(!(myIsCollClosed && myCollectorVwr.IsNull())) 
825        
826         myCollectorVwr->Update();
827     }
828   }
829 }
830
831
832 //=======================================================================
833 //function : EraseSelected
834 //purpose  : 
835 //=======================================================================
836
837 void AIS_InteractiveContext::EraseSelected(const Standard_Boolean PutInCollector,
838                                            const Standard_Boolean updateviewer)
839 {
840   
841   if(!HasOpenedContext()){
842     Standard_Boolean found = Standard_False;
843     Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
844     Handle(AIS_InteractiveObject) iObj;
845     for(sel->Init();sel->More();sel->Next()) {
846       iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
847       Erase(iObj,Standard_False,PutInCollector);
848       found = Standard_True;
849     }
850     if(found && updateviewer) {
851       myMainVwr->Update();
852       if(PutInCollector && !myCollectorVwr.IsNull())
853         myCollectorVwr->Update();
854     }
855   }
856 }
857 //=======================================================================
858 //function : 
859 //purpose  : 
860 //=======================================================================
861
862 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
863                                                        const Standard_Integer WhichContext)
864 {
865   if(anIObj.IsNull()) return Standard_False;
866
867   if(!HasOpenedContext()) return Standard_False;
868   if(myObjects.IsBound(anIObj)) return Standard_False;
869   if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
870   
871   // Protection : if one tries to preserve a temporary object
872   // which is not in the local active context... rob 11-06-97
873
874   Standard_Integer IsItInLocal = myCurLocalIndex;
875   Standard_Boolean Found(Standard_False);
876
877   while(IsItInLocal>0 && !Found){
878     if(!myLocalContexts.IsBound(IsItInLocal))
879       IsItInLocal--;
880     else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
881       Found = Standard_True;
882     else
883       IsItInLocal--;
884   }
885
886   if(!Found) return Standard_False;
887   
888
889 //  const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ? 
890 //    myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
891   // CLE
892   // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
893   Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
894   // ENDCLE
895   
896   
897   if(LS->IsTemporary()){
898     Standard_Integer DM,HM,SM;
899     GetDefModes(anIObj,DM,HM,SM);
900     
901     SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
902     if(LS->DisplayMode()!= DM ){
903       Standard_Integer LSM =  LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
904       myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
905     }
906
907     Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
908                                                         DM,
909                                                         SM,
910                                                         Standard_False);
911 //    GS->SubIntensityOn();
912     myObjects.Bind(anIObj,GS);
913     mgrSelector->Load(anIObj);
914     mgrSelector->Activate(anIObj,SM,myMainSel);
915     
916     LS->SetTemporary(Standard_False);
917   }                                 
918   return Standard_True;
919 }
920
921
922 //=======================================================================
923 //purpose  : 
924 //=======================================================================
925
926 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const 
927 {
928   if(anIObj.IsNull()) return AIS_DS_None;
929
930   if(myObjects.IsBound(anIObj))
931     return myObjects(anIObj)->GraphicStatus();
932
933   AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
934   for(;ItM.More();ItM.Next()){
935     if(ItM.Value()->IsIn(anIObj))
936       return AIS_DS_Temporary;
937   }
938   
939   return AIS_DS_None;
940   
941 }
942
943
944
945
946 //=======================================================================
947 //function : DisplayedModes
948 //purpose  : 
949 //=======================================================================
950
951 const TColStd_ListOfInteger& AIS_InteractiveContext::
952 DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const 
953 {
954   return myObjects(anIObj)->DisplayedModes();
955 }
956
957
958 //=======================================================================
959 //function : Remove
960 //purpose  : 
961 //=======================================================================
962 void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
963                                     const Standard_Boolean updateviewer)
964 {
965
966   if(anIObj.IsNull()) return;
967
968   if(!HasOpenedContext()){ 
969     ClearGlobal(anIObj,updateviewer);
970   }
971   else
972     {
973       Standard_Boolean  WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
974       AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
975       for (;It.More() ;It.Next()){
976         if(It.Value()->AcceptErase())
977           WasInCtx = It.Value()->Remove(anIObj);
978         
979       }
980       //      if(!WasInCtx)
981       ClearGlobal(anIObj,updateviewer);
982 //      else
983 //      if(updateviewer) myMainVwr->Update();
984     }
985 }
986
987 //=======================================================================
988 //function : RemoveAll
989 //purpose  : 
990 //=======================================================================
991 void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
992 {
993   AIS_ListOfInteractive aList;
994   ObjectsInside(aList);
995   AIS_ListIteratorOfListOfInteractive aListIterator;
996   for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
997     Remove(aListIterator.Value(), Standard_False);
998   }
999         
1000   if(updateviewer)
1001     myMainVwr->Update();
1002 }
1003
1004 //=======================================================================
1005 //function : Clear
1006 //purpose  : 
1007 //=======================================================================
1008
1009 void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
1010                                    const Standard_Boolean updateviewer)
1011 {
1012   if(anIObj.IsNull()) return;
1013
1014   if(!HasOpenedContext()){ 
1015     ClearGlobal(anIObj,updateviewer);
1016   }
1017   else
1018     {
1019       
1020       Standard_Boolean  WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
1021       AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
1022       for (;It.More() ;It.Next()){
1023         if(It.Value()->AcceptErase())
1024           WasInCtx = It.Value()->Remove(anIObj);
1025         
1026       }
1027       if(!WasInCtx)
1028         ClearGlobal(anIObj,updateviewer);
1029       else
1030         if(updateviewer) myMainVwr->Update();
1031     }
1032 }
1033
1034
1035
1036
1037 //=======================================================================
1038 //function : ClearPrs
1039 //purpose  : 
1040 //=======================================================================
1041
1042 void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
1043                                       const Standard_Integer aMode,
1044                                       const Standard_Boolean updateviewer)
1045 {
1046   if(anIObj.IsNull()) return;
1047
1048   if(!HasOpenedContext()){
1049     ClearGlobalPrs(anIObj,aMode,updateviewer);
1050   }
1051   else
1052     {
1053       Standard_Boolean  WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
1054       AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
1055       for (;It.More() ;It.Next()){
1056         if(It.Value()->AcceptErase())
1057           WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
1058       }
1059       if(!WasInCtx)
1060         ClearGlobalPrs(anIObj,aMode,updateviewer);
1061       else
1062         if(updateviewer) myMainVwr->Update();
1063       
1064     }
1065 }
1066
1067 //=======================================================================
1068 //function : Hilight
1069 //purpose  : 
1070 //=======================================================================
1071
1072 void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
1073                                      const Standard_Boolean updateviewer)
1074 {
1075   if(anIObj.IsNull()) return;
1076
1077   if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1078   if (!HasOpenedContext())
1079     {
1080       if(!myObjects.IsBound(anIObj)) return;
1081
1082       // CLE
1083       // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1084       // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
1085       Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1086
1087       // ENDCLE
1088       STATUS->SetHilightStatus (Standard_True);
1089       
1090       switch(STATUS->GraphicStatus()){
1091       case AIS_DS_Displayed:
1092         {
1093           Standard_Integer DispMode,HiMode,SelMode;
1094           GetDefModes(anIObj,DispMode,HiMode,SelMode);
1095 //        if(!STATUS->IsDModeIn(HiMode)){
1096 //          myMainPM->Display(anIObj,HiMode);
1097 //        }
1098           myMainPM->Highlight(anIObj,HiMode);
1099           if(updateviewer) myMainVwr->Update();
1100           break;
1101         }
1102       case AIS_DS_Erased:
1103         {
1104           Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1105           myCollectorPM->Highlight(anIObj,HiMode);
1106           if(updateviewer) myCollectorVwr->Update();
1107           break;
1108         }
1109       default:
1110         break;
1111       }
1112     }
1113   else
1114     myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
1115   if(updateviewer) myMainVwr->Update();
1116 }
1117 //=======================================================================
1118 //function : Hilight
1119 //purpose  : 
1120 //=======================================================================
1121
1122 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
1123                                               const Quantity_NameOfColor aCol,
1124                                               const Standard_Boolean updateviewer)
1125 {
1126   if(anIObj.IsNull()) return;
1127
1128   if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1129
1130   if (!HasOpenedContext())
1131     {
1132       if(!myObjects.IsBound(anIObj)) return;
1133
1134       const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1135       STATUS->SetHilightStatus (Standard_True);
1136       
1137       switch(STATUS->GraphicStatus()){
1138       case AIS_DS_Displayed:
1139         {
1140           Standard_Integer DispMode,HiMode,SelMode;
1141           GetDefModes(anIObj,DispMode,HiMode,SelMode);
1142 //        if(!STATUS->IsDModeIn(HiMode)){
1143 //          myMainPM->Display(anIObj,HiMode);
1144 //        }
1145           myMainPM->Color(anIObj,aCol,HiMode);
1146           STATUS->SetHilightColor(aCol);
1147           if(updateviewer) myMainVwr->Update();
1148           break;
1149         }
1150       case AIS_DS_Erased:
1151         {
1152           Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1153           myCollectorPM->Color(anIObj,aCol,HiMode);
1154           if(updateviewer) myCollectorVwr->Update();
1155           break;
1156         }
1157       default:
1158         break;  
1159       }
1160     }
1161   else
1162     myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
1163   if(updateviewer) myMainVwr->Update();
1164 }
1165
1166 //=======================================================================
1167 //function : Unhilight
1168 //purpose  : 
1169 //=======================================================================
1170
1171 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
1172 {
1173   if(anIObj.IsNull()) return;
1174
1175   if (!HasOpenedContext())
1176     {
1177       if(!myObjects.IsBound(anIObj)) return;
1178
1179       const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1180       STATUS->SetHilightStatus (Standard_False);
1181       STATUS->SetHilightColor(Quantity_NOC_WHITE);
1182       
1183       switch(STATUS->GraphicStatus()){
1184       case AIS_DS_Displayed:
1185         {
1186           Standard_Integer DispMode,HiMode,SelMode;
1187           GetDefModes(anIObj,DispMode,HiMode,SelMode);
1188           myMainPM->Unhighlight(anIObj,HiMode);
1189 //        if(!STATUS->IsDModeIn(HiMode))
1190 //          myMainPM->Erase(anIObj,HiMode);
1191           if(updateviewer) myMainVwr->Update();
1192           break;
1193         }
1194       case AIS_DS_Erased:
1195         {
1196           Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
1197           myCollectorPM->Unhighlight(anIObj,HiMode);
1198           if(updateviewer) myCollectorVwr->Update();
1199           break;
1200         }
1201       default:
1202         break;  
1203       }
1204     }
1205   else
1206     myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
1207   if(updateviewer) myMainVwr->Update();
1208 }
1209
1210 //=======================================================================
1211 //function : IsHilighted
1212 //purpose  : 
1213 //=======================================================================
1214
1215 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const 
1216 {
1217   if(anIObj.IsNull()) return Standard_False;
1218
1219   if (!HasOpenedContext()){
1220     if(!myObjects.IsBound(anIObj)) 
1221       return Standard_False;
1222     return myObjects(anIObj)->IsHilighted();
1223   }
1224   AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1225   for(;ItM.More();ItM.Next()){
1226     if(ItM.Value()->IsHilighted(anIObj))
1227       return Standard_True;
1228   }
1229   return Standard_False;
1230 }
1231
1232 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1233                                                      Standard_Boolean& WithColor,
1234                                                      Quantity_NameOfColor& TheHiCol) const
1235 {
1236   if(!HasOpenedContext()){
1237     if(myObjects.IsBound(anIObj)){
1238       const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1239       if(STAT->IsHilighted()){
1240         if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1241           WithColor=Standard_True;
1242           TheHiCol = STAT->HilightColor();
1243         }
1244         else
1245           WithColor = Standard_False;
1246         return Standard_True;
1247       }
1248     }
1249     return Standard_False;
1250   }
1251   Standard_Integer MaxIndex = HighestIndex();
1252   for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1253     if(myLocalContexts.IsBound(i)){
1254       if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1255         return Standard_True;
1256     }
1257     
1258   }
1259   return Standard_False;
1260 }
1261
1262
1263
1264 //=======================================================================
1265 //function : IsDisplayed
1266 //purpose  : 
1267 //=======================================================================
1268
1269 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const 
1270 {
1271   if(anIObj.IsNull()) return Standard_False;
1272
1273
1274   if(myObjects.IsBound(anIObj)) 
1275     if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1276       return Standard_True;
1277   
1278   AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1279   for(;ItM.More();ItM.Next()){
1280     if(ItM.Value()->IsDisplayed(anIObj))
1281       return Standard_True;
1282   }
1283   return Standard_False;
1284   
1285 }
1286 //=======================================================================
1287 //function : IsDisplayed
1288 //purpose  : 
1289 //=======================================================================
1290
1291 Standard_Boolean AIS_InteractiveContext::IsInCollector(const Handle(AIS_InteractiveObject)& anIObj) const 
1292 {
1293   if(anIObj.IsNull()) return Standard_False;
1294
1295
1296   if(myObjects.IsBound(anIObj)) 
1297     return (myObjects(anIObj)->GraphicStatus()==AIS_DS_Erased);
1298   return Standard_False;
1299 }
1300
1301
1302 //=======================================================================
1303 //function : IsDisplayed
1304 //purpose  : 
1305 //=======================================================================
1306
1307 Standard_Boolean AIS_InteractiveContext::
1308 IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
1309             const Standard_Integer aMode) const 
1310 {
1311   if(anIObj.IsNull()) return Standard_False;
1312   if(myObjects.IsBound(anIObj)) {
1313     if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
1314        myObjects(anIObj)->IsDModeIn(aMode)) 
1315       return Standard_True;
1316   }
1317   
1318   AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1319   for(;ItM.More();ItM.Next()){
1320     if(ItM.Value()->IsDisplayed(anIObj,aMode))
1321       return Standard_True;
1322   }
1323   return Standard_False;
1324 }
1325
1326
1327 //=======================================================================
1328 //function : DisplayPriority
1329 //purpose  : 
1330 //=======================================================================
1331
1332 Standard_Integer AIS_InteractiveContext::
1333 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const 
1334 {
1335   if(anIObj.IsNull()) return -1;
1336   if(myObjects.IsBound(anIObj)){
1337     // CLE
1338     // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
1339     Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1340     // ENDCLE
1341     Standard_Integer DM,HM,SM ;
1342     GetDefModes(anIObj,DM,HM,SM);
1343     switch(STATUS->GraphicStatus()){
1344     case AIS_DS_Displayed:
1345       {
1346         return myMainPM->DisplayPriority(anIObj,DM);
1347         break;
1348       }
1349     case AIS_DS_Erased:
1350       return myCollectorPM->DisplayPriority(anIObj,HM);
1351     default:
1352       break;
1353     }
1354     return 0;
1355   }
1356   return 0;
1357 }
1358 //=======================================================================
1359 //function : SetDisplayPriority
1360 //purpose  : 
1361 //=======================================================================
1362
1363 void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
1364                                                const Standard_Integer aPriority)
1365 {
1366   if(anIObj.IsNull())
1367     return;
1368   if(!anIObj->HasInteractiveContext())
1369     anIObj->SetContext(this);
1370   if(myObjects.IsBound(anIObj)){
1371     // CLE
1372     // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
1373     Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1374     // ENDCLE
1375     Standard_Integer DM,HM,SM ;
1376     GetDefModes(anIObj,DM,HM,SM);
1377     switch(STATUS->GraphicStatus()){
1378     case AIS_DS_Displayed:
1379       {
1380         myMainPM->SetDisplayPriority(anIObj,DM,aPriority);
1381         break;
1382       }
1383     case AIS_DS_Erased:
1384       {
1385         myCollectorPM->SetDisplayPriority(anIObj,HM,aPriority);
1386         break;
1387       }
1388     default:
1389       break;
1390     }
1391   }
1392   else if (HasOpenedContext())
1393     {myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);}
1394 }
1395
1396 //=======================================================================
1397 //function : Redisplay
1398 //purpose  : 
1399 //=======================================================================
1400
1401 void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
1402                                       const Standard_Boolean updateviewer,
1403                                       const Standard_Boolean allmodes)
1404 {
1405   if(AISDebugModeOn()){
1406     cout<<"===>AIS_InteractiveContext::Redisplay de :";
1407     cout<<anIObj->DynamicType()->Name()<<endl;
1408   }
1409
1410   RecomputePrsOnly(anIObj,updateviewer,allmodes);
1411   RecomputeSelectionOnly(anIObj);
1412 }
1413
1414 //=======================================================================
1415 //function : Redisplay
1416 //purpose  : 
1417 //=======================================================================
1418
1419 void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
1420                                        const Standard_Integer /*Sign*/,
1421                                       const Standard_Boolean updateviewer)
1422 {
1423   Standard_Boolean found_viewer(Standard_False),found_coll(Standard_False);
1424   // update
1425   for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
1426     // CLE
1427     // const Handle(AIS_InteractiveObject)& IO = It.Key();
1428     Handle(AIS_InteractiveObject) IO = It.Key();
1429     // ENDCLE
1430     if(IO->Type()== KOI){ 
1431 #ifdef DEB
1432 //      Standard_Boolean good = (Sign==-1)? Standard_True : 
1433 //        ((IO->Signature()==Sign)? Standard_True:Standard_False);
1434 #endif
1435       Redisplay(IO,Standard_False);
1436       switch(It.Value()->GraphicStatus()){
1437       case AIS_DS_Displayed:
1438         found_viewer = Standard_True;
1439         break;
1440       case AIS_DS_Erased:
1441         found_coll = Standard_True;
1442         break;
1443       default:
1444         break;
1445       }
1446     }
1447   }
1448   // update viewer...
1449   if(updateviewer){
1450     if(found_viewer)
1451       myMainVwr->Update();
1452     if(found_coll)
1453       myCollectorVwr->Update();
1454   }
1455 }
1456
1457
1458 //=======================================================================
1459 //function : RecomputePrsOnly
1460 //purpose  : 
1461 //=======================================================================
1462
1463 void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
1464                                               const Standard_Boolean updateviewer,
1465                                               const Standard_Boolean allmodes)
1466 {
1467   if(anIObj.IsNull()) return;
1468   anIObj->Update(allmodes);
1469   
1470   if(updateviewer)  {
1471     if(HasOpenedContext())
1472       myMainVwr->Update();
1473     else{
1474       if(myObjects.IsBound(anIObj)){
1475         switch(myObjects(anIObj)->GraphicStatus()){
1476         case AIS_DS_Displayed:
1477           myMainVwr->Update();
1478           break;
1479         case AIS_DS_Erased:
1480           {
1481             if(!myCollectorVwr.IsNull())
1482               myCollectorVwr->Update();
1483           }
1484         default:
1485           break;
1486         }
1487       }
1488     }
1489   }
1490 }
1491 //=======================================================================
1492 //function : RecomputeSelectionOnly
1493 //purpose  : 
1494 //=======================================================================
1495 void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj)
1496 {
1497   if(anIObj.IsNull()) return;
1498   mgrSelector->RecomputeSelection(anIObj);
1499
1500
1501
1502   TColStd_ListOfInteger LI;
1503   TColStd_ListIteratorOfListOfInteger Lit;
1504   ActivatedModes(anIObj,LI);
1505   if(!HasOpenedContext()){
1506     if(!myObjects.IsBound(anIObj)) return;
1507     switch(myObjects(anIObj)->GraphicStatus())
1508       {
1509       case AIS_DS_Displayed:
1510         {
1511           for(Lit.Initialize(LI);Lit.More();Lit.Next())
1512             mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
1513           break;
1514         }
1515       case AIS_DS_Erased:
1516         {
1517           for(Lit.Initialize(LI);Lit.More();Lit.Next())
1518             mgrSelector->Activate(anIObj,Lit.Value(),myCollectorSel);
1519           
1520           break;
1521         }
1522       default:
1523         break;
1524       }
1525   }
1526 }
1527
1528 //=======================================================================
1529 //function : Update
1530 //purpose  : 
1531 //=======================================================================
1532
1533 void AIS_InteractiveContext::Update(const Handle(AIS_InteractiveObject)& anIObj,
1534                                     const Standard_Boolean updateviewer)
1535 {
1536   if(anIObj.IsNull()) return;
1537
1538   
1539
1540   TColStd_ListOfInteger LL;
1541   anIObj->ToBeUpdated(LL);
1542   TColStd_ListIteratorOfListOfInteger ITI(LL);
1543   Standard_Boolean wasupdated(Standard_False);
1544   
1545   for (;ITI.More();ITI.Next()){
1546     anIObj->Update(ITI.Value(),Standard_False);
1547     wasupdated = Standard_True;
1548   }
1549   
1550   if(wasupdated)
1551     mgrSelector->Update(anIObj);
1552   
1553   if(updateviewer){
1554     if(!myObjects.IsBound(anIObj)) return;
1555     switch(myObjects(anIObj)->GraphicStatus()){
1556     case AIS_DS_Displayed:
1557     case AIS_DS_Temporary:
1558       myMainVwr->Update();
1559       break;
1560     case AIS_DS_Erased:
1561       myCollectorVwr->Update();
1562       break;
1563     default:
1564       break;
1565     }
1566   }
1567 }
1568
1569
1570
1571 //=======================================================================
1572 //function : SetLocation
1573 //purpose  : 
1574 //=======================================================================
1575
1576 void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
1577                                          const TopLoc_Location& aLoc)
1578 {
1579   if(anIObj.IsNull()) return;
1580
1581
1582   if(anIObj->HasLocation() && aLoc.IsIdentity()){
1583     anIObj->ResetLocation();
1584     mgrSelector->Update(anIObj,Standard_False);
1585     return;
1586   }
1587   if(aLoc.IsIdentity()) return ;
1588
1589   // first reset the previous location to properly clean everything...
1590   if(anIObj->HasLocation())
1591     anIObj->ResetLocation();
1592
1593
1594   anIObj->SetLocation(aLoc);
1595   
1596   if(!HasOpenedContext())
1597     mgrSelector->Update(anIObj,Standard_False);
1598   else
1599     {
1600       // CLE
1601       // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1602       Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
1603       // ENDCLE
1604       mgrSelector->Update(anIObj,tempSel,Standard_False);
1605     }
1606 }
1607 //=======================================================================
1608 //function : ResetLocation
1609 //purpose  : 
1610 //=======================================================================
1611 void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
1612 {
1613   if(anIObj.IsNull()) return;
1614
1615   anIObj->ResetLocation();
1616   mgrSelector->Update(anIObj,Standard_False);
1617 }
1618
1619 //=======================================================================
1620 //function : HasLocation
1621 //purpose  : 
1622 //=======================================================================
1623
1624 Standard_Boolean AIS_InteractiveContext::
1625 HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
1626 {
1627   if(anIObj.IsNull()) return Standard_False;
1628
1629   return anIObj->HasLocation();
1630 }
1631
1632 const TopLoc_Location& AIS_InteractiveContext::
1633 Location(const Handle(AIS_InteractiveObject)& anIObj) const
1634 {
1635   return anIObj->Location();
1636 }
1637
1638 //=======================================================================
1639 //function : SetDeviationCoefficient
1640 //purpose  : 
1641 //=======================================================================
1642
1643 void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
1644 {
1645   myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
1646 }
1647 //=======================================================================
1648 //function : SetDeviationAngle
1649 //purpose  : 
1650 //=======================================================================
1651
1652 void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
1653 {
1654   myDefaultDrawer->SetDeviationCoefficient(anAngle);
1655 }
1656
1657 //=======================================================================
1658 //function : DeviationAngle
1659 //purpose  : Gets  deviationAngle
1660 //=======================================================================
1661
1662 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1663 {
1664   //return M_PI/180.0e0 ;
1665     return myDefaultDrawer->DeviationAngle();
1666 }
1667
1668 //=======================================================================
1669 //function : DeviationCoefficient
1670 //purpose  : 
1671 //=======================================================================
1672
1673 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const 
1674 {
1675   return myDefaultDrawer->DeviationCoefficient();
1676 }
1677 //=======================================================================
1678 //function : SetHLRDeviationCoefficient
1679 //purpose  : 
1680 //=======================================================================
1681
1682 void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
1683 {
1684   myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
1685 }
1686
1687 //=======================================================================
1688 //function : HLRDeviationCoefficient
1689 //purpose  : 
1690 //=======================================================================
1691
1692 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const 
1693 {
1694   return myDefaultDrawer->HLRDeviationCoefficient();
1695 }
1696
1697 //=======================================================================
1698 //function : SetHLRAngle
1699 //purpose  : 
1700 //=======================================================================
1701
1702 void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
1703 {
1704   myDefaultDrawer->SetHLRAngle(anAngle);
1705 }
1706
1707 //=======================================================================
1708 //function : SetHLRAngleAndDeviation
1709 //purpose  : compute with anangle a HLRAngle and a HLRDeviationCoefficient 
1710 //           and set them in myHLRAngle and in myHLRDeviationCoefficient
1711 //           of myDefaultDrawer 
1712 //=======================================================================
1713
1714 void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
1715 {
1716
1717   Standard_Real OutAngl,OutDefl;
1718   HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1719
1720   myDefaultDrawer->SetHLRAngle(OutAngl);
1721   myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
1722
1723 }
1724
1725 //=======================================================================
1726 //function : HLRAngle
1727 //purpose  : 
1728 //=======================================================================
1729
1730 Standard_Real AIS_InteractiveContext::HLRAngle() const 
1731 {
1732   return myDefaultDrawer->HLRAngle();
1733 }
1734
1735 //=======================================================================
1736 //function : SetDisplayMode
1737 //purpose  : 
1738 //=======================================================================
1739
1740 void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
1741                                            const Standard_Boolean updateviewer)
1742 {
1743   if(aMode==myDisplayMode) return;
1744   AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
1745
1746   for(;It.More();It.Next()){
1747     // CLE
1748     // const Handle(AIS_InteractiveObject)& anObj = It.Key();
1749     Handle(AIS_InteractiveObject) anObj = It.Key();
1750     // ENDCLE
1751     Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
1752                                   anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) ||
1753                                   anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) );
1754     
1755     if ((!anObj->HasDisplayMode()) && Processed) 
1756       {
1757         if(anObj->AcceptDisplayMode(aMode)){
1758           // CLE
1759           // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
1760           Handle(AIS_GlobalStatus) STATUS = It.Value();
1761           // ENDCLE
1762           if(STATUS->IsDModeIn(myDisplayMode))
1763             STATUS->RemoveDisplayMode(myDisplayMode);
1764           
1765           STATUS->AddDisplayMode(aMode);
1766           
1767           if(STATUS->GraphicStatus()== AIS_DS_Displayed){
1768             myMainPM->Erase(anObj, myDisplayMode);
1769             myMainPM->Display(anObj, aMode);
1770             if(STATUS->IsSubIntensityOn())
1771               myMainPM->Color(anObj,mySubIntensity,aMode);
1772           }
1773           //  myDisplayMode = aMode;
1774         }
1775       }
1776     
1777   } 
1778   myDisplayMode = aMode;
1779   if(updateviewer) myMainVwr->Update();
1780 }
1781
1782 //=======================================================================
1783 //function : SetDisplayMode
1784 //purpose  : 
1785 //=======================================================================
1786
1787 void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj, 
1788                                            const Standard_Integer aMode,
1789                                            const Standard_Boolean updateviewer)
1790 {
1791   
1792   if(!anIObj->HasInteractiveContext())
1793     anIObj->SetContext(this);
1794   if(!HasOpenedContext()){
1795     
1796     if(!myObjects.IsBound(anIObj)) 
1797       anIObj->SetDisplayMode(aMode);
1798 #ifdef BUC60632
1799     else if( anIObj->AcceptDisplayMode(aMode) ) 
1800 #else
1801     else
1802 #endif
1803     {
1804       // CLE
1805       // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1806       Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
1807       // ENDCLE
1808 #ifndef OCC4373      
1809       // the interactive object has no mode : OldMode = Mode Session
1810       //                    already has a mode : OldMode = old mode Propre
1811
1812       Standard_Integer OldMode = anIObj->HasDisplayMode() ?  anIObj->DisplayMode(): myDisplayMode;
1813       
1814       if(STATUS->IsDModeIn(OldMode))
1815         STATUS->RemoveDisplayMode(OldMode);
1816       STATUS->AddDisplayMode(aMode);
1817       
1818       if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1819         if(aMode!=OldMode ){
1820           if(myMainPM->IsHighlighted(anIObj,OldMode))
1821             myMainPM->Unhighlight(anIObj,OldMode);
1822           
1823           myMainPM->Erase(anIObj,OldMode);
1824 #else
1825       // SAN : erase presentations for all display modes different from <aMode>
1826       if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1827         TColStd_ListOfInteger aModesToRemove;
1828         TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
1829         for(;ItL.More();ItL.Next()){
1830
1831           Standard_Integer OldMode = ItL.Value();
1832
1833           if(OldMode!=aMode){
1834             aModesToRemove.Append(OldMode);
1835             if(myMainPM->IsHighlighted(anIObj,OldMode))
1836               myMainPM->Unhighlight(anIObj,OldMode);
1837             myMainPM->Erase(anIObj,OldMode);
1838           }
1839         }
1840
1841         for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
1842           STATUS->RemoveDisplayMode(ItL.Value());
1843
1844         if(!STATUS->IsDModeIn(aMode))
1845           STATUS->AddDisplayMode(aMode);
1846 #endif
1847         
1848         myMainPM->Display(anIObj,aMode);
1849         Standard_Integer DM,HM,SM;
1850         GetDefModes(anIObj,DM,HM,SM);
1851         if(STATUS->IsHilighted()){
1852           myMainPM->Highlight(anIObj,HM);
1853         }
1854         if(STATUS->IsSubIntensityOn()){
1855           myMainPM->Color(anIObj,mySubIntensity,aMode);
1856         }
1857         if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
1858           myMainVwr->Viewer()->SetTransparency(Standard_True);
1859         
1860         if(updateviewer) myMainVwr->Update();
1861 #ifndef OCC4373 
1862         }
1863 #endif
1864       }
1865       anIObj->SetDisplayMode(aMode);
1866     }
1867   }
1868 }
1869
1870 //=======================================================================
1871 //function : UnsetDisplayMode
1872 //purpose  : 
1873 //=======================================================================
1874
1875 void AIS_InteractiveContext::
1876 UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
1877                  const Standard_Boolean updateviewer)
1878 {
1879   if(anIObj.IsNull()) return ;
1880   if(!anIObj->HasDisplayMode()) return;
1881   
1882   if(!myObjects.IsBound(anIObj))
1883     anIObj->UnsetDisplayMode();
1884   else
1885     {
1886       Standard_Integer OldMode = anIObj->DisplayMode();
1887       if(myDisplayMode==OldMode) return;
1888       const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
1889       STATUS->RemoveDisplayMode(OldMode);
1890       if(!STATUS->IsDModeIn(myDisplayMode))
1891         STATUS->AddDisplayMode(myDisplayMode);
1892       if(STATUS->GraphicStatus()==AIS_DS_Displayed){
1893         if(myMainPM->IsHighlighted(anIObj,OldMode))
1894           myMainPM->Unhighlight(anIObj,OldMode);
1895         myMainPM->Erase(anIObj,OldMode);
1896         myMainPM->Display(anIObj,myDisplayMode);
1897         Standard_Integer DM,HM,SM;
1898         GetDefModes(anIObj,DM,HM,SM);
1899         if(STATUS->IsHilighted()){
1900           myMainPM->Highlight(anIObj,HM);
1901         }
1902         if(STATUS->IsSubIntensityOn()){
1903           myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
1904         }
1905         if(updateviewer) myMainVwr->Update();
1906       }
1907       anIObj->UnsetDisplayMode();
1908       
1909     }
1910 }
1911
1912 //=======================================================================
1913 //function : SetCurrentFacingModel
1914 //purpose  : 
1915 //=======================================================================
1916
1917 #ifdef GER61351
1918 void AIS_InteractiveContext::SetCurrentFacingModel(
1919                         const Handle(AIS_InteractiveObject)& anIObj,
1920                         const Aspect_TypeOfFacingModel aModel) { 
1921  if (  !anIObj.IsNull ()  ) {
1922    anIObj->SetCurrentFacingModel(aModel);
1923  }
1924 }
1925 #endif
1926
1927 //=======================================================================
1928 //function : SetColor
1929 //purpose  : 
1930 //=======================================================================
1931
1932 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, 
1933                                      const Quantity_NameOfColor aColor,
1934                                      const Standard_Boolean updateviewer)
1935 #ifdef GER61351
1936 {
1937   SetColor(anIObj,Quantity_Color(aColor),updateviewer);
1938 }
1939
1940 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, 
1941                                      const Quantity_Color &aColor,
1942                                      const Standard_Boolean updateviewer)
1943 #endif
1944 {
1945   if(anIObj.IsNull()) return ;
1946  
1947   if(!anIObj->HasInteractiveContext())
1948     anIObj->SetContext(this);
1949   anIObj->SetColor(aColor);
1950   if(anIObj->RecomputeEveryPrs())
1951     anIObj->Redisplay();
1952   else
1953     {
1954       Standard_Integer NbDisp=0;
1955       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
1956       for (;ITI.More();ITI.Next())
1957         {
1958           anIObj->Update(ITI.Value(),Standard_False);
1959           NbDisp++;
1960         }
1961       anIObj->SetRecomputeOk();
1962 #ifdef DEB
1963       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
1964 #endif
1965     }
1966
1967
1968 #ifdef DEB
1969 //   // pour isg
1970 //   if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
1971 //     Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
1972 //     Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
1973 //     gp_Trsf T; 
1974 //     gp_Dir D =Tr->Component()->XDirection();
1975 //     gp_Pnt O = Tr->Component()->Location();
1976 //     gp_Vec V(D);V*=Lx/5.;
1977 //     T.SetRotation(gp_Ax1(O,D),M_PI/6.);
1978 //     T.SetTranslationPart(V);
1979 //     TopLoc_Location L,IncLoc(T);
1980    
1981 //     for(Standard_Integer I=1;I<90;I++){
1982 //       if(anIObj->HasLocation())
1983 //      L = anIObj->Location() * IncLoc;
1984 //       else
1985 //      L = IncLoc;
1986 //       SetLocation(anIObj,L);
1987 //       UpdateCurrentViewer();
1988 //     }
1989 //      for(I=1;I<90;I++){
1990 //        L = anIObj->Location() /IncLoc;
1991 //       SetLocation(anIObj,L);
1992 //       UpdateCurrentViewer();
1993 //     }
1994 //    ResetLocation(anIObj);
1995 //   }
1996  #endif
1997   if(updateviewer) UpdateCurrentViewer();
1998 }
1999
2000 //=======================================================================
2001 //function : SetDeviationCoefficient
2002 //purpose  : 
2003 //=======================================================================
2004
2005 void AIS_InteractiveContext::SetDeviationCoefficient(
2006                                      const Handle(AIS_InteractiveObject)& anIObj, 
2007                                      const Standard_Real   aCoefficient,
2008                                      const Standard_Boolean updateviewer)
2009 {
2010 //  cout<<" Coefficient:"<< aCoefficient <<endl;
2011   if(anIObj.IsNull()) return ;
2012  
2013   if(!anIObj->HasInteractiveContext())
2014     anIObj->SetContext(this);
2015
2016   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2017   if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
2018   if(anIObj->Signature()!=0) return;
2019   (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
2020
2021
2022
2023   if(anIObj->RecomputeEveryPrs())
2024     anIObj->Redisplay();
2025   else
2026     {
2027       Standard_Integer NbDisp=0;
2028       TColStd_ListOfInteger LL;
2029       anIObj->ToBeUpdated(LL);
2030       TColStd_ListIteratorOfListOfInteger ITI(LL);
2031       for (;ITI.More();ITI.Next())
2032         {
2033           anIObj->Update(ITI.Value(),Standard_False);
2034           NbDisp++;
2035         }
2036       anIObj->SetRecomputeOk();
2037 #ifdef DEB
2038       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2039 #endif
2040     }
2041   if(updateviewer) UpdateCurrentViewer();
2042 }
2043
2044 //=======================================================================
2045 //function : SetHLRDeviationCoefficient
2046 //purpose  : 
2047 //=======================================================================
2048
2049 void AIS_InteractiveContext::SetHLRDeviationCoefficient(
2050                                      const Handle(AIS_InteractiveObject)& anIObj, 
2051                                      const Standard_Real    aCoefficient,
2052                                      const Standard_Boolean updateviewer)
2053 {
2054 //  cout<<" HLRCoefficient:"<< aCoefficient <<endl;
2055   if(anIObj.IsNull()) return ;
2056  
2057   if(!anIObj->HasInteractiveContext())
2058     anIObj->SetContext(this);
2059   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2060   if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
2061   if(anIObj->Signature()!=0) return;
2062   (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
2063
2064
2065
2066   if(anIObj->RecomputeEveryPrs())
2067     anIObj->Redisplay();
2068   else
2069     {
2070       Standard_Integer NbDisp=0;
2071
2072       TColStd_ListOfInteger LL;
2073       anIObj->ToBeUpdated(LL);
2074       TColStd_ListIteratorOfListOfInteger ITI(LL);
2075       for (;ITI.More();ITI.Next())
2076         {
2077           anIObj->Update(ITI.Value(),Standard_False);
2078           NbDisp++;
2079         }
2080       anIObj->SetRecomputeOk();
2081 #ifdef DEB
2082       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2083 #endif
2084     }
2085   if(updateviewer) UpdateCurrentViewer();
2086 }
2087
2088
2089 //=======================================================================
2090 //function : SetDeviationAngle
2091 //purpose  : 
2092 //=======================================================================
2093
2094 void AIS_InteractiveContext::SetDeviationAngle(
2095                                      const Handle(AIS_InteractiveObject)& anIObj, 
2096                                      const Standard_Real   anAngle,
2097                                      const Standard_Boolean updateviewer)
2098 {
2099 //  cout<<" Angle:"<< anAngle <<endl;
2100   if(anIObj.IsNull()) return ;
2101  
2102   if(!anIObj->HasInteractiveContext())
2103     anIObj->SetContext(this);
2104   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2105   if(anIObj->Type()!=AIS_KOI_Shape) return;
2106   if(anIObj->Signature()!=0) return;
2107   (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
2108
2109
2110   if(anIObj->RecomputeEveryPrs())
2111     anIObj->Redisplay();
2112   else
2113     {
2114       Standard_Integer NbDisp=0;
2115       TColStd_ListOfInteger LL;
2116       anIObj->ToBeUpdated(LL);
2117       TColStd_ListIteratorOfListOfInteger ITI(LL);
2118       for (;ITI.More();ITI.Next())
2119         {
2120           anIObj->Update(ITI.Value(),Standard_False);
2121           NbDisp++;
2122         }
2123       anIObj->SetRecomputeOk();
2124 #ifdef DEB
2125       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2126 #endif
2127     }
2128   if(updateviewer) UpdateCurrentViewer();
2129 }
2130 //=======================================================================
2131 //function : SetDeviationAngle
2132 //purpose  : 
2133 //=======================================================================
2134
2135 void AIS_InteractiveContext::SetAngleAndDeviation(
2136                                      const Handle(AIS_InteractiveObject)& anIObj, 
2137                                      const Standard_Real   anAngle,
2138                                      const Standard_Boolean updateviewer)
2139 {
2140 //  cout<<" Angle:"<< anAngle <<endl;
2141   if(anIObj.IsNull()) return ;
2142 //   Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
2143   if(!anIObj->HasInteractiveContext())
2144     anIObj->SetContext(this);
2145
2146   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2147   if(anIObj->Type()!=AIS_KOI_Shape) return;
2148   if(anIObj->Signature()!=0) return;
2149   (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
2150
2151
2152   if(anIObj->RecomputeEveryPrs())
2153     anIObj->Redisplay();
2154   else
2155     Update(anIObj,updateviewer);
2156 }
2157
2158 //=======================================================================
2159 //function : SetDeviationAngle
2160 //purpose  : 
2161 //=======================================================================
2162
2163 void AIS_InteractiveContext::SetHLRAngleAndDeviation(
2164                                      const Handle(AIS_InteractiveObject)& anIObj, 
2165                                      const Standard_Real   anAngle,
2166                                      const Standard_Boolean updateviewer)
2167 {
2168 //  cout<<" Angle:"<< anAngle <<endl;
2169
2170   if(anIObj.IsNull()) return ;
2171    if(!anIObj->HasInteractiveContext())
2172     anIObj->SetContext(this);
2173
2174   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2175   if(anIObj->Type()!=AIS_KOI_Shape) return;
2176   if(anIObj->Signature()!=0) return;
2177   (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
2178
2179
2180   if(anIObj->RecomputeEveryPrs())
2181     anIObj->Redisplay();
2182   else
2183     {
2184       Standard_Integer NbDisp=0;
2185
2186       TColStd_ListOfInteger LL;
2187       anIObj->ToBeUpdated(LL);
2188       TColStd_ListIteratorOfListOfInteger ITI(LL);
2189       for (;ITI.More();ITI.Next())
2190         {
2191           anIObj->Update(ITI.Value(),Standard_False);
2192           NbDisp++;
2193         }
2194       anIObj->SetRecomputeOk();
2195 #ifdef DEB
2196       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2197 #endif
2198     }
2199   if(updateviewer) UpdateCurrentViewer();
2200 }
2201
2202 //=======================================================================
2203 //function : SetHLRDeviationAngle
2204 //purpose  : 
2205 //=======================================================================
2206
2207 void AIS_InteractiveContext::SetHLRDeviationAngle(
2208                                      const Handle(AIS_InteractiveObject)& anIObj, 
2209                                      const Standard_Real   anAngle,
2210                                      const Standard_Boolean updateviewer)
2211 {
2212 //  cout<<" HLRAngle:"<< anAngle <<endl;
2213   if(anIObj.IsNull()) return ;
2214  
2215   if(!anIObj->HasInteractiveContext())
2216     anIObj->SetContext(this);
2217   // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2218   if( anIObj->Type()!=AIS_KOI_Shape) return;
2219   if(anIObj->Signature()!=0) return;
2220   (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
2221
2222
2223   if(anIObj->RecomputeEveryPrs())
2224     anIObj->Redisplay();
2225   else
2226     {
2227       Standard_Integer NbDisp=0;
2228       TColStd_ListOfInteger LL;
2229       anIObj->ToBeUpdated(LL);
2230       TColStd_ListIteratorOfListOfInteger ITI(LL);
2231       for (;ITI.More();ITI.Next())
2232         {
2233           anIObj->Update(ITI.Value(),Standard_False);
2234           NbDisp++;
2235         }
2236       anIObj->SetRecomputeOk();
2237 #ifdef DEB
2238       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2239 #endif
2240     }
2241   if(updateviewer) UpdateCurrentViewer();
2242 }
2243
2244 //=======================================================================
2245 //function : UnsetColor
2246 //purpose  : 
2247 //=======================================================================
2248
2249 void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
2250                                      const Standard_Boolean updateviewer)
2251 {
2252   if(anIObj.IsNull()) return ;
2253    anIObj->UnsetColor();
2254   if(anIObj->RecomputeEveryPrs())
2255     anIObj->Redisplay();
2256   else
2257     {
2258       Standard_Integer NbDisp =0;
2259       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2260       for (;ITI.More();ITI.Next())
2261         {
2262           anIObj->Update(ITI.Value(),Standard_False);
2263           NbDisp++;
2264         }
2265 #ifdef DEB
2266       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2267 #endif
2268       anIObj->SetRecomputeOk();
2269     }
2270   if(updateviewer) 
2271     UpdateCurrentViewer();
2272 }
2273
2274 //=======================================================================
2275 //function : HasColor
2276 //purpose  : 
2277 //=======================================================================
2278
2279 Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const 
2280 {
2281   return anIObj->HasColor();
2282
2283 }
2284
2285 //=======================================================================
2286 //function : Color
2287 //purpose  : 
2288 //=======================================================================
2289
2290 Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const 
2291 {
2292   return anIObj->Color();
2293 }
2294
2295 #ifdef GER61351
2296 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
2297                                              Quantity_Color &aColor) const 
2298 {
2299   anIObj->Color(aColor);
2300 }
2301 #endif
2302
2303 //=======================================================================
2304 //function : Width
2305 //purpose  : 
2306 //=======================================================================
2307
2308 Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const 
2309 {
2310   return anIObj->Width();
2311 }
2312
2313 //=======================================================================
2314 //function : SetWidth
2315 //purpose  : 
2316 //=======================================================================
2317
2318 void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2319                                      const Standard_Real aValue,
2320                                      const Standard_Boolean updateviewer)
2321 {
2322   if(anIObj.IsNull()) return ;
2323  
2324   if(!anIObj->HasInteractiveContext())
2325     anIObj->SetContext(this);
2326   anIObj->SetWidth(aValue);
2327   if(anIObj->RecomputeEveryPrs())
2328     anIObj->Redisplay();
2329   else
2330     {
2331       Standard_Integer NbDisp=0;
2332       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2333       for (;ITI.More();ITI.Next())
2334         {
2335           anIObj->Update(ITI.Value(),Standard_False);
2336           NbDisp++;
2337         }
2338 #ifdef DEB
2339       cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
2340 #endif
2341       anIObj->SetRecomputeOk();
2342     }
2343    if(updateviewer) 
2344     UpdateCurrentViewer();
2345 }
2346
2347 //=======================================================================
2348 //function : UnsetWidth
2349 //purpose  : 
2350 //=======================================================================
2351
2352 void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
2353                                        const Standard_Boolean updateviewer)
2354 {
2355   if(anIObj.IsNull()) return ;
2356    anIObj->UnsetWidth();
2357   if(anIObj->RecomputeEveryPrs())
2358     anIObj->Redisplay();
2359   else
2360     {
2361       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2362       for (;ITI.More();ITI.Next())
2363         {
2364           anIObj->Update(ITI.Value(),Standard_False);
2365         }
2366       anIObj->SetRecomputeOk();
2367     }
2368    if(updateviewer) 
2369     UpdateCurrentViewer();
2370 }
2371
2372 //=======================================================================
2373 //function : SetMaterial
2374 //purpose  : 
2375 //=======================================================================
2376
2377 void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2378 //POP pour K4L
2379                                         const Graphic3d_NameOfMaterial aName,
2380 //                                      const Graphic3d_NameOfPhysicalMaterial aName,
2381                                         const Standard_Boolean updateviewer)
2382 {
2383   if(!anIObj->HasInteractiveContext())
2384     anIObj->SetContext(this);
2385   anIObj->SetMaterial(aName);
2386   if(anIObj->RecomputeEveryPrs())
2387     anIObj->Redisplay();
2388   else
2389     {
2390       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2391       for (;ITI.More();ITI.Next())
2392         {
2393           anIObj->Update(ITI.Value(),Standard_False);
2394         }
2395       anIObj->SetRecomputeOk();
2396     }
2397    if(updateviewer)
2398     UpdateCurrentViewer();
2399
2400 }
2401
2402 //=======================================================================
2403 //function : UnsetMaterial
2404 //purpose  : 
2405 //=======================================================================
2406
2407 void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
2408                                           const Standard_Boolean updateviewer)
2409 {
2410   if(anIObj.IsNull()) return ;
2411   anIObj->UnsetMaterial();
2412   if(anIObj->RecomputeEveryPrs())
2413     anIObj->Redisplay();
2414   else
2415     {
2416       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2417       for (;ITI.More();ITI.Next())
2418         {
2419           anIObj->Update(ITI.Value(),Standard_False);
2420         }
2421       anIObj->SetRecomputeOk();
2422     }
2423   if(updateviewer)
2424     UpdateCurrentViewer();
2425 }
2426
2427 //=======================================================================
2428 //function : SetTransparency
2429 //purpose  : 
2430 //=======================================================================
2431
2432 void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2433                                             const Standard_Real aValue,
2434                                             const Standard_Boolean updateviewer)
2435 {
2436   if(anIObj.IsNull()) return ;
2437    if(!anIObj->HasInteractiveContext())
2438     anIObj->SetContext(this);
2439
2440 #ifdef BUC60577 //right optimization
2441   if(!anIObj->IsTransparent() && aValue<=0.05) return;
2442 #else  
2443 //  if(!anIObj->IsTransparent() && aValue<=0.05) return;
2444 #endif
2445   if(aValue<=0.05){
2446     UnsetTransparency(anIObj,updateviewer);
2447     return;
2448   }
2449   
2450   if(!myMainVwr->Viewer()->Transparency())
2451     myMainVwr->Viewer()->SetTransparency(Standard_True);
2452   anIObj->SetTransparency(aValue);
2453   if(anIObj->RecomputeEveryPrs())
2454     anIObj->Redisplay();
2455   else
2456     {
2457       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2458       for (;ITI.More();ITI.Next())
2459         {
2460           anIObj->Update(ITI.Value(),Standard_False);
2461         }
2462       anIObj->SetRecomputeOk();
2463     }
2464    if(updateviewer)
2465     UpdateCurrentViewer();
2466 }
2467
2468 //=======================================================================
2469 //function : UnsetTransparency
2470 //purpose  : 
2471 //=======================================================================
2472
2473 void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
2474                                               const Standard_Boolean updateviewer)
2475 {
2476   if(anIObj.IsNull()) return ;
2477    anIObj->UnsetTransparency();
2478   if(anIObj->RecomputeEveryPrs())
2479     anIObj->Redisplay();
2480   else
2481     {
2482       TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
2483       for (;ITI.More();ITI.Next())
2484         {
2485           anIObj->Update(ITI.Value(),Standard_False);
2486         }
2487       anIObj->SetRecomputeOk();
2488     }
2489
2490   // To Unset transparency in the viewer, if no other object is transparent ...(Speed)
2491   AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
2492   Standard_Boolean FoundTransp(Standard_False);
2493   for(;It.More() && !FoundTransp ;It.Next()){
2494     if(It.Key()->IsTransparent())
2495       FoundTransp = Standard_True;
2496   }
2497   if(!FoundTransp)
2498     myMainVwr->Viewer()->SetTransparency(Standard_False);
2499   
2500   
2501   if(updateviewer)
2502     UpdateCurrentViewer();
2503 }
2504
2505 //=======================================================================
2506 //function : SetDegenerateModel
2507 //purpose  : 
2508 //=======================================================================
2509
2510 #ifdef G003
2511 void AIS_InteractiveContext :: SetDegenerateModel (
2512                           const Handle( AIS_InteractiveObject )& anObject,
2513                           const Aspect_TypeOfDegenerateModel   aModel,
2514                           const Quantity_Ratio                 aRatio
2515                                ) {
2516  if (  !anObject.IsNull ()  ) {
2517   if (  !anObject -> HasInteractiveContext ()  ) 
2518                                 anObject -> SetContext ( this );
2519   anObject->SetDegenerateModel(aModel,aRatio);
2520
2521  }  // end if
2522 }  // end AIS_InteractiveContext :: SetDegenerateModel
2523
2524 void AIS_InteractiveContext :: SetDegenerateModel (
2525                            const Aspect_TypeOfDegenerateModel aModel,
2526                            const Quantity_Ratio            aRatio
2527                                ) {
2528
2529  AIS_DataMapIteratorOfDataMapOfIOStatus it ( myObjects );
2530
2531  while (  it.More ()  ) {
2532
2533   Handle( AIS_InteractiveObject ) obj = it.Key ();
2534
2535   obj->SetDegenerateModel(aModel,aRatio);
2536
2537   it.Next ();
2538
2539  }  // end while
2540
2541 }  // end AIS_InteractiveContext :: SetDegenerateModel
2542 #endif
2543
2544 #ifdef IMP140200
2545 //=======================================================================
2546 //function : SetSelectedAspect
2547 //purpose  : 
2548 //=======================================================================
2549 void AIS_InteractiveContext::SetSelectedAspect(
2550                                 const Handle(Prs3d_BasicAspect)& anAspect,
2551                                 const Standard_Boolean globalChange,
2552                                 const Standard_Boolean updateViewer) {
2553   if( !HasOpenedContext() ) {
2554     Standard_Boolean found = Standard_False;
2555     Handle(AIS_Selection) sel = 
2556                 AIS_Selection::Selection(myCurrentName.ToCString());
2557     Handle(AIS_InteractiveObject) object;
2558     for( sel->Init() ; sel->More() ; sel->Next()) {
2559       found = Standard_True;
2560       object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
2561       object->SetAspect(anAspect,globalChange);
2562     }
2563     if( found && updateViewer) {
2564       myMainVwr->Update();
2565       if( !(myIsCollClosed && myCollectorVwr.IsNull()) ) 
2566                                         myCollectorVwr->Update();
2567     }
2568   }
2569 }
2570 #endif
2571
2572 //=======================================================================
2573 //function : SetLocalAttributes
2574 //purpose  : 
2575 //=======================================================================
2576
2577 void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj, 
2578                                                 const Handle(AIS_Drawer)& aDrawer,
2579                                                 const Standard_Boolean updateviewer)
2580 {
2581   if(anIObj.IsNull()) return ;
2582   if(!anIObj->HasInteractiveContext())
2583     anIObj->SetContext(this);
2584   anIObj->SetAttributes(aDrawer);
2585   Update(anIObj,updateviewer);
2586   
2587 }
2588
2589 //=======================================================================
2590 //function : UnsetLocalAttributes
2591 //purpose  : 
2592 //=======================================================================
2593 void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
2594                                                   const Standard_Boolean updateviewer)
2595 {
2596   if(anIObj.IsNull()) return ;
2597   if(!anIObj->HasInteractiveContext())
2598     anIObj->SetContext(this);
2599   anIObj->UnsetAttributes();
2600   Update(anIObj,updateviewer);
2601 }
2602
2603
2604 //=======================================================================
2605 //function : Status
2606 //purpose  : 
2607 //=======================================================================
2608
2609 void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const 
2610 {
2611   astatus = "";
2612
2613   if(anIObj.IsNull()) return ;
2614   if(myObjects.IsBound(anIObj)){
2615     astatus += "\t ____________________________________________";
2616     astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2617     const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
2618     switch(ST->GraphicStatus()){
2619     case AIS_DS_Displayed:
2620       {
2621         astatus +="\t| -->Displayed\n";
2622         break;
2623       }
2624     case AIS_DS_Erased:
2625       {
2626         astatus +="\t| -->Erased\n";
2627         break;
2628       }
2629     case AIS_DS_FullErased:
2630       {
2631         astatus +="\t| -->Full Erased\n";
2632         break;
2633       }
2634     default:
2635       break;
2636     }
2637     astatus += "\t| Active Display Modes in the MainViewer :\n";
2638     TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
2639     for(;ItL.More();ItL.Next()){
2640       astatus += "\t|\t Mode ";
2641       astatus += TCollection_AsciiString(ItL.Value());
2642       astatus+="\n";
2643     }   
2644     if(IsCurrent(anIObj)) astatus +="\t| Current\n";
2645     if(IsSelected(anIObj)) astatus +="\t| Selected\n";
2646
2647     astatus += "\t| Active Selection Modes in the MainViewer :\n";
2648     for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
2649       astatus += "\t\t Mode ";
2650       astatus += TCollection_AsciiString(ItL.Value());
2651       astatus+="\n";
2652     }   
2653     astatus += "\t ____________________________________________";
2654       
2655     }
2656 }
2657
2658
2659 //=======================================================================
2660 //function : GetDefModes
2661 //purpose  : 
2662 //=======================================================================
2663
2664 void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
2665                                      Standard_Integer& DispMode,
2666                                      Standard_Integer& HiMode,
2667                                      Standard_Integer& SelMode) const 
2668 {
2669   if(anIObj.IsNull()) return ;
2670   DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() : 
2671   (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
2672   
2673   HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
2674 #ifdef BUC61051
2675   SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
2676 #else
2677   SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
2678 #endif
2679 }
2680
2681
2682 //=======================================================================
2683 //function : EraseGlobal
2684 //purpose  : 
2685 //=======================================================================
2686
2687 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj, 
2688                                          const Standard_Boolean updateviewer, 
2689                                          const Standard_Boolean PutInCollector)
2690 {
2691   if(anIObj.IsNull()) return ;
2692   if(!myObjects.IsBound(anIObj)) return;
2693
2694   // CLE
2695   // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2696   Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2697   // ENDCLE
2698   Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
2699   if(STATUS->GraphicStatus()==AIS_DS_Displayed){
2700     
2701     TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2702     for(;ItL.More();ItL.Next()){
2703       if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2704         myMainPM->Unhighlight(anIObj,ItL.Value());
2705       myMainPM->Erase(anIObj,ItL.Value());
2706     }
2707     if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
2708       myMainPM->Erase(anIObj,Dmode);
2709     
2710     for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
2711       mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
2712     if(updateviewer) myMainVwr->Update();
2713   }
2714   if(PutInCollector && !myCollectorPM.IsNull()){
2715     myCollectorPM->Display(anIObj,Dmode);
2716 #ifdef OCC328
2717     Standard_Integer SMode = anIObj->SelectionMode();
2718     mgrSelector->Activate(anIObj,SMode,myCollectorSel);
2719 #else
2720     mgrSelector->Activate(anIObj,0,myCollectorSel);
2721 #endif
2722     if(STATUS->IsHilighted())
2723       myCollectorPM->Highlight(anIObj,Dmode);
2724     STATUS->SetGraphicStatus(AIS_DS_Erased);
2725     if(updateviewer) myCollectorVwr->Update();
2726   }
2727   else
2728     STATUS->SetGraphicStatus(AIS_DS_FullErased);
2729   
2730 }
2731
2732 //=======================================================================
2733 //function : ClearGlobal
2734 //purpose  : 
2735 //=======================================================================
2736
2737 void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj, 
2738                                          const Standard_Boolean updateviewer)
2739 {
2740   if(anIObj.IsNull()) return ;
2741   if(!myObjects.IsBound(anIObj)) return;
2742   // CLE
2743   // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2744   Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
2745   // ENDCLE
2746    TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
2747    for(;ItL.More();ItL.Next()){
2748      if(STATUS->IsHilighted()){
2749        if(IsCurrent(anIObj))
2750 #ifdef OCC204
2751          AddOrRemoveCurrentObject( anIObj, updateviewer );
2752 #else
2753          AddOrRemoveCurrentObject(anIObj);
2754 #endif
2755        else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
2756          myMainPM->Unhighlight(anIObj,ItL.Value());
2757      }
2758      myMainPM->Erase(anIObj,ItL.Value());
2759      myMainPM->Clear(anIObj,ItL.Value());
2760      if(anIObj->HasHilightMode()){
2761        Standard_Integer im = anIObj->HilightMode();
2762        myMainPM->Unhighlight(anIObj,im);
2763        myMainPM->Erase(anIObj,im);
2764   
2765      }
2766    }
2767
2768   //Object removes from Detected sequence
2769   Standard_Integer i = 1;
2770   for(i = 1; i < myAISDetectedSeq.Length(); i++)
2771   {
2772     Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2773     if( !anObj.IsNull() && anObj != anIObj )
2774       myAISDetectedSeq.Remove( i );
2775   }
2776
2777   if(myLastinMain == anIObj)
2778     myLastinMain.Nullify();
2779   if(myLastinColl == anIObj)
2780     myLastinColl.Nullify();
2781
2782   if(myLastPicked == anIObj)
2783     myLastPicked.Nullify();
2784
2785   // OCC21671: Remove IO from the selection manager in any case
2786   // to avoid memory leaks
2787   mgrSelector->Remove(anIObj);
2788
2789   switch(STATUS->GraphicStatus()){
2790   case AIS_DS_Erased:
2791      { 
2792        Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; 
2793        if(STATUS->IsHilighted()){
2794          myCollectorPM->Unhighlight(anIObj,DM);
2795        }
2796        myCollectorPM->Erase(anIObj,DM);
2797        myCollectorPM->Clear(anIObj,DM);
2798        if(updateviewer) myCollectorVwr->Update();
2799        break;
2800      }
2801    case AIS_DS_Displayed:
2802      {
2803        if(updateviewer) myMainVwr->Update();
2804        break;
2805      }
2806    default:
2807      break;
2808    }
2809   myObjects.UnBind(anIObj);
2810   
2811 }
2812
2813 //=======================================================================
2814 //function : ClearGlobalPrs
2815 //purpose  : 
2816 //=======================================================================
2817
2818 void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj, 
2819                                             const Standard_Integer aMode,
2820                                             const Standard_Boolean updateviewer)
2821 {
2822   if(anIObj.IsNull()) return ;
2823   if(!myObjects.IsBound(anIObj)) return;
2824   const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
2825   
2826   Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; 
2827   if(STATUS->IsDModeIn(aMode)){
2828     if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
2829       myMainPM->Unhighlight(anIObj,aMode);
2830     
2831     myMainPM->Erase(anIObj,aMode);
2832     myMainPM->Clear(anIObj,aMode);
2833   }
2834   
2835   if(STATUS->GraphicStatus()== AIS_DS_Erased)
2836     {
2837       if(DM==aMode){
2838         if(STATUS->IsHilighted())
2839           myCollectorPM->Unhighlight(anIObj,aMode);
2840         myCollectorPM->Erase(anIObj,DM);
2841         myCollectorPM->Clear(anIObj,DM);
2842       }
2843       if(updateviewer) myCollectorVwr->Update();
2844     }
2845   else if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
2846     myMainVwr->Update();
2847 }
2848
2849 //=======================================================================
2850 //function : DrawHiddenLine
2851 //purpose  : 
2852 //=======================================================================
2853
2854 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
2855
2856   return myDefaultDrawer->DrawHiddenLine();
2857 }
2858
2859 //=======================================================================
2860 //function : EnableDrawHiddenLine
2861 //purpose  : 
2862 //=======================================================================
2863
2864 void AIS_InteractiveContext::EnableDrawHiddenLine () const {
2865   myDefaultDrawer->EnableDrawHiddenLine();
2866 }
2867
2868 //=======================================================================
2869 //function : DisableDrawHiddenLine 
2870 //purpose  : 
2871 //=======================================================================
2872
2873 void AIS_InteractiveContext::DisableDrawHiddenLine () const {
2874   myDefaultDrawer->DisableDrawHiddenLine();
2875 }
2876
2877 //=======================================================================
2878 //function : HiddenLineAspect
2879 //purpose  : 
2880 //=======================================================================
2881
2882 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const  {
2883   return myDefaultDrawer->HiddenLineAspect();
2884 }
2885
2886 //=======================================================================
2887 //function : SetHiddenLineAspect
2888 //purpose  : 
2889 //=======================================================================
2890
2891 void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
2892   myDefaultDrawer->SetHiddenLineAspect(anAspect);
2893 }
2894
2895 //=======================================================================
2896 //function : SetIsoNumber
2897 //purpose  : 
2898 //=======================================================================
2899
2900 void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
2901 {
2902   switch(Type){
2903   case AIS_TOI_IsoU:
2904     myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2905     break;
2906   case AIS_TOI_IsoV:
2907     myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2908     break;
2909   case AIS_TOI_Both:
2910     myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
2911     myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
2912     break;
2913  
2914   }
2915 }
2916 //=======================================================================
2917 //function : IsoNumber
2918 //purpose  : 
2919 //=======================================================================
2920
2921 Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
2922 {
2923   
2924   switch(Type){
2925   case AIS_TOI_IsoU:
2926     return myDefaultDrawer->UIsoAspect()->Number();
2927   case AIS_TOI_IsoV:
2928     return myDefaultDrawer->VIsoAspect()->Number();
2929   case AIS_TOI_Both:
2930     return (myDefaultDrawer->UIsoAspect()->Number()==
2931             myDefaultDrawer->VIsoAspect()->Number()) ? 
2932               myDefaultDrawer->UIsoAspect()->Number(): -1;
2933   }
2934   return 0;
2935 }
2936
2937 //=======================================================================
2938 //function : IsoOnPlane
2939 //purpose  : 
2940 //=======================================================================
2941
2942 void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
2943 {
2944   myDefaultDrawer->SetIsoOnPlane(SwitchOn);
2945 }
2946
2947 //=======================================================================
2948 //function : IsoOnPlane
2949 //purpose  : 
2950 //=======================================================================
2951
2952 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const 
2953 {
2954   return myDefaultDrawer->IsoOnPlane();
2955 }
2956
2957 //=======================================================================
2958 //function : SetSelectionMode
2959 //purpose  : 
2960 //=======================================================================
2961
2962 void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject&, const Standard_Integer )
2963 {
2964 }
2965
2966 //=======================================================================
2967 //function : UnsetSelectionMode
2968 //purpose  : 
2969 //=======================================================================
2970
2971 void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObject&)
2972 {
2973 }
2974
2975 //=======================================================================
2976 //function : SetSensitivityMode
2977 //purpose  : 
2978 //=======================================================================
2979
2980 void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
2981
2982   if( HasOpenedContext() )
2983         myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
2984   else {
2985     myMainSel->SetSensitivityMode(aMode);
2986     if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivityMode(aMode);
2987   }
2988 }
2989
2990 //=======================================================================
2991 //function : SensitivityMode
2992 //purpose  : 
2993 //=======================================================================
2994
2995 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
2996
2997   if( HasOpenedContext() )
2998         return myLocalContexts(myCurLocalIndex)->SensitivityMode();
2999   return myMainSel->SensitivityMode();
3000 }
3001
3002 //=======================================================================
3003 //function : SetSensitivity
3004 //purpose  : 
3005 //=======================================================================
3006
3007 void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
3008
3009   if( HasOpenedContext() )
3010         myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
3011   else {
3012     myMainSel->SetSensitivity(aPrecision);
3013     if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivity(aPrecision);
3014   }
3015 }
3016
3017 //=======================================================================
3018 //function : Sensitivity
3019 //purpose  : 
3020 //=======================================================================
3021
3022 Standard_Real AIS_InteractiveContext::Sensitivity() const {
3023
3024   if( HasOpenedContext() )
3025         return myLocalContexts(myCurLocalIndex)->Sensitivity();
3026   return myMainSel->Sensitivity();
3027 }
3028
3029 //=======================================================================
3030 //function : SetPixelTolerance
3031 //purpose  : 
3032 //=======================================================================
3033
3034 void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
3035
3036   if( HasOpenedContext() )
3037         myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
3038   else {
3039     myMainSel->SetPixelTolerance(aPrecision);
3040     if( !myCollectorSel.IsNull() ) myCollectorSel->SetPixelTolerance(aPrecision);
3041   }
3042 }
3043
3044 //=======================================================================
3045 //function : PixelTolerance
3046 //purpose  : 
3047 //=======================================================================
3048
3049 Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
3050
3051   if( HasOpenedContext() )
3052         return myLocalContexts(myCurLocalIndex)->PixelTolerance();
3053   return myMainSel->PixelTolerance();
3054 }
3055
3056 //=======================================================================
3057 //function : IsInLocal
3058 //purpose  : 
3059 //=======================================================================
3060
3061 Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle_AIS_InteractiveObject& anIObj,
3062                                                    Standard_Integer& TheIndex) const 
3063 {
3064   if(anIObj.IsNull()) return Standard_False;
3065   // if it exists at neutral point 0 index is returned
3066   if(myObjects.IsBound(anIObj)) {
3067     TheIndex = 0;
3068     return Standard_False;
3069   }
3070   for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
3071     if(myLocalContexts.IsBound(I)){
3072       if(myLocalContexts(I)->IsIn(anIObj)){
3073         TheIndex = I;
3074         return Standard_True;
3075         
3076       }
3077     }
3078   }
3079   TheIndex =-1;
3080   return Standard_False;
3081 }  
3082   
3083 //=======================================================================
3084 //function : InitAttributes
3085 //purpose  : 
3086 //=======================================================================
3087
3088 void AIS_InteractiveContext::InitAttributes()
3089 {
3090
3091   mgrSelector->Add(myMainSel);
3092   myCurrentName   = AIS_Context_NewCurName();
3093   mySelectionName = AIS_Context_NewSelName();
3094
3095   AIS_Selection::CreateSelection(mySelectionName.ToCString());
3096   AIS_Selection::CreateSelection(myCurrentName.ToCString());
3097
3098   
3099   myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
3100   Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
3101   myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
3102
3103 //  myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
3104   Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
3105   HLA->SetColor(Quantity_NOC_GRAY20);
3106   HLA->SetWidth(1);
3107   HLA->SetTypeOfLine(Aspect_TOL_DASH);
3108
3109   // tolerance to 4 pixels...
3110   SetPixelTolerance();
3111
3112   // Customizing the drawer for trihedrons and planes...
3113
3114   Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
3115   Standard_Real aLength(100.);
3116   DA->SetAxisLength(aLength,aLength,aLength);
3117   Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
3118   DA->FirstAxisAspect()->SetColor(col);
3119   DA->SecondAxisAspect()->SetColor(col);
3120   DA->ThirdAxisAspect()->SetColor(col);
3121
3122   Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
3123   aLength =200.;
3124   PA->SetPlaneLength(aLength,aLength);
3125   PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
3126   
3127
3128 }
3129
3130
3131 //=======================================================================
3132 //function : TrihedronSize
3133 //purpose  : 
3134 //=======================================================================
3135 Standard_Real AIS_InteractiveContext::TrihedronSize() const
3136 {
3137   return myDefaultDrawer->DatumAspect()->FirstAxisLength();
3138 }
3139 //=======================================================================
3140 //function : SetTrihedronSize
3141 //purpose  : 
3142 //=======================================================================
3143 void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
3144 {
3145   myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
3146   Redisplay(AIS_KOI_Datum,3,Standard_False);
3147   Redisplay(AIS_KOI_Datum,4,Standard_True);
3148 }
3149
3150
3151
3152 //=======================================================================
3153 //function : SetPlaneSize
3154 //purpose  : 
3155 //=======================================================================
3156 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
3157                                           const Standard_Real aValY,
3158                                           const Standard_Boolean /*updateviewer*/)
3159 {
3160   myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
3161   Redisplay(AIS_KOI_Datum,7);
3162 }
3163
3164 //=======================================================================
3165 //function : SetPlaneSize
3166 //purpose  : 
3167 //=======================================================================
3168
3169 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
3170                                           const Standard_Boolean updateviewer)
3171 {
3172   SetPlaneSize(aVal,aVal,updateviewer);
3173 }
3174
3175 //=======================================================================
3176 //function : PlaneSize
3177 //purpose  : 
3178 //=======================================================================
3179
3180 Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
3181 {
3182   LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
3183   LY =  myDefaultDrawer->PlaneAspect()->PlaneYLength();
3184   return (Abs(LX-LY)<=Precision::Confusion());
3185 }
3186
3187
3188
3189 //=======================================================================
3190 //function :
3191 //purpose  : 
3192 //=======================================================================
3193 void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
3194 {
3195   myIsAutoActivateSelMode = Auto;
3196 }
3197
3198 //=======================================================================
3199 //function :
3200 //purpose  : 
3201 //=======================================================================
3202 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
3203 {
3204   return myIsAutoActivateSelMode;
3205 }
3206
3207 //=======================================================================
3208 //function : SetZLayer
3209 //purpose  : 
3210 //=======================================================================
3211
3212 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
3213                                         const Standard_Integer theLayerId)
3214 {
3215   if (theIObj.IsNull ())
3216     return;
3217
3218   if (myObjects.IsBound (theIObj))
3219   {
3220     switch (myObjects (theIObj)->GraphicStatus ())
3221     {
3222       case AIS_DS_Displayed:
3223       {
3224         theIObj->SetZLayer (myMainPM, theLayerId);
3225         break;
3226       }
3227       case AIS_DS_Erased:
3228       {
3229         theIObj->SetZLayer (myCollectorPM, theLayerId);
3230         break;
3231       }
3232       default:
3233         break;
3234     }
3235   }
3236   else if (HasOpenedContext ())
3237   {
3238     myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
3239   }
3240 }
3241
3242 //=======================================================================
3243 //function : GetZLayer
3244 //purpose  : 
3245 //=======================================================================
3246
3247 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
3248 {
3249   if (theIObj.IsNull ())
3250     return -1;
3251
3252   if (myObjects.IsBound (theIObj))
3253   {
3254     return theIObj->GetZLayer (myMainPM);
3255   }
3256   else if (HasOpenedContext ())
3257   {
3258     return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);
3259   }
3260
3261   return -1;
3262 }