Salome HOME
NPAL14803 Colors in MED Save&Reload presistance
authordmv <dmv@opencascade.com>
Tue, 11 Mar 2008 10:14:24 +0000 (10:14 +0000)
committerdmv <dmv@opencascade.com>
Tue, 11 Mar 2008 10:14:24 +0000 (10:14 +0000)
src/DriverMED/DriverMED_Family.cxx
src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx
src/SMESHDS/SMESHDS_GroupBase.cxx

index 16363f8e63ee46d80c9c2188d80a5708758cbd0e..b95f4b1cba46cc3cc06554bb29a7c04acea7e61d 100644 (file)
@@ -382,7 +382,17 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup)
   myGroupNames.insert(string(theGroup->GetStoreName()));
 
   Quantity_Color aColor = theGroup->GetColor();
-  myGroupAttributVal = aColor.Hue();
+  double aRed = aColor.Red();
+  double aGreen = aColor.Green();
+  double aBlue = aColor.Blue();
+  int aR = aRed*255;
+  int aG = aGreen*255;
+  int aB = aBlue*255;
+  cout << "aRed = " << aR << endl;
+  cout << "aGreen = " << aG << endl;
+  cout << "aBlue = " << aB << endl;
+  myGroupAttributVal = (int)(aR*1000000 + aG*1000 + aB);
+  cout << "myGroupAttributVal = " << myGroupAttributVal << endl;
 }
 
 //=============================================================================
index e500ed3ade57f9743d8b19250ebc55a6ba48a606..ed6c28b97269a33c70802a7c57d06bcdf0f8a7ab 100644 (file)
@@ -113,10 +113,19 @@ DriverMED_R_SMESHDS_Mesh
            
             TInt aNbGrp = aFamilyInfo->GetNbGroup();
             if(MYDEBUG) MESSAGE("belong to " << aNbGrp << " groups");
+           bool isAttrOk = false;
+           if(aFamilyInfo->GetNbAttr() == aNbGrp)
+             isAttrOk = true;
             for (TInt iGr = 0; iGr < aNbGrp; iGr++) {
               string aGroupName = aFamilyInfo->GetGroupName(iGr);
+              if(isAttrOk){
+               TInt anAttrVal = aFamilyInfo->GetAttrVal(iGr);
+               aFamily->SetGroupAttributVal(anAttrVal);
+             }
+             
               if(MYDEBUG) MESSAGE(aGroupName);
               aFamily->AddGroupName(aGroupName);
+             
             }
             aFamily->SetId( aFamId );
             myFamilies[aFamId] = aFamily;
@@ -793,6 +802,9 @@ void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
       {
         element = *anElemsIter;
        theGroup->SMDSGroup().Add(element);
+       int aGroupAttrVal = aFamily->GetGroupAttributVal();
+       if( aGroupAttrVal != 0)
+         theGroup->SetColorGroup(aGroupAttrVal);
       }
       if ( element )
         theGroup->SetType( theGroup->SMDSGroup().GetType() );
index 1fc450002d7551063469835050a91c7bd45c1495..90b91add67f7fa75be50276a40d9bbefb6fac145 100644 (file)
@@ -169,13 +169,22 @@ 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]");
-    return;
-  }
-
-  Quantity_Color aColor( (double)theColorGroup, 1.0, 1.0, Quantity_TOC_HLS );
+  cout << "theColorGroup = " << theColorGroup << endl;
+
+  int aRed = ( theColorGroup/1000000 );
+  int aGreen = ( theColorGroup -aRed*1000000)/1000;
+  int aBlue = ( theColorGroup - aRed*1000000 - aGreen*1000 );
+  cout << "aRed = " << aRed << endl;
+  cout << "aGreen = " << aGreen << endl;
+  cout << "aBlue = " << aBlue << endl;
+  double aR = aRed/255.0;
+  double aG = aGreen/255.0;
+  double aB = aBlue/255.0;
+  cout << "aR = " << aR << endl;
+  cout << "aG = " << aG << endl;
+  cout << "aB = " << aB << endl;
+
+  Quantity_Color aColor( aR, aG, aB, Quantity_TOC_RGB );
   SetColor( aColor );
 }
   
@@ -187,9 +196,17 @@ 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 = aRed*255;
+  int aG = aGreen*255;
+  int aB = aBlue*255;
+  cout << "aRed = " << aR << endl;
+  cout << "aGreen = " << aG << endl;
+  cout << "aBlue = " << aB << endl;
+  int aRet = (int)(aR*1000000 + aG*1000 + aB);
+
+  return aRet;
 }