1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_AttributeTableOfReal.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeTableOfReal.hxx"
28 #include "SALOMEDS.hxx"
30 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal
31 (SALOMEDSImpl_AttributeTableOfReal* theAttr)
32 :SALOMEDS_GenericAttribute(theAttr)
35 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr)
36 :SALOMEDS_GenericAttribute(theAttr)
39 SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal()
43 void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
47 SALOMEDS::Locker lock;
48 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetTitle(theTitle);
50 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
53 std::string SALOMEDS_AttributeTableOfReal::GetTitle()
57 SALOMEDS::Locker lock;
58 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetTitle();
60 else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
64 void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle)
68 SALOMEDS::Locker lock;
69 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitle(theIndex, theTitle);
71 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
74 std::string SALOMEDS_AttributeTableOfReal::GetRowTitle(int theIndex)
78 SALOMEDS::Locker lock;
80 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitle(theIndex);
83 throw SALOMEDS::AttributeTable::IncorrectIndex();
87 aTitle = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitle(theIndex);
92 void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
95 int aLength = theTitles.size(), i;
98 SALOMEDS::Locker lock;
99 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitles(theTitles);
102 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
103 aSeq->length(aLength);
104 for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
105 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq);
109 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
111 std::vector<std::string> aVector;
114 SALOMEDS::Locker lock;
115 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitles();
118 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
119 aLength = aSeq->length();
120 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
125 void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::string& theTitle)
129 SALOMEDS::Locker lock;
130 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
132 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
135 std::string SALOMEDS_AttributeTableOfReal::GetColumnTitle(int theIndex)
139 SALOMEDS::Locker lock;
141 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitle(theIndex);
144 throw SALOMEDS::AttributeTable::IncorrectIndex();
148 aTitle = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitle(theIndex);
153 void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
155 int aLength = theTitles.size(), i;
158 SALOMEDS::Locker lock;
159 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitles(theTitles);
162 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
163 aSeq->length(aLength);
164 for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
165 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq);
169 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
171 std::vector<std::string> aVector;
174 SALOMEDS::Locker lock;
175 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitles();
178 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
179 aLength = aSeq->length();
180 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
185 void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string& theUnit)
189 SALOMEDS::Locker lock;
190 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnit(theIndex, theUnit);
192 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
195 std::string SALOMEDS_AttributeTableOfReal::GetRowUnit(int theIndex)
199 SALOMEDS::Locker lock;
201 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnit(theIndex);
204 throw SALOMEDS::AttributeTable::IncorrectIndex();
208 aTitle = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnit(theIndex);
213 void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
215 int aLength = theUnits.size(), i;
218 SALOMEDS::Locker lock;
219 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnits(theUnits);
222 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
223 aSeq->length(aLength);
224 for (i = 0; i < aLength; i++) aSeq[i] = theUnits[i].c_str();
225 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq);
229 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
231 std::vector<std::string> aVector;
234 SALOMEDS::Locker lock;
235 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnits();
238 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
239 aLength = aSeq->length();
240 for (i = 0; i < aLength; i++) aVector.push_back(std::string(aSeq[i].in()));
245 int SALOMEDS_AttributeTableOfReal::GetNbRows()
249 SALOMEDS::Locker lock;
250 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbRows();
252 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
256 int SALOMEDS_AttributeTableOfReal::GetNbColumns()
260 SALOMEDS::Locker lock;
261 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbColumns();
263 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
267 void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
269 int aLength = theData.size(), i;
272 SALOMEDS::Locker lock;
273 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
275 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
278 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
282 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
283 aSeq->length(aLength);
284 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
285 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq);
289 void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>& theData)
291 int aLength = theData.size(), i;
294 SALOMEDS::Locker lock;
295 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
297 aTable->SetRowData(theRow, theData);
300 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
304 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
305 aSeq->length(aLength);
306 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
307 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq);
311 std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
313 std::vector<double> aVector;
316 SALOMEDS::Locker lock;
317 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowData(theRow);
320 SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
321 aLength = aRow->length();
322 for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
328 void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData)
330 int aLength = theData.size(), i;
333 SALOMEDS::Locker lock;
334 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
336 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
339 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
343 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
344 aColumn->length(aLength);
345 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
346 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn);
350 void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<double>& theData)
352 int aLength = theData.size(), i;
355 SALOMEDS::Locker lock;
356 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
358 aTable->SetColumnData(theColumn, theData);
361 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
365 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
366 aColumn->length(aLength);
367 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
368 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
372 std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
374 std::vector<double> aVector;
377 SALOMEDS::Locker lock;
378 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnData(theColumn);
381 SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
382 aLength = aColumn->length();
383 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
388 void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn)
392 SALOMEDS::Locker lock;
394 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->PutValue(theValue, theRow, theColumn);
397 throw SALOMEDS::AttributeTable::IncorrectIndex();
401 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
405 bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
409 SALOMEDS::Locker lock;
410 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->HasValue(theRow, theColumn);
412 else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
416 double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
420 SALOMEDS::Locker lock;
422 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetValue(theRow, theColumn);
425 throw SALOMEDS::AttributeTable::IncorrectIndex();
429 aValue = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetValue(theRow, theColumn);
434 void SALOMEDS_AttributeTableOfReal::RemoveValue(int theRow, int theColumn)
437 SALOMEDS::Locker lock;
439 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->RemoveValue(theRow, theColumn);
442 throw SALOMEDS::AttributeTable::IncorrectIndex();
446 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->RemoveValue(theRow, theColumn);
450 std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
452 std::vector<int> aVector;
455 SALOMEDS::Locker lock;
456 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetSetRowIndices(theRow);
459 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
460 aLength = aSet->length();
461 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
466 void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
469 SALOMEDS::Locker lock;
470 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetNbColumns(theNbColumns);
472 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
475 std::vector<int> SALOMEDS_AttributeTableOfReal::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
477 std::vector<int> aVector;
480 SALOMEDS::Locker lock;
482 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortRow(theRow,
483 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
484 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
487 throw SALOMEDS::AttributeTable::IncorrectIndex();
491 SALOMEDS::LongSeq_var aSet =
492 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortRow(theRow,
493 (SALOMEDS::AttributeTable::SortOrder)theOrder,
494 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
495 aLength = aSet->length();
496 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
501 std::vector<int> SALOMEDS_AttributeTableOfReal::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
503 std::vector<int> aVector;
506 SALOMEDS::Locker lock;
508 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortColumn(theColumn,
509 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
510 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
513 throw SALOMEDS::AttributeTable::IncorrectIndex();
517 SALOMEDS::LongSeq_var aSet =
518 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortColumn(theColumn,
519 (SALOMEDS::AttributeTable::SortOrder)theOrder,
520 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
521 aLength = aSet->length();
522 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
527 std::vector<int> SALOMEDS_AttributeTableOfReal::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
529 std::vector<int> aVector;
532 SALOMEDS::Locker lock;
534 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortByRow(theRow,
535 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
536 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
539 throw SALOMEDS::AttributeTable::IncorrectIndex();
543 SALOMEDS::LongSeq_var aSet =
544 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByRow(theRow,
545 (SALOMEDS::AttributeTable::SortOrder)theOrder,
546 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
547 aLength = aSet->length();
548 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
553 std::vector<int> SALOMEDS_AttributeTableOfReal::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
555 std::vector<int> aVector;
558 SALOMEDS::Locker lock;
560 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortByColumn(theColumn,
561 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
562 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
565 throw SALOMEDS::AttributeTable::IncorrectIndex();
569 SALOMEDS::LongSeq_var aSet =
570 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByColumn(theColumn,
571 (SALOMEDS::AttributeTable::SortOrder)theOrder,
572 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
573 aLength = aSet->length();
574 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
579 void SALOMEDS_AttributeTableOfReal::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2)
582 SALOMEDS::Locker lock;
584 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
587 throw SALOMEDS::AttributeTable::IncorrectIndex();
591 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
595 void SALOMEDS_AttributeTableOfReal::SwapRows(int theRow1, int theRow2)
598 SALOMEDS::Locker lock;
600 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SwapRows(theRow1, theRow2);
603 throw SALOMEDS::AttributeTable::IncorrectIndex();
607 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SwapRows(theRow1, theRow2);
611 void SALOMEDS_AttributeTableOfReal::SwapColumns(int theColumn1, int theColumn2)
614 SALOMEDS::Locker lock;
616 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SwapColumns(theColumn1, theColumn2);
619 throw SALOMEDS::AttributeTable::IncorrectIndex();
623 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SwapColumns(theColumn1, theColumn2);