<li>From the following standard dialog box:
-\image html importtablefromfile.png
+\image html importtables.png
+
+choose the necessary *.txt, *.tab or *.csv file containing tables and
+click \b Open button.
+
+Checkbox "Use first string as title" is checked if it is needed to use
+information from first string of file as titles of columns of table.
-choose the necessary *.txt or *.tab file containing tables and
-click \b Open button.
</li>
<li>In the Object Browser \b Post-Pro will create a new folder having
contain your exported table, and click \b OK button. Your table will
be exported.
-\image html exporttable.png
+You can perform export table to *.txt or *.tab file
+
+\image html exporttables1.png
+
+Or you can perform export table to *.csv file
+
+\image html exporttables2.png
</li>
</ul>
ViewManager GetViewManager();
/*!
- * Imports tables from a file and create TableAttribute in Sudy
+ * Imports tables from a file and create TableAttribute in Study
*/
- SALOMEDS::SObject ImportTables(in string theFileName);
+ SALOMEDS::SObject ImportTables(in string theFileName,
+ in boolean theFirstStrAsTitle);
/*!
* Export table to a file
return !theStmIn.eof();
}
+
+ //=======================================================================
+ //function : findNextCell
+ //purpose : auxilary for ImportCSVTable
+ //=======================================================================
+ bool findNextCell(std::ifstream& aStmIn, QString& aStr,
+ QString& aCell, const char theSeparator)
+ {
+ aCell = "";
+ int index, tmpind = 0;
+ if( aStr.at(0) == theSeparator ) {
+ aStr.remove(0,1);
+ aStr = aStr.trimmed();
+ if(aStr.size()==0) return true;
+ }
+ QString aTmp = aStr;
+ if( aTmp.at(0) == '"' ) {
+ // find closed "
+ while( !aStmIn.eof() ) {
+ tmpind = aTmp.indexOf('"',1);
+ if( tmpind < 0 ) {
+ while( !aStmIn.eof() ) {
+ aCell.push_back(aTmp);
+ aCell.push_back('\n');
+ ::getLine( aStmIn, aTmp );
+ tmpind = aTmp.indexOf('"',1);
+ if( tmpind >= 0 ) {
+ break;
+ }
+ }
+ }
+ if(tmpind < 0)
+ return false;
+ // read next symbol
+ if( aTmp.at(tmpind+1) == '"' ) {
+ // "" is found => need to continue
+ aCell.push_back(aTmp.left(tmpind+1));
+ aTmp = aTmp.mid(tmpind+2);
+ }
+ else if( aTmp.at(tmpind+1) == theSeparator ) {
+ index = tmpind+1;
+ break;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+ else {
+ // find index for separator
+ index = aTmp.indexOf( theSeparator );
+ }
+ if( index < 0 ) {
+ aCell += aTmp;
+ aStr = "";
+ }
+ else {
+ if(index>0) aCell += aTmp.left(index);
+ aStr = aTmp.mid(index).trimmed();
+ }
+ if( aCell.size()>0 && aCell.at(0) == '"' ) {
+ // remove first and last symbols
+ int last = aCell.size()-1;
+ aCell.remove(last,1);
+ aCell.remove(0,1);
+ }
+ // replace "" to " in aCell
+ QChar ctmp = '"';
+ QString tmp(ctmp);
+ tmp += ctmp;
+ index = aCell.indexOf(tmp);
+ while(index>=0) {
+ aCell.remove(index,1);
+ index = aCell.indexOf(tmp);
+ }
+ return true;
+ }
+
}
//---------------------------------------------------------------
void
-VISU::ImportTables( const char* theFileName, TTableContainer& theContainer )
+VISU::ImportTables( const char* theFileName, TTableContainer& theContainer,
+ bool theFirstStrAsTitle)
{
std::ifstream aStmIn;
QFileInfo aFileInfo( theFileName );
if( !aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size() )
return;
+ QString tmp(theFileName);
+ tmp = tmp.trimmed();
+ tmp = tmp.right(3).trimmed();
+
+ if( tmp == QString("csv") ) {
+ const char separator = ',';
+ ImportCSVTable(theFileName, theContainer, theFirstStrAsTitle, separator);
+ return;
+ }
+
aStmIn.open( theFileName );
QString aTmp;
do {
TTable2D& aTable2D = *aTableIDMapper;
if(MYDEBUG) std::cout << "New table is found" << std::endl;
+ bool IsFirst = true;
while( !aStmIn.eof() && aTmp.trimmed() != "" ){
QString data = aTmp.trimmed();
QString cmt = "";
else {
TTable2D::TRow aRow;
if(MYDEBUG) std::cout << "...New row is found: " << std::endl;
- if ( !cmt.isEmpty() ) {
- aRow.myTitle = cmt.toLatin1().constData();
- if(MYDEBUG) std::cout << "......ROW TITLE is: " << cmt.toLatin1().constData() << std::endl;
- }
QString datar1 = data.replace(QRegExp("\t"), " ");
QStringList aValList = datar1.split( " ", QString::SkipEmptyParts );
- for ( int i = 0; i < aValList.count(); i++ ) {
- if ( aValList[i].trimmed() != "" ) {
- TTable2D::TValue aVal = aValList[i].trimmed().toLatin1().constData();
- aRow.myValues.push_back( aVal );
+ if( aTable2D.myColumnTitles.size()==0 && IsFirst && theFirstStrAsTitle ) {
+ for ( int i = 0; i < aValList.count(); i++ ) {
+ QString tmpstr = aValList[ i ].trimmed();
+ aTable2D.myColumnTitles.push_back( tmpstr.toLatin1().constData() );
}
}
- if( aRow.myValues.size() > 0 )
- aTable2D.myRows.push_back( aRow );
+ else {
+ if ( !cmt.isEmpty() ) {
+ aRow.myTitle = cmt.toLatin1().constData();
+ if(MYDEBUG) std::cout << "......ROW TITLE is: " << cmt.toLatin1().constData() << std::endl;
+ }
+ //QString datar1 = data.replace(QRegExp("\t"), " ");
+ //QStringList aValList = datar1.split( " ", QString::SkipEmptyParts );
+ for ( int i = 0; i < aValList.count(); i++ ) {
+ if ( aValList[i].trimmed() != "" ) {
+ TTable2D::TValue aVal = aValList[i].trimmed().toLatin1().constData();
+ aRow.myValues.push_back( aVal );
+ }
+ }
+ if( aRow.myValues.size() > 0 )
+ aTable2D.myRows.push_back( aRow );
+ }
+ IsFirst = false;
// ************** OLD CODE ******************
/*
TValue aVal;
}
+//=======================================================================
+//function : ImportCSVTable
+//purpose :
+//=======================================================================
+void VISU::ImportCSVTable(const char* theFileName, TTableContainer& theContainer,
+ bool theFirstStrAsTitle, const char theSeparator)
+{
+ std::ifstream aStmIn;
+ QFileInfo aFileInfo( theFileName );
+ if( !aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size() )
+ return;
+ aStmIn.open( theFileName );
+ QString aTmp;
+ do {
+ // find beginning of table (tables are separated by empty lines)
+ while( ::getLine( aStmIn, aTmp ) && aTmp.trimmed() == "");
+
+ PTableIDMapper aTableIDMapper( new TTableIDMapper() );
+ TTable2D& aTable2D = *aTableIDMapper;
+ if(MYDEBUG) std::cout << "New table is found" << std::endl;
+
+ bool IsFirst = true;
+ QStringList aValList;
+
+ while( !aStmIn.eof() ) {
+ QString aCell = "";
+ if( !(::findNextCell(aStmIn, aTmp, aCell, theSeparator)) ) {
+ return;
+ }
+ if( aTmp.size()==0 ) {
+ // make table row
+ aValList.push_back(aCell);
+ if( IsFirst && theFirstStrAsTitle ) {
+ for ( int i = 0; i < aValList.count(); i++ ) {
+ aTable2D.myColumnTitles.push_back( aValList[i].trimmed().toLatin1().constData() );
+ }
+ }
+ else {
+ TTable2D::TRow aRow;
+ for ( int i = 0; i < aValList.count(); i++ ) {
+ if ( aValList[i].trimmed() != "" ) {
+ TTable2D::TValue aVal = aValList[i].trimmed().toLatin1().constData();
+ aRow.myValues.push_back( aVal );
+ }
+ else {
+ aRow.myValues.push_back( "Empty" );
+ }
+ }
+ if( aRow.myValues.size() > 0 ) {
+ aTable2D.myRows.push_back( aRow );
+ }
+ }
+ // clear list of values and read next string
+ aValList.clear();
+ ::getLine( aStmIn, aTmp );
+ IsFirst = false;
+ }
+ else {
+ // put value to table cell
+ aValList.push_back(aCell);
+ }
+ }
+
+ if( aTable2D.Check() ) {
+ if(MYDEBUG) std::cout << "aTable2D is checked OK " << aTable2D.myTitle << std::endl;
+ theContainer.push_back( aTableIDMapper );
+ }
+
+ } while ( !aStmIn.eof() );
+ aStmIn.close();
+
+ if(MYDEBUG) std::cout << "After close" << std::endl;
+}
+
+
//---------------------------------------------------------------
VISU::TTableIDMapper
::TTableIDMapper():
myOutput->ShallowCopy( aFilter->GetOutput() );
aFilter->Delete();
}
+
//---------------------------------------------------------------
typedef std::vector<PTableIDMapper> TTableContainer;
VISU_CONVERTOR_EXPORT
- void ImportTables( const char* theFileName, TTableContainer& theContainer );
+ void ImportTables( const char* theFileName, TTableContainer& theContainer,
+ bool theFirstStrAsTitle = false);
+ void ImportCSVTable(const char* theFileName,
+ TTableContainer& theContainer,
+ bool theFirstStrAsTitle,
+ const char theSeparator);
//---------------------------------------------------------------
}
}
- SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
- return myVisuGen->ImportTables(theFileName);
+ SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName,
+ bool theFirstStrAsTitle)
+ {
+ return myVisuGen->ImportTables(theFileName,theFirstStrAsTitle);
}
virtual ViewManager_ptr GetViewManager();
- virtual SALOMEDS::SObject_ptr ImportTables(const char* theFileName);
- virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
+ virtual SALOMEDS::SObject_ptr ImportTables(const char* theFileName,
+ bool theFirstStrAsTitle = false);
+ virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable,
+ const char* theFileName);
//Create Result
virtual Result_ptr ImportFile(const char* theFileName);
virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField);
//Create Presentation Of Submeshes
- virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity);
+ virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName,
+ VISU::Entity theEntity);
virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName,
VISU::Entity theEntity, const char* theFamilyName);
- virtual Mesh_ptr GroupMesh(Result_ptr theResult, const char* theMeshName, const char* theGroupName);
+ virtual Mesh_ptr GroupMesh(Result_ptr theResult, const char* theMeshName,
+ const char* theGroupName);
//Rename Presentation Of Submeshes
virtual void RenameEntityInStudy(Result_ptr theResult, const char* theMeshName,
VISU::Entity theEntity, const char* theNewName);
- virtual void RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual void RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName,
+ VISU::Entity theEntity,
const char* theFamilyName, const char* theNewName);
virtual void RenameGroupInStudy (Result_ptr theResult, const char* theMeshName,
const char* theGroupName, const char* theNewName);
</message>
<message>
<source>FLT_TABLE_FILES</source>
- <translation>Tables (*.txt *.tab)</translation>
+ <translation>Tables (*.txt *.tab *.csv)</translation>
</message>
<message>
<source>IMPORT_FROM_FILE</source>
<source>USE_BUILD_PROGRESS</source>
<translation>Use build progress</translation>
</message>
+ <message>
+ <source>FIRST_STR_AS_TITLE</source>
+ <translation>Use first string as title</translation>
+ </message>
<message>
<source>MEN_LOAD_COMPONENT_DATA</source>
<translation>Load Component Data</translation>
aFilter.append( tr("FLT_TABLE_FILES") );
aFilter.append( tr("FLT_ALL_FILES") );
- QString anInitialPath = "";
- if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
- anInitialPath = QDir::currentPath();
-
- QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this),
- anInitialPath,
- aFilter,
- tr("TLT_IMPORT_TABLE"));
+ //QString anInitialPath = "";
+ //if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ // anInitialPath = QDir::currentPath();
+
+ //QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this),
+ // anInitialPath,
+ // aFilter,
+ // tr("TLT_IMPORT_TABLE"));
+
+ SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+ bool aFirstStrAsTitle = aResourceMgr->booleanValue("VISU", "first_str_as_title", false);
+
+ SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("FIRST_STR_AS_TITLE") );
+ fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) );
+ fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles );
+ fd.setFilters( aFilter );
+ fd.SetChecked( aFirstStrAsTitle );
+ if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() )
+ fd.setDirectory( QDir::currentPath() );
+
+ QStringList aFiles;
+ if ( !fd.exec() )
+ return; // cancelled, return
+ aFiles = fd.selectedFiles();
+ aFirstStrAsTitle = fd.IsChecked();
+
if ( aFiles.count() == 0 )
return; // nothing selected
QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
application()->putInfo( anInfo );
- CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData());
+ CORBA::Object_var anObject =
+ GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData(),
+ aFirstStrAsTitle);
if (CORBA::is_nil(anObject.in())) {
errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
// get name for the file
QStringList aFilter;
aFilter.append("Table Files (*.txt *.tab)");
+ aFilter.append("CSV Table Files (*.csv)");
QFileInfo aFileInfo =
SUIT_FileDlg::getFileName(GetDesktop(this),
if (aTypeName == "ImportTables") {
QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
if(anIsExist){
- std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
- theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.toLatin1().data()<<"')"<<endl;
+ std::string aName =
+ GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
+ QString aFirstStrAsTitle =
+ VISU::Storable::FindValue(aMap,"myFirstStrAsTitle",&anIsExist);
+ theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"
+ <<aFileName.toLatin1().data()<<"',"
+ <<aFirstStrAsTitle.toLatin1().data()<<")"<<endl;
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
thePrefix += PREFIX;
//----------------------------------------------------------------------------
SALOMEDS::SObject_ptr
VISU_Gen_i
- ::ImportTables(const char* theFileName)
+ ::ImportTables(const char* theFileName, bool theFirstStrAsTitle)
{
if(myStudyDocument->GetProperties()->IsLocked())
return SALOMEDS::SObject::_nil();
- SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument);
+ SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument,
+ theFirstStrAsTitle);
SALOMEDS::Study_var aStudy = aRes->GetStudy();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aRes);
virtual
SALOMEDS::SObject_ptr
- ImportTables(const char* theFileName);
+ ImportTables(const char* theFileName, bool theFirstStrAsTitle = false);
virtual
CORBA::Boolean
}
SALOMEDS::SObject_var
-VISU::ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy)
+VISU::ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy,
+ bool theFirstStrAsTitle)
{
// Set "C" numeric locale to import numbers correctly
Kernel_Utils::Localizer loc;
TTableContainer aContainer;
- ImportTables( theFileName, aContainer );
+ ImportTables( theFileName, aContainer, theFirstStrAsTitle );
if ( aContainer.empty() )
return SALOMEDS::SObject::_nil();
anAttr = aStudyBuilder->FindOrCreateAttribute(aFileObject, "AttributeString");
SALOMEDS::AttributeString_var aComment = SALOMEDS::AttributeString::_narrow(anAttr);
QString aString;
- aString.sprintf("myComment=ImportTables;myFileName=%s",
- aFileInfo.absoluteFilePath().toLatin1().data());
+ aString.sprintf("myComment=ImportTables;myFileName=%s;myFirstStrAsTitle=%d",
+ aFileInfo.absoluteFilePath().toLatin1().data(),theFirstStrAsTitle);
aComment->SetValue(aString.toLatin1().data());
- for(int i = 0, iEnd = aContainer.size(); i < iEnd; i++){
+ for(int i = 0, iEnd = aContainer.size(); i < iEnd; i++) {
PTableIDMapper aTableIDMapper = aContainer[i];
const TTable2D& aTable2D = *aTableIDMapper;
SALOMEDS::SObject_var aRealObject = aStudyBuilder->NewObject(aFileObject);
if(MYDEBUG) MESSAGE("aTable2D.myTitle = "<<aTable2D.myTitle);
if ( aTable2D.myTitle != "" ) {
aName->SetValue(aTable2D.myTitle.c_str());
- } else {
+ }
+ else {
QString aNewName;
aNewName.sprintf("Table:%d",i);
aName->SetValue(aNewName.toLatin1().data());
aTable2D.getColumns(aNewTable2D);
int kEnd = aNewTable2D.myRows[0].myValues.size();
aTableOfReal->SetNbColumns(kEnd);
- for(int j = 0, jEnd = aNewTable2D.myRows.size(); j < jEnd; j++){
+ for(int j = 0, jEnd = aNewTable2D.myRows.size(); j < jEnd; j++) {
if(MYDEBUG) MESSAGE("j = "<<j<<"; kEnd = "<<kEnd);
- for(int k = 0; k < kEnd; k++){
+ for(int k = 0; k < kEnd; k++) {
QString aVal = aNewTable2D.myRows[j].myValues[k].c_str();
bool anIsOk = false;
double aValue = aVal.toDouble(&anIsOk);
return aFileObject;
}
+
+//=======================================================================
+//function : updateStrForCSV
+//purpose : auxilary for ExportTableToFile
+//=======================================================================
+void updateStrForCSV(QString& aStr, const char aSep)
+{
+ int index = aStr.indexOf('"');
+ while(index>=0) {
+ aStr.insert(index,'"');
+ if( index+2 >= aStr.size() ) break;
+ index = aStr.indexOf('"',index+2);
+ }
+ index = aStr.indexOf(aSep);
+ if(index>=0) {
+ // current string contains separator => need to use "..."
+ aStr.insert(0,'"');
+ aStr.push_back('"');
+ }
+}
+
+
+//=======================================================================
+//function : ExportTableToFile
+//purpose :
+//=======================================================================
template<class TTableAttr> bool ExportTableToFile(const TTableAttr& aTabAttr,
const char* theFileName)
{
SALOMEDS::StringSeq_var aRowUnits = aTabAttr->GetRowUnits();
SALOMEDS::StringSeq_var aColumnTitles = aTabAttr->GetColumnTitles();
+ //--------------------------------------------------
+ // write as *.csv file if it is needed
+ //--------------------------------------------------
+ QString tmp(theFileName);
+ tmp = tmp.trimmed();
+ tmp = tmp.right(3).trimmed();
+ if( tmp == QString("csv") ) {
+ const char aSep = ',';
+ // write column titles
+ QString aLine(aRowTitles[0]);
+ updateStrForCSV(aLine,aSep);
+ for(int i=1; i<aRowsNb; i++) {
+ aLine += aSep;
+ QString aTmp(aRowTitles[i]);
+ updateStrForCSV(aTmp,aSep);
+ aLine += aTmp;
+ }
+ aLine += "\n";
+ aFile.write(aLine.toLatin1() );
+ // write table data
+ QString aValue;
+ for (int j = 1; j <= aColNb; j++) {
+ QString aLine = "";
+ if(aTabAttr->HasValue(j,1)) {
+ aLine = aValue.sprintf("%.16g",(double)aTabAttr->GetValue(1,j));
+ }
+ for (int i = 2; i <= aRowsNb; i++) {
+ if(aTabAttr->HasValue(i,j)) {
+ aLine += aSep + aValue.sprintf("%.16g",(double)aTabAttr->GetValue(i,j));
+ }
+ else aLine += aSep;
+ }
+ aLine += "\n";
+ aFile.write(aLine.toLatin1() );
+ }
+
+ aFile.close();
+ return true;
+ }
+ //--------------------------------------------------
+ // end of writing as *.csv file
+ //--------------------------------------------------
+
/* The given table is rare (some cells is empty) or not? */
bool isRareTable = false;
for (int i = 1; i <= aRowsNb; i++)
/* COLUMN_TITLES */
if ( anAbscissTitle.length() || anOrdinate.length() ) {
- aLine = "#COLUMN_TITLES: " + anAbscissTitle + " | " + anOrdinate + "\n";
+ aLine = "#COLUMN_TITLES: " + anAbscissTitle + " | " + anOrdinate;
+ int tmpind = aLine.indexOf("\n");
+ while(tmpind>=0) {
+ aLine.remove(tmpind,1);
+ tmpind = aLine.indexOf("\n");
+ }
+ aLine += "\n";
aFile.write(aLine.toLatin1() );
}
QString aUnitsSep = "";
QString aTitlesStr = "#COLUMN_TITLES: ";
QString aUnitsStr = "#COLUMN_UNITS: ";
- for (int i = 1; i <= aRowsNb; i++)
- {
- if (!QString(aRowTitles[i-1]).trimmed().isEmpty()) {
- aTitlesStr += (aTitlesSep + aRowTitles[i-1]);
- if (aTitlesSep.isEmpty()) aTitlesSep = " | ";
- }
- if (!QString(aRowUnits[i-1]).trimmed().isEmpty()) {
- aUnitsStr += (aUnitsSep + aRowUnits[i-1]);
- if (aUnitsSep.isEmpty()) aUnitsSep = " ";
- }
+ for (int i = 1; i <= aRowsNb; i++) {
+ if (!QString(aRowTitles[i-1]).trimmed().isEmpty()) {
+ aTitlesStr += (aTitlesSep + aRowTitles[i-1]);
+ if (aTitlesSep.isEmpty()) aTitlesSep = " | ";
+ }
+ if (!QString(aRowUnits[i-1]).trimmed().isEmpty()) {
+ aUnitsStr += (aUnitsSep + aRowUnits[i-1]);
+ if (aUnitsSep.isEmpty()) aUnitsSep = " ";
}
+ }
+ int tmpind = aTitlesStr.indexOf("\n");
+ while(tmpind>=0) {
+ aTitlesStr.remove(tmpind,1);
+ tmpind = aTitlesStr.indexOf("\n");
+ }
aTitlesStr += "\n";
aUnitsStr += "\n";
aFile.write(aTitlesStr.toLatin1());
/* CURVE COORDINATES */
QString aSep, aValue, aColTitle;
- for (int j = 1; j <= aColNb; j++)
- {
- aLine = ""; aSep = "";
- for (int i = 1; i <= aRowsNb; i++)
- {
- aLine += (aSep + aValue.sprintf("%.16g", (double)(aTabAttr->GetValue(i,j))));
- if (aSep.isEmpty()) aSep = " ";
- }
- if (!aLine.trimmed().isEmpty()) {
- aColTitle = aColumnTitles[j-1];
- if (!aColTitle.trimmed().isEmpty())
- aLine = aLine + " #TITLE: " + aColTitle;
- aLine += "\n";
- aFile.write(aLine.toLatin1());
- }
+ for (int j = 1; j <= aColNb; j++) {
+ aLine = ""; aSep = "";
+ for (int i = 1; i <= aRowsNb; i++) {
+ aLine += (aSep + aValue.sprintf("%.16g", (double)(aTabAttr->GetValue(i,j))));
+ if (aSep.isEmpty()) aSep = " ";
}
+ if (!aLine.trimmed().isEmpty()) {
+ aColTitle = aColumnTitles[j-1];
+ if (!aColTitle.trimmed().isEmpty())
+ aLine = aLine + " #TITLE: " + aColTitle;
+ aLine += "\n";
+ aFile.write(aLine.toLatin1());
+ }
+ }
} //end of else
aFile.close();
{
//Find table
SALOMEDS::GenericAttribute_var anAttr ;
- if (theTable->FindAttribute(anAttr, "AttributeTableOfReal"))
- {
- SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal ::_narrow(anAttr);
- return ExportTableToFile ( aTabAttr , theFileName);
-
- }
+ 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);
+ SALOMEDS::AttributeTableOfInteger_var aTabAttr =
+ SALOMEDS::AttributeTableOfInteger ::_narrow(anAttr);
return ExportTableToFile ( aTabAttr , theFileName);
-
}
return false;
}
virtual std::string GetObjectEntry();
};
- SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy);
+ SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy,
+ bool theFirstStrAsTitle = false);
bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
//==============================================================================
class VISU_I_EXPORT Curve_i : public virtual POA_VISU::Curve,