Salome HOME
Base implementation of dumping study document in to Python script (Feature #14).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.cxx
index 1c8368ffaf5d37f99c03aeb4cd531f6065a0d6b2..798cf88ed181a2ca635233e75e260fc7e699509d 100644 (file)
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Tool.h"
 
+#include <HYDROData_Bathymetry.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
-#include <HYDROData_Bathymetry.h>
 
 #include <CAM_Application.h>
 #include <CAM_DataObject.h>
@@ -194,7 +194,17 @@ void HYDROGUI_DataModel::update( const int theStudyId )
     Handle(HYDROData_Image) anImageObj =
       Handle(HYDROData_Image)::DownCast( anIterator.Current() );
     if( !anImageObj.IsNull() )
-      createObject( anImageRootObj, anImageObj );
+    {
+      if( LightApp_DataObject* anImageDataObj = createObject( anImageRootObj, anImageObj ) )
+      {
+        for( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
+        {
+          Handle(HYDROData_Image) aRefImageObj = anImageObj->Reference( anIndex );
+          if( !aRefImageObj.IsNull() && !aRefImageObj->IsRemoved() )
+            createObject( anImageDataObj, aRefImageObj, anImageDataObj->entry() );
+        }
+      }
+    }
   }
 
   LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, "BATHYMETRIES" );
@@ -279,6 +289,10 @@ void HYDROGUI_DataModel::updateModel()
 Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
                                                             const ObjectKind theObjectKind )
 {
+  QString anEntry = theEntry;
+  if( anEntry.indexOf( "_" ) != -1 ) // reference object
+    anEntry = anEntry.section( "_", -1 );
+
   Handle(HYDROData_Document) aDocument = getDocument();
   if( !aDocument.IsNull() )
   {
@@ -288,8 +302,8 @@ Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEn
       Handle(HYDROData_Object) anObject = anIterator.Current();
       if( !anObject.IsNull() )
       {
-        QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObject );
-        if( anEntry == theEntry )
+        QString anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
+        if( anEntryRef == anEntry )
           return anObject;
       }
     }
@@ -366,9 +380,10 @@ Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
-                                                       Handle(HYDROData_Object) theModelObject )
+                                                       Handle(HYDROData_Object) theModelObject,
+                                                       const QString& theParentEntry )
 {
-  return new HYDROGUI_DataObject( theParent, theModelObject );
+  return new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,