Salome HOME
DCQ : Merge with Ecole Ete a6.
[modules/visu.git] / src / VISU_I / VISU_Table_i.cc
index 12d15ee401aa66637f3f7fe1fee9f18cd2894739..0c683dc3bf98503b26ae309d2d45bdde33ec8abc 100644 (file)
@@ -37,6 +37,7 @@
 #include <strstream>
 
 #include <qfileinfo.h>
+#include <qfile.h>
 
 using namespace std;
 
@@ -45,7 +46,6 @@ static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
-
 //----------------------------------------------------------------
 //                      Table Object
 //----------------------------------------------------------------
@@ -71,7 +71,7 @@ const char* VISU::Table_i::GetComment() const
 VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry )
      : PrsObject_i(theStudy)
 {
-  myObjectEntry = theObjectEntry; 
+  mySObj = SALOMEDS::SObject::_duplicate((theStudy->FindObjectID(theObjectEntry)));
   myOrientation = VISU::Table::HORIZONTAL;
 }
 /*!
@@ -79,19 +79,20 @@ VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry
 */
 VISU::Table_i::~Table_i()
 {
+  MESSAGE("Table_i::~Table_i");
 }
 /*!
   Gets number of rows in table
 */
 CORBA::Long VISU::Table_i::GetNbRows()
 {
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myObjectEntry.c_str() );
+  SALOMEDS::SObject_var SO = mySObj;
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   if ( !SO->_is_nil() ) {
     SALOMEDS::GenericAttribute_var        anAttr;
     if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
       SALOMEDS::AttributeTableOfInteger_var anInt =  SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
-      return anInt->GetNbRows();
+       return anInt->GetNbRows();
     }
     else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
       SALOMEDS::AttributeTableOfReal_var aReal =  SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
@@ -105,7 +106,7 @@ CORBA::Long VISU::Table_i::GetNbRows()
 */
 CORBA::Long VISU::Table_i::GetNbColumns()
 {
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myObjectEntry.c_str() );
+  SALOMEDS::SObject_var SO = mySObj;
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   if ( !SO->_is_nil() ) {
     SALOMEDS::GenericAttribute_var        anAttr;
@@ -127,6 +128,21 @@ VISU::Storable* VISU::Table_i::Create()
 {
   // generate name ... 
   myName = GetTableTitle(); 
+
+  // mpv (PAL 5357): if name attribute already exist at this label, use it as name of table
+  if ( myName == "" )
+    if ( !mySObj->_is_nil() ) {
+      CutLines_i* pCutLines = NULL;
+      CORBA::Object_var anObj = SObjectToObject(mySObj);
+      if(!CORBA::is_nil(anObj)){
+       VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj);
+         if(!aCutLines->_is_nil())
+           pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines).in());
+       }
+      if (!pCutLines)
+       if (mySObj->GetName()) myName = mySObj->GetName();
+    }
+
   if ( myName == "" )
     myName = GenerateName();
   // ... and build the object
@@ -137,59 +153,57 @@ VISU::Storable* VISU::Table_i::Create()
 */
 VISU::Storable* VISU::Table_i::Build( int theRestoring ) 
 {
+  
   // look for reference SObject with table attribute
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myObjectEntry.c_str() );
+  SALOMEDS::SObject_var SO = mySObj;
+
   if ( !SO->_is_nil() ) {
     CutLines_i* pCutLines = NULL;
     CORBA::Object_var anObj = SObjectToObject(SO);
     if(!CORBA::is_nil(anObj)){
       VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj);
       if(!aCutLines->_is_nil())
-       pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines));
+       pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines).in());
     }
     SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
     SALOMEDS::GenericAttribute_var anAttr;
-    if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) || 
-        Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) || pCutLines) {
-      // look for component
-      if ( !theRestoring ) {
+    // look for component
+    if ( !theRestoring ) {
        SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
        // create SObject and set attributes
        QString aComment;
        aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TTABLE);
        string anEntry = CreateAttributes( myStudy, 
-                                          SComponent->GetID(),
-                                          "",
-                                          GetID(),
-                                          GetName(),
-                                          "",
-                                          aComment.latin1(), 
-                                          true );
+                                         SO->GetID(),//SComponent->GetID(),
+                                         "",
+                                         GetID(),
+                                         GetName(),
+                                         "",
+                                         aComment.latin1(), 
+                                         pCutLines );
        // create SObject referenced to real table object
-       SALOMEDS::SObject_var newSO = myStudy->FindObjectID( anEntry.c_str() );
+       mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID( anEntry.c_str() ));
        if(pCutLines) {
-         pCutLines->BuildTableOfReal(newSO);
-         myObjectEntry = anEntry;
+         pCutLines->BuildTableOfReal(mySObj);
        }
