]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESHDS/SMESHDS_GroupBase.cxx
Salome HOME
Dump Python extension
[modules/smesh.git] / src / SMESHDS / SMESHDS_GroupBase.cxx
index 1fc450002d7551063469835050a91c7bd45c1495..f21b6df54bca97f4fccbec4b3b63164b4e572823 100644 (file)
@@ -169,13 +169,20 @@ void SMESHDS_GroupBase::SetType(SMDSAbs_ElementType theType)
 
 void SMESHDS_GroupBase::SetColorGroup(int theColorGroup)
 {
-  if( theColorGroup < 0 || theColorGroup > 360 )
-  {
-    MESSAGE("SMESHDS_GroupBase::SetColorGroup : Value must be in range [0,360]");
+  int aRed = ( theColorGroup/1000000 );
+  int aGreen = ( theColorGroup -aRed*1000000)/1000;
+  int aBlue = ( theColorGroup - aRed*1000000 - aGreen*1000 );
+  double aR = aRed/255.0;
+  double aG = aGreen/255.0;
+  double aB = aBlue/255.0;
+  if ( aR < 0. || aR > 1. || // PAL19395
+       aG < 0. || aG > 1. ||
+       aB < 0. || aB > 1. )
+// #ifdef _DEBUG_
+//     cout << "SMESHDS_GroupBase::SetColorGroup("<<theColorGroup<<"), invalid color ignored"<<endl;
+// #endif
     return;
-  }
-
-  Quantity_Color aColor( (double)theColorGroup, 1.0, 1.0, Quantity_TOC_HLS );
+  Quantity_Color aColor( aR, aG, aB, Quantity_TOC_RGB );
   SetColor( aColor );
 }
   
@@ -187,9 +194,14 @@ void SMESHDS_GroupBase::SetColorGroup(int theColorGroup)
 int SMESHDS_GroupBase::GetColorGroup() const
 {
   Quantity_Color aColor = GetColor();
-  double aHue = aColor.Hue();
-  if( aHue < 0 )
-    return 0;
-  return (int)( aHue );
+  double aRed = aColor.Red();
+  double aGreen = aColor.Green();
+  double aBlue = aColor.Blue();
+  int aR = int( aRed  *255 );
+  int aG = int( aGreen*255 );
+  int aB = int( aBlue *255 );
+  int aRet = (int)(aR*1000000 + aG*1000 + aB);
+
+  return aRet;
 }