1 // File : SALOMEDS_AttributeTableOfReal.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDS_AttributeTableOfReal.hxx"
7 #include <TCollection_AsciiString.hxx>
8 #include <TCollection_ExtendedString.hxx>
9 #include <TColStd_HSequenceOfInteger.hxx>
10 #include <TColStd_HSequenceOfReal.hxx>
11 #include <TColStd_HSequenceOfExtendedString.hxx>
14 SALOMEDS_AttributeTableOfReal
15 ::SALOMEDS_AttributeTableOfReal(const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr)
16 :SALOMEDS_GenericAttribute(theAttr)
19 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr)
20 :SALOMEDS_GenericAttribute(theAttr)
23 SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal()
27 void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
30 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
31 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
34 std::string SALOMEDS_AttributeTableOfReal::GetTitle()
38 aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetTitle()).ToCString();
39 else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
43 void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle)
46 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitle(theIndex,
47 (char*)theTitle.c_str());
48 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
51 void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
54 int aLength = theTitles.size(), i;
56 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
57 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
58 Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitles(aSeq);
61 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
62 aSeq->length(aLength);
63 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
64 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq);
69 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
71 std::vector<std::string> aVector;
74 Handle(TColStd_HSequenceOfExtendedString) aSeq;
75 aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowTitles();
76 aLength = aSeq->Length();
77 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
80 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
81 aLength = aSeq->length();
82 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
87 void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::string& theTitle)
90 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetColumnTitle(theIndex,
91 (char*)theTitle.c_str());
92 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
95 void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
98 int aLength = theTitles.size(), i;
100 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
101 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
102 Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetColumnTitles(aSeq);
105 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
106 aSeq->length(aLength);
107 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
108 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq);
112 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
114 std::vector<std::string> aVector;
117 Handle(TColStd_HSequenceOfExtendedString) aSeq;
118 aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnTitles();
119 aLength = aSeq->Length();
120 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
123 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
124 aLength = aSeq->length();
125 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
130 void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string& theUnit)
133 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowUnit(theIndex,
134 (char*)theUnit.c_str());
135 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
138 void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
141 int aLength = theUnits.size(), i;
143 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
144 for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
145 Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowUnits(aSeq);
148 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
149 aSeq->length(aLength);
150 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
151 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq);
155 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
157 std::vector<std::string> aVector;
160 Handle(TColStd_HSequenceOfExtendedString) aSeq;
161 aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowUnits();
162 aLength = aSeq->Length();
163 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
166 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
167 aLength = aSeq->length();
168 for(i = 0; i<aLength; i++) aVector.push_back(TCollection_AsciiString((char*)aSeq[i].in()).ToCString());
173 int SALOMEDS_AttributeTableOfReal::GetNbRows()
176 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbRows();
177 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
181 int SALOMEDS_AttributeTableOfReal::GetNbColumns()
184 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbColumns();
185 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
190 void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
193 int aLength = theData.size(), i;
195 Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
196 aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
197 Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
198 for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
200 aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
203 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
207 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
208 aSeq->length(aLength);
209 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
210 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq);
214 void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>& theData)
217 int aLength = theData.size(), i;
219 Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
220 aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
221 Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
222 for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
224 aTable->SetRowData(theRow, aRow);
227 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
231 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
232 aSeq->length(aLength);
233 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
234 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq);
238 std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
240 std::vector<double> aVector;
243 Handle(TColStd_HSequenceOfReal) aRow;
244 aRow = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowData(theRow);
245 aLength = aRow->Length();
246 for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i));
249 SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
250 for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
256 void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData)
259 int aLength = theData.size(), i;
261 Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
262 aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
263 Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
264 for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
266 aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
269 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
273 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
274 aColumn->length(aLength);
275 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
276 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn);
280 void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<double>& theData)
283 int aLength = theData.size(), i;
285 Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
286 aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
287 Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
288 for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
290 aTable->SetRowData(theColumn, aColumn);
293 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
297 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
298 aColumn->length(aLength);
299 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
300 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
304 std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
306 std::vector<double> aVector;
309 Handle(TColStd_HSequenceOfReal) aColumn;
310 aColumn = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnData(theColumn);
311 aLength = aColumn->Length();
312 for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i));
315 SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
316 for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
321 void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn)
326 Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->PutValue(theValue, theRow, theColumn);
329 throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
333 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
337 bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
340 if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->HasValue(theRow, theColumn);
341 else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
345 double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
350 aValue = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetValue(theRow, theColumn);
353 throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
357 aValue = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetValue(theRow, theColumn);
362 std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
364 std::vector<int> aVector;
367 Handle(TColStd_HSequenceOfInteger) aSet;
368 aSet = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetSetRowIndices(theRow);
369 aLength = aSet->Length();
370 for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
373 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
374 for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
379 void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
381 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
382 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);