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