From 7389f96df05199f0ac0c4a23acbc4e4c5f874b0f Mon Sep 17 00:00:00 2001 From: dbp Date: Thu, 8 May 2014 11:26:39 +0400 Subject: [PATCH] 0023804: Visualization - unexpected color modulation during texture mapping AIS_TexturedShape - use material set to the Drawer, not default undefined one Test case for issue CR23804 --- src/AIS/AIS_TexturedShape.cxx | 21 +++++++++++++++++++-- src/AIS/AIS_TexturedShape.hxx | 3 +++ tests/bugs/vis/bug23804 | 25 +++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/vis/bug23804 diff --git a/src/AIS/AIS_TexturedShape.cxx b/src/AIS/AIS_TexturedShape.cxx index 1f5f56279c..e50d019b7b 100644 --- a/src/AIS/AIS_TexturedShape.cxx +++ b/src/AIS/AIS_TexturedShape.cxx @@ -188,6 +188,24 @@ void AIS_TexturedShape::DisableTextureModulate() myModulate = Standard_False; } +//======================================================================= +//function : SetColor +//purpose : +//======================================================================= + +void AIS_TexturedShape::SetColor (const Quantity_Color& theColor) +{ + AIS_Shape::SetColor (theColor); + + if (!GetContext().IsNull()) + { + if (GetContext()->MainPrsMgr()->HasPresentation (this, 3)) + { + updateAttributes (GetContext()->MainPrsMgr()->Presentation (this, 3)->Presentation()); + } + } +} + //======================================================================= //function : UpdateAttributes //purpose : @@ -205,8 +223,7 @@ void AIS_TexturedShape::UpdateAttributes() void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& thePrs) { - Prs3d_ShadingAspect aDummy; - myAspect = aDummy.Aspect(); + myAspect = new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect()); if (HasPolygonOffsets()) { // Issue 23115: copy polygon offset settings passed through myDrawer diff --git a/src/AIS/AIS_TexturedShape.hxx b/src/AIS/AIS_TexturedShape.hxx index 76ca3ab116..3247174130 100644 --- a/src/AIS/AIS_TexturedShape.hxx +++ b/src/AIS/AIS_TexturedShape.hxx @@ -98,6 +98,9 @@ public: //! @name methods to alter texture mapping properties //! @endcode Standard_EXPORT void UpdateAttributes(); + //! Sets the color + Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor); + //! Enables texture modulation Standard_EXPORT void EnableTextureModulate(); diff --git a/tests/bugs/vis/bug23804 b/tests/bugs/vis/bug23804 new file mode 100644 index 0000000000..baea5ec33e --- /dev/null +++ b/tests/bugs/vis/bug23804 @@ -0,0 +1,25 @@ +puts "============" +puts "CR23804" +puts "============" +puts "" + +############################################################ +# Unexpected color modulation during texture mapping +############################################################ + +box b 100 100 100 +vinit +vdisplay b +vfit +vsetdispmode b 1 +vsetmaterial b plastic +vdump $imagedir/${casename}_1.png + +vsetcolor b ANTIQUEWHITE +vdump $imagedir/${casename}_2.png + +vtexture b 3 +vdump $imagedir/${casename}_3.png + +vsetcolor b ANTIQUEWHITE +vdump $imagedir/${casename}_4.png