1 // Created on: 1998-09-30
2 // Created by: Sergey RUIN
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Lastly modified by :
18 // +---------------------------------------------------------------------------+
19 // ! ivan ! SetMode ! 5-04-2001! 3.0-00-1!
20 // +---------------------------------------------------------------------------+
21 #include <TPrsStd_AISPresentation.ixx>
23 #include <TDF_DefaultDeltaOnRemoval.hxx>
24 #include <TDF_DefaultDeltaOnModification.hxx>
25 #include <TDF_DeltaOnAddition.hxx>
26 #include <TDF_Tool.hxx>
27 #include <TCollection_ExtendedString.hxx>
28 #include <TPrsStd_AISViewer.hxx>
29 #include <AIS_InteractiveContext.hxx>
30 #include <AIS_InteractiveObject.hxx>
31 #include <TPrsStd_Driver.hxx>
32 #include <TPrsStd_DriverTable.hxx>
45 //=======================================================================
48 //=======================================================================
49 Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set(const TDF_Label& L,const Standard_GUID& driver)
52 Handle(TPrsStd_AISPresentation) P;
54 if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
55 P = new TPrsStd_AISPresentation ();
58 P->SetDriverGUID(driver);
63 //=======================================================================
66 //=======================================================================
67 void TPrsStd_AISPresentation::Unset (const TDF_Label& L)
69 Handle(TPrsStd_AISPresentation) P;
71 if (L.FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
77 //=======================================================================
80 //=======================================================================
81 Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set (const Handle(TDF_Attribute)& master)
83 Handle(TPrsStd_AISPresentation) P;
85 if (!master->Label().FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
86 P = new TPrsStd_AISPresentation ();
87 master->Label().AddAttribute(P);
90 P->SetDriverGUID( master->ID() );
98 //=======================================================================
101 //=======================================================================
102 const Standard_GUID& TPrsStd_AISPresentation::GetID()
104 static Standard_GUID TPrsStd_AISPresentationID("04fb4d00-5690-11d1-8940-080009dc3333");
105 return TPrsStd_AISPresentationID;
109 //=======================================================================
110 //function : TPrsStd_AISPresentation
112 //=======================================================================
113 TPrsStd_AISPresentation::TPrsStd_AISPresentation () :
114 myDriverGUID("00000000-0000-0000-0000-000000000000"),
116 myColor(Quantity_NOC_WHITE),
117 myMaterial(Graphic3d_NOM_BRASS),
123 isDisplayed(Standard_False),
124 hasOwnColor(Standard_False),
125 hasOwnMaterial(Standard_False),
126 hasOwnTransparency(Standard_False),
127 hasOwnWidth(Standard_False)
129 ,hasOwnMode(Standard_False),
130 hasOwnSelectionMode(Standard_False)
135 //=======================================================================
138 //=======================================================================
139 void TPrsStd_AISPresentation::Display (const Standard_Boolean update)
142 if( update || myAIS.IsNull() ) {
149 //=======================================================================
152 //=======================================================================
153 void TPrsStd_AISPresentation::Erase (const Standard_Boolean remove)
155 if( isDisplayed ) AISErase(remove);
158 //=======================================================================
161 //=======================================================================
162 void TPrsStd_AISPresentation::Update ()
168 //=======================================================================
169 //function : IsDisplayed
171 //=======================================================================
172 Standard_Boolean TPrsStd_AISPresentation::IsDisplayed () const
178 //=======================================================================
179 //function :SetDriverGUID
181 //=======================================================================
182 void TPrsStd_AISPresentation::SetDriverGUID(const Standard_GUID& guid)
184 // OCC2932 correction
185 if(myDriverGUID == guid) return;
192 //=======================================================================
193 //function :GetDriverGUID
195 //=======================================================================
196 Standard_GUID TPrsStd_AISPresentation::GetDriverGUID() const
202 //=======================================================================
205 //=======================================================================
206 Graphic3d_NameOfMaterial TPrsStd_AISPresentation::Material() const
211 //=======================================================================
212 //function :HasMaterial
214 //=======================================================================
215 Standard_Boolean TPrsStd_AISPresentation::HasOwnMaterial() const
217 return hasOwnMaterial;
220 //=======================================================================
221 //function :UnsetMaterial
223 //=======================================================================
224 void TPrsStd_AISPresentation::UnsetMaterial()
226 // OCC2932 correction
227 if(hasOwnMaterial == Standard_False && !myAIS.IsNull()) {
228 if(!myAIS->HasMaterial())
233 hasOwnMaterial = Standard_False;
234 if( myAIS.IsNull() ) AISUpdate();
235 if( !myAIS.IsNull() && myAIS->HasMaterial() ) {
236 Handle(AIS_InteractiveContext) ctx;
237 Handle(TPrsStd_AISViewer) viewer;
238 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
240 ctx->UnsetMaterial(myAIS, Standard_False);
242 myAIS->UnsetMaterial();
246 //=======================================================================
247 //function :SetMaterial
249 //=======================================================================
250 void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial aName)
252 // OCC2932 correction
253 if(myMaterial == aName && hasOwnMaterial == Standard_True && !myAIS.IsNull()) {
254 if(myAIS->HasMaterial() && myAIS->Material() == aName)
260 hasOwnMaterial = Standard_True;
261 if( myAIS.IsNull() ) AISUpdate();
262 if( !myAIS.IsNull() ) {
263 if( myAIS->HasMaterial() && myAIS->Material() == aName ) return; // AIS has already had that material
264 Handle(AIS_InteractiveContext) ctx;
265 Handle(TPrsStd_AISViewer) viewer;
266 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
268 ctx->SetMaterial(myAIS, aName, Standard_False);
270 myAIS->SetMaterial(aName);
275 //=======================================================================
276 //function :SetTransparency
278 //=======================================================================
279 void TPrsStd_AISPresentation::SetTransparency(const Standard_Real aValue)
281 // OCC2932 correction
282 if(hasOwnTransparency == Standard_True && myTransparency == aValue && !myAIS.IsNull())
283 if(myAIS->Transparency() == aValue)
287 myTransparency = aValue;
288 hasOwnTransparency = Standard_True;
289 if( myAIS.IsNull() ) AISUpdate();
290 if( !myAIS.IsNull() ) {
291 if( myAIS->Transparency() == aValue ) return; // AIS has already had that transparency
292 Handle(AIS_InteractiveContext) ctx;
293 Handle(TPrsStd_AISViewer) viewer;
294 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
296 ctx->SetTransparency(myAIS, aValue, Standard_False);
298 myAIS->SetTransparency(aValue);
303 //=======================================================================
304 //function :Transparency
306 //=======================================================================
307 Standard_Real TPrsStd_AISPresentation::Transparency() const
309 return myTransparency;
312 //=======================================================================
313 //function :UnsetTransparency
315 //=======================================================================
316 void TPrsStd_AISPresentation::UnsetTransparency()
318 // OCC2932 correction
319 if(!hasOwnTransparency)
323 hasOwnTransparency = Standard_False;
324 if( myAIS.IsNull() ) AISUpdate();
325 if( !myAIS.IsNull() ) {
326 Handle(AIS_InteractiveContext) ctx;
327 Handle(TPrsStd_AISViewer) viewer;
328 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
330 ctx->UnsetTransparency(myAIS, Standard_False);
332 myAIS->UnsetTransparency();
336 //=======================================================================
337 //function :HasTransparency
339 //=======================================================================
340 Standard_Boolean TPrsStd_AISPresentation::HasOwnTransparency() const
342 return hasOwnTransparency;
345 //=======================================================================
348 //=======================================================================
349 Quantity_NameOfColor TPrsStd_AISPresentation::Color() const
354 //=======================================================================
357 //=======================================================================
358 Standard_Boolean TPrsStd_AISPresentation::HasOwnColor() const
363 //=======================================================================
364 //function :UnsetColor
366 //=======================================================================
367 void TPrsStd_AISPresentation::UnsetColor()
369 // OCC2932 correction
370 if(!hasOwnColor && !myAIS.IsNull())
371 if(!myAIS->HasColor())
375 hasOwnColor = Standard_False;
376 if( myAIS.IsNull() ) AISUpdate();
377 if( !myAIS.IsNull() && myAIS->HasColor() ) {
378 Handle(AIS_InteractiveContext) ctx;
379 Handle(TPrsStd_AISViewer) viewer;
380 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
382 ctx->UnsetColor(myAIS, Standard_False);
388 //=======================================================================
391 //=======================================================================
392 void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor aColor)
394 // OCC2932 correction
395 if(hasOwnColor && myColor == aColor && ! myAIS.IsNull())
396 if(myAIS->HasColor() && myAIS->Color() == aColor )
401 hasOwnColor = Standard_True;
402 if( myAIS.IsNull() ) AISUpdate();
403 if( !myAIS.IsNull() ) {
404 if( myAIS->HasColor() && myAIS->Color() == aColor ) return; // AIS has already had that color
405 Handle(AIS_InteractiveContext) ctx;
406 Handle(TPrsStd_AISViewer) viewer;
407 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
409 ctx->SetColor(myAIS, aColor, Standard_False);
411 myAIS->SetColor(aColor);
416 //=======================================================================
419 //=======================================================================
420 Standard_Real TPrsStd_AISPresentation::Width() const
425 //=======================================================================
428 //=======================================================================
429 Standard_Boolean TPrsStd_AISPresentation::HasOwnWidth() const
434 //=======================================================================
437 //=======================================================================
438 void TPrsStd_AISPresentation::SetWidth(const Standard_Real aWidth)
440 // OCC2932 correction
441 if(hasOwnWidth && myWidth == aWidth && myAIS.IsNull())
442 if(myAIS->HasWidth() && myAIS->Width() == aWidth )
447 hasOwnWidth = Standard_True;
448 if( myAIS.IsNull() ) AISUpdate();
449 if( !myAIS.IsNull() ) {
450 if( myAIS->HasWidth() && myAIS->Width() == aWidth ) return; // AIS has already had that width
451 Handle(AIS_InteractiveContext) ctx;
452 Handle(TPrsStd_AISViewer) viewer;
453 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
455 ctx->SetWidth(myAIS, aWidth, Standard_False);
457 myAIS->SetWidth(aWidth);
461 //=======================================================================
462 //function :UnsetWidth
464 //=======================================================================
465 void TPrsStd_AISPresentation::UnsetWidth()
467 // OCC2932 correction
468 if(!hasOwnWidth && !myAIS.IsNull())
469 if(!myAIS->HasWidth())
473 hasOwnWidth = Standard_False;
474 if( myAIS.IsNull() ) AISUpdate();
475 if( !myAIS.IsNull() && myAIS->HasWidth() ) {
476 Handle(AIS_InteractiveContext) ctx;
477 Handle(TPrsStd_AISViewer) viewer;
478 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
480 ctx->UnsetWidth(myAIS, Standard_False);
488 //=======================================================================
491 //=======================================================================
493 Standard_Integer TPrsStd_AISPresentation::Mode() const
498 //=======================================================================
499 //function :HasOwnMode
501 //=======================================================================
502 Standard_Boolean TPrsStd_AISPresentation::HasOwnMode() const
507 //=======================================================================
510 //=======================================================================
511 void TPrsStd_AISPresentation::SetMode(const Standard_Integer theMode)
513 // OCC2932 correction
514 if(hasOwnMode && myMode == theMode && !myAIS.IsNull())
515 if(myAIS->DisplayMode() == theMode )
520 hasOwnMode = Standard_True;
521 if( myAIS.IsNull() ) AISUpdate();
522 if( !myAIS.IsNull() ) {
523 if( myAIS->DisplayMode() == theMode ) return; // AIS has already had that mode
524 Handle(AIS_InteractiveContext) ctx;
525 Handle(TPrsStd_AISViewer) viewer;
526 if( TPrsStd_AISViewer::Find(Label(), viewer) )
527 ctx = viewer->GetInteractiveContext();
529 ctx->SetDisplayMode(myAIS, theMode, Standard_False);
531 myAIS->SetDisplayMode(theMode);
535 //=======================================================================
536 //function :UnsetMode
538 //=======================================================================
539 void TPrsStd_AISPresentation::UnsetMode()
541 // OCC2932 correction
542 if(HasOwnMode() == Standard_False && myAIS.IsNull() == Standard_False)
543 if(!myAIS->HasDisplayMode())
547 hasOwnMode = Standard_False;
548 if( myAIS.IsNull() ) AISUpdate();
549 if( !myAIS.IsNull() && myAIS->HasDisplayMode() ) {
550 Handle(AIS_InteractiveContext) ctx;
551 Handle(TPrsStd_AISViewer) viewer;
552 if( TPrsStd_AISViewer::Find(Label(), viewer) )
553 ctx = viewer->GetInteractiveContext();
555 ctx->UnsetDisplayMode(myAIS, Standard_False);
557 myAIS->UnsetDisplayMode();
562 //=======================================================================
563 //function : SelectionMode
565 //=======================================================================
567 Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
569 return mySelectionMode;
572 //=======================================================================
573 //function :HasOwnSelectionMode
575 //=======================================================================
576 Standard_Boolean TPrsStd_AISPresentation::HasOwnSelectionMode() const
578 return hasOwnSelectionMode;
581 //=======================================================================
582 //function :SetSelectionMode
584 //=======================================================================
585 void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode)
587 // OCC2932 correction
588 if(hasOwnSelectionMode && mySelectionMode == theSelectionMode && !myAIS.IsNull())
589 if(myAIS->SelectionMode() == theSelectionMode )
593 mySelectionMode = theSelectionMode;
594 hasOwnSelectionMode = Standard_True;
595 if( myAIS.IsNull() ) AISUpdate();
596 if( !myAIS.IsNull() ) {
597 if( myAIS->SelectionMode() == theSelectionMode ) return;
598 myAIS->SetSelectionMode(theSelectionMode);
602 //=======================================================================
603 //function :UnsetSelectionMode
605 //=======================================================================
606 void TPrsStd_AISPresentation::UnsetSelectionMode()
608 if(!hasOwnSelectionMode && !myAIS.IsNull())
609 if(!myAIS->HasSelectionMode())
613 hasOwnSelectionMode = Standard_False;
614 if( myAIS.IsNull() ) AISUpdate();
615 if( !myAIS.IsNull() && myAIS->HasSelectionMode() ) {
616 myAIS->UnsetSelectionMode();
622 //=======================================================================
625 //=======================================================================
626 const Standard_GUID& TPrsStd_AISPresentation::ID() const { return GetID(); }
629 //=======================================================================
630 //function : BackupCopy
632 //=======================================================================
633 Handle(TDF_Attribute) TPrsStd_AISPresentation::BackupCopy() const
635 Handle(TPrsStd_AISPresentation) copy = new TPrsStd_AISPresentation;
636 copy->myTransparency = myTransparency;
637 copy->myColor = myColor;
638 copy->myMode= myMode;
640 copy->myWidth= myWidth;
642 copy->myMaterial = myMaterial;
643 copy->hasOwnColor = hasOwnColor;
644 copy->hasOwnMaterial = hasOwnMaterial;
645 copy->hasOwnWidth = hasOwnWidth;
646 copy->hasOwnMode=hasOwnMode;
647 copy->hasOwnTransparency = hasOwnTransparency;
648 copy->myAIS.Nullify();
649 copy->isDisplayed = isDisplayed;
650 copy->myDriverGUID = myDriverGUID;
652 copy->mySelectionMode= mySelectionMode;
653 copy->hasOwnSelectionMode = hasOwnSelectionMode;
659 //=======================================================================
660 //function : NewEmpty
662 //=======================================================================
663 Handle(TDF_Attribute) TPrsStd_AISPresentation::NewEmpty() const
665 return new TPrsStd_AISPresentation ();
668 //=======================================================================
671 //=======================================================================
672 void TPrsStd_AISPresentation::Restore (const Handle(TDF_Attribute)& With)
674 Handle(TPrsStd_AISPresentation) with = Handle(TPrsStd_AISPresentation)::DownCast(With);
678 if(!with->HasOwnMaterial()) hasOwnMaterial = Standard_False;
681 myMaterial = with->Material();
683 hasOwnMaterial = Standard_True;
686 myMaterial = with->Material();
689 if(!with->HasOwnColor()) hasOwnColor = Standard_False;
692 myColor = with->Color();
694 hasOwnColor = Standard_True;
697 myColor = with->Color();
700 if(!with->HasOwnWidth()) hasOwnWidth = Standard_False;
703 myWidth = with->Width();
705 hasOwnWidth = Standard_True;
708 myWidth = with->Width();
711 if(!with->HasOwnMode()) hasOwnMode = Standard_False;
714 myMode = with->Mode();
716 hasOwnMode = Standard_True;
719 myMode = with->Mode();
723 if(!with->HasOwnSelectionMode()) hasOwnSelectionMode = Standard_False;
726 mySelectionMode = with->SelectionMode();
728 hasOwnSelectionMode = Standard_True;
731 mySelectionMode = with->SelectionMode();
735 if(!with->HasOwnTransparency()) hasOwnTransparency = Standard_False;
738 myTransparency = with->Transparency();
740 hasOwnTransparency = Standard_True;
743 myTransparency = with->Transparency();
746 isDisplayed = with->IsDisplayed();
747 myDriverGUID = with->GetDriverGUID();
750 //=======================================================================
753 //=======================================================================
754 void TPrsStd_AISPresentation::Paste (const Handle(TDF_Attribute)& Into,
755 const Handle(TDF_RelocationTable)& ) const
757 Handle(TPrsStd_AISPresentation) into = Handle(TPrsStd_AISPresentation)::DownCast(Into);
761 if(!hasOwnMaterial) into->hasOwnMaterial = Standard_False;
763 into->myMaterial = myMaterial;
764 into->hasOwnMaterial = Standard_True;
767 if(!hasOwnColor) into->hasOwnColor = Standard_False;
769 into->myColor = myColor;
770 into->hasOwnColor = Standard_True;
773 if(!hasOwnWidth) into->hasOwnWidth = Standard_False;
775 into->myWidth = myWidth;
776 into->hasOwnWidth = Standard_True;
778 if(!hasOwnMode) into->hasOwnMode = Standard_False;
780 into->myMode = myMode;
781 into->hasOwnMode = Standard_True;
785 if(!hasOwnSelectionMode) into->hasOwnSelectionMode = Standard_False;
787 into->mySelectionMode = mySelectionMode;
788 into->hasOwnSelectionMode = Standard_True;
792 if(!hasOwnTransparency) into->hasOwnTransparency = Standard_False;
794 into->myTransparency = myTransparency;
795 into->hasOwnTransparency = Standard_True;
798 if (into->isDisplayed)
799 into->AISErase(Standard_True);
801 into->isDisplayed = isDisplayed;
802 into->myDriverGUID = myDriverGUID;
804 into->myAIS.Nullify();
807 //=======================================================================
808 //function : AfterAddition
809 //purpose : erase if displayed
810 //=======================================================================
811 void TPrsStd_AISPresentation::AfterAddition()
816 //=======================================================================
817 //function : BeforeRemoval
818 //purpose : erase if displayed
819 //=======================================================================
820 void TPrsStd_AISPresentation::BeforeRemoval()
825 //=======================================================================
826 //function : BeforeForget
827 //purpose : erase if displayed
828 //=======================================================================
829 void TPrsStd_AISPresentation::BeforeForget()
831 if( !myAIS.IsNull() ) {
832 AISErase(Standard_True); //Remove AISObject from context
838 //=======================================================================
839 //function : AfterResume
840 //purpose : display if displayed
841 //=======================================================================
842 void TPrsStd_AISPresentation::AfterResume()
845 if( IsDisplayed() ) AISDisplay();
849 //=======================================================================
850 //function : BeforeUndo
851 //purpose : le NamedShape associe doit etre present
852 //=======================================================================
854 Standard_Boolean TPrsStd_AISPresentation::BeforeUndo (const Handle(TDF_AttributeDelta)& AD,
855 const Standard_Boolean )
857 Handle(TPrsStd_AISPresentation) P;
858 AD->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), P);
860 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
861 if( !P.IsNull() ) P->BeforeForget();
863 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
865 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
866 if( !P.IsNull() ) P->BeforeForget();
869 return Standard_True;
873 //=======================================================================
874 //function : AfterUndo
875 //purpose : le NamedShape associe doit etre present
876 //=======================================================================
878 Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeDelta)& AD,
879 const Standard_Boolean )
881 Handle(TPrsStd_AISPresentation) P;
882 AD->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), P);
884 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
886 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
887 if( !P.IsNull() ) P->AfterAddition();
889 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
890 if( !P.IsNull() ) P->AfterResume();
893 return Standard_True;
898 //=======================================================================
899 //function : AISUpdate
901 //=======================================================================
903 void TPrsStd_AISPresentation::AISUpdate ()
907 Handle(AIS_InteractiveContext) ctx;
908 if(!Label().IsNull()) {
909 Handle(TPrsStd_AISViewer) viewer;
910 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
912 Handle(TPrsStd_Driver) driver;
913 if (TPrsStd_DriverTable::Get()->FindDriver(GetDriverGUID(), driver)) {
914 if (myAIS.IsNull()) { // build a new AIS
915 Handle(AIS_InteractiveObject) newais;
916 if (driver->Update (Label(), newais)) {
918 newais->SetOwner(this);
922 Handle(AIS_InteractiveObject) theais = myAIS;
923 if (driver->Update (Label(), theais)) {
924 if (! (theais == myAIS)) {
925 if(!ctx.IsNull()) ctx->Remove(myAIS);
926 myAIS = theais; //Driver has built new AIS
927 theais->SetOwner(this);
935 //Apply the visualization settings
936 if( !myAIS.IsNull() ) {
939 if( !(myAIS->HasColor()) || (myAIS->HasColor() && myAIS->Color() != myColor) ) {
940 if(!ctx.IsNull()) ctx->SetColor(myAIS, myColor, Standard_False);
941 else myAIS->SetColor(myColor);
945 if( hasOwnMaterial ) {
946 if( !(myAIS->HasMaterial()) || (myAIS->HasMaterial() && myAIS->Material() != myMaterial) ) {
947 if(!ctx.IsNull()) ctx->SetMaterial(myAIS, myMaterial, Standard_False );
948 else myAIS->SetMaterial(myMaterial);
952 if( hasOwnTransparency ) {
953 if( myAIS->Transparency() != myTransparency ) {
954 if(!ctx.IsNull()) ctx->SetTransparency(myAIS, myTransparency, Standard_False);
955 else myAIS->SetTransparency(myTransparency);
960 if( !(myAIS->HasWidth()) || (myAIS->HasWidth() && myAIS->Width() != myWidth) ) {
961 if(!ctx.IsNull()) ctx->SetWidth(myAIS, myWidth, Standard_False);
962 else myAIS->SetWidth(myWidth);
967 if( myAIS->DisplayMode() != myMode ) {
968 myAIS->SetDisplayMode(myMode);
975 if (hasOwnSelectionMode) {
976 if (myAIS->SelectionMode() != mySelectionMode ) {
977 myAIS->SetSelectionMode(mySelectionMode);
984 if( isDisplayed && !ctx.IsNull() ) ctx->Redisplay(myAIS, Standard_False);
989 //=======================================================================
990 //function : AISDisplay
992 //=======================================================================
994 void TPrsStd_AISPresentation::AISDisplay ()
997 if (!Label().IsNull()) {
998 Handle(TPrsStd_AISViewer) viewer;
999 if( !TPrsStd_AISViewer::Find(Label(), viewer) ) return;
1000 Handle(AIS_InteractiveContext) ctx = viewer->GetInteractiveContext();
1001 if( ctx.IsNull() ) return;
1003 if (!myAIS.IsNull()) {
1005 if( !(myAIS->GetContext()).IsNull() && (myAIS->GetContext()) != ctx ) myAIS->GetContext()->Remove(myAIS);
1007 if( isDisplayed && ctx->IsDisplayed(myAIS) ) return;
1009 ctx->Display(myAIS, Standard_False);
1011 if( ctx->IsDisplayed(myAIS) ) SetDisplayed(Standard_True);
1017 //=======================================================================
1018 //function : AISErase
1020 //=======================================================================
1022 void TPrsStd_AISPresentation::AISErase (const Standard_Boolean remove)
1024 SetDisplayed(Standard_False);
1025 Handle(AIS_InteractiveContext) ctx, ownctx;
1027 if ( !myAIS.IsNull() ) {
1029 if ( !Label().IsNull()) {
1030 Handle(TPrsStd_AISViewer) viewer;
1031 if( !TPrsStd_AISViewer::Find(Label(), viewer) ) return;
1032 ownctx = myAIS->GetContext();
1033 ctx = viewer->GetInteractiveContext();
1035 if( !ctx.IsNull() ) ctx->Remove (myAIS,Standard_False);
1036 if( !ownctx.IsNull() && ownctx != ctx ) ownctx->Remove (myAIS,Standard_False);
1037 myAIS->SetToUpdate();
1040 if( !ctx.IsNull() ) ctx->Erase (myAIS,Standard_False);
1041 if( !ownctx.IsNull() && ownctx != ctx ) ownctx->Erase (myAIS,Standard_False);
1046 if( !ownctx.IsNull() ) {
1047 ownctx->Remove (myAIS,Standard_False);
1048 myAIS->SetToUpdate();
1051 if( !ownctx.IsNull() ) ownctx->Erase (myAIS,Standard_False);
1057 //=======================================================================
1060 //=======================================================================
1061 Handle(AIS_InteractiveObject) TPrsStd_AISPresentation::GetAIS() const
1067 //=======================================================================
1068 //function :SetDisplayed
1070 //=======================================================================
1071 void TPrsStd_AISPresentation::SetDisplayed(const Standard_Boolean B)