1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0030969: Coding Rules - refactor Quantity_Color.cxx color table definition

The table of named colors has been compressed and moved out
from Quantity_Color.cxx into Quantity_ColorTable.pxx.

Quantity_NameOfColor - grayscale enumeration values have been re-ordered to fix discontinuity.
Duplicating colors has been merged within enumeration:
  CHARTREUSE=CHARTREUSE1, GOLD=GOLD1, GREEN=GREEN1, ORANGE=ORANGE1,
  ORANGERED=ORANGERED1, RED=RED1, TOMATO=TOMATO1, YELLOW=YELLOW1.
Added aliases to several other common colors:
  BLUE=BLUE1, CYAN=CYAN1, LIGHTCYAN=LIGHTCYAN1, MAGENTA=MAGENTA1.

Quantity_Color class definition has been cleaned to follow OCCT coding style.
Quantity_Color now stores NCollection_Vec3<float> as class field instead of separate components.
Removed unused class Quantity_ColorDefinitionError.

New methods Quantity_Color::Convert_LinearRGB_To_sRGB() and Quantity_Color::Convert_sRGB_To_LinearRGB()
converting RGB components from linear to non-linear sRGB colorspace and vice versa.
Image_PixMap::PixelColor() and Image_PixMap::SetPixelColor() methods have been extended
with an optional argument for performing linearization/delinearization of 8-bit sRGB pixel formats.

Draw Harness command AISColor has been corrected to take color name instead of enumeration index.
This commit is contained in:
kgv
2019-09-16 23:06:38 +03:00
committed by apn
parent b008226203
commit aaf8d6a98d
444 changed files with 2134 additions and 5011 deletions

View File

@@ -367,35 +367,57 @@ static Standard_Integer DPrsStd_AISColor (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
if( nb == 4 ) {
prs->SetColor((Quantity_NameOfColor)Draw::Atoi(arg[3]));
TPrsStd_AISViewer::Update(L);
}
else
if (prs->HasOwnColor()){
di << "Color = " << prs->Color() << "\n";
di<<prs->Color();
}
else{
di << "DPrsStd_AISColor: Warning : Color wasn't set\n";
di<<(-1);
}
return 0;
}
if (nb != 3 && nb != 4)
{
std::cout << "Syntax error: wrong number of arguments\n";
return 1;
}
di << "DPrsStd_AISColor : Error" << "\n";
return 1;
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument (arg[1], D))
{
std::cout << "Syntax error: '" << arg[1] << "' is not a document\n";
return 1;
}
TDF_Label L;
if (!DDF::FindLabel (D->GetData(), arg[2], L))
{
std::cout << "Syntax error: '" << arg[2] << "' label cannot be found in the document\n";
return 1;
}
Handle(TPrsStd_AISViewer) viewer;
Handle(TPrsStd_AISPresentation) prs;
if (!TPrsStd_AISViewer::Find (L, viewer)
||!L.FindAttribute (TPrsStd_AISPresentation::GetID(), prs))
{
std::cout << "Syntax error: '" << arg[2] << "' label has no presentation\n";
return 1;
}
if (nb == 4)
{
Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
if (!Quantity_Color::ColorFromName (arg[3], aColor))
{
std::cout << "Syntax error: unknown color '" << arg[3] << "'\n";
return 1;
}
prs->SetColor (aColor);
TPrsStd_AISViewer::Update (L);
}
else if (prs->HasOwnColor())
{
di << "Color = " << Quantity_Color::StringName (prs->Color()) << "\n";
di << Quantity_Color::StringName (prs->Color());
}
else
{
di << "DPrsStd_AISColor: Warning : Color wasn't set\n";
di << (-1);
}
return 0;
}
//=======================================================================