1 // Created on: 1997-12-16
2 // Created by: Jean Louis Frenkel
3 // Copyright (c) 1997-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 #include <PrsMgr_PresentableObject.hxx>
19 #include <Graphic3d_AspectFillArea3d.hxx>
20 #include <Prs3d_Drawer.hxx>
21 #include <Prs3d_LineAspect.hxx>
22 #include <Prs3d_PointAspect.hxx>
23 #include <Prs3d_Presentation.hxx>
24 #include <Prs3d_Projector.hxx>
25 #include <Prs3d_ShadingAspect.hxx>
26 #include <PrsMgr_Presentation.hxx>
27 #include <PrsMgr_PresentationManager.hxx>
28 #include <Standard_NotImplemented.hxx>
29 #include <TColStd_MapOfInteger.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
33 //=======================================================================
34 //function : getIdentityTrsf
36 //=======================================================================
37 const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf()
39 static const gp_Trsf THE_IDENTITY_TRSF;
40 return THE_IDENTITY_TRSF;
43 //=======================================================================
44 //function : PrsMgr_PresentableObject
46 //=======================================================================
47 PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType)
49 myDrawer (new Prs3d_Drawer()),
50 myTypeOfPresentation3d (theType),
52 myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
54 hasOwnColor (Standard_False),
55 hasOwnMaterial (Standard_False),
57 myInfiniteState (Standard_False),
58 myIsMutable (Standard_False),
59 myHasOwnPresentations (Standard_True),
60 myToPropagateVisualState (Standard_True)
62 myDrawer->SetDisplayMode (-1);
65 //=======================================================================
66 //function : ~PrsMgr_PresentableObject
67 //purpose : destructor
68 //=======================================================================
69 PrsMgr_PresentableObject::~PrsMgr_PresentableObject()
71 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
73 // should never happen - assertion can be used
74 const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value();
76 aPrs3d->myPresentableObject = NULL;
79 for (PrsMgr_ListOfPresentableObjectsIter anIter (myChildren); anIter.More(); anIter.Next())
81 anIter.Value()->SetCombinedParentTransform (Handle(Geom_Transformation)());
82 anIter.Value()->myParent = NULL;
86 //=======================================================================
89 //=======================================================================
90 void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
91 const Handle(PrsMgr_Presentation)& thePrs,
92 const Standard_Integer theMode)
94 const Handle(Prs3d_Presentation)& aStruct3d = thePrs;
95 Compute (thePrsMgr, aStruct3d, theMode);
96 aStruct3d->SetTransformation (myTransformation);
97 aStruct3d->SetClipPlanes (myClipPlanes);
98 aStruct3d->SetTransformPersistence (TransformPersistence());
101 //=======================================================================
104 //=======================================================================
105 void PrsMgr_PresentableObject::Compute(const Handle(Prs3d_Projector)& /*aProjector*/,
106 const Handle(Prs3d_Presentation)& /*aPresentation*/)
108 throw Standard_NotImplemented("cannot compute under a specific projector");
111 //=======================================================================
114 //=======================================================================
115 void PrsMgr_PresentableObject::Compute(const Handle(Prs3d_Projector)& /* aProjector*/,
116 const Handle(Geom_Transformation)& /*aTrsf*/,
117 const Handle(Prs3d_Presentation)& /*aPresentation*/)
119 throw Standard_NotImplemented("cannot compute under a specific projector");
122 //=======================================================================
123 //function : ToBeUpdated
125 //=======================================================================
126 Standard_Boolean PrsMgr_PresentableObject::ToBeUpdated (Standard_Boolean theToIncludeHidden) const
128 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
130 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
131 if (aModedPrs->MustBeUpdated())
133 if (theToIncludeHidden)
135 return Standard_True;
138 Handle(PrsMgr_PresentationManager) aPrsMgr = aModedPrs->PresentationManager();
139 if (aPrsMgr->IsDisplayed (this, aModedPrs->Mode())
140 || aPrsMgr->IsHighlighted(this, aModedPrs->Mode()))
142 return Standard_True;
146 return Standard_False;
149 //=======================================================================
150 //function : UpdatePresentations
152 //=======================================================================
153 Standard_Boolean PrsMgr_PresentableObject::UpdatePresentations (Standard_Boolean theToIncludeHidden)
155 Standard_Boolean hasUpdates = Standard_False;
156 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
158 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
159 if (aModedPrs->MustBeUpdated())
161 Handle(PrsMgr_PresentationManager) aPrsMgr = aModedPrs->PresentationManager();
162 if (theToIncludeHidden
163 || aPrsMgr->IsDisplayed (this, aModedPrs->Mode())
164 || aPrsMgr->IsHighlighted(this, aModedPrs->Mode()))
166 hasUpdates = Standard_True;
167 aPrsMgr->Update (this, aModedPrs->Mode());
174 //=======================================================================
177 //=======================================================================
178 void PrsMgr_PresentableObject::Update (Standard_Integer theMode, Standard_Boolean theToClearOther)
180 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More();)
182 if (aPrsIter.Value()->Mode() == theMode)
184 Handle(PrsMgr_PresentationManager) aPrsMgr = aPrsIter.Value()->PresentationManager();
185 if (aPrsMgr->IsDisplayed (this, theMode)
186 || aPrsMgr->IsHighlighted(this, theMode))
188 aPrsMgr->Update (this, theMode);
189 aPrsIter.Value()->SetUpdateStatus (Standard_False);
193 SetToUpdate (aPrsIter.Value()->Mode());
196 else if (theToClearOther)
198 myPresentations.Remove (aPrsIter);
205 //=======================================================================
206 //function : SetToUpdate
208 //=======================================================================
209 void PrsMgr_PresentableObject::SetToUpdate (Standard_Integer theMode)
211 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
214 || aPrsIter.Value()->Mode() == theMode)
216 aPrsIter.ChangeValue()->SetUpdateStatus (Standard_True);
221 //=======================================================================
222 //function : ToBeUpdated
223 //purpose : gets the list of modes to be updated
224 //=======================================================================
225 void PrsMgr_PresentableObject::ToBeUpdated (TColStd_ListOfInteger& theOutList) const
228 TColStd_MapOfInteger MI(myPresentations.Length());
229 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
231 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
232 if (aModedPrs->MustBeUpdated()
233 && MI.Add (aModedPrs->Mode()))
235 theOutList.Append (aModedPrs->Mode());
240 //=======================================================================
241 //function : SetTypeOfPresentation
243 //=======================================================================
244 void PrsMgr_PresentableObject::SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d theType)
246 myTypeOfPresentation3d = theType;
247 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
249 const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
250 aPrs->SetVisual (myTypeOfPresentation3d == PrsMgr_TOP_ProjectorDependant
251 ? Graphic3d_TOS_COMPUTED
252 : Graphic3d_TOS_ALL);
256 //=======================================================================
257 //function : setLocalTransformation
259 //=======================================================================
260 void PrsMgr_PresentableObject::setLocalTransformation (const Handle(Geom_Transformation)& theTransformation)
262 myLocalTransformation = theTransformation;
263 UpdateTransformation();
266 //=======================================================================
267 //function : ResetTransformation
269 //=======================================================================
270 void PrsMgr_PresentableObject::ResetTransformation()
272 setLocalTransformation (Handle(Geom_Transformation)());
275 //=======================================================================
276 //function : SetCombinedParentTransform
278 //=======================================================================
279 void PrsMgr_PresentableObject::SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf)
281 myCombinedParentTransform = theTrsf;
282 UpdateTransformation();
285 //=======================================================================
286 //function : UpdateTransformation
288 //=======================================================================
289 void PrsMgr_PresentableObject::UpdateTransformation()
291 myTransformation.Nullify();
292 myInvTransformation = gp_Trsf();
293 if (!myCombinedParentTransform.IsNull() && myCombinedParentTransform->Form() != gp_Identity)
295 if (!myLocalTransformation.IsNull() && myLocalTransformation->Form() != gp_Identity)
297 const gp_Trsf aTrsf = myCombinedParentTransform->Trsf() * myLocalTransformation->Trsf();
298 myTransformation = new Geom_Transformation (aTrsf);
299 myInvTransformation = aTrsf.Inverted();
303 myTransformation = myCombinedParentTransform;
304 myInvTransformation = myCombinedParentTransform->Trsf().Inverted();
307 else if (!myLocalTransformation.IsNull() && myLocalTransformation->Form() != gp_Identity)
309 myTransformation = myLocalTransformation;
310 myInvTransformation = myLocalTransformation->Trsf().Inverted();
313 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
315 aPrsIter.ChangeValue()->SetTransformation (myTransformation);
318 for (PrsMgr_ListOfPresentableObjectsIter aChildIter (myChildren); aChildIter.More(); aChildIter.Next())
320 aChildIter.Value()->SetCombinedParentTransform (myTransformation);
324 //=======================================================================
325 //function : recomputeComputed
327 //=======================================================================
328 void PrsMgr_PresentableObject::recomputeComputed() const
330 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
332 const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value();
337 //=======================================================================
338 //function : SetTransformPersistence
340 //=======================================================================
341 void PrsMgr_PresentableObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
343 myTransformPersistence = theTrsfPers;
344 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
346 const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value();
347 aPrs3d->SetTransformPersistence (myTransformPersistence);
352 //=======================================================================
353 //function : GetTransformPersistence
355 //=======================================================================
356 gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const
358 if (myTransformPersistence.IsNull())
362 else if (myTransformPersistence->IsZoomOrRotate())
364 return myTransformPersistence->AnchorPoint();
366 else if (!myTransformPersistence->IsTrihedronOr2d())
371 Standard_Real anX = 0.0;
372 if ((myTransformPersistence->Corner2d() & Aspect_TOTP_RIGHT) != 0)
376 else if ((myTransformPersistence->Corner2d() & Aspect_TOTP_LEFT) != 0)
381 Standard_Real anY = 0.0;
382 if ((myTransformPersistence->Corner2d() & Aspect_TOTP_TOP) != 0)
386 else if ((myTransformPersistence->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
391 return gp_Pnt (anX, anY, myTransformPersistence->Offset2d().x());
394 //=======================================================================
395 //function : AddChild
397 //=======================================================================
398 void PrsMgr_PresentableObject::AddChild (const Handle(PrsMgr_PresentableObject)& theObject)
400 Handle(PrsMgr_PresentableObject) aHandleGuard = theObject;
401 if (theObject->myParent != NULL)
403 theObject->myParent->RemoveChild (aHandleGuard);
406 myChildren.Append (theObject);
407 theObject->myParent = this;
408 theObject->SetCombinedParentTransform (myTransformation);
411 //=======================================================================
412 //function : AddChildWithCurrentTransformation
414 //=======================================================================
415 void PrsMgr_PresentableObject::AddChildWithCurrentTransformation(const Handle(PrsMgr_PresentableObject)& theObject)
417 gp_Trsf aTrsf = Transformation().Inverted() * theObject->Transformation();
418 theObject->SetLocalTransformation(aTrsf);
422 //=======================================================================
423 //function : RemoveChild
425 //=======================================================================
426 void PrsMgr_PresentableObject::RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject)
428 PrsMgr_ListOfPresentableObjectsIter anIter (myChildren);
429 for (; anIter.More(); anIter.Next())
431 if (anIter.Value() == theObject)
433 theObject->myParent = NULL;
434 theObject->SetCombinedParentTransform (Handle(Geom_Transformation)());
435 myChildren.Remove (anIter);
441 //=======================================================================
442 //function : RemoveChildWithRestoreTransformation
444 //=======================================================================
445 void PrsMgr_PresentableObject::RemoveChildWithRestoreTransformation(const Handle(PrsMgr_PresentableObject)& theObject)
447 gp_Trsf aTrsf = theObject->Transformation();
448 RemoveChild(theObject);
449 theObject->SetLocalTransformation(aTrsf);
452 //=======================================================================
453 //function : SetZLayer
455 //=======================================================================
456 void PrsMgr_PresentableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId)
458 if (myDrawer->ZLayer() == theLayerId)
463 myDrawer->SetZLayer (theLayerId);
464 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
466 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
467 aModedPrs->SetZLayer (theLayerId);
471 // =======================================================================
472 // function : AddClipPlane
474 // =======================================================================
475 void PrsMgr_PresentableObject::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
477 // add to collection and process changes
478 if (myClipPlanes.IsNull())
480 myClipPlanes = new Graphic3d_SequenceOfHClipPlane();
483 myClipPlanes->Append (thePlane);
487 // =======================================================================
488 // function : RemoveClipPlane
490 // =======================================================================
491 void PrsMgr_PresentableObject::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
493 if (myClipPlanes.IsNull())
498 // remove from collection and process changes
499 for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*myClipPlanes); aPlaneIt.More(); aPlaneIt.Next())
501 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
502 if (aPlane != thePlane)
505 myClipPlanes->Remove (aPlaneIt);
511 // =======================================================================
512 // function : SetClipPlanes
514 // =======================================================================
515 void PrsMgr_PresentableObject::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
517 // change collection and process changes
518 myClipPlanes = thePlanes;
522 // =======================================================================
523 // function : UpdateClipping
525 // =======================================================================
526 void PrsMgr_PresentableObject::UpdateClipping()
528 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
530 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
531 aModedPrs->SetClipPlanes (myClipPlanes);
535 //=======================================================================
536 //function : SetInfiniteState
538 //=======================================================================
539 void PrsMgr_PresentableObject::SetInfiniteState (const Standard_Boolean theFlag)
541 if (myInfiniteState == theFlag)
546 myInfiniteState = theFlag;
547 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
549 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
550 aModedPrs->SetInfiniteState (theFlag);
554 // =======================================================================
555 // function : SetMutable
557 // =======================================================================
558 void PrsMgr_PresentableObject::SetMutable (const Standard_Boolean theIsMutable)
560 if (myIsMutable == theIsMutable)
565 myIsMutable = theIsMutable;
566 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
568 const Handle(PrsMgr_Presentation)& aModedPrs = aPrsIter.Value();
569 aModedPrs->SetMutable (theIsMutable);
573 // =======================================================================
574 // function : UnsetAttributes
576 // =======================================================================
577 void PrsMgr_PresentableObject::UnsetAttributes()
579 Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer();
580 if (myDrawer->HasLink())
582 aDrawer->Link(myDrawer->Link());
586 hasOwnColor = Standard_False;
587 hasOwnMaterial = Standard_False;
589 myDrawer->SetTransparency (0.0f);
592 //=======================================================================
593 //function : SetHilightMode
595 //=======================================================================
596 void PrsMgr_PresentableObject::SetHilightMode (const Standard_Integer theMode)
598 if (myHilightDrawer.IsNull())
600 myHilightDrawer = new Prs3d_Drawer();
601 myHilightDrawer->Link (myDrawer);
602 myHilightDrawer->SetAutoTriangulation (Standard_False);
603 myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
604 myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
606 if (myDynHilightDrawer.IsNull())
608 myDynHilightDrawer = new Prs3d_Drawer();
609 myDynHilightDrawer->Link (myDrawer);
610 myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
611 myDynHilightDrawer->SetAutoTriangulation (Standard_False);
612 myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top);
614 myHilightDrawer ->SetDisplayMode (theMode);
615 myDynHilightDrawer->SetDisplayMode (theMode);
618 //=======================================================================
619 //function : SynchronizeAspects
621 //=======================================================================
622 void PrsMgr_PresentableObject::SynchronizeAspects()
624 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
626 const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
627 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Groups()); aGroupIter.More(); aGroupIter.Next())
629 if (!aGroupIter.Value().IsNull())
631 aGroupIter.ChangeValue()->SynchronizeAspects();
637 //=======================================================================
638 //function : replaceAspects
640 //=======================================================================
641 void PrsMgr_PresentableObject::replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
643 if (theMap.IsEmpty())
648 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
650 const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
651 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Groups()); aGroupIter.More(); aGroupIter.Next())
653 if (!aGroupIter.Value().IsNull())
655 aGroupIter.ChangeValue()->ReplaceAspects (theMap);
661 //=======================================================================
662 //function : BoundingBox
664 //=======================================================================
665 void PrsMgr_PresentableObject::BoundingBox (Bnd_Box& theBndBox)
667 if (myDrawer->DisplayMode() == -1)
669 if (!myPresentations.IsEmpty())
671 const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations.First();
672 const Graphic3d_BndBox3d& aBndBox = aPrs3d->CStructure()->BoundingBox();
673 if (aBndBox.IsValid())
675 theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
676 aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
685 for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (myChildren); aPrsIter.More(); aPrsIter.Next())
687 if (const Handle(PrsMgr_PresentableObject)& aChild = aPrsIter.Value())
690 aChild->BoundingBox (aBox);
691 theBndBox.Add (aBox);
697 for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
699 const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
700 if (aPrs3d->Mode() == myDrawer->DisplayMode())
702 const Graphic3d_BndBox3d& aBndBox = aPrs3d->CStructure()->BoundingBox();
703 if (aBndBox.IsValid())
705 theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
706 aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
717 //=======================================================================
718 //function : Material
720 //=======================================================================
721 Graphic3d_NameOfMaterial PrsMgr_PresentableObject::Material() const
723 return myDrawer->ShadingAspect()->Material().Name();
726 //=======================================================================
727 //function : SetMaterial
729 //=======================================================================
730 void PrsMgr_PresentableObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
732 myDrawer->SetupOwnShadingAspect();
733 myDrawer->ShadingAspect()->SetMaterial (theMaterial);
734 hasOwnMaterial = Standard_True;
737 //=======================================================================
738 //function : UnsetMaterial
740 //=======================================================================
741 void PrsMgr_PresentableObject::UnsetMaterial()
748 if (HasColor() || IsTransparent())
750 if (myDrawer->HasLink())
752 myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Aspect()->BackMaterial());
757 SetColor (myDrawer->Color());
762 SetTransparency (myDrawer->Transparency());
767 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
770 hasOwnMaterial = Standard_False;
773 //=======================================================================
774 //function : SetTransparency
776 //=======================================================================
777 void PrsMgr_PresentableObject::SetTransparency (const Standard_Real theValue)
779 myDrawer->SetupOwnShadingAspect();
780 myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue));
781 myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (Standard_ShortReal(theValue));
782 myDrawer->SetTransparency (Standard_ShortReal(theValue));
785 //=======================================================================
786 //function : UnsetTransparency
788 //=======================================================================
789 void PrsMgr_PresentableObject::UnsetTransparency()
791 if (HasColor() || HasMaterial())
793 myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (0.0f);
794 myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (0.0f);
798 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
800 myDrawer->SetTransparency (0.0f);
803 //=======================================================================
804 //function : SetPolygonOffsets
806 //=======================================================================
807 void PrsMgr_PresentableObject::SetPolygonOffsets (const Standard_Integer theMode,
808 const Standard_ShortReal theFactor,
809 const Standard_ShortReal theUnits)
811 myDrawer->SetupOwnShadingAspect();
812 myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets (theMode, theFactor, theUnits);
813 SynchronizeAspects();
816 //=======================================================================
817 //function : HasPolygonOffsets
819 //=======================================================================
820 Standard_Boolean PrsMgr_PresentableObject::HasPolygonOffsets() const
822 return !(myDrawer->HasOwnShadingAspect()
823 || (myDrawer->HasLink()
824 && myDrawer->ShadingAspect() == myDrawer->Link()->ShadingAspect()));
827 //=======================================================================
828 //function : PolygonOffsets
830 //=======================================================================
831 void PrsMgr_PresentableObject::PolygonOffsets (Standard_Integer& theMode,
832 Standard_ShortReal& theFactor,
833 Standard_ShortReal& theUnits) const
835 if (HasPolygonOffsets())
837 myDrawer->ShadingAspect()->Aspect()->PolygonOffsets (theMode, theFactor, theUnits);
841 // =======================================================================
842 // function : DumpJson
844 // =======================================================================
845 void PrsMgr_PresentableObject::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
847 DUMP_CLASS_BEGIN (theOStream, PrsMgr_PresentableObject);
849 DUMP_FIELD_VALUE_POINTER (theOStream, myParent);
851 DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOwnWidth);
852 DUMP_FIELD_VALUE_NUMERICAL (theOStream, hasOwnColor);
853 DUMP_FIELD_VALUE_NUMERICAL (theOStream, hasOwnMaterial);
855 DUMP_FIELD_VALUE_NUMERICAL (theOStream, myInfiniteState);
856 DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsMutable);
857 DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnPresentations);