Salome HOME
#refs 522 (very draft) //import only
[modules/hydro.git] / src / HYDROData / HYDROData_Object.cxx
index 242a09748a610faad504e8a0ee08bc3395731667..81cbe38ac4198022ae9a658d7cd9e76c4ca44184 100644 (file)
@@ -1,3 +1,24 @@
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// 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.com
+//
 
 #include "HYDROData_Object.h"
 
@@ -132,6 +153,38 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetGroups() const
   return GetReferenceObjects( DataTag_EdgesGroup );
 }
 
+Handle(HYDROData_ShapesGroup) HYDROData_Object::GetGroup( const int theGroupId ) const
+{
+  Handle(HYDROData_ShapesGroup) aResGroup;
+
+  HYDROData_SequenceOfObjects aGroups = GetGroups();
+  if ( theGroupId < 0 || theGroupId >= aGroups.Length() )
+    return aResGroup;
+
+  aResGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( theGroupId + 1 ) );
+
+  return aResGroup;
+}
+
+int HYDROData_Object::GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup ) const
+{
+  int aRes = -1;
+
+  HYDROData_SequenceOfObjects aGroups = GetGroups();
+  for ( int i = 1, n = aGroups.Length(); i <= n; ++i )
+  {
+    Handle(HYDROData_ShapesGroup) aGroup =
+      Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( i ) );
+    if ( IsEqual( theGroup, aGroup ) )
+    {
+      aRes = i - 1;
+      break;
+    }
+  }
+
+  return aRes;
+}
+
 bool HYDROData_Object::SetAltitudeObject( 
   const Handle(HYDROData_IAltitudeObject)& theAltitude )
 {
@@ -188,24 +241,37 @@ QColor HYDROData_Object::GetBorderColor() const
   return GetColor( getDefaultBorderColor(), DataTag_BorderColor );
 }
 
-QColor HYDROData_Object::DefaultFillingColor()
+QColor HYDROData_Object::getDefaultFillingColor() const
 {
   return QColor( Qt::yellow );
 }
 
-QColor HYDROData_Object::DefaultBorderColor()
+QColor HYDROData_Object::getDefaultBorderColor() const
 {
   return QColor( Qt::transparent );
 }
 
-QColor HYDROData_Object::getDefaultFillingColor() const
+QStringList HYDROData_Object::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
 {
-  return DefaultFillingColor();
-}
+  QStringList aResList = HYDROData_Entity::dumpObjectCreation( theTreatedObjects );
+  if ( aResList.isEmpty() )
+    return aResList; //Object was not created
 
-QColor HYDROData_Object::getDefaultBorderColor() const
-{
-  return DefaultBorderColor();
+  QStringList aColorsDef;
+
+  QColor aFillingColor = GetFillingColor();
+  setPythonObjectColor( aColorsDef, aFillingColor, getDefaultFillingColor(), "SetFillingColor" );
+
+  QColor aBorderColor = GetBorderColor();
+  setPythonObjectColor( aColorsDef, aBorderColor, getDefaultBorderColor(), "SetBorderColor" );
+
+  if ( !aColorsDef.isEmpty() )
+  {
+    aResList << aColorsDef;
+    aResList << QString( "" );
+  }
+
+  return aResList;
 }
 
 ObjectKind HYDROData_Object::getAltitudeObjectType() const
@@ -267,10 +333,6 @@ Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject()
   return aNewGroup;
 }
 
-void HYDROData_Object::createGroupObjects()
-{
-}
-
 void HYDROData_Object::removeGroupObjects()
 {
   TDF_Label aLabel = myLab.FindChild( DataTag_EdgesGroup, false );