From fe23313d8d135d444ecf5d63e5530adde7e248e4 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 22 Apr 2010 10:16:59 +0000 Subject: [PATCH] Issue 0020465: [CEA 335] sort tables in visualisation mode --- idl/SALOMEDS_Attributes.idl | 12 ++- .../SALOMEDS_AttributeTableOfInteger.cxx | 80 ++++++++++++------- .../SALOMEDS_AttributeTableOfInteger.hxx | 8 +- .../SALOMEDS_AttributeTableOfInteger_i.cxx | 68 +++++++++++----- .../SALOMEDS_AttributeTableOfInteger_i.hxx | 16 ++-- .../SALOMEDS_AttributeTableOfReal.cxx | 80 ++++++++++++------- .../SALOMEDS_AttributeTableOfReal.hxx | 8 +- .../SALOMEDS_AttributeTableOfReal_i.cxx | 68 +++++++++++----- .../SALOMEDS_AttributeTableOfReal_i.hxx | 16 ++-- .../SALOMEDS_AttributeTableOfString.cxx | 80 ++++++++++++------- .../SALOMEDS_AttributeTableOfString.hxx | 8 +- .../SALOMEDS_AttributeTableOfString_i.cxx | 68 +++++++++++----- .../SALOMEDS_AttributeTableOfString_i.hxx | 16 ++-- .../SALOMEDSClient_AttributeTable.hxx | 8 +- .../SALOMEDSImpl_AttributeTableOfInteger.cxx | 30 +++++-- .../SALOMEDSImpl_AttributeTableOfInteger.hxx | 8 +- .../SALOMEDSImpl_AttributeTableOfReal.cxx | 28 ++++++- .../SALOMEDSImpl_AttributeTableOfReal.hxx | 8 +- .../SALOMEDSImpl_AttributeTableOfString.cxx | 28 ++++++- .../SALOMEDSImpl_AttributeTableOfString.hxx | 8 +- 20 files changed, 433 insertions(+), 213 deletions(-) diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl index 424acc3bd..39130e2c3 100644 --- a/idl/SALOMEDS_Attributes.idl +++ b/idl/SALOMEDS_Attributes.idl @@ -1096,8 +1096,9 @@ module SALOMEDS \param row row index \param order sort order (ascending/descending) \param policy sort policy (specifies how to process empty cells) + \return list of mixed column indices */ - void SortRow(in long row, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); + LongSeq SortRow(in long row, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); /*! \brief Sort values in the specified table column. @@ -1111,8 +1112,9 @@ module SALOMEDS \param column column index \param order sort order (ascending/descending) \param policy sort policy (specifies how to process empty cells) + \return list of mixed row indices */ - void SortColumn(in long column, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); + LongSeq SortColumn(in long column, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); /*! \brief Sort table columns by the specified row. @@ -1125,8 +1127,9 @@ module SALOMEDS \param row row index \param order sort order (ascending/descending) \param policy sort policy (specifies how to process empty cells) + \return list of mixed column indices */ - void SortByRow(in long row, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); + LongSeq SortByRow(in long row, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); /*! \brief Sort table rows by the specified column. @@ -1139,8 +1142,9 @@ module SALOMEDS \param column column index \param order sort order (ascending/descending) \param policy sort policy (specifies how to process empty cells) + \return list of mixed row indices */ - void SortByColumn(in long column, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); + LongSeq SortByColumn(in long column, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex); /*! \brief Swap values in two table cells. diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx index 1d46b0fee..10e37953b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx @@ -479,84 +479,108 @@ void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns) else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns); } -void SALOMEDS_AttributeTableOfInteger::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfInteger::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortRow(theRow, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortRow(theRow, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortRow(theRow, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortRow(theRow, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfInteger::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfInteger::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortColumn(theColumn, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortColumn(theColumn, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortColumn(theColumn, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortColumn(theColumn, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfInteger::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfInteger::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortByRow(theRow, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortByRow(theRow, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByRow(theRow, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByRow(theRow, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfInteger::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfInteger::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortByColumn(theColumn, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortByColumn(theColumn, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByColumn(theColumn, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByColumn(theColumn, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } void SALOMEDS_AttributeTableOfInteger::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2) diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.hxx index c79798fde..ba25d90c8 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.hxx @@ -77,10 +77,10 @@ public: virtual std::vector GetRowSetIndices(int theRow); virtual void SetNbColumns(int theNbColumns); - virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2); virtual void SwapRows(int theRow1, int theRow2); virtual void SwapColumns(int theColumn1, int theColumn2); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx index e630b6909..08147016c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx @@ -422,9 +422,9 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile() return aStreamFile._retn(); } -void SALOMEDS_AttributeTableOfInteger_i::SortRow(CORBA::Long theRow, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -433,18 +433,25 @@ void SALOMEDS_AttributeTableOfInteger_i::SortRow(CORBA::Long theRow, SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast(_impl); if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfInteger_i::SortColumn(CORBA::Long theColumn, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -453,18 +460,25 @@ void SALOMEDS_AttributeTableOfInteger_i::SortColumn(CORBA::Long theColumn, SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast(_impl); if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfInteger_i::SortByRow(CORBA::Long theRow, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortByRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -473,18 +487,25 @@ void SALOMEDS_AttributeTableOfInteger_i::SortByRow(CORBA::Long theRow, SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast(_impl); if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfInteger_i::SortByColumn(CORBA::Long theColumn, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortByColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -493,13 +514,20 @@ void SALOMEDS_AttributeTableOfInteger_i::SortByColumn(CORBA::Long theColumn, SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast(_impl); if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } void SALOMEDS_AttributeTableOfInteger_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx index 60aa6f79c..1c3daff5c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx @@ -93,17 +93,17 @@ public: virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow); virtual void SetNbColumns(CORBA::Long theNbColumns); - virtual void SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); virtual void SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx index 8ff7fe29f..de81d2a47 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx @@ -472,84 +472,108 @@ void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns) else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns); } -void SALOMEDS_AttributeTableOfReal::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfReal::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortRow(theRow, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortRow(theRow, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortRow(theRow, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortRow(theRow, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfReal::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfReal::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortColumn(theColumn, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortColumn(theColumn, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortColumn(theColumn, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortColumn(theColumn, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfReal::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfReal::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortByRow(theRow, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortByRow(theRow, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByRow(theRow, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByRow(theRow, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfReal::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfReal::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortByColumn(theColumn, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortByColumn(theColumn, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByColumn(theColumn, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByColumn(theColumn, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } void SALOMEDS_AttributeTableOfReal::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2) diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.hxx index 92e04c1c8..82adcc341 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.hxx @@ -77,10 +77,10 @@ public: virtual std::vector GetRowSetIndices(int theRow); virtual void SetNbColumns(int theNbColumns); - virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2); virtual void SwapRows(int theRow1, int theRow2); virtual void SwapColumns(int theColumn1, int theColumn2); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx index 06aa05cae..59bdda74f 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx @@ -398,9 +398,9 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() return aStreamFile._retn(); } -void SALOMEDS_AttributeTableOfReal_i::SortRow(CORBA::Long theRow, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -409,18 +409,25 @@ void SALOMEDS_AttributeTableOfReal_i::SortRow(CORBA::Long theRow, SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfReal_i::SortColumn(CORBA::Long theColumn, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -429,18 +436,25 @@ void SALOMEDS_AttributeTableOfReal_i::SortColumn(CORBA::Long theColumn, SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfReal_i::SortByRow(CORBA::Long theRow, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -449,18 +463,25 @@ void SALOMEDS_AttributeTableOfReal_i::SortByRow(CORBA::Long theRow, SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfReal_i::SortByColumn(CORBA::Long theColumn, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -469,13 +490,20 @@ void SALOMEDS_AttributeTableOfReal_i::SortByColumn(CORBA::Long theColumn, SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } void SALOMEDS_AttributeTableOfReal_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx index 858d68bcb..5e0ee60b4 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx @@ -93,17 +93,17 @@ public: virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow); virtual void SetNbColumns(CORBA::Long theNbColumns); - virtual void SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); virtual void SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx index 9fabf6e08..d8fb0493b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx @@ -476,84 +476,108 @@ void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns) else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns); } -void SALOMEDS_AttributeTableOfString::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfString::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortRow(theRow, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortRow(theRow, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortRow(theRow, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortRow(theRow, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfString::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfString::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortColumn(theColumn, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortColumn(theColumn, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortColumn(theColumn, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortColumn(theColumn, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfString::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfString::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortByRow(theRow, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortByRow(theRow, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByRow(theRow, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByRow(theRow, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } -void SALOMEDS_AttributeTableOfString::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) +std::vector SALOMEDS_AttributeTableOfString::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) { + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; try { - dynamic_cast(_local_impl)->SortByColumn(theColumn, - (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); + aVector = dynamic_cast(_local_impl)->SortByColumn(theColumn, + (SALOMEDSImpl_AttributeTable::SortOrder)theOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } } else { - SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByColumn(theColumn, - (SALOMEDS::AttributeTable::SortOrder)theOrder, - (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByColumn(theColumn, + (SALOMEDS::AttributeTable::SortOrder)theOrder, + (SALOMEDS::AttributeTable::SortPolicy)thePolicy); + aLength = aSet->length(); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } + return aVector; } void SALOMEDS_AttributeTableOfString::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2) diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.hxx index 1cf38fa03..77670bcf6 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.hxx @@ -77,10 +77,10 @@ public: virtual std::vector GetRowSetIndices(int theRow); virtual void SetNbColumns(int theNbColumns); - virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); - virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy); + virtual std::vector SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy); virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2); virtual void SwapRows(int theRow1, int theRow2); virtual void SwapColumns(int theColumn1, int theColumn2); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx index 329186d37..d33a39b73 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx @@ -398,9 +398,9 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile() return aStreamFile._retn(); } -void SALOMEDS_AttributeTableOfString_i::SortRow(CORBA::Long theRow, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::SortRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -409,18 +409,25 @@ void SALOMEDS_AttributeTableOfString_i::SortRow(CORBA::Long theRow, SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast(_impl); if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfString_i::SortColumn(CORBA::Long theColumn, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::SortColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -429,18 +436,25 @@ void SALOMEDS_AttributeTableOfString_i::SortColumn(CORBA::Long theColumn, SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast(_impl); if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfString_i::SortByRow(CORBA::Long theRow, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::SortByRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -449,18 +463,25 @@ void SALOMEDS_AttributeTableOfString_i::SortByRow(CORBA::Long theRow, SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast(_impl); if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfString_i::SortByColumn(CORBA::Long theColumn, - SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::SortByColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex) { SALOMEDS::Locker lock; @@ -469,13 +490,20 @@ void SALOMEDS_AttributeTableOfString_i::SortByColumn(CORBA::Long theColumn, SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast(_impl); if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; try { - aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, - (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); } catch(...) { throw SALOMEDS::AttributeTable::IncorrectIndex(); } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } void SALOMEDS_AttributeTableOfString_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx index 5c8623f6e..abd2232a0 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx @@ -94,17 +94,17 @@ public: virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow); virtual void SetNbColumns(CORBA::Long theNbColumns); - virtual void SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); - virtual void SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, - SALOMEDS::AttributeTable::SortPolicy sortPolicy) + virtual SALOMEDS::LongSeq* SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) throw (SALOMEDS::AttributeTable::IncorrectIndex); virtual void SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, diff --git a/src/SALOMEDSClient/SALOMEDSClient_AttributeTable.hxx b/src/SALOMEDSClient/SALOMEDSClient_AttributeTable.hxx index bfe77205f..1bc425a5b 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_AttributeTable.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_AttributeTable.hxx @@ -67,10 +67,10 @@ public: virtual std::vector GetRowSetIndices(int theRow) = 0; virtual void SetNbColumns(int theNbColumns) = 0; - virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0; - virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0; - virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0; - virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0; + virtual std::vector SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0; + virtual std::vector SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0; + virtual std::vector SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0; + virtual std::vector SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0; virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2) = 0; virtual void SwapRows(int theRow1, int theRow2) = 0; virtual void SwapColumns(int theColumn1, int theColumn2) = 0; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx index 6094d0c7f..c5a123ebb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx @@ -561,9 +561,10 @@ void SALOMEDSImpl_AttributeTableOfInteger::Load(const std::string& value) } } -void SALOMEDSImpl_AttributeTableOfInteger::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfInteger::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) { - CheckLocked(); + CheckLocked(); + std::vector result; if ( theRow > 0 && theRow <= myNbRows ) { std::vector indices( myNbColumns ); int cnt = 0; @@ -584,6 +585,7 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortRow(const int theRow, SortOrder s other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int col = 0; col < indices.size(); col++ ) { int idx = indices[col]; @@ -596,11 +598,13 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortRow(const int theRow, SortOrder s } // no need for SetModifyFlag(), since it is done by SwapCells() } + return result; } -void SALOMEDSImpl_AttributeTableOfInteger::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfInteger::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theColumn > 0 && theColumn <= myNbColumns ) { std::vector indices( myNbRows ); int cnt = 0; @@ -621,6 +625,7 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortColumn(const int theColumn, SortO other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int row = 0; row < indices.size(); row++ ) { int idx = indices[row]; @@ -633,11 +638,13 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortColumn(const int theColumn, SortO } // no need for SetModifyFlag(), since it is done by SwapCells() } + return result; } -void SALOMEDSImpl_AttributeTableOfInteger::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfInteger::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theRow > 0 && theRow <= myNbRows ) { std::vector indices( myNbColumns ); int cnt = 0; @@ -658,6 +665,7 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortByRow(const int theRow, SortOrder other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int col = 0; col < indices.size(); col++ ) { int idx = indices[col]; @@ -670,11 +678,13 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortByRow(const int theRow, SortOrder } // no need for SetModifyFlag(), since it is done by SwapColumns() } + return result; } -void SALOMEDSImpl_AttributeTableOfInteger::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfInteger::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theColumn > 0 && theColumn <= myNbColumns ) { std::vector indices( myNbRows ); int cnt = 0; @@ -695,6 +705,7 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortByColumn(const int theColumn, Sor other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int row = 0; row < indices.size(); row++ ) { int idx = indices[row]; @@ -707,6 +718,7 @@ void SALOMEDSImpl_AttributeTableOfInteger::SortByColumn(const int theColumn, Sor } // no need for SetModifyFlag(), since it is done by SwapRows() } + return result; } void SALOMEDSImpl_AttributeTableOfInteger::SwapCells(const int theRow1, const int theColumn1, @@ -744,6 +756,10 @@ void SALOMEDSImpl_AttributeTableOfInteger::SwapRows(const int theRow1, const int CheckLocked(); for (int i = 1; i <= myNbColumns; i++) SwapCells(theRow1, i, theRow2, i); + // swap row titles + std::string tmp = myRows[theRow1-1]; + myRows[theRow1-1] = myRows[theRow2-1]; + myRows[theRow2-1] = tmp; // no need for SetModifyFlag(), since it is done by SwapCells() } @@ -752,6 +768,10 @@ void SALOMEDSImpl_AttributeTableOfInteger::SwapColumns(const int theColumn1, con CheckLocked(); for (int i = 1; i <= myNbRows; i++) SwapCells(i, theColumn1, i, theColumn2); + // swap column titles + std::string tmp = myCols[theColumn1-1]; + myCols[theColumn1-1] = myCols[theColumn2-1]; + myCols[theColumn2-1] = tmp; // no need for SetModifyFlag(), since it is done by SwapCells() } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx index 79f06515c..9c4948180 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx @@ -86,10 +86,10 @@ public: std::vector GetSetRowIndices(const int theRow); std::vector GetSetColumnIndices(const int theColumn); - void SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); - void SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); - void SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); - void SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); void SwapCells(const int theRow1, const int theColumn1, const int theRow2, const int theColumn2); void SwapRows(const int theRow1, const int theRow2); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx index 30f8b0ee9..6036e27c1 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx @@ -560,9 +560,10 @@ void SALOMEDSImpl_AttributeTableOfReal::Load(const std::string& value) } -void SALOMEDSImpl_AttributeTableOfReal::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfReal::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theRow > 0 && theRow <= myNbRows ) { std::vector indices( myNbColumns ); int cnt = 0; @@ -583,6 +584,7 @@ void SALOMEDSImpl_AttributeTableOfReal::SortRow(const int theRow, SortOrder sort other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int col = 0; col < indices.size(); col++ ) { int idx = indices[col]; @@ -595,11 +597,13 @@ void SALOMEDSImpl_AttributeTableOfReal::SortRow(const int theRow, SortOrder sort } // no need for SetModifyFlag(), since it is done by SwapCells() } + return result; } -void SALOMEDSImpl_AttributeTableOfReal::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfReal::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theColumn > 0 && theColumn <= myNbColumns ) { std::vector indices( myNbRows ); int cnt = 0; @@ -620,6 +624,7 @@ void SALOMEDSImpl_AttributeTableOfReal::SortColumn(const int theColumn, SortOrde other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int row = 0; row < indices.size(); row++ ) { int idx = indices[row]; @@ -632,11 +637,13 @@ void SALOMEDSImpl_AttributeTableOfReal::SortColumn(const int theColumn, SortOrde } // no need for SetModifyFlag(), since it is done by SwapCells() } + return result; } -void SALOMEDSImpl_AttributeTableOfReal::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfReal::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theRow > 0 && theRow <= myNbRows ) { std::vector indices( myNbColumns ); int cnt = 0; @@ -657,6 +664,7 @@ void SALOMEDSImpl_AttributeTableOfReal::SortByRow(const int theRow, SortOrder so other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int col = 0; col < indices.size(); col++ ) { int idx = indices[col]; @@ -669,11 +677,13 @@ void SALOMEDSImpl_AttributeTableOfReal::SortByRow(const int theRow, SortOrder so } // no need for SetModifyFlag(), since it is done by SwapColumns() } + return result; } -void SALOMEDSImpl_AttributeTableOfReal::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfReal::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theColumn > 0 && theColumn <= myNbColumns ) { std::vector indices( myNbRows ); int cnt = 0; @@ -694,6 +704,7 @@ void SALOMEDSImpl_AttributeTableOfReal::SortByColumn(const int theColumn, SortOr other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int row = 0; row < indices.size(); row++ ) { int idx = indices[row]; @@ -706,6 +717,7 @@ void SALOMEDSImpl_AttributeTableOfReal::SortByColumn(const int theColumn, SortOr } // no need for SetModifyFlag(), since it is done by SwapRows() } + return result; } void SALOMEDSImpl_AttributeTableOfReal::SwapCells(const int theRow1, const int theColumn1, @@ -743,6 +755,10 @@ void SALOMEDSImpl_AttributeTableOfReal::SwapRows(const int theRow1, const int th CheckLocked(); for (int i = 1; i <= myNbColumns; i++) SwapCells(theRow1, i, theRow2, i); + // swap row titles + std::string tmp = myRows[theRow1-1]; + myRows[theRow1-1] = myRows[theRow2-1]; + myRows[theRow2-1] = tmp; // no need for SetModifyFlag(), since it is done by SwapCells() } @@ -751,6 +767,10 @@ void SALOMEDSImpl_AttributeTableOfReal::SwapColumns(const int theColumn1, const CheckLocked(); for (int i = 1; i <= myNbRows; i++) SwapCells(i, theColumn1, i, theColumn2); + // swap column titles + std::string tmp = myCols[theColumn1-1]; + myCols[theColumn1-1] = myCols[theColumn2-1]; + myCols[theColumn2-1] = tmp; // no need for SetModifyFlag(), since it is done by SwapCells() } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx index 12c1f3286..e9fbc024e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx @@ -85,10 +85,10 @@ public: std::vector GetSetRowIndices(const int theRow); std::vector GetSetColumnIndices(const int theColumn); - void SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); - void SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); - void SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); - void SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); void SwapCells(const int theRow1, const int theColumn1, const int theRow2, const int theColumn2); void SwapRows(const int theRow1, const int theRow2); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx index 9fb52990c..80e6b8892 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx @@ -575,9 +575,10 @@ void SALOMEDSImpl_AttributeTableOfString::Load(const std::string& value) } } -void SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theRow > 0 && theRow <= myNbRows ) { std::vector indices( myNbColumns ); int cnt = 0; @@ -598,6 +599,7 @@ void SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder so other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int col = 0; col < indices.size(); col++ ) { int idx = indices[col]; @@ -610,11 +612,13 @@ void SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder so } // no need for SetModifyFlag(), since it is done by SwapCells() } + return result; } -void SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theColumn > 0 && theColumn <= myNbColumns ) { std::vector indices( myNbRows ); int cnt = 0; @@ -635,6 +639,7 @@ void SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOr other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int row = 0; row < indices.size(); row++ ) { int idx = indices[row]; @@ -647,11 +652,13 @@ void SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOr } // no need for SetModifyFlag(), since it is done by SwapCells() } + return result; } -void SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theRow > 0 && theRow <= myNbRows ) { std::vector indices( myNbColumns ); int cnt = 0; @@ -672,6 +679,7 @@ void SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int col = 0; col < indices.size(); col++ ) { int idx = indices[col]; @@ -684,11 +692,13 @@ void SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder } // no need for SetModifyFlag(), since it is done by SwapColumns() } + return result; } -void SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) +std::vector SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy ) { CheckLocked(); + std::vector result; if ( theColumn > 0 && theColumn <= myNbColumns ) { std::vector indices( myNbRows ); int cnt = 0; @@ -709,6 +719,7 @@ void SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, Sort other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1; indices = other; } + result = indices; for ( int row = 0; row < indices.size(); row++ ) { int idx = indices[row]; @@ -721,6 +732,7 @@ void SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, Sort } // no need for SetModifyFlag(), since it is done by SwapRows() } + return result; } void SALOMEDSImpl_AttributeTableOfString::SwapCells(const int theRow1, const int theColumn1, @@ -758,6 +770,10 @@ void SALOMEDSImpl_AttributeTableOfString::SwapRows(const int theRow1, const int CheckLocked(); for (int i = 1; i <= myNbColumns; i++) SwapCells(theRow1, i, theRow2, i); + // swap row titles + std::string tmp = myRows[theRow1-1]; + myRows[theRow1-1] = myRows[theRow2-1]; + myRows[theRow2-1] = tmp; // no need for SetModifyFlag(), since it is done by SwapCells() } @@ -766,5 +782,9 @@ void SALOMEDSImpl_AttributeTableOfString::SwapColumns(const int theColumn1, cons CheckLocked(); for (int i = 1; i <= myNbRows; i++) SwapCells(i, theColumn1, i, theColumn2); + // swap column titles + std::string tmp = myCols[theColumn1-1]; + myCols[theColumn1-1] = myCols[theColumn2-1]; + myCols[theColumn2-1] = tmp; // no need for SetModifyFlag(), since it is done by SwapCells() } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx index aefe6c542..e91718e7d 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx @@ -84,10 +84,10 @@ public: std::vector GetSetRowIndices(const int theRow); std::vector GetSetColumnIndices(const int theColumn); - void SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); - void SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); - void SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); - void SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy); + std::vector SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy); void SwapCells(const int theRow1, const int theColumn1, const int theRow2, const int theColumn2); void SwapRows(const int theRow1, const int theRow2); -- 2.39.2