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