-       SALOMEDS::SObject_var refSO = Builder->NewObject( newSO );
-       Builder->Addreference( refSO, SO );
+       // mpv (PAL5357): reference attributes are unnecessary now
+       //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
+       //Builder->Addreference( refSO, SO );
       }
-      return this;
-    }
+    return this;
   }
   return NULL;
 }
 /*!
   Restores table object from stream
 */
-VISU::Storable* VISU::Table_i::Restore( const Storable::TRestoringMap& theMap )
-     throw( std::logic_error& )
+VISU::Storable* VISU::Table_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO)
 {
   if(MYDEBUG) MESSAGE(GetComment());
   myName = (const char*)(VISU::Storable::FindValue(theMap,"myName"));
-  myObjectEntry = (const char *)(VISU::Storable::FindValue(theMap,"myObjectEntry"));
   myTitle = (const char*)(VISU::Storable::FindValue(theMap,"myTitle"));
   myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
+  mySObj = SALOMEDS::SObject::_duplicate(SO);
   return Build( true );
 }
 /*!
@@ -198,7 +212,6 @@ VISU::Storable* VISU::Table_i::Restore( const Storable::TRestoringMap& theMap )
 void VISU::Table_i::ToStream( std::ostringstream& theStr )
 {
   Storable::DataToStream( theStr, "myName",        myName.c_str() );
-  Storable::DataToStream( theStr, "myObjectEntry", myObjectEntry.c_str() );
   Storable::DataToStream( theStr, "myTitle",       myTitle.c_str() );
   Storable::DataToStream( theStr, "myOrientation", myOrientation );
 }
@@ -207,18 +220,17 @@ void VISU::Table_i::ToStream( std::ostringstream& theStr )
 */
 VISU::Storable* VISU::Table_i::Restore(SALOMEDS::SObject_ptr theSObject, 
                                       const string& thePrefix, const Storable::TRestoringMap& theMap)
