Archived issue #0030969

Coding Rules - refactor Quantity_Color.cxx color table definition

Open CASCADEOCCT:Codingclosed31 public notes

Search issues

Description

Quantity_Color.cxx defines a large table of standard colors.
It is desired refactoring this table to be better aligned.

static Standard_Integer VColTable (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
{
  FILE* aFile = OSD_OpenFile ("col.hxx", "wb");
  if (aFile == NULL) { std::cerr << "FAILED\n";  return 1; }
  for (int aColIter = 0; aColIter <= Quantity_NOC_WHITE; ++aColIter)
  {
    Quantity_Color aColor ((Quantity_NameOfColor )aColIter);
    TCollection_AsciiString aHex = Quantity_Color::ColorToHex(aColor).SubString (2, 7);
    Fprintf (aFile, "RawColor(%-20s, 0x%s, %f, %f, %f),\n",
             Quantity_Color::StringName ((Quantity_NameOfColor )aColIter), aHex.ToCString(),
             aColor.Red(), aColor.Green(), aColor.Blue());
  }
  fclose(aFile);
  return 0;
}

Steps to reproduce

N/A

Public activity

31 archived notes

Participants are labeled by their role within this record.

01Commenter 3
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Mon Sep 16 23:06:38 2019 +0300

    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.
    
    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.
    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.
02Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
03Commenter 3
Let's postpone it till 7.5.0. Minor remark: there is no sense in prefixing calls to the class' own methods by its name within the class definition, like calls to Quantity_Color::valuesOf() in Quantity_Color.hxx.
04Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
05Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
06Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
07Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
08Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
09Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
10Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
11Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
12Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
13Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
14Commenter 3
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Mon Sep 16 23:06:38 2019 +0300

    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::ColorToHex() now rounds-up float values to closest integer.
    Quantity_ColorRGBA::ColorToHex() - added method formatting color into hex with alpha component.
    
    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.
    
    vdrawtext command now uses ViewerTest::ParseColor() for parsing color argument, so that it accepts hex.
    vreadpixel command now has been extended with -hex argument for printing color in hex format.
15Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
16Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
17Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
18Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
19Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
20Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
21Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
22Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
23Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
24Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
25Commenter 3
Branch [archived branch] has been created by Author.

[revision removed]


No new revisions were added by this update.
26Author
27Commenter 27
The patches were reviewed without remarks
28Commenter 3
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
29Commenter 3
Branch [archived branch] has been deleted by Author.

[revision removed]
30Commenter 3
Branch [archived branch] has been deleted by Author.

[revision removed]
31Commenter 3
Branch [archived branch] has been deleted by Author.

[revision removed]

Related records