1 // Created on: 1998-09-30
2 // Created by: Sergey RUIN
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
24 // Lastly modified by :
25 // +---------------------------------------------------------------------------+
26 // ! ivan ! SetMode ! 5-04-2001! 3.0-00-1!
27 // +---------------------------------------------------------------------------+
28 #include <TPrsStd_AISPresentation.ixx>
30 #include <TDF_DefaultDeltaOnRemoval.hxx>
31 #include <TDF_DefaultDeltaOnModification.hxx>
32 #include <TDF_DeltaOnAddition.hxx>
33 #include <TDF_Tool.hxx>
34 #include <TCollection_ExtendedString.hxx>
35 #include <TPrsStd_AISViewer.hxx>
36 #include <AIS_InteractiveContext.hxx>
37 #include <AIS_InteractiveObject.hxx>
38 #include <TPrsStd_Driver.hxx>
39 #include <TPrsStd_DriverTable.hxx>
52 //=======================================================================
55 //=======================================================================
56 Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set(const TDF_Label& L,const Standard_GUID& driver)
59 Handle(TPrsStd_AISPresentation) P;
61 if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
62 P = new TPrsStd_AISPresentation ();
65 P->SetDriverGUID(driver);
70 //=======================================================================
73 //=======================================================================
74 void TPrsStd_AISPresentation::Unset (const TDF_Label& L)
76 Handle(TPrsStd_AISPresentation) P;
78 if (L.FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
84 //=======================================================================
87 //=======================================================================
88 Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set (const Handle(TDF_Attribute)& master)
90 Handle(TPrsStd_AISPresentation) P;
92 if (!master->Label().FindAttribute(TPrsStd_AISPresentation::GetID(),P)) {
93 P = new TPrsStd_AISPresentation ();
94 master->Label().AddAttribute(P);
97 P->SetDriverGUID( master->ID() );
105 //=======================================================================
108 //=======================================================================
109 const Standard_GUID& TPrsStd_AISPresentation::GetID()
111 static Standard_GUID TPrsStd_AISPresentationID("04fb4d00-5690-11d1-8940-080009dc3333");
112 return TPrsStd_AISPresentationID;
116 //=======================================================================
117 //function : TPrsStd_AISPresentation
119 //=======================================================================
120 TPrsStd_AISPresentation::TPrsStd_AISPresentation () :
121 myDriverGUID("00000000-0000-0000-0000-000000000000"),
123 myColor(Quantity_NOC_WHITE),
124 myMaterial(Graphic3d_NOM_BRASS),
130 isDisplayed(Standard_False),
131 hasOwnColor(Standard_False),
132 hasOwnMaterial(Standard_False),
133 hasOwnTransparency(Standard_False),
134 hasOwnWidth(Standard_False)
136 ,hasOwnMode(Standard_False),
137 hasOwnSelectionMode(Standard_False)
142 //=======================================================================
145 //=======================================================================
146 void TPrsStd_AISPresentation::Display (const Standard_Boolean update)
149 if( update || myAIS.IsNull() ) {
156 //=======================================================================
159 //=======================================================================
160 void TPrsStd_AISPresentation::Erase (const Standard_Boolean remove)
162 if( isDisplayed ) AISErase(remove);
165 //=======================================================================
168 //=======================================================================
169 void TPrsStd_AISPresentation::Update ()
175 //=======================================================================
176 //function : IsDisplayed
178 //=======================================================================
179 Standard_Boolean TPrsStd_AISPresentation::IsDisplayed () const
185 //=======================================================================
186 //function :SetDriverGUID
188 //=======================================================================
189 void TPrsStd_AISPresentation::SetDriverGUID(const Standard_GUID& guid)
191 // OCC2932 correction
192 if(myDriverGUID == guid) return;
199 //=======================================================================
200 //function :GetDriverGUID
202 //=======================================================================
203 Standard_GUID TPrsStd_AISPresentation::GetDriverGUID() const
209 //=======================================================================
212 //=======================================================================
213 Graphic3d_NameOfMaterial TPrsStd_AISPresentation::Material() const
218 //=======================================================================
219 //function :HasMaterial
221 //=======================================================================
222 Standard_Boolean TPrsStd_AISPresentation::HasOwnMaterial() const
224 return hasOwnMaterial;
227 //=======================================================================
228 //function :UnsetMaterial
230 //=======================================================================
231 void TPrsStd_AISPresentation::UnsetMaterial()
233 // OCC2932 correction
234 if(hasOwnMaterial == Standard_False && !myAIS.IsNull()) {
235 if(!myAIS->HasMaterial())
240 hasOwnMaterial = Standard_False;
241 if( myAIS.IsNull() ) AISUpdate();
242 if( !myAIS.IsNull() && myAIS->HasMaterial() ) {
243 Handle(AIS_InteractiveContext) ctx;
244 Handle(TPrsStd_AISViewer) viewer;
245 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
247 ctx->UnsetMaterial(myAIS, Standard_False);
249 myAIS->UnsetMaterial();
253 //=======================================================================
254 //function :SetMaterial
256 //=======================================================================
257 void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial aName)
259 // OCC2932 correction
260 if(myMaterial == aName && hasOwnMaterial == Standard_True && !myAIS.IsNull()) {
261 if(myAIS->HasMaterial() && myAIS->Material() == aName)
267 hasOwnMaterial = Standard_True;
268 if( myAIS.IsNull() ) AISUpdate();
269 if( !myAIS.IsNull() ) {
270 if( myAIS->HasMaterial() && myAIS->Material() == aName ) return; // AIS has already had that material
271 Handle(AIS_InteractiveContext) ctx;
272 Handle(TPrsStd_AISViewer) viewer;
273 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
275 ctx->SetMaterial(myAIS, aName, Standard_False);
277 myAIS->SetMaterial(aName);
282 //=======================================================================
283 //function :SetTransparency
285 //=======================================================================
286 void TPrsStd_AISPresentation::SetTransparency(const Standard_Real aValue)
288 // OCC2932 correction
289 if(hasOwnTransparency == Standard_True && myTransparency == aValue && !myAIS.IsNull())
290 if(myAIS->Transparency() == aValue)
294 myTransparency = aValue;
295 hasOwnTransparency = Standard_True;
296 if( myAIS.IsNull() ) AISUpdate();
297 if( !myAIS.IsNull() ) {
298 if( myAIS->Transparency() == aValue ) return; // AIS has already had that transparency
299 Handle(AIS_InteractiveContext) ctx;
300 Handle(TPrsStd_AISViewer) viewer;
301 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
303 ctx->SetTransparency(myAIS, aValue, Standard_False);
305 myAIS->SetTransparency(aValue);
310 //=======================================================================
311 //function :Transparency
313 //=======================================================================
314 Standard_Real TPrsStd_AISPresentation::Transparency() const
316 return myTransparency;
319 //=======================================================================
320 //function :UnsetTransparency
322 //=======================================================================
323 void TPrsStd_AISPresentation::UnsetTransparency()
325 // OCC2932 correction
326 if(!hasOwnTransparency)
330 hasOwnTransparency = Standard_False;
331 if( myAIS.IsNull() ) AISUpdate();
332 if( !myAIS.IsNull() ) {
333 Handle(AIS_InteractiveContext) ctx;
334 Handle(TPrsStd_AISViewer) viewer;
335 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
337 ctx->UnsetTransparency(myAIS, Standard_False);
339 myAIS->UnsetTransparency();
343 //=======================================================================
344 //function :HasTransparency
346 //=======================================================================
347 Standard_Boolean TPrsStd_AISPresentation::HasOwnTransparency() const
349 return hasOwnTransparency;
352 //=======================================================================
355 //=======================================================================
356 Quantity_NameOfColor TPrsStd_AISPresentation::Color() const
361 //=======================================================================
364 //=======================================================================
365 Standard_Boolean TPrsStd_AISPresentation::HasOwnColor() const
370 //=======================================================================
371 //function :UnsetColor
373 //=======================================================================
374 void TPrsStd_AISPresentation::UnsetColor()
376 // OCC2932 correction
377 if(!hasOwnColor && !myAIS.IsNull())
378 if(!myAIS->HasColor())
382 hasOwnColor = Standard_False;
383 if( myAIS.IsNull() ) AISUpdate();
384 if( !myAIS.IsNull() && myAIS->HasColor() ) {
385 Handle(AIS_InteractiveContext) ctx;
386 Handle(TPrsStd_AISViewer) viewer;
387 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
389 ctx->UnsetColor(myAIS, Standard_False);
395 //=======================================================================
398 //=======================================================================
399 void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor aColor)
401 // OCC2932 correction
402 if(hasOwnColor && myColor == aColor && ! myAIS.IsNull())
403 if(myAIS->HasColor() && myAIS->Color() == aColor )
408 hasOwnColor = Standard_True;
409 if( myAIS.IsNull() ) AISUpdate();
410 if( !myAIS.IsNull() ) {
411 if( myAIS->HasColor() && myAIS->Color() == aColor ) return; // AIS has already had that color
412 Handle(AIS_InteractiveContext) ctx;
413 Handle(TPrsStd_AISViewer) viewer;
414 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
416 ctx->SetColor(myAIS, aColor, Standard_False);
418 myAIS->SetColor(aColor);
423 //=======================================================================
426 //=======================================================================
427 Standard_Real TPrsStd_AISPresentation::Width() const
432 //=======================================================================
435 //=======================================================================
436 Standard_Boolean TPrsStd_AISPresentation::HasOwnWidth() const
441 //=======================================================================
444 //=======================================================================
445 void TPrsStd_AISPresentation::SetWidth(const Standard_Real aWidth)
447 // OCC2932 correction
448 if(hasOwnWidth && myWidth == aWidth && myAIS.IsNull())
449 if(myAIS->HasWidth() && myAIS->Width() == aWidth )
454 hasOwnWidth = Standard_True;
455 if( myAIS.IsNull() ) AISUpdate();
456 if( !myAIS.IsNull() ) {
457 if( myAIS->HasWidth() && myAIS->Width() == aWidth ) return; // AIS has already had that width
458 Handle(AIS_InteractiveContext) ctx;
459 Handle(TPrsStd_AISViewer) viewer;
460 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
462 ctx->SetWidth(myAIS, aWidth, Standard_False);
464 myAIS->SetWidth(aWidth);
468 //=======================================================================
469 //function :UnsetWidth
471 //=======================================================================
472 void TPrsStd_AISPresentation::UnsetWidth()
474 // OCC2932 correction
475 if(!hasOwnWidth && !myAIS.IsNull())
476 if(!myAIS->HasWidth())
480 hasOwnWidth = Standard_False;
481 if( myAIS.IsNull() ) AISUpdate();
482 if( !myAIS.IsNull() && myAIS->HasWidth() ) {
483 Handle(AIS_InteractiveContext) ctx;
484 Handle(TPrsStd_AISViewer) viewer;
485 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
487 ctx->UnsetWidth(myAIS, Standard_False);
495 //=======================================================================
498 //=======================================================================
500 Standard_Integer TPrsStd_AISPresentation::Mode() const
505 //=======================================================================
506 //function :HasOwnMode
508 //=======================================================================
509 Standard_Boolean TPrsStd_AISPresentation::HasOwnMode() const
514 //=======================================================================
517 //=======================================================================
518 void TPrsStd_AISPresentation::SetMode(const Standard_Integer theMode)
520 // OCC2932 correction
521 if(hasOwnMode && myMode == theMode && !myAIS.IsNull())
522 if(myAIS->DisplayMode() == theMode )
527 hasOwnMode = Standard_True;
528 if( myAIS.IsNull() ) AISUpdate();
529 if( !myAIS.IsNull() ) {
530 if( myAIS->DisplayMode() == theMode ) return; // AIS has already had that mode
531 Handle(AIS_InteractiveContext) ctx;
532 Handle(TPrsStd_AISViewer) viewer;
533 if( TPrsStd_AISViewer::Find(Label(), viewer) )
534 ctx = viewer->GetInteractiveContext();
536 ctx->SetDisplayMode(myAIS, theMode, Standard_False);
538 myAIS->SetDisplayMode(theMode);
542 //=======================================================================
543 //function :UnsetMode
545 //=======================================================================
546 void TPrsStd_AISPresentation::UnsetMode()
548 // OCC2932 correction
549 if(HasOwnMode() == Standard_False && myAIS.IsNull() == Standard_False)
550 if(!myAIS->HasDisplayMode())
554 hasOwnMode = Standard_False;
555 if( myAIS.IsNull() ) AISUpdate();
556 if( !myAIS.IsNull() && myAIS->HasDisplayMode() ) {
557 Handle(AIS_InteractiveContext) ctx;
558 Handle(TPrsStd_AISViewer) viewer;
559 if( TPrsStd_AISViewer::Find(Label(), viewer) )
560 ctx = viewer->GetInteractiveContext();
562 ctx->UnsetDisplayMode(myAIS, Standard_False);
564 myAIS->UnsetDisplayMode();
569 //=======================================================================
570 //function : SelectionMode
572 //=======================================================================
574 Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
576 return mySelectionMode;
579 //=======================================================================
580 //function :HasOwnSelectionMode
582 //=======================================================================
583 Standard_Boolean TPrsStd_AISPresentation::HasOwnSelectionMode() const
585 return hasOwnSelectionMode;
588 //=======================================================================
589 //function :SetSelectionMode
591 //=======================================================================
592 void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode)
594 // OCC2932 correction
595 if(hasOwnSelectionMode && mySelectionMode == theSelectionMode && !myAIS.IsNull())
596 if(myAIS->SelectionMode() == theSelectionMode )
600 mySelectionMode = theSelectionMode;
601 hasOwnSelectionMode = Standard_True;
602 if( myAIS.IsNull() ) AISUpdate();
603 if( !myAIS.IsNull() ) {
604 if( myAIS->SelectionMode() == theSelectionMode ) return;
605 myAIS->SetSelectionMode(theSelectionMode);
609 //=======================================================================
610 //function :UnsetSelectionMode
612 //=======================================================================
613 void TPrsStd_AISPresentation::UnsetSelectionMode()
615 if(!hasOwnSelectionMode && !myAIS.IsNull())
616 if(!myAIS->HasSelectionMode())
620 hasOwnSelectionMode = Standard_False;
621 if( myAIS.IsNull() ) AISUpdate();
622 if( !myAIS.IsNull() && myAIS->HasSelectionMode() ) {
623 myAIS->UnsetSelectionMode();
629 //=======================================================================
632 //=======================================================================
633 const Standard_GUID& TPrsStd_AISPresentation::ID() const { return GetID(); }
636 //=======================================================================
637 //function : BackupCopy
639 //=======================================================================
640 Handle(TDF_Attribute) TPrsStd_AISPresentation::BackupCopy() const
642 Handle(TPrsStd_AISPresentation) copy = new TPrsStd_AISPresentation;
643 copy->myTransparency = myTransparency;
644 copy->myColor = myColor;
645 copy->myMode= myMode;
647 copy->myWidth= myWidth;
649 copy->myMaterial = myMaterial;
650 copy->hasOwnColor = hasOwnColor;
651 copy->hasOwnMaterial = hasOwnMaterial;
652 copy->hasOwnWidth = hasOwnWidth;
653 copy->hasOwnMode=hasOwnMode;
654 copy->hasOwnTransparency = hasOwnTransparency;
655 copy->myAIS.Nullify();
656 copy->isDisplayed = isDisplayed;
657 copy->myDriverGUID = myDriverGUID;
659 copy->mySelectionMode= mySelectionMode;
660 copy->hasOwnSelectionMode = hasOwnSelectionMode;
666 //=======================================================================
667 //function : NewEmpty
669 //=======================================================================
670 Handle(TDF_Attribute) TPrsStd_AISPresentation::NewEmpty() const
672 return new TPrsStd_AISPresentation ();
675 //=======================================================================
678 //=======================================================================
679 void TPrsStd_AISPresentation::Restore (const Handle(TDF_Attribute)& With)
681 Handle(TPrsStd_AISPresentation) with = Handle(TPrsStd_AISPresentation)::DownCast(With);
685 if(!with->HasOwnMaterial()) hasOwnMaterial = Standard_False;
688 myMaterial = with->Material();
690 hasOwnMaterial = Standard_True;
693 myMaterial = with->Material();
696 if(!with->HasOwnColor()) hasOwnColor = Standard_False;
699 myColor = with->Color();
701 hasOwnColor = Standard_True;
704 myColor = with->Color();
707 if(!with->HasOwnWidth()) hasOwnWidth = Standard_False;
710 myWidth = with->Width();
712 hasOwnWidth = Standard_True;
715 myWidth = with->Width();
718 if(!with->HasOwnMode()) hasOwnMode = Standard_False;
721 myMode = with->Mode();
723 hasOwnMode = Standard_True;
726 myMode = with->Mode();
730 if(!with->HasOwnSelectionMode()) hasOwnSelectionMode = Standard_False;
733 mySelectionMode = with->SelectionMode();
735 hasOwnSelectionMode = Standard_True;
738 mySelectionMode = with->SelectionMode();
742 if(!with->HasOwnTransparency()) hasOwnTransparency = Standard_False;
745 myTransparency = with->Transparency();
747 hasOwnTransparency = Standard_True;
750 myTransparency = with->Transparency();
753 isDisplayed = with->IsDisplayed();
754 myDriverGUID = with->GetDriverGUID();
757 //=======================================================================
760 //=======================================================================
761 void TPrsStd_AISPresentation::Paste (const Handle(TDF_Attribute)& Into,
762 const Handle(TDF_RelocationTable)& ) const
764 Handle(TPrsStd_AISPresentation) into = Handle(TPrsStd_AISPresentation)::DownCast(Into);
768 if(!hasOwnMaterial) into->hasOwnMaterial = Standard_False;
770 into->myMaterial = myMaterial;
771 into->hasOwnMaterial = Standard_True;
774 if(!hasOwnColor) into->hasOwnColor = Standard_False;
776 into->myColor = myColor;
777 into->hasOwnColor = Standard_True;
780 if(!hasOwnWidth) into->hasOwnWidth = Standard_False;
782 into->myWidth = myWidth;
783 into->hasOwnWidth = Standard_True;
785 if(!hasOwnMode) into->hasOwnMode = Standard_False;
787 into->myMode = myMode;
788 into->hasOwnMode = Standard_True;
792 if(!hasOwnSelectionMode) into->hasOwnSelectionMode = Standard_False;
794 into->mySelectionMode = mySelectionMode;
795 into->hasOwnSelectionMode = Standard_True;
799 if(!hasOwnTransparency) into->hasOwnTransparency = Standard_False;
801 into->myTransparency = myTransparency;
802 into->hasOwnTransparency = Standard_True;
805 if (into->isDisplayed)
806 into->AISErase(Standard_True);
808 into->isDisplayed = isDisplayed;
809 into->myDriverGUID = myDriverGUID;
811 into->myAIS.Nullify();
814 //=======================================================================
815 //function : AfterAddition
816 //purpose : erase if displayed
817 //=======================================================================
818 void TPrsStd_AISPresentation::AfterAddition()
823 //=======================================================================
824 //function : BeforeRemoval
825 //purpose : erase if displayed
826 //=======================================================================
827 void TPrsStd_AISPresentation::BeforeRemoval()
832 //=======================================================================
833 //function : BeforeForget
834 //purpose : erase if displayed
835 //=======================================================================
836 void TPrsStd_AISPresentation::BeforeForget()
838 if( !myAIS.IsNull() ) {
839 AISErase(Standard_True); //Remove AISObject from context
845 //=======================================================================
846 //function : AfterResume
847 //purpose : display if displayed
848 //=======================================================================
849 void TPrsStd_AISPresentation::AfterResume()
852 if( IsDisplayed() ) AISDisplay();
856 //=======================================================================
857 //function : BeforeUndo
858 //purpose : le NamedShape associe doit etre present
859 //=======================================================================
861 Standard_Boolean TPrsStd_AISPresentation::BeforeUndo (const Handle(TDF_AttributeDelta)& AD,
862 const Standard_Boolean )
864 Handle(TPrsStd_AISPresentation) P;
865 AD->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), P);
867 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
868 if( !P.IsNull() ) P->BeforeForget();
870 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
872 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
873 if( !P.IsNull() ) P->BeforeForget();
876 return Standard_True;
880 //=======================================================================
881 //function : AfterUndo
882 //purpose : le NamedShape associe doit etre present
883 //=======================================================================
885 Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeDelta)& AD,
886 const Standard_Boolean )
888 Handle(TPrsStd_AISPresentation) P;
889 AD->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), P);
891 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
893 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
894 if( !P.IsNull() ) P->AfterAddition();
896 else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
897 if( !P.IsNull() ) P->AfterResume();
900 return Standard_True;
905 //=======================================================================
906 //function : AISUpdate
908 //=======================================================================
910 void TPrsStd_AISPresentation::AISUpdate ()
914 Handle(AIS_InteractiveContext) ctx;
915 if(!Label().IsNull()) {
916 Handle(TPrsStd_AISViewer) viewer;
917 if( TPrsStd_AISViewer::Find(Label(), viewer) ) ctx = viewer->GetInteractiveContext();
919 Handle(TPrsStd_Driver) driver;
920 if (TPrsStd_DriverTable::Get()->FindDriver(GetDriverGUID(), driver)) {
921 if (myAIS.IsNull()) { // build a new AIS
922 Handle(AIS_InteractiveObject) newais;
923 if (driver->Update (Label(), newais)) {
925 newais->SetOwner(this);
929 Handle(AIS_InteractiveObject) theais = myAIS;
930 if (driver->Update (Label(), theais)) {
931 if (! (theais == myAIS)) {
932 if(!ctx.IsNull()) ctx->Remove(myAIS);
933 myAIS = theais; //Driver has built new AIS
934 theais->SetOwner(this);
942 //Apply the visualization settings
943 if( !myAIS.IsNull() ) {
946 if( !(myAIS->HasColor()) || (myAIS->HasColor() && myAIS->Color() != myColor) ) {
947 if(!ctx.IsNull()) ctx->SetColor(myAIS, myColor, Standard_False);
948 else myAIS->SetColor(myColor);
952 if( hasOwnMaterial ) {
953 if( !(myAIS->HasMaterial()) || (myAIS->HasMaterial() && myAIS->Material() != myMaterial) ) {
954 if(!ctx.IsNull()) ctx->SetMaterial(myAIS, myMaterial, Standard_False );
955 else myAIS->SetMaterial(myMaterial);
959 if( hasOwnTransparency ) {
960 if( myAIS->Transparency() != myTransparency ) {
961 if(!ctx.IsNull()) ctx->SetTransparency(myAIS, myTransparency, Standard_False);
962 else myAIS->SetTransparency(myTransparency);
967 if( !(myAIS->HasWidth()) || (myAIS->HasWidth() && myAIS->Width() != myWidth) ) {
968 if(!ctx.IsNull()) ctx->SetWidth(myAIS, myWidth, Standard_False);
969 else myAIS->SetWidth(myWidth);
974 if( myAIS->DisplayMode() != myMode ) {
975 myAIS->SetDisplayMode(myMode);
982 if (hasOwnSelectionMode) {
983 if (myAIS->SelectionMode() != mySelectionMode ) {
984 myAIS->SetSelectionMode(mySelectionMode);
991 if( isDisplayed && !ctx.IsNull() ) ctx->Redisplay(myAIS, Standard_False);
996 //=======================================================================
997 //function : AISDisplay
999 //=======================================================================
1001 void TPrsStd_AISPresentation::AISDisplay ()
1004 if (!Label().IsNull()) {
1005 Handle(TPrsStd_AISViewer) viewer;
1006 if( !TPrsStd_AISViewer::Find(Label(), viewer) ) return;
1007 Handle(AIS_InteractiveContext) ctx = viewer->GetInteractiveContext();
1008 if( ctx.IsNull() ) return;
1010 if (!myAIS.IsNull()) {
1012 if( !(myAIS->GetContext()).IsNull() && (myAIS->GetContext()) != ctx ) myAIS->GetContext()->Remove(myAIS);
1014 if( isDisplayed && ctx->IsDisplayed(myAIS) ) return;
1016 ctx->Display(myAIS, Standard_False);
1018 if( ctx->IsDisplayed(myAIS) ) SetDisplayed(Standard_True);
1024 //=======================================================================
1025 //function : AISErase
1027 //=======================================================================
1029 void TPrsStd_AISPresentation::AISErase (const Standard_Boolean remove)
1031 SetDisplayed(Standard_False);
1032 Handle(AIS_InteractiveContext) ctx, ownctx;
1034 if ( !myAIS.IsNull() ) {
1035 ownctx = myAIS->GetContext();
1036 if ( !Label().IsNull()) {
1037 Handle(TPrsStd_AISViewer) viewer;
1038 if( !TPrsStd_AISViewer::Find(Label(), viewer) ) return;
1039 ctx = viewer->GetInteractiveContext();
1041 if( !ctx.IsNull() ) ctx->Remove (myAIS,Standard_False);
1042 if( !ownctx.IsNull() && ownctx != ctx ) ownctx->Remove (myAIS,Standard_False);
1043 myAIS->SetToUpdate();
1046 if( !ctx.IsNull() ) ctx->Erase (myAIS,Standard_False);
1047 if( !ownctx.IsNull() && ownctx != ctx ) ownctx->Erase (myAIS,Standard_False);
1052 if( !ownctx.IsNull() ) {
1053 ownctx->Remove (myAIS,Standard_False);
1054 myAIS->SetToUpdate();
1057 if( !ownctx.IsNull() ) ownctx->Erase (myAIS,Standard_False);
1063 //=======================================================================
1066 //=======================================================================
1067 Handle(AIS_InteractiveObject) TPrsStd_AISPresentation::GetAIS() const
1073 //=======================================================================
1074 //function :SetDisplayed
1076 //=======================================================================
1077 void TPrsStd_AISPresentation::SetDisplayed(const Standard_Boolean B)