1 // Created: Wed Sep 30 08:50:34 1998
3 // <srn@popox.nnov.matra-dtv.fr>
7 // Lastly modified by :
8 // +---------------------------------------------------------------------------+
9 // ! ivan ! SetMode ! 5-04-2001! 3.0-00-1!
10 // +---------------------------------------------------------------------------+
11 #include <TPrsStd_AISPresentation.ixx>
13 #include <TDF_DefaultDeltaOnRemoval.hxx>
14 #include <TDF_DefaultDeltaOnModification.hxx>
15 #include <TDF_DeltaOnAddition.hxx>
16 #include <TDF_Tool.hxx>
17 #include <TCollection_ExtendedString.hxx>
18 #include <TPrsStd_AISViewer.hxx>
19 #include <AIS_InteractiveContext.hxx>
20 #include <AIS_InteractiveObject.hxx>
21 #include <TPrsStd_Driver.hxx>
22 #include <TPrsStd_DriverTable.hxx>
35 //=======================================================================
38 //=======================================================================
39 Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set(const TDF_Label& L,const Standard_GUID& driver)
42 Handle(TPrsStd_AISPresentation) P;
44 if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
45 P = new TPrsStd_AISPresentation ();
48 P->SetDriverGUID(driver);
53 //=======================================================================
56 //=======================================================================
57 void TPrsStd_AISPresentation::Unset (const TDF_Label& L)
59 Handle(TPrsStd_AISPresentation) P;
61 if (L.FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
67 //=======================================================================
70 //=======================================================================
71 Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set (const Handle(TDF_Attribute)& master)
73 Handle(TPrsStd_AISPresentation) P;
75 if (!master->Label().FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
76 P = new TPrsStd_AISPresentation ();
77 master->Label().AddAttribute(P);
80 P->SetDriverGUID( master->ID() );
88 //=======================================================================
91 //=======================================================================
92 const Standard_GUID& TPrsStd_AISPresentation::GetID()
94 static Standard_GUID TPrsStd_AISPresentationID("04fb4d00-5690-11d1-8940-080009dc3333");
95 return TPrsStd_AISPresentationID;
99 //=======================================================================
100 //function : TPrsStd_AISPresentation
102 //=======================================================================
103 TPrsStd_AISPresentation::TPrsStd_AISPresentation () :
104 myDriverGUID("00000000-0000-0000-0000-000000000000"),
106 myColor(Quantity_NOC_WHITE),
107 myMaterial(Graphic3d_NOM_BRASS),
113 isDisplayed(Standard_False),
114 hasOwnColor(Standard_False),
115 hasOwnMaterial(Standard_False),
116 hasOwnTransparency(Standard_False),
117 hasOwnWidth(Standard_False)
119 ,hasOwnMode(Standard_False),
120 hasOwnSelectionMode(Standard_False)
125 //=======================================================================
128 //=======================================================================
129 void TPrsStd_AISPresentation::Display (const Standard_Boolean update)
132 if( update || myAIS.IsNull() ) {
139 //=======================================================================
142 //=======================================================================
143 void TPrsStd_AISPresentation::Erase (const Standard_Boolean remove)
145 if( isDisplayed ) AISErase(remove);
148 //=======================================================================
151 //=======================================================================
152 void TPrsStd_AISPresentation::Update ()
158 //=======================================================================
159 //function : IsDisplayed
161 //=======================================================================
162 Standard_Boolean TPrsStd_AISPresentation::IsDisplayed () const
168 //=======================================================================
169 //function :SetDriverGUID
171 //=======================================================================
172 void TPrsStd_AISPresentation::SetDriverGUID(const Standard_GUID& guid)
174 // OCC2932 correction
175 if(myDriverGUID == guid) return;
182 //=======================================================================
183 //function :GetDriverGUID
185 //=======================================================================
186 Standard_GUID TPrsStd_AISPresentation::GetDriverGUID() const
192 //=======================================================================
195 //=======================================================================
196 Graphic3d_NameOfMaterial TPrsStd_AISPresentation::Material() const
201 //=======================================================================
202 //function :HasMaterial
204 //=======================================================================
205 Standard_Boolean TPrsStd_AISPresentation::HasOwnMaterial() const
207 return hasOwnMaterial;
210 //=======================================================================
211 //function :UnsetMaterial
213 //=======================================================================
214 void TPrsStd_AISPresentation::UnsetMaterial()
216 // OCC2932 correction
217 if(hasOwnMaterial == Standard_False && !myAIS.IsNull()) {
218 if(!myAIS->HasMaterial())
223 hasOwnMaterial = Standard_False;
224 if( myAIS.IsNull() ) AISUpdate();
225 if( !myAIS.IsNull() && myAIS->HasMaterial() ) {
226 Handle(AIS_InteractiveContext) ctx;
227 Handle(TPrsStd_AISViewer) viewer;
228 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
230 ctx->UnsetMaterial(myAIS, Standard_False);
232 myAIS->UnsetMaterial();
236 //=======================================================================
237 //function :SetMaterial
239 //=======================================================================
240 void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial aName)
242 // OCC2932 correction
243 if(myMaterial == aName && hasOwnMaterial == Standard_True && !myAIS.IsNull()) {
244 if(myAIS->HasMaterial() && myAIS->Material() == aName)
250 hasOwnMaterial = Standard_True;
251 if( myAIS.IsNull() ) AISUpdate();
252 if( !myAIS.IsNull() ) {
253 if( myAIS->HasMaterial() && myAIS->Material() == aName ) return; // AIS has already had that material
254 Handle(AIS_InteractiveContext) ctx;
255 Handle(TPrsStd_AISViewer) viewer;
256 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
258 ctx->SetMaterial(myAIS, aName, Standard_False);
260 myAIS->SetMaterial(aName);
265 //=======================================================================
266 //function :SetTransparency
268 //=======================================================================
269 void TPrsStd_AISPresentation::SetTransparency(const Standard_Real aValue)
271 // OCC2932 correction
272 if(hasOwnTransparency == Standard_True && myTransparency == aValue && !myAIS.IsNull())
273 if(myAIS->Transparency() == aValue)
277 myTransparency = aValue;
278 hasOwnTransparency = Standard_True;
279 if( myAIS.IsNull() ) AISUpdate();
280 if( !myAIS.IsNull() ) {
281 if( myAIS->Transparency() == aValue ) return; // AIS has already had that transparency
282 Handle(AIS_InteractiveContext) ctx;
283 Handle(TPrsStd_AISViewer) viewer;
284 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
286 ctx->SetTransparency(myAIS, aValue, Standard_False);
288 myAIS->SetTransparency(aValue);
293 //=======================================================================
294 //function :Transparency
296 //=======================================================================
297 Standard_Real TPrsStd_AISPresentation::Transparency() const
299 return myTransparency;
302 //=======================================================================
303 //function :UnsetTransparency
305 //=======================================================================
306 void TPrsStd_AISPresentation::UnsetTransparency()
308 // OCC2932 correction
309 if(!hasOwnTransparency)
313 hasOwnTransparency = Standard_False;
314 if( myAIS.IsNull() ) AISUpdate();
315 if( !myAIS.IsNull() ) {
316 Handle(AIS_InteractiveContext) ctx;
317 Handle(TPrsStd_AISViewer) viewer;
318 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
320 ctx->UnsetTransparency(myAIS, Standard_False);
322 myAIS->UnsetTransparency();
326 //=======================================================================
327 //function :HasTransparency
329 //=======================================================================
330 Standard_Boolean TPrsStd_AISPresentation::HasOwnTransparency() const
332 return hasOwnTransparency;
335 //=======================================================================
338 //=======================================================================
339 Quantity_NameOfColor TPrsStd_AISPresentation::Color() const
344 //=======================================================================
347 //=======================================================================
348 Standard_Boolean TPrsStd_AISPresentation::HasOwnColor() const
353 //=======================================================================
354 //function :UnsetColor
356 //=======================================================================
357 void TPrsStd_AISPresentation::UnsetColor()
359 // OCC2932 correction
360 if(!hasOwnColor && !myAIS.IsNull())
361 if(!myAIS->HasColor())
365 hasOwnColor = Standard_False;
366 if( myAIS.IsNull() ) AISUpdate();
367 if( !myAIS.IsNull() && myAIS->HasColor() ) {
368 Handle(AIS_InteractiveContext) ctx;
369 Handle(TPrsStd_AISViewer) viewer;
370 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
372 ctx->UnsetColor(myAIS, Standard_False);
378 //=======================================================================
381 //=======================================================================
382 void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor aColor)
384 // OCC2932 correction
385 if(hasOwnColor && myColor == aColor && ! myAIS.IsNull())
386 if(myAIS->HasColor() && myAIS->Color() == aColor )
391 hasOwnColor = Standard_True;
392 if( myAIS.IsNull() ) AISUpdate();
393 if( !myAIS.IsNull() ) {
394 if( myAIS->HasColor() && myAIS->Color() == aColor ) return; // AIS has already had that color
395 Handle(AIS_InteractiveContext) ctx;
396 Handle(TPrsStd_AISViewer) viewer;
397 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
399 ctx->SetColor(myAIS, aColor, Standard_False);
401 myAIS->SetColor(aColor);
406 //=======================================================================
409 //=======================================================================
410 Standard_Real TPrsStd_AISPresentation::Width() const
415 //=======================================================================
418 //=======================================================================
419 Standard_Boolean TPrsStd_AISPresentation::HasOwnWidth() const
424 //=======================================================================
427 //=======================================================================
428 void TPrsStd_AISPresentation::SetWidth(const Standard_Real aWidth)
430 // OCC2932 correction
431 if(hasOwnWidth && myWidth == aWidth && myAIS.IsNull())
432 if(myAIS->HasWidth() && myAIS->Width() == aWidth )
437 hasOwnWidth = Standard_True;
438 if( myAIS.IsNull() ) AISUpdate();
439 if( !myAIS.IsNull() ) {
440 if( myAIS->HasWidth() && myAIS->Width() == aWidth ) return; // AIS has already had that width
441 Handle(AIS_InteractiveContext) ctx;
442 Handle(TPrsStd_AISViewer) viewer;
443 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
445 ctx->SetWidth(myAIS, aWidth, Standard_False);
447 myAIS->SetWidth(aWidth);
451 //=======================================================================
452 //function :UnsetWidth
454 //=======================================================================
455 void TPrsStd_AISPresentation::UnsetWidth()
457 // OCC2932 correction
458 if(!hasOwnWidth && !myAIS.IsNull())
459 if(!myAIS->HasWidth())
463 hasOwnWidth = Standard_False;
464 if( myAIS.IsNull() ) AISUpdate();
465 if( !myAIS.IsNull() && myAIS->HasWidth() ) {
466 Handle(AIS_InteractiveContext) ctx;
467 Handle(TPrsStd_AISViewer) viewer;
468 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
470 ctx->UnsetWidth(myAIS, Standard_False);
478 //=======================================================================
481 //=======================================================================
483 Standard_Integer TPrsStd_AISPresentation::Mode() const
488 //=======================================================================
489 //function :HasOwnMode
491 //=======================================================================
492 Standard_Boolean TPrsStd_AISPresentation::HasOwnMode() const
497 //=======================================================================
500 //=======================================================================
501 void TPrsStd_AISPresentation::SetMode(const Standard_Integer theMode)
503 // OCC2932 correction
504 if(hasOwnMode && myMode == theMode && !myAIS.IsNull())
505 if(myAIS->DisplayMode() == theMode )
510 hasOwnMode = Standard_True;
511 if( myAIS.IsNull() ) AISUpdate();
512 if( !myAIS.IsNull() ) {
513 if( myAIS->DisplayMode() == theMode ) return; // AIS has already had that mode
514 Handle(AIS_InteractiveContext) ctx;
515 Handle(TPrsStd_AISViewer) viewer;
516 if( TPrsStd_AISViewer::Find(Label(), viewer) )
517 ctx = viewer->GetInteractiveContext();
519 ctx->SetDisplayMode(myAIS, theMode, Standard_False);
521 myAIS->SetDisplayMode(theMode);
525 //=======================================================================
526 //function :UnsetMode
528 //=======================================================================
529 void TPrsStd_AISPresentation::UnsetMode()
531 // OCC2932 correction
532 if(HasOwnMode() == Standard_False && myAIS.IsNull() == Standard_False)
533 if(!myAIS->HasDisplayMode())
537 hasOwnMode = Standard_False;
538 if( myAIS.IsNull() ) AISUpdate();
539 if( !myAIS.IsNull() && myAIS->HasDisplayMode() ) {
540 Handle(AIS_InteractiveContext) ctx;
541 Handle(TPrsStd_AISViewer) viewer;
542 if( TPrsStd_AISViewer::Find(Label(), viewer) )
543 ctx = viewer->GetInteractiveContext();
545 ctx->UnsetDisplayMode(myAIS, Standard_False);
547 myAIS->UnsetDisplayMode();
552 //=======================================================================
553 //function : SelectionMode
555 //=======================================================================
557 Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
559 return mySelectionMode;
562 //=======================================================================
563 //function :HasOwnSelectionMode
565 //=======================================================================
566 Standard_Boolean TPrsStd_AISPresentation::HasOwnSelectionMode() const
568 return hasOwnSelectionMode;
571 //=======================================================================
572 //function :SetSelectionMode
574 //=======================================================================
575 void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode)
577 // OCC2932 correction
578 if(hasOwnSelectionMode && mySelectionMode == theSelectionMode && !myAIS.IsNull())
579 if(myAIS->SelectionMode() == theSelectionMode )
583 mySelectionMode = theSelectionMode;
584 hasOwnSelectionMode = Standard_True;
585 if( myAIS.IsNull() ) AISUpdate();
586 if( !myAIS.IsNull() ) {
587 if( myAIS->SelectionMode() == theSelectionMode ) return;
588 myAIS->SetSelectionMode(theSelectionMode);
592 //=======================================================================
593 //function :UnsetSelectionMode
595 //=======================================================================
596 void TPrsStd_AISPresentation::UnsetSelectionMode()
598 if(!hasOwnSelectionMode && !myAIS.IsNull())
599 if(!myAIS->HasSelectionMode())
603 hasOwnSelectionMode = Standard_False;
604 if( myAIS.IsNull() ) AISUpdate();
605 if( !myAIS.IsNull() && myAIS->HasSelectionMode() ) {
606 myAIS->UnsetSelectionMode();
612 //=======================================================================
615 //=======================================================================
616 const Standard_GUID& TPrsStd_AISPresentation::ID() const { return GetID(); }
619 //=======================================================================
620 //function : BackupCopy
622 //=======================================================================
623 Handle(TDF_Attribute) TPrsStd_AISPresentation::BackupCopy() const
625 Handle(TPrsStd_AISPresentation) copy = new TPrsStd_AISPresentation;
626 copy->myTransparency = myTransparency;
627 copy->myColor = myColor;
628 copy->myMode= myMode;
630 copy->myWidth= myWidth;
632 copy->myMaterial = myMaterial;
633 copy->hasOwnColor = hasOwnColor;
634 copy->hasOwnMaterial = hasOwnMaterial;
635 copy->hasOwnWidth = hasOwnWidth;
636 copy->hasOwnMode=hasOwnMode;
637 copy->hasOwnTransparency = hasOwnTransparency;
638 copy->myAIS.Nullify();
639 copy->isDisplayed = isDisplayed;
640 copy->myDriverGUID = myDriverGUID;
642 copy->mySelectionMode= mySelectionMode;
643 copy->hasOwnSelectionMode = hasOwnSelectionMode;
649 //=======================================================================
650 //function : NewEmpty
652 //=======================================================================
653 Handle(TDF_Attribute) TPrsStd_AISPresentation::NewEmpty() const
655 return new TPrsStd_AISPresentation ();
658 //=======================================================================
661 //=======================================================================
662 void TPrsStd_AISPresentation::Restore (const Handle(TDF_Attribute)& With)
664 Handle(TPrsStd_AISPresentation) with = Handle(TPrsStd_AISPresentation)::DownCast(With);
668 if(!with->HasOwnMaterial()) hasOwnMaterial = Standard_False;
671 myMaterial = with->Material();
673 hasOwnMaterial = Standard_True;
676 myMaterial = with->Material();
679 if(!with->HasOwnColor()) hasOwnColor = Standard_False;
682 myColor = with->Color();
684 hasOwnColor = Standard_True;
687 myColor = with->Color();
690 if(!with->HasOwnWidth()) hasOwnWidth = Standard_False;
693 myWidth = with->Width();
695 hasOwnWidth = Standard_True;
698 myWidth = with->Width();
701 if(!with->HasOwnMode()) hasOwnMode = Standard_False;
704 myMode = with->Mode();
706 hasOwnMode = Standard_True;
709 myMode = with->Mode();
713 if(!with->HasOwnSelectionMode()) hasOwnSelectionMode = Standard_False;
716 mySelectionMode = with->SelectionMode();
718 hasOwnSelectionMode = Standard_True;
721 mySelectionMode = with->SelectionMode();
725 if(!with->HasOwnTransparency()) hasOwnTransparency = Standard_False;
728 myTransparency = with->Transparency();
730 hasOwnTransparency = Standard_True;
733 myTransparency = with->Transparency();
736 isDisplayed = with->IsDisplayed();
737 myDriverGUID = with->GetDriverGUID();
740 //=======================================================================
743 //=======================================================================
744 void TPrsStd_AISPresentation::Paste (const Handle(TDF_Attribute)& Into,
745 const Handle(TDF_RelocationTable)& ) const
747 Handle(TPrsStd_AISPresentation) into = Handle(TPrsStd_AISPresentation)::DownCast(Into);
751 if(!hasOwnMaterial) into->hasOwnMaterial = Standard_False;
753 into->myMaterial = myMaterial;
754 into->hasOwnMaterial = Standard_True;
757 if(!hasOwnColor) into->hasOwnColor = Standard_False;
759 into->myColor = myColor;
760 into->hasOwnColor = Standard_True;
763 if(!hasOwnWidth) into->hasOwnWidth = Standard_False;
765 into->myWidth = myWidth;
766 into->hasOwnWidth = Standard_True;
768 if(!hasOwnMode) into->hasOwnMode = Standard_False;
770 into->myMode = myMode;
771 into->hasOwnMode = Standard_True;
775 if(!hasOwnSelectionMode) into->hasOwnSelectionMode = Standard_False;
777 into->mySelectionMode = mySelectionMode;
778 into->hasOwnSelectionMode = Standard_True;
782 if(!hasOwnTransparency) into->hasOwnTransparency = Standard_False;
784 into->myTransparency = myTransparency;
785 into->hasOwnTransparency = Standard_True;
788 if (into->isDisplayed)
789 into->AISErase(Standard_True);
791 into->isDisplayed = isDisplayed;
792 into->myDriverGUID = myDriverGUID;
794 into->myAIS.Nullify();
797 //=======================================================================
798 //function : AfterAddition
799 //purpose : erase if displayed
800 //=======================================================================
801 void TPrsStd_AISPresentation::AfterAddition()
806 //=======================================================================
807 //function : BeforeRemoval
808 //purpose : erase if displayed
809 //=======================================================================
810 void TPrsStd_AISPresentation::BeforeRemoval()
815 //=======================================================================
816 //function : BeforeForget
817 //purpose : erase if displayed
818 //=======================================================================
819 void TPrsStd_AISPresentation::BeforeForget()
821 if( !myAIS.IsNull() ) {
822 AISErase(Standard_True); //Remove AISObject from context
828 //=======================================================================
829 //function : AfterResume
830 //purpose : display if displayed
831 //=======================================================================
832 void TPrsStd_AISPresentation::AfterResume()
835 if( IsDisplayed() ) AISDisplay();
839 //=======================================================================
840 //function : BeforeUndo
841 //purpose : le NamedShape associe doit etre present
842 //=======================================================================
844 Standard_Boolean TPrsStd_AISPresentation::BeforeUndo (const Handle(TDF_AttributeDelta)& AD,
845 const Standard_Boolean )
847 Handle(TPrsStd_AISPresentation) P;
848 AD->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), P);
850 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
851 if( !P.IsNull() ) P->BeforeForget();
853 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
855 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
856 if( !P.IsNull() ) P->BeforeForget();
859 return Standard_True;
863 //=======================================================================
864 //function : AfterUndo
865 //purpose : le NamedShape associe doit etre present
866 //=======================================================================
868 Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeDelta)& AD,
869 const Standard_Boolean )
871 Handle(TPrsStd_AISPresentation) P;
872 AD->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), P);
874 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
876 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
877 if( !P.IsNull() ) P->AfterAddition();
879 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
880 if( !P.IsNull() ) P->AfterResume();
883 return Standard_True;
888 //=======================================================================
889 //function : AISUpdate
891 //=======================================================================
893 void TPrsStd_AISPresentation::AISUpdate ()
897 Handle(AIS_InteractiveContext) ctx;
898 if(!Label().IsNull()) {
899 Handle(TPrsStd_AISViewer) viewer;
900 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
902 Handle(TPrsStd_Driver) driver;
903 if (TPrsStd_DriverTable::Get()->FindDriver(GetDriverGUID(), driver)) {
904 if (myAIS.IsNull()) { // build a new AIS
905 Handle(AIS_InteractiveObject) newais;
906 if (driver->Update (Label(), newais)) {
908 newais->SetOwner(this);
912 Handle(AIS_InteractiveObject) theais = myAIS;
913 if (driver->Update (Label(), theais)) {
914 if (! (theais == myAIS)) {
915 if(!ctx.IsNull()) ctx->Remove(myAIS);
916 myAIS = theais; //Driver has built new AIS
917 theais->SetOwner(this);
925 //Apply the visualization settings
926 if( !myAIS.IsNull() ) {
929 if( !(myAIS->HasColor()) || (myAIS->HasColor() && myAIS->Color() != myColor) ) {
930 if(!ctx.IsNull()) ctx->SetColor(myAIS, myColor, Standard_False);
931 else myAIS->SetColor(myColor);
935 if( hasOwnMaterial ) {
936 if( !(myAIS->HasMaterial()) || (myAIS->HasMaterial() && myAIS->Material() != myMaterial) ) {
937 if(!ctx.IsNull()) ctx->SetMaterial(myAIS, myMaterial, Standard_False );
938 else myAIS->SetMaterial(myMaterial);
942 if( hasOwnTransparency ) {
943 if( myAIS->Transparency() != myTransparency ) {
944 if(!ctx.IsNull()) ctx->SetTransparency(myAIS, myTransparency, Standard_False);
945 else myAIS->SetTransparency(myTransparency);
950 if( !(myAIS->HasWidth()) || (myAIS->HasWidth() && myAIS->Width() != myWidth) ) {
951 if(!ctx.IsNull()) ctx->SetWidth(myAIS, myWidth, Standard_False);
952 else myAIS->SetWidth(myWidth);
957 if( myAIS->DisplayMode() != myMode ) {
958 myAIS->SetDisplayMode(myMode);
965 if (hasOwnSelectionMode) {
966 if (myAIS->SelectionMode() != mySelectionMode ) {
967 myAIS->SetSelectionMode(mySelectionMode);
974 if( isDisplayed && !ctx.IsNull() ) ctx->Redisplay(myAIS, Standard_False);
979 //=======================================================================
980 //function : AISDisplay
982 //=======================================================================
984 void TPrsStd_AISPresentation::AISDisplay ()
987 if (!Label().IsNull()) {
988 Handle(TPrsStd_AISViewer) viewer;
989 if( !TPrsStd_AISViewer::Find(Label(), viewer) ) return;
990 Handle(AIS_InteractiveContext) ctx = viewer->GetInteractiveContext();
991 if( ctx.IsNull() ) return;
993 if (!myAIS.IsNull()) {
995 if( !(myAIS->GetContext()).IsNull() && (myAIS->GetContext()) != ctx ) myAIS->GetContext()->Remove(myAIS);
997 if( isDisplayed && ctx->IsDisplayed(myAIS) ) return;
999 ctx->Display(myAIS, Standard_False);
1001 if( ctx->IsDisplayed(myAIS) ) SetDisplayed(Standard_True);
1007 //=======================================================================
1008 //function : AISErase
1010 //=======================================================================
1012 void TPrsStd_AISPresentation::AISErase (const Standard_Boolean remove)
1014 SetDisplayed(Standard_False);
1015 Handle(AIS_InteractiveContext) ctx, ownctx;
1017 if ( !myAIS.IsNull() ) {
1018 ownctx = myAIS->GetContext();
1019 if ( !Label().IsNull()) {
1020 Handle(TPrsStd_AISViewer) viewer;
1021 if( !TPrsStd_AISViewer::Find(Label(), viewer) ) return;
1022 ctx = viewer->GetInteractiveContext();
1024 if( !ctx.IsNull() ) ctx->Remove (myAIS,Standard_False);
1025 if( !ownctx.IsNull() && ownctx != ctx ) ownctx->Remove (myAIS,Standard_False);
1026 myAIS->SetToUpdate();
1029 if( !ctx.IsNull() ) ctx->Erase (myAIS,Standard_False);
1030 if( !ownctx.IsNull() && ownctx != ctx ) ownctx->Erase (myAIS,Standard_False);
1035 if( !ownctx.IsNull() ) {
1036 ownctx->Remove (myAIS,Standard_False);
1037 myAIS->SetToUpdate();
1040 if( !ownctx.IsNull() ) ownctx->Erase (myAIS,Standard_False);
1046 //=======================================================================
1049 //=======================================================================
1050 Handle(AIS_InteractiveObject) TPrsStd_AISPresentation::GetAIS() const
1056 //=======================================================================
1057 //function :SetDisplayed
1059 //=======================================================================
1060 void TPrsStd_AISPresentation::SetDisplayed(const Standard_Boolean B)