1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_Table_i.cc
24 // Author : Vadim SANDLER
27 #include "VISU_Table_i.hh"
29 #include "VISU_CutLines_i.hh"
30 #include "VISU_Result_i.hh"
32 #include "SPlot2d_Curve.h"
38 #include <qfileinfo.h>
45 static int MYDEBUG = 0;
47 static int MYDEBUG = 0;
49 //----------------------------------------------------------------
51 //----------------------------------------------------------------
52 int VISU::Table_i::myNbPresent = 0;
53 const string VISU::Table_i::myComment = "TABLE";
57 const char* VISU::Table_i::GenerateName()
59 return VISU::GenerateName( "Table", ++myNbPresent );
64 const char* VISU::Table_i::GetComment() const
66 return myComment.c_str();
71 VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry )
72 : PrsObject_i(theStudy)
74 mySObj = SALOMEDS::SObject::_duplicate((theStudy->FindObjectID(theObjectEntry)));
75 myOrientation = VISU::Table::HORIZONTAL;
80 VISU::Table_i::~Table_i()
82 MESSAGE("Table_i::~Table_i");
85 Gets number of rows in table
87 CORBA::Long VISU::Table_i::GetNbRows()
89 SALOMEDS::SObject_var SO = mySObj;
90 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
91 if ( !SO->_is_nil() ) {
92 SALOMEDS::GenericAttribute_var anAttr;
93 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
94 SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
95 return anInt->GetNbRows();
97 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
98 SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
99 return aReal->GetNbRows();
105 Gets number of columns in table
107 CORBA::Long VISU::Table_i::GetNbColumns()
109 SALOMEDS::SObject_var SO = mySObj;
110 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
111 if ( !SO->_is_nil() ) {
112 SALOMEDS::GenericAttribute_var anAttr;
113 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
114 SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
115 return anInt->GetNbColumns();
117 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
118 SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
119 return aReal->GetNbColumns();
127 VISU::Storable* VISU::Table_i::Create()
130 myName = GetTableTitle();
132 // mpv (PAL 5357): if name attribute already exist at this label, use it as name of table
134 if ( !mySObj->_is_nil() ) {
135 CutLines_i* pCutLines = NULL;
136 CORBA::Object_var anObj = SObjectToObject(mySObj);
137 if(!CORBA::is_nil(anObj)){
138 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj);
139 if(!aCutLines->_is_nil())
140 pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines).in());
143 if (mySObj->GetName()) myName = mySObj->GetName();
147 myName = GenerateName();
148 // ... and build the object
149 return Build( false );
152 Builds presentation of table
154 VISU::Storable* VISU::Table_i::Build( int theRestoring )
157 // look for reference SObject with table attribute
158 SALOMEDS::SObject_var SO = mySObj;
160 if ( !SO->_is_nil() ) {
161 CutLines_i* pCutLines = NULL;
162 CORBA::Object_var anObj = SObjectToObject(SO);
163 if(!CORBA::is_nil(anObj)){
164 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj);
165 if(!aCutLines->_is_nil())
166 pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines).in());
168 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
169 SALOMEDS::GenericAttribute_var anAttr;
170 // look for component
171 if ( !theRestoring ) {
172 SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
173 // create SObject and set attributes
176 aComment.sprintf("myComment=%s;myType=%d;mySourceId=CutLines",GetComment(),VISU::TTABLE);
178 aComment.sprintf("myComment=%s;myType=%d;mySourceId=TableAttr",GetComment(),VISU::TTABLE);
179 SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
180 if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){
181 SALOMEDS::AttributeComment_var aCommentAttr =
182 SALOMEDS::AttributeComment::_narrow(anAttr);
183 CORBA::String_var aValue = aCommentAttr->Value();
184 Storable::TRestoringMap aMap;
185 Storable::StrToMap(aValue.in(),aMap);
187 QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
189 if(strcmp(aMethodName.latin1(),"ImportTables") == 0){
190 aComment.sprintf("myComment=%s;myType=%d;mySourceId=TableFile",GetComment(),VISU::TTABLE);
196 string anEntry = CreateAttributes( myStudy,
197 SO->GetID(),//SComponent->GetID(),
204 // create SObject referenced to real table object
205 mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID( anEntry.c_str() ));
207 pCutLines->BuildTableOfReal(mySObj);
209 // mpv (PAL5357): reference attributes are unnecessary now
210 //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
211 //Builder->Addreference( refSO, SO );
218 Restores table object from stream
220 VISU::Storable* VISU::Table_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO)
222 if(MYDEBUG) MESSAGE(GetComment());
223 myName = (const char*)(VISU::Storable::FindValue(theMap,"myName"));
224 myTitle = (const char*)(VISU::Storable::FindValue(theMap,"myTitle"));
225 myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
226 mySObj = SALOMEDS::SObject::_duplicate(SO);
227 return Build( true );
230 Flushes table data into stream
232 void VISU::Table_i::ToStream( std::ostringstream& theStr )
234 Storable::DataToStream( theStr, "myName", myName.c_str() );
235 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
236 Storable::DataToStream( theStr, "myOrientation", myOrientation );
239 Called from engine to restore table from the file
241 VISU::Storable* VISU::Table_i::Restore(SALOMEDS::SObject_ptr theSObject,
242 const string& thePrefix, const Storable::TRestoringMap& theMap)
244 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
245 VISU::Table_i* pResent = new VISU::Table_i( aStudy, "" );
246 return pResent->Restore( theMap, theSObject);
249 Gets title for the original table object
251 const char* VISU::Table_i::GetTableTitle()
253 SALOMEDS::SObject_var SO = mySObj;
254 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
255 SALOMEDS::GenericAttribute_var anAttr;
256 SALOMEDS::AttributeTableOfInteger_var anInt;
257 SALOMEDS::AttributeTableOfReal_var aReal;
258 if ( !SO->_is_nil() ) {
259 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
260 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
261 return anInt->GetTitle();
263 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
264 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
265 return aReal->GetTitle();
271 void VISU::Table_i::RemoveFromStudy(){
272 VISU::RemoveFromStudy(mySObj,false);
275 //----------------------------------------------------------------
277 //----------------------------------------------------------------
279 Restores table object from the stream [ static ]
281 static VISU::Table_i* GetTable( SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSO ) {
282 CORBA::Object_var anObject = VISU::SObjectToObject( theSO );
283 if( !CORBA::is_nil( anObject ) ) {
284 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
285 if( !CORBA::is_nil( aTable ) )
286 return dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
291 int VISU::Curve_i::myNbPresent = 0;
292 const string VISU::Curve_i::myComment = "CURVE";
296 const char* VISU::Curve_i::GenerateName()
298 return VISU::GenerateName( "Curve", ++myNbPresent );
303 const char* VISU::Curve_i::GetComment() const
305 return myComment.c_str();
309 NB : theHRow, theVRow are the indexes of rows in the Table object and numbered from the 1 to GetNbRows()
311 VISU::Curve_i::Curve_i(SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::Long theHRow, CORBA::Long theVRow )
312 : PrsObject_i(theStudy), myTable( theTable ), myHRow( theHRow ), myVRow( theVRow )
315 myLine = VISU::Curve::SOLIDLINE;
317 myMarker = VISU::Curve::CIRCLE;
318 myColor.R = 0.0; myColor.G = 0.0; myColor.B = 0.0;
323 VISU::Curve_i::~Curve_i()
325 MESSAGE("Curve_i::~Curve_i");
330 VISU::Storable* VISU::Curve_i::Create()
333 myName = GetVerTitle();
335 myName = GenerateName();
336 // ... and build the object
337 return Build( false );
340 Builds presentation of curve
342 VISU::Storable* VISU::Curve_i::Build(int theRestoring )
344 if ( myTable != NULL ) {
345 // getting table SObject by it's entry
346 int nbRows = myTable->GetNbRows();
347 if ( myHRow > 0 && myHRow <= nbRows && myVRow > 0 && myVRow <= nbRows ) {
348 if ( !theRestoring ) {
349 // look for component
350 SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
351 // create SObject and set attributes
353 aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TCURVE);
354 string anEntry = CreateAttributes( myStudy,
355 myTable->GetObjectEntry(),
362 // create SObject referenced to real table object
363 mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
372 Returns CORBA::True if curve refers to valid table data
374 CORBA::Boolean VISU::Curve_i::IsValid()
376 // getting table SObject by it's entry
377 SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
378 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
379 SALOMEDS::GenericAttribute_var anAttr;
380 SALOMEDS::AttributeTableOfInteger_var anInt;
381 SALOMEDS::AttributeTableOfReal_var aReal;
382 if ( !SO->_is_nil() ) {
383 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
384 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
385 if ( myHRow > 0 && myHRow <= anInt->GetNbRows() && myVRow > 0 && myVRow <= anInt->GetNbRows() ) {
389 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
390 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
391 if ( myHRow > 0 && myHRow <= aReal->GetNbRows() && myVRow > 0 && myVRow <= aReal->GetNbRows() ) {
399 Returns hor.axis title
401 string VISU::Curve_i::GetHorTitle()
404 // getting table SObject by it's entry
405 SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
406 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
407 SALOMEDS::GenericAttribute_var anAttr;
408 SALOMEDS::AttributeTableOfInteger_var anInt;
409 SALOMEDS::AttributeTableOfReal_var aReal;
410 if ( !SO->_is_nil() ) {
411 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
412 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
413 SALOMEDS::StringSeq_var rowTitles = anInt->GetRowTitles();
414 if ( rowTitles->length() > 0 && myHRow > 0 && myHRow <= anInt->GetNbRows() ) {
415 title = rowTitles[ myHRow-1 ];
418 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
419 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
420 SALOMEDS::StringSeq_var rowTitles = aReal->GetRowTitles();
421 if ( rowTitles->length() > 0 && myHRow > 0 && myHRow <= aReal->GetNbRows() ) {
422 title = rowTitles[ myHRow-1 ];
429 Returns ver.axis title
431 string VISU::Curve_i::GetVerTitle()
434 // getting table SObject by it's entry
435 SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
436 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
437 SALOMEDS::GenericAttribute_var anAttr;
438 SALOMEDS::AttributeTableOfInteger_var anInt;
439 SALOMEDS::AttributeTableOfReal_var aReal;
440 if ( !SO->_is_nil() ) {
441 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
442 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
443 SALOMEDS::StringSeq_var rowTitles = anInt->GetRowTitles();
444 if ( rowTitles->length() > 0 && myVRow > 0 && myVRow <= anInt->GetNbRows() )
445 title = rowTitles[ myVRow-1 ];
447 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
448 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
449 SALOMEDS::StringSeq_var rowTitles = aReal->GetRowTitles();
450 if ( rowTitles->length() > 0 && myVRow > 0 && myVRow <= aReal->GetNbRows() )
451 title = rowTitles[ myVRow-1 ];
457 Returns hor.axis units
459 string VISU::Curve_i::GetHorUnits()
462 // getting table SObject by it's entry
463 SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
464 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
465 SALOMEDS::GenericAttribute_var anAttr;
466 SALOMEDS::AttributeTableOfInteger_var anInt;
467 SALOMEDS::AttributeTableOfReal_var aReal;
468 if ( !SO->_is_nil() ) {
469 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
470 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
471 SALOMEDS::StringSeq_var rowUnits = anInt->GetRowUnits();
472 if ( rowUnits->length() > 0 && myHRow > 0 && myHRow <= anInt->GetNbRows() )
473 units = rowUnits[ myHRow-1 ];
475 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
476 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
477 SALOMEDS::StringSeq_var rowUnits = aReal->GetRowUnits();
478 if ( rowUnits->length() > 0 && myHRow > 0 && myHRow <= aReal->GetNbRows() )
479 units = rowUnits[ myHRow-1 ];
485 Returns ver.axis units
487 string VISU::Curve_i::GetVerUnits()
490 // getting table SObject by it's entry
491 SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
492 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
493 SALOMEDS::GenericAttribute_var anAttr;
494 SALOMEDS::AttributeTableOfInteger_var anInt;
495 SALOMEDS::AttributeTableOfReal_var aReal;
496 if ( !SO->_is_nil() ) {
497 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
498 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
499 SALOMEDS::StringSeq_var rowUnits = anInt->GetRowUnits();
500 if ( rowUnits->length() > 0 && myVRow > 0 && myVRow <= anInt->GetNbRows() )
501 units = rowUnits[ myVRow-1];
503 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
504 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
505 SALOMEDS::StringSeq_var rowUnits = aReal->GetRowUnits();
506 if ( rowUnits->length() > 0 && myVRow > 0 && myVRow <= aReal->GetNbRows() )
507 units = rowUnits[ myVRow-1 ];
515 int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList )
517 theHorList = 0; theVerList = 0;
518 // getting table SObject by it's entry
519 SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
520 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
521 SALOMEDS::GenericAttribute_var anAttr;
522 SALOMEDS::AttributeTableOfInteger_var anInt;
523 SALOMEDS::AttributeTableOfReal_var aReal;
524 if ( !SO->_is_nil() ) {
525 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
526 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
527 int nbCols = anInt->GetNbColumns() ;
528 if ( nbCols > 0 && myHRow > 0 && myHRow <= anInt->GetNbRows() && myVRow > 0 && myVRow <= anInt->GetNbRows() ) {
530 for ( int j = 1; j <= nbCols; j++ ) {
531 if ( anInt->HasValue( myHRow, j ) && anInt->HasValue( myVRow, j ) )
534 if ( nbPoints > 0 ) {
535 theHorList = new double[ nbPoints ];
536 theVerList = new double[ nbPoints ];
538 for ( int j = 1; j <= nbCols; j++ ) {
539 if ( anInt->HasValue( myHRow, j ) && anInt->HasValue( myVRow, j ) ) {
540 theHorList[k] = anInt->GetValue( myHRow, j );
541 theVerList[k] = anInt->GetValue( myVRow, j );
549 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
550 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
551 int nbCols = aReal->GetNbColumns() ;
552 if ( nbCols > 0 && myHRow > 0 && myHRow <= aReal->GetNbRows() && myVRow > 0 && myVRow <= aReal->GetNbRows() ) {
554 for ( int j = 1; j <= nbCols; j++ ) {
555 if ( aReal->HasValue( myHRow, j ) && aReal->HasValue( myVRow, j ) )
558 if ( nbPoints > 0 ) {
559 theHorList = new double[ nbPoints ];
560 theVerList = new double[ nbPoints ];
562 for ( int j = 1; j <= nbCols; j++ ) {
563 if ( aReal->HasValue( myHRow, j ) && aReal->HasValue( myVRow, j ) ) {
564 theHorList[k] = aReal->GetValue( myHRow, j );
565 theVerList[k] = aReal->GetValue( myVRow, j );
577 Creates curve Plot2d presentation object
579 SPlot2d_Curve* VISU::Curve_i::CreatePresentation()
582 SPlot2d_Curve* crv = new SPlot2d_Curve();
583 crv->setHorTitle( GetHorTitle().c_str() );
584 string tlt = GetTitle();
585 if ( tlt.length() <= 0 )
587 //crv->setVerTitle( strdup( GetVerTitle().c_str() ) );
588 //crv->setVerTitle( strdup( GetName() ) );
589 crv->setVerTitle( tlt.c_str() );
590 crv->setHorUnits( GetHorUnits().c_str() );
591 crv->setVerUnits( GetVerUnits().c_str() );
594 int nbPoints = GetData( xList, yList );
595 if ( nbPoints > 0 && xList && yList ) {
596 crv->setData( xList, yList, nbPoints );
598 //cout << "********** Number of points: " << nbPoints <<endl;
599 //for ( int i =0 ; i < nbPoints; i++ ) {
600 // cout << i<<"\t"<<xList[i] << "\t"<< yList[i] << endl;
602 crv->setLine( (Plot2d_Curve::LineType)GetLine(), GetLineWidth() );
603 crv->setMarker( (Plot2d_Curve::MarkerType)GetMarker() );
604 SALOMEDS::Color color = GetColor();
605 crv->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
606 crv->setAutoAssign( IsAuto() );
607 crv->setIO(new SALOME_InteractiveObject(mySObj->GetID(),"VISU",GetName()));
609 crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry(),"VISU",myTable->GetName()));
613 Restores curve object from stream
615 VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO)
617 if(MYDEBUG) MESSAGE(GetComment());
618 mySObj = SALOMEDS::SObject::_duplicate(theSO);
619 myName = VISU::Storable::FindValue(theMap,"myName").latin1();
620 myHRow = VISU::Storable::FindValue(theMap,"myHRow").toInt();
621 myVRow = VISU::Storable::FindValue(theMap,"myVRow").toInt();
622 myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
623 myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
624 myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
625 myMarker = ( VISU::Curve::MarkerType )( VISU::Storable::FindValue(theMap,"myMarker").toInt() );
626 myLine = ( VISU::Curve::LineType )( VISU::Storable::FindValue(theMap,"myLine").toInt() );
627 myLineWidth = VISU::Storable::FindValue(theMap,"myLineWidth").toInt();
628 myAuto = VISU::Storable::FindValue(theMap,"myAuto").toInt();
629 return Build( true );
632 Flushes curve data into stream
634 void VISU::Curve_i::ToStream( std::ostringstream& theStr )
636 Storable::DataToStream( theStr, "myName", myName.c_str() );
637 Storable::DataToStream( theStr, "myHRow", myHRow );
638 Storable::DataToStream( theStr, "myVRow", myVRow );
639 Storable::DataToStream( theStr, "myColor.R", myColor.R );
640 Storable::DataToStream( theStr, "myColor.G", myColor.G );
641 Storable::DataToStream( theStr, "myColor.B", myColor.B );
642 Storable::DataToStream( theStr, "myMarker", myMarker );
643 Storable::DataToStream( theStr, "myLine", myLine );
644 Storable::DataToStream( theStr, "myLineWidth", myLineWidth );
645 Storable::DataToStream( theStr, "myAuto", myAuto );
648 Gets reference table's entry
650 const char* VISU::Curve_i::GetTableID() {
651 return myTable->GetObjectEntry();
654 Called from engine to restore curve from the file
656 VISU::Storable* VISU::Curve_i::Restore(SALOMEDS::SObject_ptr theSObject,
657 const string& thePrefix, const Storable::TRestoringMap& theMap)
659 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
660 VISU::Table_i* pTable = GetTable(aStudy, theSObject->GetFather());
661 if( pTable != NULL ) {
662 VISU::Curve_i* pResent = new VISU::Curve_i( aStudy, pTable, 0, 0 );
663 return pResent->Restore( theMap, theSObject);
668 void VISU::Curve_i::RemoveFromStudy(){
669 VISU::RemoveFromStudy(mySObj,false);
672 //----------------------------------------------------------------
674 //----------------------------------------------------------------
675 int VISU::Container_i::myNbPresent = 0;
676 const string VISU::Container_i::myComment = "CONTAINER";
680 const char* VISU::Container_i::GenerateName()
682 return VISU::GenerateName( "Plot2DView", ++myNbPresent );
687 const char* VISU::Container_i::GetComment() const
689 return myComment.c_str();
694 VISU::Container_i::Container_i( SALOMEDS::Study_ptr theStudy )
695 : PrsObject_i( theStudy )
701 VISU::Container_i::~Container_i()
703 MESSAGE("Container_i::~Container_i");
707 Inserts curve into the container
709 void VISU::Container_i::AddCurve( Curve_ptr theCurve )
711 if ( myStudy->_is_nil() )
713 SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
714 if ( mySO->_is_nil() )
716 PortableServer::POA_ptr aPOA = GetPOA();
717 Curve_i* pCurve = dynamic_cast<Curve_i*>( aPOA->reference_to_servant( theCurve ) );
719 QString entry = pCurve->GetEntry();
720 SALOMEDS::SObject_var SO = myStudy->FindObjectID( entry.latin1() );
721 if ( !SO->_is_nil() && myCurves.find( entry ) == myCurves.end() ) {
722 myCurves.append( entry );
723 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
724 SALOMEDS::SObject_var newSO = Builder->NewObject( mySO );
725 Builder->Addreference( newSO, SO );
730 Removes curve from the container
732 void VISU::Container_i::RemoveCurve( Curve_ptr theCurve )
734 if ( myStudy->_is_nil() )
736 SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
737 if ( mySO->_is_nil() )
739 PortableServer::POA_ptr aPOA = GetPOA();
740 Curve_i* pCurve = dynamic_cast<Curve_i*>( aPOA->reference_to_servant( theCurve ) );
742 QString entry = pCurve->GetEntry();
743 if ( myCurves.find( entry ) != myCurves.end() ) {
745 myCurves.remove( entry );
746 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
747 SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
748 for ( ; CI->More(); CI->Next() ) {
749 SALOMEDS::SObject_var childSO = CI->Value();
750 SALOMEDS::SObject_var refSO;
751 if ( childSO->ReferencedObject( refSO ) && !refSO->_is_nil() && entry == QString( refSO->GetID() ) ) {
752 Builder->RemoveObject( childSO );
759 Gets number of curves in the container
761 CORBA::Long VISU::Container_i::GetNbCurves()
764 return myCurves.count();
769 void VISU::Container_i::Clear()
771 if ( myStudy->_is_nil() )
773 SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
774 if ( mySO->_is_nil() )
776 QStringList toDelete;
777 SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
778 for ( ; CI->More(); CI->Next() ) {
779 toDelete.append( CI->Value()->GetID() );
781 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
782 for ( int i = 0; i < toDelete.count(); i++ ) {
783 SALOMEDS::SObject_var SO = myStudy->FindObjectID( toDelete[i].latin1() );
784 Builder->RemoveObject( SO );
789 Creates container object
791 VISU::Storable* VISU::Container_i::Create()
794 myName = GenerateName();
795 // ... and build the object
796 return Build( false );
799 Builds presentation of container
801 VISU::Storable* VISU::Container_i::Build( int theRestoring )
803 if ( !theRestoring ) {
804 // looking for component
805 SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
806 // create SObject and set attributes
808 aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TCONTAINER);
809 string anEntry = CreateAttributes( myStudy,
817 mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
822 Updates presentation of container
824 void VISU::Container_i::Update()
826 if ( myStudy->_is_nil() )
828 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
829 SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
830 SALOMEDS::GenericAttribute_var anAttr;
831 if ( !mySO->_is_nil() ) {
832 QStringList toDelete;
834 for ( i = 0; i < myCurves.count(); i++ ) {
835 SALOMEDS::SObject_var SO = myStudy->FindObjectID( myCurves[i].latin1() );
836 if ( !SO->_is_nil() && Builder->FindAttribute( SO, anAttr, "AttributeIOR" ) ) {
837 // if real Curve Object still exists
838 SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
840 for ( ; CI->More(); CI->Next() ) {
841 SALOMEDS::SObject_var childSO = CI->Value();
842 SALOMEDS::SObject_var refSO;
843 if ( childSO->ReferencedObject( refSO ) && !refSO->_is_nil() && myCurves[i] == QString( refSO->GetID() ) ) {
844 bFound = true; break;
848 // create SObject referenced to real curve object if is not yet added
849 SALOMEDS::SObject_var newSO = Builder->NewObject( mySO );
850 Builder->Addreference( newSO, SO );
854 // real Curve Object doesn't exist (might be removed)
855 toDelete.append( myCurves[i] );
858 for ( i = 0; i < toDelete.count(); i++ ) {
859 myCurves.remove( toDelete[i] );
862 SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
863 for ( ; CI->More(); CI->Next() ) {
864 SALOMEDS::SObject_var childSO = CI->Value();
865 SALOMEDS::SObject_var refSO;
866 if ( childSO->ReferencedObject( refSO ) && ( refSO->_is_nil() || !Builder->FindAttribute( refSO, anAttr, "AttributeIOR" ) ||
867 myCurves.find( refSO->GetID() ) == myCurves.end() ) ) {
868 toDelete.append( childSO->GetID() );
871 for ( i = 0; i < toDelete.count(); i++ ) {
872 SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
873 for ( ; CI->More(); CI->Next() ) {
874 SALOMEDS::SObject_var childSO = CI->Value();
875 if ( toDelete[i] == CI->Value()->GetID() ) {
876 Builder->RemoveObject( childSO );
883 Gets curve from container by index
884 NB : curves are numbered from 1
886 VISU::Curve_i* VISU::Container_i::GetCurve( CORBA::Long theIndex )
888 if ( theIndex > 0 && theIndex <= myCurves.count() ) {
889 SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
890 SALOMEDS::GenericAttribute_var anAttr;
891 SALOMEDS::SObject_var SO = myStudy->FindObjectID( myCurves[ theIndex-1 ].latin1() );
892 CORBA::Object_var anObject = VISU::SObjectToObject( SO );
893 if( !CORBA::is_nil( anObject ) ) {
894 // if real Curve Object exists
895 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
896 if( !CORBA::is_nil( aCurve ) )
897 return dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
903 Restores container data from the stream
905 VISU::Storable* VISU::Container_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO )
907 if(MYDEBUG) MESSAGE(GetComment());
908 mySObj = SALOMEDS::SObject::_duplicate(SO);
909 myName = VISU::Storable::FindValue( theMap, "myName" ).latin1();
910 QString val = VISU::Storable::FindValue( theMap, "myCurves" );
911 myCurves = QStringList::split( QString( "*" ), val, false );
912 return Build( true );
915 Flushes container data into the stream
917 void VISU::Container_i::ToStream( std::ostringstream& theStr )
919 Storable::DataToStream( theStr, "myName", myName.c_str() );
920 Storable::DataToStream( theStr, "myCurves", myCurves.join( QString( "*" ) ) );
921 // theStr<<" myName "<<myName;
922 // theStr<<" myCurves "<<myCurves.join( QString( "*" ) ).latin1()<<"* ";
925 Called from engine to restore container from the file
927 VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject,
928 const string& thePrefix, const Storable::TRestoringMap& theMap)
930 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
931 VISU::Container_i* pResent = new VISU::Container_i( aStudy );
932 return pResent->Restore( theMap, theSObject );
935 void VISU::Container_i::RemoveFromStudy(){
936 VISU::RemoveFromStudy(mySObj,false);
939 //-------------------------------------------------------------
940 // Implementation of reading from file
941 //-------------------------------------------------------------
942 typedef string TValue;
943 typedef vector<TValue> TValues;
951 typedef vector<TRow> TRows;
955 vector<string> myColumnUnits;
956 vector<string> myColumnTitles;
959 if(myRows.empty()) return 0;
960 int iEnd = myRows[0].myValues.size();
961 if(iEnd == 0) return 0;
962 if(myColumnTitles.size() != iEnd) myColumnTitles.resize(iEnd);
963 if(myColumnUnits.size() != iEnd) myColumnUnits.resize(iEnd);
964 int jEnd = myRows.size();
965 for(int j = 0; j < jEnd; j++)
966 if(myRows[j].myValues.size() != iEnd)
970 void getColumns(TTable2D& theTable2D) const {
971 TRows& aRows = theTable2D.myRows;
973 if(myRows.empty()) return;
974 int jEnd = myRows.size();
975 //Define Titles & Units
976 theTable2D.myColumnTitles.resize(jEnd);
977 theTable2D.myColumnUnits.resize(jEnd);
978 for(int j = 0; j < jEnd; j++){
979 theTable2D.myColumnTitles[j] = myRows[j].myTitle;
980 theTable2D.myColumnUnits[j] = myRows[j].myUnit;
983 int iEnd = myRows[0].myValues.size();
984 for(int i = 0; i < iEnd; i++){
986 aNewRow.myTitle = myColumnTitles[i];
987 aNewRow.myUnit = myColumnUnits[i];
988 aNewRow.myValues.resize(jEnd);
989 for(int j = 0; j < jEnd; j++){
990 aNewRow.myValues[j] = myRows[j].myValues[i];
992 aRows.push_back(aNewRow);
997 typedef vector<TTable2D> TTableCont;
999 int getLine(ifstream& theStmIn, QString& theString){
1002 while(theStmIn.get(tmp)){
1004 if(tmp == '\n') break;
1007 theString = aStrOut.str();
1008 return !theStmIn.eof();
1011 void ImportTables(const char* theFileName, TTableCont& theTableCont){
1013 QFileInfo aFileInfo( theFileName );
1014 if( !aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size() )
1016 aStmIn.open( theFileName );
1019 // find beginning of table (tables are separated by empty lines)
1020 while( getLine( aStmIn, aTmp ) && aTmp.stripWhiteSpace() == "");
1022 if(MYDEBUG) cout << "New table is found" << endl;
1023 while( !aStmIn.eof() && aTmp.stripWhiteSpace() != "" ){
1024 QString data = aTmp.stripWhiteSpace();
1026 QString keyword = "";
1027 // split string to data and comment (comment starts from '#' symbol)
1028 int index = aTmp.find( "#" );
1030 data = aTmp.left( index ).stripWhiteSpace();
1031 cmt = aTmp.mid( index+1 ).stripWhiteSpace();
1033 // if comment is not empty, try to get keyword from it (separated by ':' symbol)
1034 if ( !cmt.isEmpty() ) {
1035 int index1 = cmt.find( ":" );
1036 if ( index1 >= 0 ) {
1037 QString tmpstr = cmt.left( index1 ).stripWhiteSpace();
1038 if ( tmpstr == QString( "TITLE" ) ||
1039 tmpstr == QString( "COLUMN_TITLES" ) ||
1040 tmpstr == QString( "COLUMN_UNITS" ) ||
1041 tmpstr == QString( "COMMENT" ) ) {
1043 cmt = cmt.mid( index1+1 ).stripWhiteSpace();
1047 // if data is empty, process only comment
1048 if ( data.isEmpty() ) {
1049 // if keyword is found, try to process it
1050 // elsewise it is a simple comment, just ignore it
1051 if ( !keyword.isEmpty() ) {
1052 if ( keyword == QString( "TITLE" ) ) {
1053 QString title = cmt;
1054 if ( aTable2D.myTitle != "" )
1055 title = QString( aTable2D.myTitle.c_str() ) + QString( " " ) + title;
1056 if(MYDEBUG) cout << "...Table TITLE is: " << title.latin1() << endl;
1057 aTable2D.myTitle = title.latin1();
1059 else if ( keyword == QString( "COLUMN_TITLES" ) ) {
1060 // comment may contain column headers
1061 QStringList aStrList = QStringList::split( "|", cmt );
1062 if(MYDEBUG) cout << "...Column TITLES are: ";
1063 for ( int i = 0; i < aStrList.count(); i++ ) {
1064 QString tmpstr = aStrList[ i ].stripWhiteSpace();
1065 if(MYDEBUG) cout << tmpstr.latin1() << " ";
1066 aTable2D.myColumnTitles.push_back( tmpstr.latin1() );
1068 if(MYDEBUG) cout << endl;
1070 else if ( keyword == QString( "COLUMN_UNITS" ) ) {
1071 // comment may contain column units
1072 QStringList aStrList = QStringList::split( " ", cmt );
1073 if(MYDEBUG) cout << "...Column UNITS are: ";
1074 for ( int i = 0; i < aStrList.count(); i++ ) {
1075 QString tmpstr = aStrList[ i ].stripWhiteSpace();
1076 if(MYDEBUG) cout << tmpstr.latin1() << " ";
1077 aTable2D.myColumnUnits.push_back( tmpstr.latin1() );
1079 if(MYDEBUG) cout << endl;
1081 else if ( keyword == QString( "COMMENT" ) ) {
1082 // keyword 'COMMENT' processing can be here
1083 // currently it is ignored
1084 if(MYDEBUG) cout << "...COMMENT: " << cmt.latin1() << endl;
1088 if(MYDEBUG) cout << "...comment: " << cmt.latin1() << endl;
1089 // simple comment processing can be here
1090 // currently it is ignored
1093 // if data is not empty, try to process it
1096 if(MYDEBUG) cout << "...New row is found: " << endl;
1097 if ( !cmt.isEmpty() ) {
1098 aRow.myTitle = cmt.latin1();
1099 if(MYDEBUG) cout << "......ROW TITLE is: " << cmt.latin1() << endl;
1101 QStringList aValList = QStringList::split( " ", data );
1102 for ( int i = 0; i < aValList.count(); i++ ) {
1103 if ( aValList[i].stripWhiteSpace() != "" ) {
1104 TValue aVal = aValList[i].stripWhiteSpace().latin1();
1105 aRow.myValues.push_back( aVal );
1108 if( aRow.myValues.size() > 0 )
1109 aTable2D.myRows.push_back( aRow );
1110 // ************** OLD CODE ******************
1113 istrstream aStream( data );
1114 aStream.precision( STRPRECISION );
1115 while( aStream >> aVal ) {
1116 aRow.myValues.push_back( aVal );
1118 if( aRow.myValues.size() > 0 )
1119 aTable2D.myRows.push_back( aRow );
1121 // ************** OLD CODE ******************
1123 getLine( aStmIn, aTmp );
1125 if( aTable2D.Check() ) {
1126 if(MYDEBUG) cout << "aTable2D is checked OK " << aTable2D.myTitle << endl;
1127 theTableCont.push_back( aTable2D );
1130 while( !aStmIn.eof() );
1132 if(MYDEBUG) cout << "After close" << endl;
1135 SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy){
1136 TTableCont aTableCont;
1137 ImportTables(theFileName,aTableCont);
1138 if(aTableCont.empty()) return SALOMEDS::SObject::_nil();
1139 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1140 SALOMEDS::SComponent_var theSComponent = VISU::FindOrCreateVisuComponent(theStudy);
1141 SALOMEDS::SObject_var aFileObject = aStudyBuilder->NewObject(theSComponent);
1142 SALOMEDS::GenericAttribute_var anAttr =
1143 aStudyBuilder->FindOrCreateAttribute(aFileObject, "AttributeName");
1144 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
1145 QFileInfo aFileInfo(theFileName);
1146 aName->SetValue(aFileInfo.fileName().latin1());
1147 anAttr = aStudyBuilder->FindOrCreateAttribute(aFileObject, "AttributeComment");
1148 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1150 aString.sprintf("myComment=ImportTables;myFileName=%s",
1151 aFileInfo.absFilePath().latin1());
1152 aComment->SetValue(aString.latin1());
1153 for(int i = 0, iEnd = aTableCont.size(); i < iEnd; i++){
1154 const TTable2D& aTable2D = aTableCont[i];
1155 SALOMEDS::SObject_var aRealObject = aStudyBuilder->NewObject(aFileObject);
1156 anAttr = aStudyBuilder->FindOrCreateAttribute(aRealObject, "AttributeName");
1157 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1158 if(MYDEBUG) cout<<"aTable2D.myTitle = "<<aTable2D.myTitle<<endl;
1159 if(aTable2D.myTitle != "")
1160 aName->SetValue(aTable2D.myTitle.c_str());
1163 aNewName.sprintf("Table:%d",i);
1164 aName->SetValue(aNewName.latin1());
1166 anAttr = aStudyBuilder->FindOrCreateAttribute(aRealObject, "AttributeTableOfReal");
1167 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
1168 aTableOfReal->SetTitle(aTable2D.myTitle.c_str());
1169 TTable2D aNewTable2D;
1170 aTable2D.getColumns(aNewTable2D);
1171 int kEnd = aNewTable2D.myRows[0].myValues.size();
1172 aTableOfReal->SetNbColumns(kEnd);
1173 for(int j = 0, jEnd = aNewTable2D.myRows.size(); j < jEnd; j++){
1174 if(MYDEBUG) cout<<"j = "<<j<<"; kEnd = "<<kEnd<<endl;
1176 for(int k = 0; k < kEnd; k++){
1177 QString aVal = aNewTable2D.myRows[j].myValues[k].c_str();
1178 bool anIsOk = false;
1179 double aValue = aVal.toDouble(&anIsOk);
1180 if(anIsOk && !aVal.contains("NAN",false) && !aVal.contains("INF",false))
1181 aTableOfReal->PutValue(aValue,j+1,k+1);
1184 aTableOfReal->SetRowTitle(j+1,aNewTable2D.myRows[j].myTitle.c_str());
1185 aTableOfReal->SetRowUnit(j+1,aNewTable2D.myRows[j].myUnit.c_str());
1187 for(int k = 0; k < kEnd; k++)
1188 aTableOfReal->SetColumnTitle(k+1,aNewTable2D.myColumnTitles[k].c_str());
1193 template<class TTableAttr> bool ExportTableToFile(const TTableAttr& aTabAttr,
1194 const char* theFileName)
1196 if (!CORBA::is_nil(aTabAttr)) {
1197 QFile aFile(theFileName);
1198 aFile.open(IO_WriteOnly);
1200 /* extract the tabe info and write it into file */
1202 QString aTitle(aTabAttr->GetTitle()); /*Table title*/
1203 int aRowsNb = aTabAttr->GetNbRows();
1204 int aColNb = aTabAttr->GetNbColumns();
1206 SALOMEDS::StringSeq_var aRowTitles = aTabAttr->GetRowTitles();
1207 QString anAbscissTitle(aRowTitles[0]); /*Absciss row title (X coord)*/
1208 anAbscissTitle.stripWhiteSpace();
1210 SALOMEDS::StringSeq_var aRowUnits = aTabAttr->GetRowUnits();
1211 QString anAbscissUnit(aRowUnits[0]);
1212 anAbscissUnit.stripWhiteSpace();
1214 SALOMEDS::StringSeq_var aColumnTitles = aTabAttr->GetColumnTitles();
1215 if (aRowsNb > 2 && aTitle.length() ) aTitle = aTitle + " - ";
1218 for (int i = 2; i <= aRowsNb; i++ )
1221 QString anOrdinate(aRowTitles[i-1]), aTail;
1222 anOrdinate.stripWhiteSpace();
1224 aLine = "#TITLE: " + aTitle +
1225 ((anOrdinate.length())? anOrdinate :
1226 (aRowsNb>2)? aTail.sprintf("%d",i-1) : aTail.sprintf("") ) + "\n";
1227 aFile.writeBlock(aLine, aLine.length() );
1230 if ( anAbscissTitle.length() || anOrdinate.length() ) {
1231 aLine = "#COLUMN_TITLES: " + anAbscissTitle + " | " + anOrdinate + "\n";
1232 aFile.writeBlock(aLine, aLine.length() );
1236 aLine = anAbscissUnit + " " +aRowUnits[i-1];
1237 if (!aLine.stripWhiteSpace().isEmpty()) {
1238 aLine = "#COLUMN_UNITS: " + aLine + "\n";
1239 aFile.writeBlock(aLine, aLine.length() );
1242 /* CURVE COORDINATES */
1243 for (int j = 1; j <= aColNb; j++)
1245 if ( aTabAttr -> HasValue(i,j) && aTabAttr -> HasValue(1, j)) {
1246 aLine = aLine.sprintf("%.16g %.16g",
1247 (double)(aTabAttr->GetValue(1,j)),
1248 (double)(aTabAttr->GetValue(i,j))); /* aTabAttr->GetValue(1,j) - X coord */
1249 if ( !aLine.stripWhiteSpace().isEmpty() ) {
1250 QString aColTitle(aColumnTitles[j-1]);
1251 if ( !aColTitle.stripWhiteSpace().isEmpty() )
1252 aLine = aLine + " #TITLE: " + aColTitle ;
1253 aFile.writeBlock(aLine + "\n", aLine.length() + 1);
1257 aFile.writeBlock("\n", 1);
1265 bool VISU::ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName)
1268 SALOMEDS::GenericAttribute_var anAttr ;
1269 if (theTable->FindAttribute(anAttr, "AttributeTableOfReal"))
1271 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal ::_narrow(anAttr);
1272 return ExportTableToFile ( aTabAttr , theFileName);
1275 else if (theTable->FindAttribute(anAttr, "AttributeTableOfInteger")) {
1277 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger ::_narrow(anAttr);
1278 return ExportTableToFile ( aTabAttr , theFileName);