-  throw(std::logic_error&)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::Table_i* pResent = new VISU::Table_i( aStudy, "" );
-  return pResent->Restore( theMap );
+  return pResent->Restore( theMap, theSObject);
 }
 /*!
   Gets title for the original table object
 */
 const char* VISU::Table_i::GetTableTitle()
 {
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( GetObjectEntry() );
+  SALOMEDS::SObject_var SO = mySObj;
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -242,14 +254,12 @@ const char* VISU::Table_i::GetTableTitle()
 /*!
   Restores table object from the stream [ static ]
 */
-static VISU::Table_i* GetTable( SALOMEDS::Study_var& theStudy, const VISU::Storable::TRestoringMap& theMap ) {
-  string anEntry = VISU::Storable::FindValue( theMap, "TableID" ).latin1();
-  SALOMEDS::SObject_var aSObject = theStudy->FindObjectID( anEntry.c_str() );
-  CORBA::Object_var anObject = VISU::SObjectToObject( aSObject );
+static VISU::Table_i* GetTable( SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSO ) {
+  CORBA::Object_var anObject = VISU::SObjectToObject( theSO );
   if( !CORBA::is_nil( anObject ) ) {
     CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
     if( !CORBA::is_nil( aTable ) )
-      return dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
+      return dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
   }
   return NULL;
 }
@@ -288,6 +298,7 @@ VISU::Curve_i::Curve_i(SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::L
 */
 VISU::Curve_i::~Curve_i()
 {
+  MESSAGE("Curve_i::~Curve_i");
 }
 /*!
   Creates curve object
@@ -304,13 +315,12 @@ VISU::Storable* VISU::Curve_i::Create()
 /*!
   Builds presentation of curve
 */
-VISU::Storable* VISU::Curve_i::Build( int theRestoring ) 
+VISU::Storable* VISU::Curve_i::Build(int theRestoring ) 
 {
   if ( myTable != NULL ) {
     // getting table SObject by it's entry
-    SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetEntry() );
     int nbRows = myTable->GetNbRows();
-    if ( !SO->_is_nil() && myHRow > 0 && myHRow <= nbRows && myVRow > 0 && myVRow <= nbRows ) {
+    if ( myHRow > 0 && myHRow <= nbRows && myVRow > 0 && myVRow <= nbRows ) {
       if ( !theRestoring ) {
        // look for component
        SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
@@ -318,13 +328,15 @@ VISU::Storable* VISU::Curve_i::Build( int theRestoring )
        QString aComment;
        aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TCURVE);
        string anEntry = CreateAttributes( myStudy, 
-                                          myTable->GetEntry(),
-                                          "",
-                                          GetID(),
-                                          GetName(),
-                                          "",
-                                          aComment.latin1(),
-                                          true );
+                                         myTable->GetObjectEntry(),
+                                         "",
+                                         GetID(),
+                                         GetName(),
+                                         "",
+                                         aComment.latin1(),
+                                         true );
+       // create SObject referenced to real table object
+       mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
       }
       return this;
     }
@@ -338,7 +350,7 @@ VISU::Storable* VISU::Curve_i::Build( int theRestoring )
 CORBA::Boolean VISU::Curve_i::IsValid()
 {
   // getting table SObject by it's entry
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetObjectEntry() );
+  SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -366,7 +378,7 @@ string VISU::Curve_i::GetHorTitle()
 {
   string title;
   // getting table SObject by it's entry
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetObjectEntry() );
+  SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -396,7 +408,7 @@ string VISU::Curve_i::GetVerTitle()
 {
   string title;
   // getting table SObject by it's entry
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetObjectEntry() );
+  SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -424,7 +436,7 @@ string VISU::Curve_i::GetHorUnits()
 {
   string units;
   // getting table SObject by it's entry
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetObjectEntry() );
+  SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -452,7 +464,7 @@ string VISU::Curve_i::GetVerUnits()
 {
   string units;
   // getting table SObject by it's entry
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetObjectEntry() );
+  SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -480,7 +492,7 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList )
 {
   theHorList = 0; theVerList = 0;
   // getting table SObject by it's entry
-  SALOMEDS::SObject_var SO = myStudy->FindObjectID( myTable->GetObjectEntry() );
+  SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
   SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var        anAttr;
   SALOMEDS::AttributeTableOfInteger_var anInt;
@@ -567,19 +579,19 @@ Plot2d_Curve* VISU::Curve_i::CreatePresentation()
   SALOMEDS::Color color = GetColor();
   crv->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
   crv->setAutoAssign( IsAuto() );
-  crv->setIO(new SALOME_InteractiveObject(strdup(GetEntry()),"VISU",strdup(GetName()))); 
+  crv->setIO(new SALOME_InteractiveObject(strdup(mySObj->GetID()),"VISU",strdup(GetName()))); 
   if ( myTable )
-    crv->setTableIO(new SALOME_InteractiveObject(strdup(myTable->GetEntry()),"VISU",strdup(myTable->GetName()))); 
+    crv->setTableIO(new SALOME_InteractiveObject(strdup(myTable->GetObjectEntry()),"VISU",strdup(myTable->GetName()))); 
   return crv;
 }
 /*!
   Restores curve object from stream
 */
-VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap )
-     throw( std::logic_error& )
+VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO)
 {
   if(MYDEBUG) MESSAGE(GetComment());
-  myName = (const char*)(VISU::Storable::FindValue(theMap,"myName"));
+  mySObj = SALOMEDS::SObject::_duplicate(theSO);
+  myName = VISU::Storable::FindValue(theMap,"myName").latin1();
   myHRow = VISU::Storable::FindValue(theMap,"myHRow").toInt();
   myVRow = VISU::Storable::FindValue(theMap,"myVRow").toInt();
   myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
@@ -587,6 +599,8 @@ VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap )
   myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
   myMarker = ( VISU::Curve::MarkerType )( VISU::Storable::FindValue(theMap,"myMarker").toInt() );
   myLine = ( VISU::Curve::LineType )( VISU::Storable::FindValue(theMap,"myLine").toInt() );
