mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0028738: Data Exchange, XCAFPrs_Style - add transparency property
Use Quantity_ColorRGBA as surface color to store a transparency in XCAFPrs_Style.
This commit is contained in:
@@ -149,10 +149,10 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
else
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor);
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorSurf, aColor))
|
||||
@@ -161,7 +161,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor);
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
}
|
||||
|
||||
Quantity_Color aColor;
|
||||
Quantity_ColorRGBA aColor;
|
||||
XCAFPrs_Style aShuoStyle;
|
||||
if (!aColorTool->IsVisible (aShuolab))
|
||||
{
|
||||
@@ -199,7 +199,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
{
|
||||
if (aColorTool->GetColor (aShuolab, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
aShuoStyle.SetColorCurv (aColor);
|
||||
aShuoStyle.SetColorCurv (aColor.GetRGB());
|
||||
aShuoStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aShuolab, XCAFDoc_ColorSurf, aColor))
|
||||
@@ -208,7 +208,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
if (aColorTool->GetColor (aShuolab, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
aShuoStyle.SetColorCurv (aColor);
|
||||
aShuoStyle.SetColorCurv (aColor.GetRGB());
|
||||
}
|
||||
}
|
||||
if (!aShuoStyle.IsSetColorCurv()
|
||||
|
@@ -140,7 +140,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
XCAFPrs_Style aDefStyle;
|
||||
DefaultStyle (aDefStyle);
|
||||
Quantity_Color aColorCurv = aDefStyle.GetColorCurv();
|
||||
Quantity_Color aColorSurf = aDefStyle.GetColorSurf();
|
||||
Quantity_ColorRGBA aColorSurf = aDefStyle.GetColorSurfRGBA();
|
||||
|
||||
SetColors (myDrawer, aColorCurv, aColorSurf);
|
||||
|
||||
@@ -180,8 +180,8 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
const XCAFPrs_Style& aStyle = aStyleGroupIter.Key();
|
||||
aDrawer->SetHidden (!aStyle.IsVisible());
|
||||
|
||||
aColorCurv = aStyle.IsSetColorCurv() ? aStyle.GetColorCurv() : aDefStyle.GetColorCurv();
|
||||
aColorSurf = aStyle.IsSetColorSurf() ? aStyle.GetColorSurf() : aDefStyle.GetColorSurf();
|
||||
aColorCurv = aStyle.IsSetColorCurv() ? aStyle.GetColorCurv() : aDefStyle.GetColorCurv();
|
||||
aColorSurf = aStyle.IsSetColorSurf() ? aStyle.GetColorSurfRGBA() : aDefStyle.GetColorSurfRGBA();
|
||||
|
||||
SetColors (aDrawer, aColorCurv, aColorSurf);
|
||||
}
|
||||
@@ -244,7 +244,7 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& the
|
||||
//=======================================================================
|
||||
void XCAFPrs_AISObject::SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_Color& theColorSurf)
|
||||
const Quantity_ColorRGBA& theColorSurf)
|
||||
{
|
||||
if (!theDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
@@ -310,11 +310,12 @@ void XCAFPrs_AISObject::SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
theDrawer->WireAspect()->SetColor (theColorCurv);
|
||||
|
||||
Graphic3d_MaterialAspect aMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
|
||||
aMaterial.SetColor (theColorSurf);
|
||||
aMaterial.SetColor (theColorSurf.GetRGB());
|
||||
aMaterial.SetAlpha (theColorSurf.Alpha());
|
||||
theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (theColorSurf);
|
||||
theDrawer->ShadingAspect()->Aspect()->SetFrontMaterial (aMaterial);
|
||||
theDrawer->UIsoAspect()->SetColor (theColorSurf);
|
||||
theDrawer->VIsoAspect()->SetColor (theColorSurf);
|
||||
theDrawer->UIsoAspect()->SetColor (theColorSurf.GetRGB());
|
||||
theDrawer->VIsoAspect()->SetColor (theColorSurf.GetRGB());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -342,8 +343,8 @@ void XCAFPrs_AISObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||
|
||||
// take current color
|
||||
const Quantity_Color aColorCurv = aDrawer->WireAspect()->Aspect()->Color();
|
||||
const Quantity_Color aSurfColor = aDrawer->ShadingAspect()->Aspect()->InteriorColor();
|
||||
const Quantity_Color aColorCurv = aDrawer->WireAspect()->Aspect()->Color();
|
||||
const Quantity_ColorRGBA aSurfColor = aDrawer->ShadingAspect()->Aspect()->InteriorColorRGBA();
|
||||
|
||||
// SetColors() will take the material from myDrawer
|
||||
SetColors (aDrawer, aColorCurv, aSurfColor);
|
||||
|
@@ -60,7 +60,12 @@ protected:
|
||||
//! Set colors to drawer
|
||||
Standard_EXPORT void SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_Color& theColorSurf);
|
||||
const Quantity_ColorRGBA& theColorSurf);
|
||||
|
||||
//! Set colors to drawer
|
||||
void SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_Color& theColorSurf) { SetColors (theDrawer, theColorCurv, Quantity_ColorRGBA (theColorSurf)); }
|
||||
|
||||
//! Fills out a default style object which is used when styles are
|
||||
//! not explicitly defined in the document.
|
||||
|
@@ -31,7 +31,7 @@ XCAFPrs_Style::XCAFPrs_Style()
|
||||
//function : SetColorSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFPrs_Style::SetColorSurf (const Quantity_Color& theColor)
|
||||
void XCAFPrs_Style::SetColorSurf (const Quantity_ColorRGBA& theColor)
|
||||
{
|
||||
myColorSurf = theColor;
|
||||
myHasColorSurf = Standard_True;
|
||||
@@ -44,7 +44,8 @@ void XCAFPrs_Style::SetColorSurf (const Quantity_Color& theColor)
|
||||
void XCAFPrs_Style::UnSetColorSurf()
|
||||
{
|
||||
myHasColorSurf = Standard_False;
|
||||
myColorSurf.SetValues (Quantity_NOC_YELLOW);
|
||||
myColorSurf.ChangeRGB().SetValues (Quantity_NOC_YELLOW);
|
||||
myColorSurf.SetAlpha (1.0f);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Quantity_ColorHasher.hxx>
|
||||
#include <Quantity_ColorRGBAHasher.hxx>
|
||||
|
||||
//! Represents a set of styling settings applicable to a (sub)shape
|
||||
class XCAFPrs_Style
|
||||
@@ -35,11 +35,17 @@ public:
|
||||
Standard_Boolean IsSetColorSurf() const { return myHasColorSurf; }
|
||||
|
||||
//! Return surface color.
|
||||
const Quantity_Color& GetColorSurf() const { return myColorSurf; }
|
||||
const Quantity_Color& GetColorSurf() const { return myColorSurf.GetRGB(); }
|
||||
|
||||
//! Set surface color.
|
||||
Standard_EXPORT void SetColorSurf (const Quantity_Color& col);
|
||||
|
||||
void SetColorSurf (const Quantity_Color& theColor) { SetColorSurf (Quantity_ColorRGBA (theColor)); }
|
||||
|
||||
//! Return surface color.
|
||||
const Quantity_ColorRGBA& GetColorSurfRGBA() const { return myColorSurf; }
|
||||
|
||||
//! Set surface color.
|
||||
Standard_EXPORT void SetColorSurf (const Quantity_ColorRGBA& theColor);
|
||||
|
||||
//! Manage surface color setting
|
||||
Standard_EXPORT void UnSetColorSurf();
|
||||
|
||||
@@ -98,7 +104,7 @@ public:
|
||||
int aHashCode = 0;
|
||||
if (theStyle.myHasColorSurf)
|
||||
{
|
||||
aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorSurf, theUpper);
|
||||
aHashCode = aHashCode ^ Quantity_ColorRGBAHasher::HashCode (theStyle.myColorSurf, theUpper);
|
||||
}
|
||||
if (theStyle.myHasColorCurv)
|
||||
{
|
||||
@@ -115,11 +121,11 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
Quantity_Color myColorSurf;
|
||||
Quantity_Color myColorCurv;
|
||||
Standard_Boolean myHasColorSurf;
|
||||
Standard_Boolean myHasColorCurv;
|
||||
Standard_Boolean myIsVisible;
|
||||
Quantity_ColorRGBA myColorSurf;
|
||||
Quantity_Color myColorCurv;
|
||||
Standard_Boolean myHasColorSurf;
|
||||
Standard_Boolean myHasColorCurv;
|
||||
Standard_Boolean myIsVisible;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user