mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0028641: Data Exchange - Support alpha-channel of color
Use Quantity_ColorRGBA instead Quantity_Color in XCAFDoc_Color attribute Add methods to color tool for processing RGBA Update Color driver Update Draw commands
This commit is contained in:
parent
1406e955b3
commit
973d410ea4
@ -49,9 +49,13 @@ Standard_Boolean BinMXCAFDoc_ColorDriver::Paste(const BinObjMgt_Persistent& theS
|
|||||||
{
|
{
|
||||||
Handle(XCAFDoc_Color) anAtt = Handle(XCAFDoc_Color)::DownCast(theTarget);
|
Handle(XCAFDoc_Color) anAtt = Handle(XCAFDoc_Color)::DownCast(theTarget);
|
||||||
Standard_Real R, G, B;
|
Standard_Real R, G, B;
|
||||||
|
Standard_ShortReal alpha;
|
||||||
Standard_Boolean isOk = theSource >> R >> G >> B;
|
Standard_Boolean isOk = theSource >> R >> G >> B;
|
||||||
if(isOk) {
|
if(isOk) {
|
||||||
anAtt->Set(R, G, B);
|
Standard_Boolean isRGBA = theSource >> alpha;
|
||||||
|
if (!isRGBA)
|
||||||
|
alpha = 1.0;
|
||||||
|
anAtt->Set(R, G, B, alpha);
|
||||||
}
|
}
|
||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
@ -66,7 +70,9 @@ void BinMXCAFDoc_ColorDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
|||||||
{
|
{
|
||||||
Handle(XCAFDoc_Color) anAtt = Handle(XCAFDoc_Color)::DownCast(theSource);
|
Handle(XCAFDoc_Color) anAtt = Handle(XCAFDoc_Color)::DownCast(theSource);
|
||||||
Standard_Real R, G, B;
|
Standard_Real R, G, B;
|
||||||
|
Standard_ShortReal alpha;
|
||||||
anAtt->GetRGB(R, G, B);
|
anAtt->GetRGB(R, G, B);
|
||||||
theTarget << R << G << B;
|
alpha = anAtt->GetAlpha();
|
||||||
|
theTarget << R << G << B << alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
|
#include <Quantity_ColorRGBA.hxx>
|
||||||
#include <Standard_GUID.hxx>
|
#include <Standard_GUID.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
#include <TDF_Attribute.hxx>
|
#include <TDF_Attribute.hxx>
|
||||||
@ -60,6 +61,23 @@ const Standard_GUID& XCAFDoc_Color::GetID()
|
|||||||
return A;
|
return A;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Set
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
||||||
|
const Quantity_ColorRGBA& C)
|
||||||
|
{
|
||||||
|
Handle(XCAFDoc_Color) A;
|
||||||
|
if (!L.FindAttribute(XCAFDoc_Color::GetID(), A)) {
|
||||||
|
A = new XCAFDoc_Color();
|
||||||
|
L.AddAttribute(A);
|
||||||
|
}
|
||||||
|
A->Set(C);
|
||||||
|
return A;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Set
|
//function : Set
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -83,16 +101,17 @@ const Standard_GUID& XCAFDoc_Color::GetID()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
||||||
const Standard_Real R,
|
const Standard_Real R,
|
||||||
const Standard_Real G,
|
const Standard_Real G,
|
||||||
const Standard_Real B)
|
const Standard_Real B,
|
||||||
|
const Standard_Real alpha)
|
||||||
{
|
{
|
||||||
Handle(XCAFDoc_Color) A;
|
Handle(XCAFDoc_Color) A;
|
||||||
if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
|
if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
|
||||||
A = new XCAFDoc_Color ();
|
A = new XCAFDoc_Color ();
|
||||||
L.AddAttribute(A);
|
L.AddAttribute(A);
|
||||||
}
|
}
|
||||||
A->Set (R,G,B);
|
A->Set (R,G,B, alpha);
|
||||||
return A;
|
return A;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +121,17 @@ Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void XCAFDoc_Color::Set(const Quantity_Color& C)
|
void XCAFDoc_Color::Set(const Quantity_Color& C)
|
||||||
|
{
|
||||||
|
Backup();
|
||||||
|
myColor.SetRGB(C);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Set
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void XCAFDoc_Color::Set(const Quantity_ColorRGBA& C)
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myColor = C;
|
myColor = C;
|
||||||
@ -115,7 +145,7 @@ void XCAFDoc_Color::Set(const Quantity_Color& C)
|
|||||||
void XCAFDoc_Color::Set(const Quantity_NameOfColor C)
|
void XCAFDoc_Color::Set(const Quantity_NameOfColor C)
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myColor.SetValues(C);
|
myColor.SetRGB(C);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -124,11 +154,15 @@ void XCAFDoc_Color::Set(const Quantity_Color& C)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void XCAFDoc_Color::Set(const Standard_Real R,
|
void XCAFDoc_Color::Set(const Standard_Real R,
|
||||||
const Standard_Real G,
|
const Standard_Real G,
|
||||||
const Standard_Real B)
|
const Standard_Real B,
|
||||||
|
const Standard_Real alpha)
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myColor.SetValues(R,G,B, Quantity_TOC_RGB);
|
Quantity_Color aColor;
|
||||||
|
aColor.SetValues(R, G, B, Quantity_TOC_RGB);
|
||||||
|
myColor.SetRGB(aColor);
|
||||||
|
myColor.SetAlpha((Standard_ShortReal)alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -137,6 +171,16 @@ void XCAFDoc_Color::Set(const Quantity_Color& C)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
const Quantity_Color& XCAFDoc_Color::GetColor() const
|
const Quantity_Color& XCAFDoc_Color::GetColor() const
|
||||||
|
{
|
||||||
|
return myColor.GetRGB();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetColorRGBA
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
const Quantity_ColorRGBA& XCAFDoc_Color::GetColorRGBA() const
|
||||||
{
|
{
|
||||||
return myColor;
|
return myColor;
|
||||||
}
|
}
|
||||||
@ -148,7 +192,7 @@ const Quantity_Color& XCAFDoc_Color::GetColor() const
|
|||||||
|
|
||||||
Quantity_NameOfColor XCAFDoc_Color::GetNOC() const
|
Quantity_NameOfColor XCAFDoc_Color::GetNOC() const
|
||||||
{
|
{
|
||||||
return myColor.Name();
|
return myColor.GetRGB().Name();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -160,8 +204,18 @@ const Quantity_Color& XCAFDoc_Color::GetColor() const
|
|||||||
Standard_Real& G,
|
Standard_Real& G,
|
||||||
Standard_Real& B) const
|
Standard_Real& B) const
|
||||||
{
|
{
|
||||||
myColor.Values(R,G,B, Quantity_TOC_RGB);
|
myColor.GetRGB().Values(R,G,B, Quantity_TOC_RGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetRGBA
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_ShortReal XCAFDoc_Color::GetAlpha() const
|
||||||
|
{
|
||||||
|
return myColor.Alpha();
|
||||||
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ID
|
//function : ID
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -179,7 +233,7 @@ const Standard_GUID& XCAFDoc_Color::ID() const
|
|||||||
|
|
||||||
void XCAFDoc_Color::Restore(const Handle(TDF_Attribute)& With)
|
void XCAFDoc_Color::Restore(const Handle(TDF_Attribute)& With)
|
||||||
{
|
{
|
||||||
myColor = Handle(XCAFDoc_Color)::DownCast(With)->GetColor();
|
myColor = Handle(XCAFDoc_Color)::DownCast(With)->GetColorRGBA();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
|
#include <Quantity_ColorRGBA.hxx>
|
||||||
#include <TDF_Attribute.hxx>
|
#include <TDF_Attribute.hxx>
|
||||||
#include <Quantity_NameOfColor.hxx>
|
#include <Quantity_NameOfColor.hxx>
|
||||||
#include <Standard_Real.hxx>
|
#include <Standard_Real.hxx>
|
||||||
class Standard_GUID;
|
class Standard_GUID;
|
||||||
class TDF_Label;
|
class TDF_Label;
|
||||||
class Quantity_Color;
|
class Quantity_Color;
|
||||||
|
class Quantity_ColorRGBA;
|
||||||
class TDF_Attribute;
|
class TDF_Attribute;
|
||||||
class TDF_RelocationTable;
|
class TDF_RelocationTable;
|
||||||
|
|
||||||
@ -45,25 +47,32 @@ public:
|
|||||||
Standard_EXPORT static const Standard_GUID& GetID();
|
Standard_EXPORT static const Standard_GUID& GetID();
|
||||||
|
|
||||||
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Quantity_Color& C);
|
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Quantity_Color& C);
|
||||||
|
|
||||||
|
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Quantity_ColorRGBA& C);
|
||||||
|
|
||||||
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Quantity_NameOfColor C);
|
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Quantity_NameOfColor C);
|
||||||
|
|
||||||
//! Find, or create, a Color attribute and set it's value
|
//! Find, or create, a Color attribute and set it's value
|
||||||
//! the Color attribute is returned.
|
//! the Color attribute is returned.
|
||||||
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Standard_Real R, const Standard_Real G, const Standard_Real B);
|
Standard_EXPORT static Handle(XCAFDoc_Color) Set (const TDF_Label& label, const Standard_Real R, const Standard_Real G, const Standard_Real B, const Standard_Real alpha = 1.0);
|
||||||
|
|
||||||
Standard_EXPORT void Set (const Quantity_Color& C);
|
Standard_EXPORT void Set (const Quantity_Color& C);
|
||||||
|
|
||||||
|
Standard_EXPORT void Set (const Quantity_ColorRGBA& C);
|
||||||
|
|
||||||
Standard_EXPORT void Set (const Quantity_NameOfColor C);
|
Standard_EXPORT void Set (const Quantity_NameOfColor C);
|
||||||
|
|
||||||
Standard_EXPORT void Set (const Standard_Real R, const Standard_Real G, const Standard_Real B);
|
Standard_EXPORT void Set (const Standard_Real R, const Standard_Real G, const Standard_Real B, const Standard_Real alpha = 1.0);
|
||||||
|
|
||||||
Standard_EXPORT const Quantity_Color& GetColor() const;
|
Standard_EXPORT const Quantity_Color& GetColor() const;
|
||||||
|
|
||||||
|
Standard_EXPORT const Quantity_ColorRGBA& GetColorRGBA() const;
|
||||||
|
|
||||||
Standard_EXPORT Quantity_NameOfColor GetNOC() const;
|
Standard_EXPORT Quantity_NameOfColor GetNOC() const;
|
||||||
|
|
||||||
//! Returns True if there is a reference on the same label
|
|
||||||
Standard_EXPORT void GetRGB (Standard_Real& R, Standard_Real& G, Standard_Real& B) const;
|
Standard_EXPORT void GetRGB (Standard_Real& R, Standard_Real& G, Standard_Real& B) const;
|
||||||
|
|
||||||
|
Standard_EXPORT Standard_ShortReal GetAlpha() const;
|
||||||
|
|
||||||
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
|
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
|
||||||
|
|
||||||
@ -86,7 +95,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
Quantity_Color myColor;
|
Quantity_ColorRGBA myColor;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -76,14 +76,29 @@ Standard_Boolean XCAFDoc_ColorTool::IsColor (const TDF_Label& lab) const
|
|||||||
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& lab,
|
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& lab,
|
||||||
Quantity_Color& col) const
|
Quantity_Color& col) const
|
||||||
{
|
{
|
||||||
if ( lab.Father() != Label() ) return Standard_False;
|
Quantity_ColorRGBA aCol;
|
||||||
|
Standard_Boolean isDone = GetColor(lab, aCol);
|
||||||
|
if (isDone)
|
||||||
|
col = aCol.GetRGB();
|
||||||
|
return isDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::GetColor(const TDF_Label& lab,
|
||||||
|
Quantity_ColorRGBA& col) const
|
||||||
|
{
|
||||||
|
if (lab.Father() != Label()) return Standard_False;
|
||||||
|
|
||||||
Handle(XCAFDoc_Color) ColorAttribute;
|
Handle(XCAFDoc_Color) ColorAttribute;
|
||||||
if ( ! lab.FindAttribute ( XCAFDoc_Color::GetID(), ColorAttribute ))
|
if (!lab.FindAttribute(XCAFDoc_Color::GetID(), ColorAttribute))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
col = ColorAttribute->GetColor();
|
col = ColorAttribute->GetColorRGBA();
|
||||||
|
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,12 +109,24 @@ Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& lab,
|
|||||||
|
|
||||||
Standard_Boolean XCAFDoc_ColorTool::FindColor (const Quantity_Color& col, TDF_Label& lab) const
|
Standard_Boolean XCAFDoc_ColorTool::FindColor (const Quantity_Color& col, TDF_Label& lab) const
|
||||||
{
|
{
|
||||||
TDF_ChildIDIterator it(Label(),XCAFDoc_Color::GetID());
|
Quantity_ColorRGBA aCol;
|
||||||
|
aCol.SetRGB(col);
|
||||||
|
return FindColor(aCol, lab);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FindColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::FindColor(const Quantity_ColorRGBA& col, TDF_Label& lab) const
|
||||||
|
{
|
||||||
|
TDF_ChildIDIterator it(Label(), XCAFDoc_Color::GetID());
|
||||||
for (; it.More(); it.Next()) {
|
for (; it.More(); it.Next()) {
|
||||||
TDF_Label aLabel = it.Value()->Label();
|
TDF_Label aLabel = it.Value()->Label();
|
||||||
Quantity_Color C;
|
Quantity_ColorRGBA C;
|
||||||
if ( ! GetColor ( aLabel, C ) ) continue;
|
if (!GetColor(aLabel, C)) continue;
|
||||||
if ( C.IsEqual ( col ) ) {
|
if (C.IsEqual(col)) {
|
||||||
lab = aLabel;
|
lab = aLabel;
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
@ -112,44 +139,71 @@ Standard_Boolean XCAFDoc_ColorTool::FindColor (const Quantity_Color& col, TDF_La
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
TDF_Label XCAFDoc_ColorTool::FindColor (const Quantity_Color& col) const
|
TDF_Label XCAFDoc_ColorTool::FindColor (const Quantity_ColorRGBA& col) const
|
||||||
{
|
{
|
||||||
TDF_Label L;
|
TDF_Label L;
|
||||||
FindColor ( col, L );
|
FindColor ( col, L );
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FindColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TDF_Label XCAFDoc_ColorTool::FindColor(const Quantity_Color& col) const
|
||||||
|
{
|
||||||
|
TDF_Label L;
|
||||||
|
FindColor(col, L);
|
||||||
|
return L;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AddColor
|
//function : AddColor
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_Color& col) const
|
TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_Color& col) const
|
||||||
|
{
|
||||||
|
Quantity_ColorRGBA aCol;
|
||||||
|
aCol.SetRGB(col);
|
||||||
|
return AddColor(aCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TDF_Label XCAFDoc_ColorTool::AddColor(const Quantity_ColorRGBA& col) const
|
||||||
{
|
{
|
||||||
TDF_Label L;
|
TDF_Label L;
|
||||||
if ( FindColor ( col, L ) ) return L;
|
if (FindColor(col, L)) return L;
|
||||||
|
|
||||||
// create a new color entry
|
// create a new color entry
|
||||||
|
|
||||||
TDF_TagSource aTag;
|
TDF_TagSource aTag;
|
||||||
L = aTag.NewChild ( Label() );
|
L = aTag.NewChild(Label());
|
||||||
|
|
||||||
XCAFDoc_Color::Set(L, col);
|
XCAFDoc_Color::Set(L, col);
|
||||||
|
|
||||||
#ifdef AUTONAMING
|
#ifdef AUTONAMING
|
||||||
// set name according to color value
|
// set name according to color value
|
||||||
TCollection_AsciiString str;
|
TCollection_AsciiString str;
|
||||||
str += col.StringName ( col.Name() );
|
Quantity_Color aColor = col.GetRGB();
|
||||||
|
str += aColor.StringName(aColor.Name());
|
||||||
str += " (";
|
str += " (";
|
||||||
str += TCollection_AsciiString ( col.Red() );
|
str += TCollection_AsciiString(aColor.Red());
|
||||||
str += ",";
|
str += ",";
|
||||||
str += TCollection_AsciiString ( col.Green() );
|
str += TCollection_AsciiString(aColor.Green());
|
||||||
str += ",";
|
str += ",";
|
||||||
str += TCollection_AsciiString ( col.Blue() );
|
str += TCollection_AsciiString(aColor.Blue());
|
||||||
|
str += ",";
|
||||||
|
str += TCollection_AsciiString(col.Alpha());
|
||||||
str += ")";
|
str += ")";
|
||||||
TDataStd_Name::Set ( L, str );
|
TDataStd_Name::Set(L, str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +263,19 @@ void XCAFDoc_ColorTool::SetColor (const TDF_Label& L,
|
|||||||
SetColor ( L, colorL, type );
|
SetColor ( L, colorL, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void XCAFDoc_ColorTool::SetColor(const TDF_Label& L,
|
||||||
|
const Quantity_ColorRGBA& Color,
|
||||||
|
const XCAFDoc_ColorType type) const
|
||||||
|
{
|
||||||
|
TDF_Label colorL = AddColor(Color);
|
||||||
|
SetColor(L, colorL, type);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : UnSetColor
|
//function : UnSetColor
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -260,6 +327,20 @@ Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& L,
|
|||||||
return GetColor ( colorL, color );
|
return GetColor ( colorL, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::GetColor(const TDF_Label& L,
|
||||||
|
const XCAFDoc_ColorType type,
|
||||||
|
Quantity_ColorRGBA& color)
|
||||||
|
{
|
||||||
|
TDF_Label colorL;
|
||||||
|
if (!GetColor(L, type, colorL)) return Standard_False;
|
||||||
|
return GetColor(colorL, color);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetColor
|
//function : SetColor
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -288,6 +369,19 @@ Standard_Boolean XCAFDoc_ColorTool::SetColor (const TopoDS_Shape& S,
|
|||||||
return SetColor ( S, colorL, type );
|
return SetColor ( S, colorL, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::SetColor(const TopoDS_Shape& S,
|
||||||
|
const Quantity_ColorRGBA& Color,
|
||||||
|
const XCAFDoc_ColorType type)
|
||||||
|
{
|
||||||
|
TDF_Label colorL = AddColor(Color);
|
||||||
|
return SetColor(S, colorL, type);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : UnSetColor
|
//function : UnSetColor
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -343,6 +437,20 @@ Standard_Boolean XCAFDoc_ColorTool::GetColor (const TopoDS_Shape& S,
|
|||||||
return GetColor ( colorL, color );
|
return GetColor ( colorL, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::GetColor(const TopoDS_Shape& S,
|
||||||
|
const XCAFDoc_ColorType type,
|
||||||
|
Quantity_ColorRGBA& color)
|
||||||
|
{
|
||||||
|
TDF_Label colorL;
|
||||||
|
if (!GetColor(S, type, colorL)) return Standard_False;
|
||||||
|
return GetColor(colorL, color);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetID
|
//function : GetID
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -459,28 +567,44 @@ Standard_Boolean XCAFDoc_ColorTool::SetInstanceColor (const TopoDS_Shape& theSha
|
|||||||
const XCAFDoc_ColorType type,
|
const XCAFDoc_ColorType type,
|
||||||
const Quantity_Color& color,
|
const Quantity_Color& color,
|
||||||
const Standard_Boolean IsCreateSHUO)
|
const Standard_Boolean IsCreateSHUO)
|
||||||
|
{
|
||||||
|
Quantity_ColorRGBA aCol;
|
||||||
|
aCol.SetRGB(color);
|
||||||
|
return SetInstanceColor(theShape, type, aCol, IsCreateSHUO);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetInstanceColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::SetInstanceColor(const TopoDS_Shape& theShape,
|
||||||
|
const XCAFDoc_ColorType type,
|
||||||
|
const Quantity_ColorRGBA& color,
|
||||||
|
const Standard_Boolean IsCreateSHUO)
|
||||||
{
|
{
|
||||||
// find shuo label structure
|
// find shuo label structure
|
||||||
TDF_LabelSequence aLabels;
|
TDF_LabelSequence aLabels;
|
||||||
if ( !ShapeTool()->FindComponent( theShape, aLabels ) )
|
if (!ShapeTool()->FindComponent(theShape, aLabels))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
Handle(XCAFDoc_GraphNode) aSHUO;
|
Handle(XCAFDoc_GraphNode) aSHUO;
|
||||||
// set the SHUO structure for this component if it is not exist
|
// set the SHUO structure for this component if it is not exist
|
||||||
if ( !ShapeTool()->FindSHUO( aLabels, aSHUO ) ) {
|
if (!ShapeTool()->FindSHUO(aLabels, aSHUO)) {
|
||||||
if (aLabels.Length() == 1) {
|
if (aLabels.Length() == 1) {
|
||||||
// set color directly for component as NAUO
|
// set color directly for component as NAUO
|
||||||
SetColor(aLabels.Value(1), color, type);
|
SetColor(aLabels.Value(1), color, type);
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
else if ( !IsCreateSHUO || !ShapeTool()->SetSHUO( aLabels, aSHUO ) ) {
|
else if (!IsCreateSHUO || !ShapeTool()->SetSHUO(aLabels, aSHUO)) {
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TDF_Label aSHUOLabel = aSHUO->Label();
|
TDF_Label aSHUOLabel = aSHUO->Label();
|
||||||
SetColor( aSHUOLabel, color, type );
|
SetColor(aSHUOLabel, color, type);
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetInstanceColor
|
//function : GetInstanceColor
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -489,39 +613,56 @@ Standard_Boolean XCAFDoc_ColorTool::SetInstanceColor (const TopoDS_Shape& theSha
|
|||||||
Standard_Boolean XCAFDoc_ColorTool::GetInstanceColor (const TopoDS_Shape& theShape,
|
Standard_Boolean XCAFDoc_ColorTool::GetInstanceColor (const TopoDS_Shape& theShape,
|
||||||
const XCAFDoc_ColorType type,
|
const XCAFDoc_ColorType type,
|
||||||
Quantity_Color& color)
|
Quantity_Color& color)
|
||||||
|
{
|
||||||
|
Quantity_ColorRGBA aCol;
|
||||||
|
Standard_Boolean isDone = GetInstanceColor(theShape, type, aCol);
|
||||||
|
if (isDone)
|
||||||
|
color = aCol.GetRGB();
|
||||||
|
return isDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetInstanceColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean XCAFDoc_ColorTool::GetInstanceColor(const TopoDS_Shape& theShape,
|
||||||
|
const XCAFDoc_ColorType type,
|
||||||
|
Quantity_ColorRGBA& color)
|
||||||
{
|
{
|
||||||
// find shuo label structure
|
// find shuo label structure
|
||||||
TDF_LabelSequence aLabels;
|
TDF_LabelSequence aLabels;
|
||||||
if ( !ShapeTool()->FindComponent( theShape, aLabels ) )
|
if (!ShapeTool()->FindComponent(theShape, aLabels))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
Handle(XCAFDoc_GraphNode) aSHUO;
|
Handle(XCAFDoc_GraphNode) aSHUO;
|
||||||
// get shuo from document by label structure
|
// get shuo from document by label structure
|
||||||
TDF_Label aCompLab = aLabels.Value(aLabels.Length());
|
TDF_Label aCompLab = aLabels.Value(aLabels.Length());
|
||||||
while (aLabels.Length() > 1) {
|
while (aLabels.Length() > 1) {
|
||||||
if ( !ShapeTool()->FindSHUO( aLabels, aSHUO ) ) {
|
if (!ShapeTool()->FindSHUO(aLabels, aSHUO)) {
|
||||||
// try to find other shuo
|
// try to find other shuo
|
||||||
aLabels.Remove(aLabels.Length());
|
aLabels.Remove(aLabels.Length());
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
TDF_Label aSHUOLabel = aSHUO->Label();
|
TDF_Label aSHUOLabel = aSHUO->Label();
|
||||||
if (GetColor ( aSHUOLabel, type, color ) )
|
if (GetColor(aSHUOLabel, type, color))
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
else
|
else
|
||||||
// try to find other shuo
|
// try to find other shuo
|
||||||
aLabels.Remove(aLabels.Length());
|
aLabels.Remove(aLabels.Length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// attempt to get color exactly of component
|
// attempt to get color exactly of component
|
||||||
if (GetColor( aCompLab, type, color ))
|
if (GetColor(aCompLab, type, color))
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
|
|
||||||
// attempt to get color of solid
|
// attempt to get color of solid
|
||||||
TopLoc_Location aLoc;
|
TopLoc_Location aLoc;
|
||||||
TopoDS_Shape S0 = theShape;
|
TopoDS_Shape S0 = theShape;
|
||||||
S0.Location( aLoc );
|
S0.Location(aLoc);
|
||||||
TDF_Label aRefLab = ShapeTool()->FindShape( S0 );
|
TDF_Label aRefLab = ShapeTool()->FindShape(S0);
|
||||||
if (!aRefLab.IsNull())
|
if (!aRefLab.IsNull())
|
||||||
return GetColor( aRefLab, type, color );
|
return GetColor(aRefLab, type, color);
|
||||||
// no color assigned
|
// no color assigned
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ class XCAFDoc_ShapeTool;
|
|||||||
class TDF_Label;
|
class TDF_Label;
|
||||||
class Standard_GUID;
|
class Standard_GUID;
|
||||||
class Quantity_Color;
|
class Quantity_Color;
|
||||||
|
class Quantity_ColorRGBA;
|
||||||
class TopoDS_Shape;
|
class TopoDS_Shape;
|
||||||
class TDF_Attribute;
|
class TDF_Attribute;
|
||||||
class TDF_RelocationTable;
|
class TDF_RelocationTable;
|
||||||
@ -67,20 +68,39 @@ public:
|
|||||||
//! Returns False if the label is not in colortable
|
//! Returns False if the label is not in colortable
|
||||||
//! or does not define a color
|
//! or does not define a color
|
||||||
Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& lab, Quantity_Color& col) const;
|
Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& lab, Quantity_Color& col) const;
|
||||||
|
|
||||||
|
//! Returns color defined by label lab
|
||||||
|
//! Returns False if the label is not in colortable
|
||||||
|
//! or does not define a color
|
||||||
|
Standard_EXPORT Standard_Boolean GetColor(const TDF_Label& lab, Quantity_ColorRGBA& col) const;
|
||||||
|
|
||||||
//! Finds a color definition in a colortable and returns
|
//! Finds a color definition in a colortable and returns
|
||||||
//! its label if found
|
//! its label if found
|
||||||
//! Returns False if color is not found in colortable
|
//! Returns False if color is not found in colortable
|
||||||
Standard_EXPORT Standard_Boolean FindColor (const Quantity_Color& col, TDF_Label& lab) const;
|
Standard_EXPORT Standard_Boolean FindColor (const Quantity_Color& col, TDF_Label& lab) const;
|
||||||
|
|
||||||
|
//! Finds a color definition in a colortable and returns
|
||||||
|
//! its label if found
|
||||||
|
//! Returns False if color is not found in colortable
|
||||||
|
Standard_EXPORT Standard_Boolean FindColor(const Quantity_ColorRGBA& col, TDF_Label& lab) const;
|
||||||
|
|
||||||
//! Finds a color definition in a colortable and returns
|
//! Finds a color definition in a colortable and returns
|
||||||
//! its label if found (or Null label else)
|
//! its label if found (or Null label else)
|
||||||
Standard_EXPORT TDF_Label FindColor (const Quantity_Color& col) const;
|
Standard_EXPORT TDF_Label FindColor (const Quantity_Color& col) const;
|
||||||
|
|
||||||
|
//! Finds a color definition in a colortable and returns
|
||||||
|
//! its label if found (or Null label else)
|
||||||
|
Standard_EXPORT TDF_Label FindColor(const Quantity_ColorRGBA& col) const;
|
||||||
|
|
||||||
//! Adds a color definition to a colortable and returns
|
//! Adds a color definition to a colortable and returns
|
||||||
//! its label (returns existing label if the same color
|
//! its label (returns existing label if the same color
|
||||||
//! is already defined)
|
//! is already defined)
|
||||||
Standard_EXPORT TDF_Label AddColor (const Quantity_Color& col) const;
|
Standard_EXPORT TDF_Label AddColor (const Quantity_Color& col) const;
|
||||||
|
|
||||||
|
//! Adds a color definition to a colortable and returns
|
||||||
|
//! its label (returns existing label if the same color
|
||||||
|
//! is already defined)
|
||||||
|
Standard_EXPORT TDF_Label AddColor(const Quantity_ColorRGBA& col) const;
|
||||||
|
|
||||||
//! Removes color from the colortable
|
//! Removes color from the colortable
|
||||||
Standard_EXPORT void RemoveColor (const TDF_Label& lab) const;
|
Standard_EXPORT void RemoveColor (const TDF_Label& lab) const;
|
||||||
@ -104,6 +124,12 @@ public:
|
|||||||
//! in the colortable
|
//! in the colortable
|
||||||
//! Adds a color as necessary
|
//! Adds a color as necessary
|
||||||
Standard_EXPORT void SetColor (const TDF_Label& L, const Quantity_Color& Color, const XCAFDoc_ColorType type) const;
|
Standard_EXPORT void SetColor (const TDF_Label& L, const Quantity_Color& Color, const XCAFDoc_ColorType type) const;
|
||||||
|
|
||||||
|
//! Sets a link with GUID defined by <type> (see
|
||||||
|
//! XCAFDoc::ColorRefGUID()) from label <L> to color <Color>
|
||||||
|
//! in the colortable
|
||||||
|
//! Adds a color as necessary
|
||||||
|
Standard_EXPORT void SetColor(const TDF_Label& L, const Quantity_ColorRGBA& Color, const XCAFDoc_ColorType type) const;
|
||||||
|
|
||||||
//! Removes a link with GUID defined by <type> (see
|
//! Removes a link with GUID defined by <type> (see
|
||||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||||
@ -120,6 +146,10 @@ public:
|
|||||||
//! Returns color assigned to <L> as <type>
|
//! Returns color assigned to <L> as <type>
|
||||||
//! Returns False if no such color is assigned
|
//! Returns False if no such color is assigned
|
||||||
Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_Color& color);
|
Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_Color& color);
|
||||||
|
|
||||||
|
//! Returns color assigned to <L> as <type>
|
||||||
|
//! Returns False if no such color is assigned
|
||||||
|
Standard_EXPORT Standard_Boolean GetColor(const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_ColorRGBA& color);
|
||||||
|
|
||||||
//! Sets a link with GUID defined by <type> (see
|
//! Sets a link with GUID defined by <type> (see
|
||||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||||
@ -133,6 +163,13 @@ public:
|
|||||||
//! Adds a color as necessary
|
//! Adds a color as necessary
|
||||||
//! Returns False if cannot find a label for shape S
|
//! Returns False if cannot find a label for shape S
|
||||||
Standard_EXPORT Standard_Boolean SetColor (const TopoDS_Shape& S, const Quantity_Color& Color, const XCAFDoc_ColorType type);
|
Standard_EXPORT Standard_Boolean SetColor (const TopoDS_Shape& S, const Quantity_Color& Color, const XCAFDoc_ColorType type);
|
||||||
|
|
||||||
|
//! Sets a link with GUID defined by <type> (see
|
||||||
|
//! XCAFDoc::ColorRefGUID()) from label <L> to color <Color>
|
||||||
|
//! in the colortable
|
||||||
|
//! Adds a color as necessary
|
||||||
|
//! Returns False if cannot find a label for shape S
|
||||||
|
Standard_EXPORT Standard_Boolean SetColor(const TopoDS_Shape& S, const Quantity_ColorRGBA& Color, const XCAFDoc_ColorType type);
|
||||||
|
|
||||||
//! Removes a link with GUID defined by <type> (see
|
//! Removes a link with GUID defined by <type> (see
|
||||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||||
@ -150,6 +187,10 @@ public:
|
|||||||
//! Returns color assigned to <L> as <type>
|
//! Returns color assigned to <L> as <type>
|
||||||
//! Returns False if no such color is assigned
|
//! Returns False if no such color is assigned
|
||||||
Standard_EXPORT Standard_Boolean GetColor (const TopoDS_Shape& S, const XCAFDoc_ColorType type, Quantity_Color& color);
|
Standard_EXPORT Standard_Boolean GetColor (const TopoDS_Shape& S, const XCAFDoc_ColorType type, Quantity_Color& color);
|
||||||
|
|
||||||
|
//! Returns color assigned to <L> as <type>
|
||||||
|
//! Returns False if no such color is assigned
|
||||||
|
Standard_EXPORT Standard_Boolean GetColor(const TopoDS_Shape& S, const XCAFDoc_ColorType type, Quantity_ColorRGBA& color);
|
||||||
|
|
||||||
//! Return TRUE if object on this label is visible, FALSE if invisible.
|
//! Return TRUE if object on this label is visible, FALSE if invisible.
|
||||||
Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& L) const;
|
Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& L) const;
|
||||||
@ -163,9 +204,18 @@ public:
|
|||||||
//! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO>
|
//! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO>
|
||||||
Standard_EXPORT Standard_Boolean SetInstanceColor (const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, const Quantity_Color& color, const Standard_Boolean isCreateSHUO = Standard_True);
|
Standard_EXPORT Standard_Boolean SetInstanceColor (const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, const Quantity_Color& color, const Standard_Boolean isCreateSHUO = Standard_True);
|
||||||
|
|
||||||
|
//! Sets the color of component that styled with SHUO structure
|
||||||
|
//! Returns FALSE if no sush component found
|
||||||
|
//! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO>
|
||||||
|
Standard_EXPORT Standard_Boolean SetInstanceColor(const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, const Quantity_ColorRGBA& color, const Standard_Boolean isCreateSHUO = Standard_True);
|
||||||
|
|
||||||
//! Gets the color of component that styled with SHUO structure
|
//! Gets the color of component that styled with SHUO structure
|
||||||
//! Returns FALSE if no sush component or color type
|
//! Returns FALSE if no sush component or color type
|
||||||
Standard_EXPORT Standard_Boolean GetInstanceColor (const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, Quantity_Color& color);
|
Standard_EXPORT Standard_Boolean GetInstanceColor (const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, Quantity_Color& color);
|
||||||
|
|
||||||
|
//! Gets the color of component that styled with SHUO structure
|
||||||
|
//! Returns FALSE if no sush component or color type
|
||||||
|
Standard_EXPORT Standard_Boolean GetInstanceColor(const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, Quantity_ColorRGBA& color);
|
||||||
|
|
||||||
//! Gets the visibility status of component that styled with SHUO structure
|
//! Gets the visibility status of component that styled with SHUO structure
|
||||||
//! Returns FALSE if no sush component
|
//! Returns FALSE if no sush component
|
||||||
|
@ -303,7 +303,7 @@ static void StatAssembly(const TDF_Label L,
|
|||||||
NbAreaProp++;
|
NbAreaProp++;
|
||||||
}
|
}
|
||||||
Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());
|
Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());
|
||||||
Quantity_Color col;
|
Quantity_ColorRGBA col;
|
||||||
Standard_Boolean IsColor = Standard_False;
|
Standard_Boolean IsColor = Standard_False;
|
||||||
if(CTool->GetColor(L,XCAFDoc_ColorGen,col))
|
if(CTool->GetColor(L,XCAFDoc_ColorGen,col))
|
||||||
IsColor = Standard_True;
|
IsColor = Standard_True;
|
||||||
@ -313,8 +313,8 @@ static void StatAssembly(const TDF_Label L,
|
|||||||
IsColor = Standard_True;
|
IsColor = Standard_True;
|
||||||
if(IsColor) {
|
if(IsColor) {
|
||||||
TCollection_AsciiString Entry1;
|
TCollection_AsciiString Entry1;
|
||||||
Entry1 = col.StringName(col.Name());
|
Entry1 = col.GetRGB().StringName(col.GetRGB().Name());
|
||||||
if(PrintStructMode) di<<"Color("<<Entry1.ToCString()<<") ";
|
if(PrintStructMode) di<<"Color("<<Entry1.ToCString()<<" "<<col.Alpha()<<") ";
|
||||||
NbShapesWithColor++;
|
NbShapesWithColor++;
|
||||||
}
|
}
|
||||||
Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(aDoc->Main());
|
Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(aDoc->Main());
|
||||||
@ -723,10 +723,10 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer
|
|||||||
}
|
}
|
||||||
else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Color)) ) {
|
else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Color)) ) {
|
||||||
Handle(XCAFDoc_Color) val = Handle(XCAFDoc_Color)::DownCast ( att );
|
Handle(XCAFDoc_Color) val = Handle(XCAFDoc_Color)::DownCast ( att );
|
||||||
Quantity_Color C = val->GetColor();
|
Quantity_ColorRGBA C = val->GetColorRGBA();
|
||||||
char string[260];
|
char string[260];
|
||||||
Sprintf ( string, "%s (%g, %g, %g)", C.StringName ( C.Name() ),
|
Sprintf ( string, "%s (%g, %g, %g, %g)", C.GetRGB().StringName ( C.GetRGB().Name() ),
|
||||||
C.Red(), C.Green(), C.Blue() );
|
C.GetRGB().Red(), C.GetRGB().Green(), C.GetRGB().Blue(), C.Alpha());
|
||||||
di << string;
|
di << string;
|
||||||
}
|
}
|
||||||
else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_DimTol)) ) {
|
else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_DimTol)) ) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Created on: 2000-08-04
|
// Created on: 2000-08-04
|
||||||
// Created by: Pavel TELKOV
|
// Created by: Pavel TELKOV
|
||||||
// Copyright (c) 2000-2014 OPEN CASCADE SAS
|
// Copyright (c) 2000-2014 OPEN CASCADE SAS
|
||||||
//
|
//
|
||||||
@ -17,7 +17,9 @@
|
|||||||
#include <DBRep.hxx>
|
#include <DBRep.hxx>
|
||||||
#include <DDocStd.hxx>
|
#include <DDocStd.hxx>
|
||||||
#include <Draw.hxx>
|
#include <Draw.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
|
#include <Quantity_ColorRGBA.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TDF_Label.hxx>
|
#include <TDF_Label.hxx>
|
||||||
#include <TDF_LabelSequence.hxx>
|
#include <TDF_LabelSequence.hxx>
|
||||||
@ -35,7 +37,7 @@
|
|||||||
static Standard_Integer setColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
static Standard_Integer setColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (argc < 6) {
|
if (argc < 6) {
|
||||||
di<<"Use: "<<argv[0]<<" Doc {Label|Shape} R G B [curve|surf]\n";
|
di<<"Use: "<<argv[0]<<" Doc {Label|Shape} R G B [alpha] [curve|surf]\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Handle(TDocStd_Document) Doc;
|
Handle(TDocStd_Document) Doc;
|
||||||
@ -45,16 +47,29 @@ static Standard_Integer setColor (Draw_Interpretor& di, Standard_Integer argc, c
|
|||||||
TDF_Label aLabel;
|
TDF_Label aLabel;
|
||||||
TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
|
TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
|
||||||
Quantity_Color Col ( Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]), Quantity_TOC_RGB );
|
Quantity_Color Col ( Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]), Quantity_TOC_RGB );
|
||||||
|
|
||||||
|
Quantity_ColorRGBA aColRGBA;
|
||||||
|
aColRGBA.SetRGB(Col);
|
||||||
|
if (argc > 6 && (argv[6][0] != 's' && argv[6][0] != 'c')) {
|
||||||
|
aColRGBA.SetAlpha((Standard_ShortReal)(Draw::Atof(argv[6])));
|
||||||
|
}
|
||||||
|
|
||||||
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
const XCAFDoc_ColorType ctype = ( argc <= 6 ? XCAFDoc_ColorGen : ( argv[6][0] == 's' ? XCAFDoc_ColorSurf : XCAFDoc_ColorCurv ) );
|
XCAFDoc_ColorType ctype = XCAFDoc_ColorGen;
|
||||||
|
if (argc > 6) {
|
||||||
|
if (argv[argc - 1][0] == 's')
|
||||||
|
ctype = XCAFDoc_ColorSurf;
|
||||||
|
else if (argv[argc - 1][0] == 'c')
|
||||||
|
ctype = XCAFDoc_ColorCurv;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !aLabel.IsNull() ) {
|
if ( !aLabel.IsNull() ) {
|
||||||
myColors->SetColor ( aLabel, Col, ctype );
|
myColors->SetColor(aLabel, aColRGBA, ctype);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TopoDS_Shape aShape= DBRep::Get(argv[2]);
|
TopoDS_Shape aShape= DBRep::Get(argv[2]);
|
||||||
if ( !aShape.IsNull() ) {
|
if ( !aShape.IsNull() ) {
|
||||||
myColors->SetColor ( aShape, Col, ctype );
|
myColors->SetColor(aShape, aColRGBA, ctype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -73,10 +88,13 @@ static Standard_Integer getColor (Draw_Interpretor& di, Standard_Integer argc, c
|
|||||||
TDF_Label aLabel;
|
TDF_Label aLabel;
|
||||||
TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
|
TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
|
||||||
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
Quantity_Color col;
|
Quantity_ColorRGBA col;
|
||||||
if ( !myColors->GetColor(aLabel, col) ) return 0;
|
if ( !myColors->GetColor(aLabel, col) ) return 0;
|
||||||
|
|
||||||
di << col.StringName ( col.Name() );
|
if ((1 - col.Alpha()) < Precision::Confusion())
|
||||||
|
di << col.GetRGB().StringName(col.GetRGB().Name());
|
||||||
|
else
|
||||||
|
di << col.GetRGB().StringName ( col.GetRGB().Name() ) << " (" << col.Alpha() << ")";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -101,12 +119,13 @@ static Standard_Integer getShapeColor (Draw_Interpretor& di, Standard_Integer ar
|
|||||||
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
const XCAFDoc_ColorType ctype = ( argc <= 3 ? XCAFDoc_ColorGen : ( argv[3][0] == 's' ? XCAFDoc_ColorSurf : XCAFDoc_ColorCurv ) );
|
const XCAFDoc_ColorType ctype = ( argc <= 3 ? XCAFDoc_ColorGen : ( argv[3][0] == 's' ? XCAFDoc_ColorSurf : XCAFDoc_ColorCurv ) );
|
||||||
|
|
||||||
Quantity_Color col;
|
Quantity_ColorRGBA col;
|
||||||
if ( !myColors->GetColor(aLabel, ctype, col) ) return 0;
|
if ( !myColors->GetColor(aLabel, ctype, col) ) return 0;
|
||||||
|
|
||||||
TCollection_AsciiString Entry;
|
if ((1 - col.Alpha()) < Precision::Confusion())
|
||||||
Entry = col.StringName ( col.Name() );
|
di << col.GetRGB().StringName(col.GetRGB().Name());
|
||||||
di << Entry.ToCString();
|
else
|
||||||
|
di << col.GetRGB().StringName(col.GetRGB().Name()) << " (" << col.Alpha() << ")";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -123,14 +142,17 @@ static Standard_Integer getAllColors (Draw_Interpretor& di, Standard_Integer arg
|
|||||||
|
|
||||||
TDF_Label aLabel;
|
TDF_Label aLabel;
|
||||||
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
Quantity_Color col;
|
Quantity_ColorRGBA col;
|
||||||
TDF_LabelSequence Labels;
|
TDF_LabelSequence Labels;
|
||||||
myColors->GetColors(Labels);
|
myColors->GetColors(Labels);
|
||||||
if (Labels.Length() >= 1) {
|
if (Labels.Length() >= 1) {
|
||||||
for ( Standard_Integer i = 1; i<= Labels.Length(); i++) {
|
for ( Standard_Integer i = 1; i<= Labels.Length(); i++) {
|
||||||
aLabel = Labels.Value(i);
|
aLabel = Labels.Value(i);
|
||||||
if ( !myColors->GetColor(aLabel, col) ) continue;
|
if ( !myColors->GetColor(aLabel, col) ) continue;
|
||||||
di << col.StringName ( col.Name() );
|
if ((1 - col.Alpha()) < Precision::Confusion())
|
||||||
|
di << col.GetRGB().StringName(col.GetRGB().Name());
|
||||||
|
else
|
||||||
|
di << col.GetRGB().StringName(col.GetRGB().Name()) << " (" << col.Alpha() << ")";
|
||||||
di << " ";
|
di << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,8 +162,8 @@ static Standard_Integer getAllColors (Draw_Interpretor& di, Standard_Integer arg
|
|||||||
|
|
||||||
static Standard_Integer addColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
static Standard_Integer addColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (argc!=5) {
|
if (argc < 5) {
|
||||||
di<<"Use: "<<argv[0]<<" DocName R G B\n";
|
di<<"Use: "<<argv[0]<<" DocName R G B [alpha]\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Handle(TDocStd_Document) Doc;
|
Handle(TDocStd_Document) Doc;
|
||||||
@ -152,7 +174,13 @@ static Standard_Integer addColor (Draw_Interpretor& di, Standard_Integer argc, c
|
|||||||
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
|
|
||||||
Quantity_Color Col ( Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]), Quantity_TOC_RGB );
|
Quantity_Color Col ( Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]), Quantity_TOC_RGB );
|
||||||
aLabel = myColors->AddColor(Col);
|
if (argc == 6) {
|
||||||
|
Quantity_ColorRGBA aColRGBA(Col);
|
||||||
|
aColRGBA.SetAlpha((Standard_ShortReal)(Draw::Atof(argv[5])));
|
||||||
|
aLabel = myColors->AddColor(aColRGBA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aLabel = myColors->AddColor(Col);
|
||||||
|
|
||||||
TCollection_AsciiString Entry;
|
TCollection_AsciiString Entry;
|
||||||
TDF_Tool::Entry(aLabel, Entry);
|
TDF_Tool::Entry(aLabel, Entry);
|
||||||
@ -180,8 +208,8 @@ static Standard_Integer removeColor (Draw_Interpretor& di, Standard_Integer argc
|
|||||||
|
|
||||||
static Standard_Integer findColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
static Standard_Integer findColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (argc!=5) {
|
if (argc < 5) {
|
||||||
di<<"Use: "<<argv[0]<<" DocName R G B\n";
|
di<<"Use: "<<argv[0]<<" DocName R G B [alpha]\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Handle(TDocStd_Document) Doc;
|
Handle(TDocStd_Document) Doc;
|
||||||
@ -189,11 +217,16 @@ static Standard_Integer findColor (Draw_Interpretor& di, Standard_Integer argc,
|
|||||||
if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
|
if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
|
||||||
|
|
||||||
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
|
|
||||||
Quantity_Color Col ( Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]), Quantity_TOC_RGB );
|
|
||||||
|
|
||||||
TCollection_AsciiString Entry;
|
TCollection_AsciiString Entry;
|
||||||
TDF_Tool::Entry(myColors->FindColor(Col), Entry);
|
Quantity_Color Col(Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]), Quantity_TOC_RGB);
|
||||||
|
if (argc == 5) {
|
||||||
|
TDF_Tool::Entry(myColors->FindColor(Col), Entry);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Quantity_ColorRGBA aColRGBA(Col);
|
||||||
|
aColRGBA.SetAlpha((Standard_ShortReal)Draw::Atof(argv[5]));
|
||||||
|
TDF_Tool::Entry(myColors->FindColor(aColRGBA), Entry);
|
||||||
|
}
|
||||||
di << Entry.ToCString();
|
di << Entry.ToCString();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -308,7 +341,7 @@ static Standard_Integer getStyledcolor (Draw_Interpretor& di, Standard_Integer a
|
|||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
aShape = DBRep::Get(argv[2]);
|
aShape = DBRep::Get(argv[2]);
|
||||||
|
|
||||||
Quantity_Color col;
|
Quantity_ColorRGBA col;
|
||||||
XCAFDoc_ColorType type;
|
XCAFDoc_ColorType type;
|
||||||
if ( argv[3] && argv[3][0] == 's' )
|
if ( argv[3] && argv[3][0] == 's' )
|
||||||
type = XCAFDoc_ColorSurf;
|
type = XCAFDoc_ColorSurf;
|
||||||
@ -319,9 +352,10 @@ static Standard_Integer getStyledcolor (Draw_Interpretor& di, Standard_Integer a
|
|||||||
Handle(XCAFDoc_ColorTool) localTool = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) localTool = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
if (localTool->GetInstanceColor( aShape, type, col) )
|
if (localTool->GetInstanceColor( aShape, type, col) )
|
||||||
{
|
{
|
||||||
TCollection_AsciiString Entry;
|
if ((1 - col.Alpha()) < Precision::Confusion())
|
||||||
Entry = col.StringName ( col.Name() );
|
di << col.GetRGB().StringName(col.GetRGB().Name());
|
||||||
di << Entry.ToCString();
|
else
|
||||||
|
di << col.GetRGB().StringName(col.GetRGB().Name()) << " (" << col.Alpha() << ")";
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -329,7 +363,7 @@ static Standard_Integer getStyledcolor (Draw_Interpretor& di, Standard_Integer a
|
|||||||
static Standard_Integer setStyledcolor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
static Standard_Integer setStyledcolor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (argc<6) {
|
if (argc<6) {
|
||||||
di<<"Use: "<<argv[0]<<" Doc shape R G B type(s/c)\n";
|
di<<"Use: "<<argv[0]<<" Doc shape R G B [alpha] type(s/c)\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Handle(TDocStd_Document) Doc;
|
Handle(TDocStd_Document) Doc;
|
||||||
@ -339,15 +373,22 @@ static Standard_Integer setStyledcolor (Draw_Interpretor& di, Standard_Integer a
|
|||||||
aShape = DBRep::Get(argv[2]);
|
aShape = DBRep::Get(argv[2]);
|
||||||
|
|
||||||
Quantity_Color col ( Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]), Quantity_TOC_RGB );
|
Quantity_Color col ( Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]), Quantity_TOC_RGB );
|
||||||
XCAFDoc_ColorType type;
|
Quantity_ColorRGBA aColRGBA;
|
||||||
if ( argv[6] && argv[6][0] == 's' )
|
aColRGBA.SetRGB(col);
|
||||||
type = XCAFDoc_ColorSurf;
|
if (argc > 6 && (argv[6][0] != 's' && argv[6][0] != 'c')) {
|
||||||
else if ( argv[6] && argv[6][0] == 'c' )
|
aColRGBA.SetAlpha((Standard_ShortReal)(Draw::Atof(argv[6])));
|
||||||
type = XCAFDoc_ColorCurv;
|
}
|
||||||
else
|
|
||||||
type = XCAFDoc_ColorGen;
|
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
|
XCAFDoc_ColorType ctype = XCAFDoc_ColorGen;
|
||||||
|
if (argc > 6) {
|
||||||
|
if (argv[argc - 1][0] == 's')
|
||||||
|
ctype = XCAFDoc_ColorSurf;
|
||||||
|
else if (argv[argc - 1][0] == 'c')
|
||||||
|
ctype = XCAFDoc_ColorCurv;
|
||||||
|
}
|
||||||
Handle(XCAFDoc_ColorTool) localTool = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
Handle(XCAFDoc_ColorTool) localTool = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
|
||||||
if (!localTool->SetInstanceColor( aShape, type, col) )
|
if (!localTool->SetInstanceColor(aShape, ctype, aColRGBA))
|
||||||
{
|
{
|
||||||
di << "cannot set color for the indicated component\n";
|
di << "cannot set color for the indicated component\n";
|
||||||
return 1;
|
return 1;
|
||||||
@ -372,7 +413,7 @@ void XDEDRAW_Colors::InitCommands(Draw_Interpretor& di)
|
|||||||
|
|
||||||
Standard_CString g = "XDE color's commands";
|
Standard_CString g = "XDE color's commands";
|
||||||
|
|
||||||
di.Add ("XSetColor","Doc {Label|Shape} R G B [c|s]\t: Set color [R G B] to shape given by Label, "
|
di.Add ("XSetColor","Doc {Label|Shape} R G B [alpha] [c|s]\t: Set color [R G B] to shape given by Label, "
|
||||||
"type of color 's' - for surface, 'c' - for curve (default generic)",
|
"type of color 's' - for surface, 'c' - for curve (default generic)",
|
||||||
__FILE__, setColor, g);
|
__FILE__, setColor, g);
|
||||||
|
|
||||||
@ -385,13 +426,13 @@ void XDEDRAW_Colors::InitCommands(Draw_Interpretor& di)
|
|||||||
di.Add ("XGetAllColors","Doc \t: Print all colors that defined in document",
|
di.Add ("XGetAllColors","Doc \t: Print all colors that defined in document",
|
||||||
__FILE__, getAllColors, g);
|
__FILE__, getAllColors, g);
|
||||||
|
|
||||||
di.Add ("XAddColor","Doc R G B \t: Add color in document to color table",
|
di.Add ("XAddColor","Doc R G B [alpha]\t: Add color in document to color table",
|
||||||
__FILE__, addColor, g);
|
__FILE__, addColor, g);
|
||||||
|
|
||||||
di.Add ("XRemoveColor","Doc Label \t: Remove color in document from color table",
|
di.Add ("XRemoveColor","Doc Label \t: Remove color in document from color table",
|
||||||
__FILE__, removeColor, g);
|
__FILE__, removeColor, g);
|
||||||
|
|
||||||
di.Add ("XFindColor","Doc R G B \t: Find label where indicated color is situated",
|
di.Add ("XFindColor","Doc R G B [alpha]\t: Find label where indicated color is situated",
|
||||||
__FILE__, findColor, g);
|
__FILE__, findColor, g);
|
||||||
|
|
||||||
di.Add ("XUnsetColor","Doc {Label|Shape} ColorType \t: Unset color ",
|
di.Add ("XUnsetColor","Doc {Label|Shape} ColorType \t: Unset color ",
|
||||||
@ -409,7 +450,7 @@ void XDEDRAW_Colors::InitCommands(Draw_Interpretor& di)
|
|||||||
di.Add ("XGetInstanceColor","Doc Shape \t: Return the color of component shape ",
|
di.Add ("XGetInstanceColor","Doc Shape \t: Return the color of component shape ",
|
||||||
__FILE__, getStyledcolor, g);
|
__FILE__, getStyledcolor, g);
|
||||||
|
|
||||||
di.Add ("XSetInstanceColor","Doc Shape color type \t: sets color for component of shape if SHUO structure exists already ",
|
di.Add ("XSetInstanceColor","Doc Shape R G B [alpha] type \t: sets color for component of shape if SHUO structure exists already ",
|
||||||
__FILE__, setStyledcolor, g);
|
__FILE__, setStyledcolor, g);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
76
tests/bugs/xde/bug28641
Normal file
76
tests/bugs/xde/bug28641
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "OCC28641"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
####################################################
|
||||||
|
# Data Exchange - Support alpha-channel of color
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
pload OCAF
|
||||||
|
|
||||||
|
# Create document with View
|
||||||
|
NewDocument D_First BinXCAF
|
||||||
|
box b 1 1 1
|
||||||
|
explode b e
|
||||||
|
explode b f
|
||||||
|
XAddShape D_First b
|
||||||
|
XSetColor D_First b_1 1 0 0 s
|
||||||
|
XSetColor D_First b_2 1 1 0 0.3 s
|
||||||
|
XSetColor D_First b_11 1 1 1 0.2 c
|
||||||
|
XSetColor D_First b_10 0 1 1 c
|
||||||
|
XAddColor D_First 0.5 0.5 1 0.1
|
||||||
|
|
||||||
|
# Write file
|
||||||
|
SaveAs D_First ${imagedir}/bug28521.xbf
|
||||||
|
Close D_First
|
||||||
|
# Read document
|
||||||
|
XOpen ${imagedir}/bug28521.xbf D_Second
|
||||||
|
|
||||||
|
# Results validation
|
||||||
|
set isOK 1
|
||||||
|
set color ""
|
||||||
|
set alpha ""
|
||||||
|
set prec 1e-7
|
||||||
|
#0:1:2:1
|
||||||
|
set res [XGetColor D_Second 0:1:2:1]
|
||||||
|
if {$res != "RED"} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
#0:1:2:2
|
||||||
|
set res [XGetColor D_Second 0:1:2:2]
|
||||||
|
regexp {([A-Z0-9]+) \(([0-9.+eE]+)\)} $res full color alpha
|
||||||
|
if {$color != "YELLOW"} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
if {[expr abs(0.3 - $alpha)] > $prec} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
#0:1:2:3
|
||||||
|
set res [XGetColor D_Second 0:1:2:3]
|
||||||
|
regexp {([A-Z0-9]+) \(([0-9.+eE]+)\)} $res full color alpha
|
||||||
|
if {$color != "WHITE"} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
if {[expr abs(0.2 - $alpha)] > $prec} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
#0:1:2:4
|
||||||
|
set res [XGetColor D_Second 0:1:2:4]
|
||||||
|
if {$res != "CYAN1"} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
#0:1:2:5
|
||||||
|
set res [XGetColor D_Second 0:1:2:5]
|
||||||
|
regexp {([A-Z0-9]+) \(([0-9.+eE]+)\)} $res full color alpha
|
||||||
|
if {$color != "LIGHTSLATEBLUE"} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
if {[expr abs(0.1 - $alpha)] > $prec} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$isOK == 0} {
|
||||||
|
puts "Error: wrong color."
|
||||||
|
}
|
||||||
|
|
||||||
|
Close D_Second
|
Loading…
x
Reference in New Issue
Block a user