mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0024930: Visualization - SetMaterial/UnsetMaterial/UnsetColor are not implemented for AIS_TexturedShape
Correction of test case for issue CR24930
This commit is contained in:
parent
0499eb0670
commit
735dc1d26e
@ -16,6 +16,7 @@
|
|||||||
#include <AIS_TexturedShape.hxx>
|
#include <AIS_TexturedShape.hxx>
|
||||||
|
|
||||||
#include <AIS_Drawer.hxx>
|
#include <AIS_Drawer.hxx>
|
||||||
|
#include <AIS_GraphicTool.hxx>
|
||||||
#include <AIS_InteractiveContext.hxx>
|
#include <AIS_InteractiveContext.hxx>
|
||||||
#include <BRepTools.hxx>
|
#include <BRepTools.hxx>
|
||||||
#include <gp_Pnt2d.hxx>
|
#include <gp_Pnt2d.hxx>
|
||||||
@ -25,7 +26,9 @@
|
|||||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
#include <Prs3d_Presentation.hxx>
|
#include <Prs3d_Presentation.hxx>
|
||||||
|
#include <PrsMgr_ModedPresentation.hxx>
|
||||||
#include <Prs3d_Root.hxx>
|
#include <Prs3d_Root.hxx>
|
||||||
|
#include <Prs3d_LineAspect.hxx>
|
||||||
#include <Prs3d_ShadingAspect.hxx>
|
#include <Prs3d_ShadingAspect.hxx>
|
||||||
#include <PrsMgr_PresentationManager3d.hxx>
|
#include <PrsMgr_PresentationManager3d.hxx>
|
||||||
#include <Standard_ErrorHandler.hxx>
|
#include <Standard_ErrorHandler.hxx>
|
||||||
@ -197,12 +200,95 @@ void AIS_TexturedShape::SetColor (const Quantity_Color& theColor)
|
|||||||
{
|
{
|
||||||
AIS_Shape::SetColor (theColor);
|
AIS_Shape::SetColor (theColor);
|
||||||
|
|
||||||
if (!GetContext().IsNull())
|
for (Standard_Integer aPrsIt = 1; aPrsIt <= Presentations().Length(); ++aPrsIt)
|
||||||
{
|
{
|
||||||
if (GetContext()->MainPrsMgr()->HasPresentation (this, 3))
|
const PrsMgr_ModedPresentation& aPrsModed = Presentations().Value (aPrsIt);
|
||||||
|
|
||||||
|
if (aPrsModed.Mode() != 3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
updateAttributes (aPrsModed.Presentation()->Presentation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : UnsetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void AIS_TexturedShape::UnsetColor()
|
||||||
|
{
|
||||||
|
AIS_Shape::UnsetColor();
|
||||||
|
|
||||||
|
for (Standard_Integer aPrsIt = 1; aPrsIt <= Presentations().Length(); ++aPrsIt)
|
||||||
|
{
|
||||||
|
const PrsMgr_ModedPresentation& aPrsModed = Presentations().Value (aPrsIt);
|
||||||
|
|
||||||
|
if (aPrsModed.Mode() != 3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Handle(Prs3d_Presentation) aPrs = aPrsModed.Presentation()->Presentation();
|
||||||
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
|
||||||
|
|
||||||
|
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
|
||||||
|
Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
|
||||||
|
Quantity_Color aColor;
|
||||||
|
AIS_GraphicTool::GetInteriorColor (myDrawer->Link(), aColor);
|
||||||
|
anAreaAsp->SetInteriorColor (aColor);
|
||||||
|
aPrs->SetPrimitivesAspect (anAreaAsp);
|
||||||
|
aPrs->SetPrimitivesAspect (aLineAsp);
|
||||||
|
// Check if aspect of given type is set for the group,
|
||||||
|
// because setting aspect for group with no already set aspect
|
||||||
|
// can lead to loss of presentation data
|
||||||
|
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
|
||||||
{
|
{
|
||||||
updateAttributes (GetContext()->MainPrsMgr()->Presentation (this, 3)->Presentation());
|
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
|
||||||
}
|
}
|
||||||
|
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
|
||||||
|
{
|
||||||
|
aGroup->SetGroupPrimitivesAspect (aLineAsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateAttributes (aPrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetMaterial
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void AIS_TexturedShape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
|
||||||
|
{
|
||||||
|
AIS_Shape::SetMaterial (theMat);
|
||||||
|
|
||||||
|
for (Standard_Integer aPrsIt = 1; aPrsIt <= Presentations().Length(); ++aPrsIt)
|
||||||
|
{
|
||||||
|
const PrsMgr_ModedPresentation& aPrsModed = Presentations().Value (aPrsIt);
|
||||||
|
|
||||||
|
if (aPrsModed.Mode() != 3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
updateAttributes (aPrsModed.Presentation()->Presentation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : UnsetMaterial
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_TexturedShape::UnsetMaterial()
|
||||||
|
{
|
||||||
|
AIS_Shape::UnsetMaterial();
|
||||||
|
|
||||||
|
for (Standard_Integer aPrsIt = 1; aPrsIt <= Presentations().Length(); ++aPrsIt)
|
||||||
|
{
|
||||||
|
const PrsMgr_ModedPresentation& aPrsModed = Presentations().Value (aPrsIt);
|
||||||
|
|
||||||
|
if (aPrsModed.Mode() != 3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
updateAttributes (aPrsModed.Presentation()->Presentation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +367,15 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
|
|||||||
myAspect->AllowBackFace();
|
myAspect->AllowBackFace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thePrs.IsNull())
|
// Go through all groups to change fill aspect for all primitives
|
||||||
|
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
|
||||||
{
|
{
|
||||||
Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (myAspect);
|
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
|
||||||
|
|
||||||
|
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
|
||||||
|
{
|
||||||
|
aGroup->SetGroupPrimitivesAspect (myAspect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +98,18 @@ public: //! @name methods to alter texture mapping properties
|
|||||||
//! @endcode
|
//! @endcode
|
||||||
Standard_EXPORT void UpdateAttributes();
|
Standard_EXPORT void UpdateAttributes();
|
||||||
|
|
||||||
//! Sets the color
|
//! Sets the color.
|
||||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor);
|
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor);
|
||||||
|
|
||||||
|
//! Removes settings for the color.
|
||||||
|
Standard_EXPORT virtual void UnsetColor();
|
||||||
|
|
||||||
|
//! Sets the material aspect.
|
||||||
|
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect);
|
||||||
|
|
||||||
|
//! Removes settings for material aspect.
|
||||||
|
Standard_EXPORT virtual void UnsetMaterial();
|
||||||
|
|
||||||
//! Enables texture modulation
|
//! Enables texture modulation
|
||||||
Standard_EXPORT void EnableTextureModulate();
|
Standard_EXPORT void EnableTextureModulate();
|
||||||
|
|
||||||
|
64
tests/bugs/vis/bug24930
Executable file
64
tests/bugs/vis/bug24930
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC24930"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload QAcommands
|
||||||
|
|
||||||
|
box b 10 10 10
|
||||||
|
vinit
|
||||||
|
vdisplay b
|
||||||
|
vsetdispmode b 1
|
||||||
|
vfit
|
||||||
|
|
||||||
|
#
|
||||||
|
set anImage_1 ${imagedir}/${casename}_1.png
|
||||||
|
vdump ${anImage_1}
|
||||||
|
#
|
||||||
|
|
||||||
|
# Enable texture
|
||||||
|
vtexture b 0
|
||||||
|
|
||||||
|
#
|
||||||
|
set anImage_2 ${imagedir}/${casename}_2.png
|
||||||
|
vdump ${anImage_2}
|
||||||
|
#
|
||||||
|
|
||||||
|
# Set new color
|
||||||
|
vsetcolor b GREEN
|
||||||
|
# Check pixel color
|
||||||
|
checkcolor 205 180 0 0.64705884456634521 0
|
||||||
|
|
||||||
|
#
|
||||||
|
set anImage_3 ${imagedir}/${casename}_3.png
|
||||||
|
vdump ${anImage_3}
|
||||||
|
#
|
||||||
|
# Reset color
|
||||||
|
vunsetcolor b
|
||||||
|
# Check pixel color
|
||||||
|
checkcolor 205 180 0.608 0.431 0.071
|
||||||
|
|
||||||
|
#
|
||||||
|
set anImage_4 ${imagedir}/${casename}_4.png
|
||||||
|
vdump ${anImage_4}
|
||||||
|
#
|
||||||
|
|
||||||
|
# Set new material
|
||||||
|
vsetmaterial b silver
|
||||||
|
# Check pixel color
|
||||||
|
checkcolor 205 180 0.380 0.380 0.380
|
||||||
|
|
||||||
|
#
|
||||||
|
set anImage_5 ${imagedir}/${casename}_5.png
|
||||||
|
vdump ${anImage_5}
|
||||||
|
#
|
||||||
|
|
||||||
|
# Unset material
|
||||||
|
vunsetmaterial b
|
||||||
|
# Check pixel color
|
||||||
|
checkcolor 205 180 0.608 0.431 0.706
|
||||||
|
|
||||||
|
#
|
||||||
|
set anImage_6 ${imagedir}/${casename}_6.png
|
||||||
|
vdump ${anImage_6}
|
||||||
|
#
|
Loading…
x
Reference in New Issue
Block a user