Salome HOME
Color Number (Color Group) parameter is returned for compatibility
[modules/smesh.git] / src / SMESHDS / SMESHDS_GroupBase.cxx
index c3fc31d7017c8df8c942e5fd963687665910caba..5221743a9a6e3087c2ce4c3cd49af071ac2dff53 100644 (file)
@@ -16,7 +16,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.salome-platform.org or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -41,8 +41,9 @@ SMESHDS_GroupBase::SMESHDS_GroupBase (const int                 theID,
                                       const SMESHDS_Mesh*       theMesh,
                                       const SMDSAbs_ElementType theType):
        myID(theID), myMesh(theMesh), myType(theType), myStoreName(""),
-       myCurIndex(0), myCurID(0)
+       myCurIndex(0), myCurID(-1)
 {
+  myColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB );
 }
 
 //=============================================================================
@@ -86,6 +87,18 @@ const SMDS_MeshElement* SMESHDS_GroupBase::findInMesh (const int theID) const
   return aElem;
 }
 
+//=============================================================================
+/*!
+ *  Internal method: resets cached iterator, should be called by ancestors
+ *  when they are modified (ex: Add() or Remove() )
+ */
+//=============================================================================
+void SMESHDS_GroupBase::resetIterator()
+{
+  myCurIndex = 0;
+  myCurID = -1;
+}
+
 //=======================================================================
 //function : Extent
 //purpose  : 
@@ -136,3 +149,35 @@ void SMESHDS_GroupBase::SetType(SMDSAbs_ElementType theType)
 {
   myType = theType;
 }
+
+//=======================================================================
+//function : SetType
+//purpose  : 
+//=======================================================================
+
+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 );
+  SetColor( aColor );
+}
+  
+//=======================================================================
+//function : SetType
+//purpose  : 
+//=======================================================================
+
+int SMESHDS_GroupBase::GetColorGroup() const
+{
+  Quantity_Color aColor = GetColor();
+  double aHue = aColor.Hue();
+  if( aHue < 0 )
+    return 0;
+  return (int)( aHue );
+}
+