+  myLineWidth = VISU::Storable::FindValue(theMap,"myLineWidth").toInt();
+  myAuto = VISU::Storable::FindValue(theMap,"myAuto").toInt();
   return Build( true );
 }
 /*!
@@ -594,34 +608,34 @@ VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap )
 */
 void VISU::Curve_i::ToStream( std::ostringstream& theStr )
 {
-  Storable::DataToStream( theStr, "TableID",   GetTableID());
-  Storable::DataToStream( theStr, "myName",    myName.c_str() );
-  Storable::DataToStream( theStr, "myHRow",    myHRow );
-  Storable::DataToStream( theStr, "myVRow",    myVRow );
-  Storable::DataToStream( theStr, "myColor.R", myColor.R );
-  Storable::DataToStream( theStr, "myColor.G", myColor.G );
-  Storable::DataToStream( theStr, "myColor.B", myColor.B );
-  Storable::DataToStream( theStr, "myMarker",  myMarker );
-  Storable::DataToStream( theStr, "myLine",    myLine );
+  Storable::DataToStream( theStr, "myName",      myName.c_str() );
+  Storable::DataToStream( theStr, "myHRow",      myHRow );
+  Storable::DataToStream( theStr, "myVRow",      myVRow );
+  Storable::DataToStream( theStr, "myColor.R",   myColor.R );
+  Storable::DataToStream( theStr, "myColor.G",   myColor.G );
+  Storable::DataToStream( theStr, "myColor.B",   myColor.B );
+  Storable::DataToStream( theStr, "myMarker",    myMarker );
+  Storable::DataToStream( theStr, "myLine",      myLine );
+  Storable::DataToStream( theStr, "myLineWidth", myLineWidth );
+  Storable::DataToStream( theStr, "myAuto",      myAuto );
 }
 /*!
   Gets reference table's entry
 */
 const char* VISU::Curve_i::GetTableID() { 
-  return CORBA::string_dup(myTable->GetEntry());
+  return CORBA::string_dup(myTable->GetObjectEntry());
 }
 /*!
   Called from engine to restore curve from the file
 */
 VISU::Storable* VISU::Curve_i::Restore(SALOMEDS::SObject_ptr theSObject, 
                                       const string& thePrefix, const Storable::TRestoringMap& theMap)
-  throw(std::logic_error&)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
-  VISU::Table_i* pTable = GetTable( aStudy, theMap );
+  VISU::Table_i* pTable = GetTable(aStudy, theSObject->GetFather());
   if( pTable != NULL ) {
     VISU::Curve_i* pResent = new VISU::Curve_i( aStudy, pTable, 0, 0 );
-    return pResent->Restore( theMap );
+    return pResent->Restore( theMap, theSObject);
   }
   return NULL;
 }
@@ -636,7 +650,7 @@ const string VISU::Container_i::myComment  = "CONTAINER";
 */
 const char* VISU::Container_i::GenerateName() 
 { 
-  return VISU::GenerateName( "Container", ++myNbPresent ); 
+  return VISU::GenerateName( "Plot2DView", ++myNbPresent ); 
 }
 /*!
   Gets comment string
@@ -657,6 +671,7 @@ VISU::Container_i::Container_i( SALOMEDS::Study_ptr theStudy )
 */
 VISU::Container_i::~Container_i()
 {
+  MESSAGE("Container_i::~Container_i");
   myCurves.clear();
 }
 /*!
@@ -716,6 +731,7 @@ void VISU::Container_i::RemoveCurve( Curve_ptr theCurve )
 */
 CORBA::Long VISU::Container_i::GetNbCurves()
 {
+  Update();
   return myCurves.count();
 }
 /*!
@@ -848,7 +864,7 @@ VISU::Curve_i* VISU::Container_i::GetCurve( CORBA::Long theIndex )
       // if real Curve Object exists 
       CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
       if( !CORBA::is_nil( aCurve ) )
-      return dynamic_cast<VISU::Curve_i*>(VISU::GetServant( aCurve ) );
+      return dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
     }
   }
   return NULL;
@@ -857,10 +873,9 @@ VISU::Curve_i* VISU::Container_i::GetCurve( CORBA::Long theIndex )
   Restores container data from the stream
 */
 VISU::Storable* VISU::Container_i::Restore( const Storable::TRestoringMap& theMap )
-     throw( std::logic_error& )
 {
   if(MYDEBUG) MESSAGE(GetComment());
-  myName = (const char*)(VISU::Storable::FindValue( theMap, "myName" )); 
+  myName = VISU::Storable::FindValue( theMap, "myName" ).latin1(); 
   QString val = VISU::Storable::FindValue( theMap, "myCurves" );
   myCurves = QStringList::split( QString( "*" ), val, false );
   return Build( true );
@@ -880,7 +895,6 @@ void VISU::Container_i::ToStream( std::ostringstream& theStr )
 */
 VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject, 
                                           const string& thePrefix, const Storable::TRestoringMap& theMap)
