Salome HOME
refs #482: new function for export calculation case
[modules/hydro.git] / src / HYDROData / HYDROData_Object.cxx
index f920341142141e0cc994c316605f9e1888f732f5..7204f97fde1bf06c1bcdec4e5cf52457713122ba 100644 (file)
@@ -57,11 +57,11 @@ void HYDROData_Object::SetName( const QString& theName )
 
 void HYDROData_Object::Update()
 {
-  HYDROData_Entity::Update();
   removeTopShape();
   removeShape3D();
   removeGroupObjects();
   checkAndSetAltitudeObject();
+  HYDROData_Entity::Update();
 }
 
 HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
@@ -132,6 +132,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 +220,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 +312,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 );