diff --git a/src/AIS/AIS_ColoredDrawer.hxx b/src/AIS/AIS_ColoredDrawer.hxx new file mode 100644 index 0000000000..b80be3f0c2 --- /dev/null +++ b/src/AIS/AIS_ColoredDrawer.hxx @@ -0,0 +1,54 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _AIS_ColoredDrawer_HeaderFile +#define _AIS_ColoredDrawer_HeaderFile + +#include +#include + +//! Customizable properties. +class AIS_ColoredDrawer : public Prs3d_Drawer +{ + DEFINE_STANDARD_RTTIEXT(AIS_ColoredDrawer, Prs3d_Drawer) +public: + + //! Default constructor. + AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink) + : myIsHidden (false), + myHasOwnColor (false), + myHasOwnWidth (false) + { + Link (theLink); + } + + bool IsHidden() const { return myIsHidden; } + void SetHidden (const bool theToHide) { myIsHidden = theToHide;} + bool HasOwnColor() const { return myHasOwnColor; } + void UnsetOwnColor() { myHasOwnColor = false; } + void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; } + bool HasOwnWidth() const { return myHasOwnWidth; } + void UnsetOwnWidth() { myHasOwnWidth = false; } + void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = true; } + +public: //! @name list of overridden properties + + bool myIsHidden; + bool myHasOwnColor; + bool myHasOwnWidth; + +}; + +DEFINE_STANDARD_HANDLE(AIS_ColoredDrawer, Prs3d_Drawer) + +#endif // _AIS_ColoredDrawer_HeaderFile diff --git a/src/AIS/AIS_ColoredShape.cxx b/src/AIS/AIS_ColoredShape.cxx index 6a639f9aa1..e8f20ddeda 100644 --- a/src/AIS/AIS_ColoredShape.cxx +++ b/src/AIS/AIS_ColoredShape.cxx @@ -195,7 +195,7 @@ void AIS_ColoredShape::SetColor (const Quantity_Color& theColor) hasOwnColor = Standard_True; LoadRecomputable (AIS_WireFrame); LoadRecomputable (AIS_Shaded); - for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) + for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) { const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value(); if (aDrawer->HasOwnColor()) @@ -229,7 +229,7 @@ void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth) myOwnWidth = theLineWidth; LoadRecomputable (AIS_WireFrame); LoadRecomputable (AIS_Shaded); - for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) + for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) { const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value(); if (aDrawer->HasOwnWidth()) @@ -259,7 +259,7 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue) myTransparency = theValue; LoadRecomputable (AIS_WireFrame); LoadRecomputable (AIS_Shaded); - for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) + for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) { const Handle(Prs3d_Drawer)& aDrawer = anIter.Value(); if (aDrawer->HasOwnShadingAspect()) @@ -280,7 +280,7 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial) //myOwnMaterial = theMaterial; hasOwnMaterial = Standard_True; LoadRecomputable (AIS_Shaded); - for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) + for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) { const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value(); //if (aDrawer->HasOwnMaterial()) continue; @@ -524,16 +524,16 @@ inline Standard_Boolean isFirstCmpContainSecondOne (const TopoDS_Shape& theFirst //function : dispatchColors //purpose : //======================================================================= -void AIS_ColoredShape::dispatchColors (const TopoDS_Shape& theBaseShape, - const DataMapOfShapeColor& theKeyshapeColorMap, - DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray) +void AIS_ColoredShape::dispatchColors (const TopoDS_Shape& theBaseShape, + const AIS_DataMapOfShapeDrawer& theKeyshapeColorMap, + DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray) { // Extract map (KeyshapeColored -> Color) // to subshapes map (Subshape -> KeyshapeColored). // This needed when colored shape is not part of // (but subshapes are) and actually container for subshapes. DataMapOfShapeShape aSubshapeKeyshapeMap; - for (DataMapOfShapeColor::Iterator aKeyShapeIter (theKeyshapeColorMap); + for (AIS_DataMapOfShapeDrawer::Iterator aKeyShapeIter (theKeyshapeColorMap); aKeyShapeIter.More(); aKeyShapeIter.Next()) { const TopoDS_Shape& aKeyShape = aKeyShapeIter.Key(); @@ -575,7 +575,7 @@ Standard_Boolean AIS_ColoredShape::isShapeEntirelyVisible (DataMapOfShapeCompd* //======================================================================= Standard_Boolean AIS_ColoredShape::isShapeEntirelyVisible() const { - for (DataMapOfShapeColor::Iterator aMapIter (myShapeColors); aMapIter.More(); aMapIter.Next()) + for (AIS_DataMapOfShapeDrawer::Iterator aMapIter (myShapeColors); aMapIter.More(); aMapIter.Next()) { if (aMapIter.Value()->IsHidden()) { diff --git a/src/AIS/AIS_ColoredShape.hxx b/src/AIS/AIS_ColoredShape.hxx index af37a86b2b..8ebbc565b6 100644 --- a/src/AIS/AIS_ColoredShape.hxx +++ b/src/AIS/AIS_ColoredShape.hxx @@ -16,49 +16,11 @@ #ifndef _AIS_ColoredShape_HeaderFile #define _AIS_ColoredShape_HeaderFile -#include +#include #include - -#include #include -#include -#include #include - -//! Customizable properties. -class AIS_ColoredDrawer : public Prs3d_Drawer -{ -public: - - AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink) - : myIsHidden (Standard_False), - myHasOwnColor (Standard_False), - myHasOwnWidth (Standard_False) - { - Link (theLink); - } - - Standard_Boolean IsHidden() const { return myIsHidden; } - void SetHidden (const Standard_Boolean theToHide) { myIsHidden = theToHide; } - Standard_Boolean HasOwnColor() const { return myHasOwnColor; } - void UnsetOwnColor() { myHasOwnColor = Standard_False; } - void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = Standard_True; } - Standard_Boolean HasOwnWidth() const { return myHasOwnWidth; } - void UnsetOwnWidth() { myHasOwnWidth = Standard_False; } - void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = Standard_True; } - -public: //! @name list of overridden properties - - Standard_Boolean myIsHidden; - Standard_Boolean myHasOwnColor; - Standard_Boolean myHasOwnWidth; - -public: - DEFINE_STANDARD_RTTIEXT(AIS_ColoredDrawer,Prs3d_Drawer) - -}; - -DEFINE_STANDARD_HANDLE(AIS_ColoredDrawer, Prs3d_Drawer) +#include //! Presentation of the shape with customizable sub-shapes properties. class AIS_ColoredShape : public AIS_Shape @@ -94,6 +56,12 @@ public: //! @name sub-shape aspects Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape, const Standard_Real theLineWidth); + //! Return the map of custom aspects. + const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; } + + //! Return the map of custom aspects. + AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; } + public: //! @name global aspects //! Setup color of entire shape. @@ -116,9 +84,8 @@ protected: //! @name override presentation computation protected: - typedef NCollection_DataMap DataMapOfShapeColor; - typedef NCollection_DataMap DataMapOfShapeShape; - typedef NCollection_IndexedDataMap DataMapOfShapeCompd; + typedef NCollection_DataMap DataMapOfShapeShape; + typedef NCollection_IndexedDataMap DataMapOfShapeCompd; protected: @@ -134,9 +101,9 @@ protected: const TopAbs_ShapeEnum theParentType, DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray); - Standard_EXPORT static void dispatchColors (const TopoDS_Shape& theBaseShape, - const DataMapOfShapeColor& theKeyshapeColorMap, - DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray); + Standard_EXPORT static void dispatchColors (const TopoDS_Shape& theBaseShape, + const AIS_DataMapOfShapeDrawer& theKeyshapeColorMap, + DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray); protected: @@ -171,7 +138,7 @@ protected: protected: - DataMapOfShapeColor myShapeColors; + AIS_DataMapOfShapeDrawer myShapeColors; public: diff --git a/src/AIS/AIS_DataMapOfShapeDrawer.hxx b/src/AIS/AIS_DataMapOfShapeDrawer.hxx new file mode 100644 index 0000000000..ffa340ea9e --- /dev/null +++ b/src/AIS/AIS_DataMapOfShapeDrawer.hxx @@ -0,0 +1,24 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _AIS_DataMapOfShapeDrawer_HeaderFile +#define _AIS_DataMapOfShapeDrawer_HeaderFile + +#include +#include +#include +#include + +typedef NCollection_DataMap AIS_DataMapOfShapeDrawer; + +#endif // _AIS_DataMapOfShapeDrawer_HeaderFile diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index d58f159619..80e93b6f7e 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -671,3 +671,50 @@ void AIS_InteractiveObject::SetIsoOnTriangulation (const Standard_Boolean theIsE { myDrawer->SetIsoOnTriangulation (theIsEnabled); } + +//======================================================================= +//function : SynchronizeAspects +//purpose : +//======================================================================= +void AIS_InteractiveObject::SynchronizeAspects() +{ + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) + { + const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation(); + if (aPrs3d.IsNull() + || aPrs3d->Presentation().IsNull()) + { + continue; + } + + for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next()) + { + Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue(); + if (aGrp.IsNull()) + { + continue; + } + + Handle(Graphic3d_AspectLine3d) aLineAspect = aGrp->LineAspect(); + Handle(Graphic3d_AspectFillArea3d) aFaceAspect = aGrp->FillAreaAspect(); + Handle(Graphic3d_AspectMarker3d) aMarkerAspect = aGrp->MarkerAspect(); + Handle(Graphic3d_AspectText3d) aTextAspect = aGrp->TextAspect(); + if (!aLineAspect.IsNull()) + { + aGrp->SetGroupPrimitivesAspect (aLineAspect); + } + if (!aFaceAspect.IsNull()) + { + aGrp->SetGroupPrimitivesAspect (aFaceAspect); + } + if (!aMarkerAspect.IsNull()) + { + aGrp->SetGroupPrimitivesAspect (aMarkerAspect); + } + if (!aTextAspect.IsNull()) + { + aGrp->SetGroupPrimitivesAspect (aTextAspect); + } + } + } +} diff --git a/src/AIS/AIS_InteractiveObject.hxx b/src/AIS/AIS_InteractiveObject.hxx index 5c2012cd95..d7a08e2760 100644 --- a/src/AIS/AIS_InteractiveObject.hxx +++ b/src/AIS/AIS_InteractiveObject.hxx @@ -453,6 +453,12 @@ public: //! Enables or disables on-triangulation build of isolines according to the flag given. Standard_EXPORT void SetIsoOnTriangulation (const Standard_Boolean theIsEnabled); + //! Synchronize presentation aspects after their modification. + //! + //! This method should be called after modifying primitive aspect properties (material, texture, shader) + //! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object). + Standard_EXPORT void SynchronizeAspects(); + friend class AIS_InteractiveContext; diff --git a/src/AIS/FILES b/src/AIS/FILES index 70d284bf6a..9a4bae746f 100644 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -22,8 +22,10 @@ AIS_Circle.cxx AIS_Circle.hxx AIS_Circle.lxx AIS_ClearMode.hxx +AIS_ColoredDrawer.hxx AIS_ColoredShape.cxx AIS_ColoredShape.hxx +AIS_DataMapOfShapeDrawer.hxx AIS_ColorScale.cxx AIS_ColorScale.hxx AIS_ConcentricRelation.cxx diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index 374e32d877..325b2260f6 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -13,6 +13,10 @@ // commercial license or contractual agreement. #include + +#include +#include +#include #include #include #include @@ -23,7 +27,6 @@ #include #include - IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer,MMgt_TShared) // ======================================================================= @@ -1069,3 +1072,185 @@ void Prs3d_Drawer::ClearLocalAttributes() myVertexDrawMode = Prs3d_VDM_Inherited; myTypeOfHLR = Prs3d_TOH_NotSet; } + +//! Copy line aspect defaults from the Link. +inline void copyLineAspect (const Handle(Prs3d_Drawer)& theLink, + Handle(Prs3d_LineAspect)& theAspect, + const Handle(Prs3d_LineAspect)& theBaseAspect) +{ + Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect; + if (!theLink.IsNull()) + { + theAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0); + *theAspect->Aspect() = *aBaseAspect->Aspect(); + } +} + +//! Assign the shader program. +template +inline void setAspectProgram (const Handle(Graphic3d_ShaderProgram)& theProgram, + T thePrsAspect) +{ + if (!thePrsAspect.IsNull()) + { + thePrsAspect->Aspect()->SetShaderProgram (theProgram); + } +} + +// ======================================================================= +// function : SetShaderProgram +// purpose : +// ======================================================================= +void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram, + const Graphic3d_GroupAspect theAspect, + const bool theToOverrideDefaults) +{ + switch (theAspect) + { + case Graphic3d_ASPECT_LINE: + { + if (theToOverrideDefaults) + { + if (myUIsoAspect.IsNull()) + { + Handle(Prs3d_IsoAspect) anAspect = UIsoAspect(); + if (!myLink.IsNull()) + { + myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1); + *myUIsoAspect->Aspect() = *anAspect->Aspect(); + myUIsoAspect->SetNumber (anAspect->Number()); + } + } + if (myVIsoAspect.IsNull()) + { + Handle(Prs3d_IsoAspect) anAspect = VIsoAspect(); + if (!myLink.IsNull()) + { + myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1); + *myVIsoAspect->Aspect() = *anAspect->Aspect(); + myUIsoAspect->SetNumber (anAspect->Number()); + } + } + if (myWireAspect.IsNull()) + { + copyLineAspect (myLink, myWireAspect, WireAspect()); + } + if (myLineAspect.IsNull()) + { + copyLineAspect (myLink, myLineAspect, LineAspect()); + } + if (mySeenLineAspect.IsNull()) + { + copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect()); + } + if (myHiddenLineAspect.IsNull()) + { + copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect()); + } + if (myVectorAspect.IsNull()) + { + copyLineAspect (myLink, myVectorAspect, VectorAspect()); + } + if (mySectionAspect.IsNull()) + { + copyLineAspect (myLink, mySectionAspect, SectionAspect()); + } + if (myFreeBoundaryAspect.IsNull()) + { + copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect()); + } + if (myUnFreeBoundaryAspect.IsNull()) + { + copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect()); + } + if (myFaceBoundaryAspect.IsNull()) + { + copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect()); + } + + if (myPlaneAspect.IsNull()) + { + myPlaneAspect = new Prs3d_PlaneAspect(); + } + if (myArrowAspect.IsNull()) + { + myArrowAspect = new Prs3d_ArrowAspect(); + } + if (myDatumAspect.IsNull()) + { + myDatumAspect = new Prs3d_DatumAspect(); + } + } + + setAspectProgram (theProgram, myUIsoAspect); + setAspectProgram (theProgram, myVIsoAspect); + setAspectProgram (theProgram, myWireAspect); + setAspectProgram (theProgram, myLineAspect); + setAspectProgram (theProgram, mySeenLineAspect); + setAspectProgram (theProgram, myHiddenLineAspect); + setAspectProgram (theProgram, myVectorAspect); + setAspectProgram (theProgram, mySectionAspect); + setAspectProgram (theProgram, myFreeBoundaryAspect); + setAspectProgram (theProgram, myUnFreeBoundaryAspect); + setAspectProgram (theProgram, myFaceBoundaryAspect); + if (!myPlaneAspect.IsNull()) + { + setAspectProgram (theProgram, myPlaneAspect->EdgesAspect()); + setAspectProgram (theProgram, myPlaneAspect->IsoAspect()); + setAspectProgram (theProgram, myPlaneAspect->ArrowAspect()); + } + if (!myDatumAspect.IsNull()) + { + setAspectProgram (theProgram, myDatumAspect->FirstAxisAspect()); + setAspectProgram (theProgram, myDatumAspect->SecondAxisAspect()); + setAspectProgram (theProgram, myDatumAspect->ThirdAxisAspect()); + } + setAspectProgram (theProgram, myArrowAspect); + return; + } + case Graphic3d_ASPECT_TEXT: + { + if (theToOverrideDefaults + && myTextAspect.IsNull()) + { + myTextAspect = new Prs3d_TextAspect(); + if (!myLink.IsNull()) + { + *myTextAspect->Aspect() = *myLink->TextAspect()->Aspect(); + } + } + + setAspectProgram (theProgram, myTextAspect); + return; + } + case Graphic3d_ASPECT_MARKER: + { + if (theToOverrideDefaults + && myPointAspect.IsNull()) + { + myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0); + if (!myLink.IsNull()) + { + *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect(); + } + } + + setAspectProgram (theProgram, myPointAspect); + return; + } + case Graphic3d_ASPECT_FILL_AREA: + { + if (myShadingAspect.IsNull() + && theToOverrideDefaults) + { + myShadingAspect = new Prs3d_ShadingAspect(); + if (!myLink.IsNull()) + { + *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect(); + } + } + setAspectProgram (theProgram, myShadingAspect); + return; + } + } +} diff --git a/src/Prs3d/Prs3d_Drawer.hxx b/src/Prs3d/Prs3d_Drawer.hxx index a114f12194..2126e1d31a 100644 --- a/src/Prs3d/Prs3d_Drawer.hxx +++ b/src/Prs3d/Prs3d_Drawer.hxx @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -854,6 +856,15 @@ public: //! Removes local attributes. Standard_EXPORT void ClearLocalAttributes(); + //! Assign shader program for specified type of primitives. + //! @param theProgram new program to set (might be NULL) + //! @param theAspect the type of primitives + //! @param theToOverrideDefaults if true then non-overridden attributes using defaults will be allocated and copied from the Link; + //! otherwise, only already customized attributes will be changed + Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram, + const Graphic3d_GroupAspect theAspect, + const bool theToOverrideDefaults = false); + protected: Handle(Prs3d_Drawer) myLink; diff --git a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx index f11ef395ab..51d3911d6a 100644 --- a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx +++ b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx @@ -554,11 +554,24 @@ static Standard_Integer VShaderProg (Draw_Interpretor& /*theDI*/, anIter.More(); anIter.Next()) { anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); - if (!anIO.IsNull()) + if (anIO.IsNull()) { - anIO->Attributes()->ShadingAspect()->Aspect()->SetShaderProgram (aProgram); + continue; + } + + if (!anIO->Attributes()->HasOwnShadingAspect()) + { + Handle(Prs3d_ShadingAspect) aNewAspect = new Prs3d_ShadingAspect(); + *aNewAspect->Aspect() = *anIO->Attributes()->ShadingAspect()->Aspect(); + aNewAspect->Aspect()->SetShaderProgram (aProgram); + anIO->Attributes()->SetShadingAspect (aNewAspect); aCtx->Redisplay (anIO, Standard_False); } + else + { + anIO->Attributes()->SetShaderProgram (aProgram, Graphic3d_ASPECT_FILL_AREA); + anIO->SynchronizeAspects(); + } } aCtx->UpdateCurrentViewer(); return 0; @@ -578,8 +591,20 @@ static Standard_Integer VShaderProg (Draw_Interpretor& /*theDI*/, std::cerr << "Warning: " << aName.ToCString() << " is not an AIS object\n"; continue; } - anIO->Attributes()->ShadingAspect()->Aspect()->SetShaderProgram (aProgram); - aCtx->Redisplay (anIO, Standard_False); + + if (!anIO->Attributes()->HasOwnShadingAspect()) + { + Handle(Prs3d_ShadingAspect) aNewAspect = new Prs3d_ShadingAspect(); + *aNewAspect->Aspect() = *anIO->Attributes()->ShadingAspect()->Aspect(); + aNewAspect->Aspect()->SetShaderProgram (aProgram); + anIO->Attributes()->SetShadingAspect (aNewAspect); + aCtx->Redisplay (anIO, Standard_False); + } + else + { + anIO->Attributes()->SetShaderProgram (aProgram, Graphic3d_ASPECT_FILL_AREA); + anIO->SynchronizeAspects(); + } } aCtx->UpdateCurrentViewer();