]> OCCT Git - occt.git/commitdiff
Data Exchange, XCAFDoc_ColorTool::AddColor() - fix generated HEX name of a color...
authorKirill Gavrilov <kirill@sview.ru>
Wed, 25 Oct 2023 12:53:18 +0000 (15:53 +0300)
committerdpasukhi <dpasukhi@opencascade.com>
Fri, 31 Jan 2025 15:38:07 +0000 (15:38 +0000)
Quantity_ColorRGBA::ColorToHex() is now used for consistent HEX formatting of RGBA colors.

src/XCAFDoc/XCAFDoc_ColorTool.cxx

index 9cbae40431897bf9b82c2aeaa3b53040baa04cff..133b2423906938f7daec6a9f6537f8a987dc9773 100644 (file)
@@ -168,13 +168,9 @@ TDF_Label XCAFDoc_ColorTool::AddColor(const Quantity_ColorRGBA& theColor) const
   if (XCAFDoc_ColorTool_AutoNaming)
   {
     // set name according to color value
-    const NCollection_Vec4<float>&       anRgbaF = theColor;
-    const NCollection_Vec4<unsigned int> anRgba(anRgbaF * 255.0f);
-    char                                 aColorHex[32];
-    Sprintf(aColorHex, "%02X%02X%02X%02X", anRgba.r(), anRgba.g(), anRgba.b(), anRgba.a());
     const TCollection_AsciiString aName =
-      TCollection_AsciiString(Quantity_Color::StringName(theColor.GetRGB().Name())) + " (#"
-      + aColorHex + ")";
+      TCollection_AsciiString(Quantity_Color::StringName(theColor.GetRGB().Name())) + " ("
+      + Quantity_ColorRGBA::ColorToHex(theColor) + ")";
     TDataStd_Name::Set(aLab, aName);
   }