-  throw(std::logic_error&)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::Container_i* pResent = new VISU::Container_i( aStudy );
@@ -901,7 +915,7 @@ struct TRow{
 
 typedef vector<TRow> TRows;
 
-struct TTable2D{
+struct TTable2D {
   string myTitle;
   vector<string> myColumnUnits;
   vector<string> myColumnTitles;
@@ -1088,3 +1102,94 @@ SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Stud
   }
   return aFileObject;
 }
+
+template<class TTableAttr> bool ExportTableToFile(const TTableAttr& aTabAttr,  
+                                                 const char* theFileName)
+{
+  if (!CORBA::is_nil(aTabAttr)) {
+    QFile aFile(theFileName);  
+    aFile.open(IO_WriteOnly);  
+
+    /* extract the tabe info and write it into file */ 
+    
+    QString aTitle(aTabAttr->GetTitle()); /*Table title*/ 
+    int aRowsNb = aTabAttr->GetNbRows();  
+    int aColNb  = aTabAttr->GetNbColumns(); 
+    
+    SALOMEDS::StringSeq_var aRowTitles = aTabAttr->GetRowTitles(); 
+    QString anAbscissTitle(aRowTitles[0]); /*Absciss row title (X coord)*/ 
+    anAbscissTitle.stripWhiteSpace();       
+
+    SALOMEDS::StringSeq_var aRowUnits = aTabAttr->GetRowUnits(); 
+    QString anAbscissUnit(aRowUnits[0]); 
+    anAbscissUnit.stripWhiteSpace();     
+    
+    SALOMEDS::StringSeq_var aColumnTitles = aTabAttr->GetColumnTitles(); 
+    if (aRowsNb > 2 && aTitle.length() )  aTitle = aTitle + " - ";
+
+    QString aLine;                      
+    for (int i = 2; i <= aRowsNb; i++ ) 
+      {                                 
+       /* TITLE */                     
+       QString anOrdinate(aRowTitles[i-1]), aTail; 
+       anOrdinate.stripWhiteSpace();                      
+
+       aLine = "#TITLE: " + aTitle +                              
+         ((anOrdinate.length())?  anOrdinate : 
+                                 (aRowsNb>2)? aTail.sprintf("%d",i-1) : aTail.sprintf("") ) + "\n"; 
+       aFile.writeBlock(aLine, aLine.length() );                               
+                                                                                   
+       /* COLUMN_TITLES */                                                     
+       if ( anAbscissTitle.length() || anOrdinate.length() ) {                    
+         aLine = "#COLUMN_TITLES: " + anAbscissTitle + " | " + anOrdinate + "\n";    
+         aFile.writeBlock(aLine, aLine.length() );                                
+       }                                                                          
+
+       /* COLUMN_UNITS */                           
+       aLine = anAbscissUnit + " " +aRowUnits[i-1]; 
+       if (!aLine.stripWhiteSpace().isEmpty()) {    
+         aLine = "#COLUMN_UNITS: " + aLine  + "\n"; 
+         aFile.writeBlock(aLine, aLine.length() );  
+       }    
+
+       /* CURVE COORDINATES */                      
+       for (int j = 1; j <= aColNb; j++)            
+         {                                          
+           if ( aTabAttr -> HasValue(i,j) &&  aTabAttr -> HasValue(1, j)) { 
+             aLine = aLine.sprintf("%.16g %.16g",            
+                                   (double)(aTabAttr->GetValue(1,j)),  
+                                   (double)(aTabAttr->GetValue(i,j)));  /* aTabAttr->GetValue(1,j) - X coord */ 
+             if ( !aLine.stripWhiteSpace().isEmpty() ) {     
+               QString aColTitle(aColumnTitles[j-1]);        
+               if ( !aColTitle.stripWhiteSpace().isEmpty() ) 
+                 aLine = aLine + "  #TITLE: " + aColTitle ;  
+               aFile.writeBlock(aLine + "\n", aLine.length() + 1); 
+             }     
+           }       
+         }   
+       aFile.writeBlock("\n", 1); 
+      }             
+    aFile.close();  
+    return true;    
+  }                 
+  return false;
+}
+bool VISU::ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName)
+{
+  //Find table
+  SALOMEDS::GenericAttribute_var anAttr ;
+  if (theTable->FindAttribute(anAttr, "AttributeTableOfReal"))
+    {
+      SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal ::_narrow(anAttr); 
+      return ExportTableToFile ( aTabAttr , theFileName);
+      
+    }
+  else if (theTable->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+
+    SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger ::_narrow(anAttr); 
+    return ExportTableToFile ( aTabAttr , theFileName);
+    
+  }
+  return false;
+}