From: kga Date: Fri, 25 Oct 2013 05:19:41 +0000 (+0000) Subject: 0022334: [CEA 952] "Sort children" sorts references as "real" children X-Git-Tag: BR_hydro_v_0_3_1~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a0626847495c3d0558c57a37ff16c6de753e020b;p=modules%2Fkernel.git 0022334: [CEA 952] "Sort children" sorts references as "real" children --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx index f3652b682..280c47ef5 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx @@ -330,21 +330,31 @@ bool SALOMEDSImpl_UseCaseBuilder::SortChildren(const SALOMEDSImpl_SObject& theOb SALOMEDSImpl_AttributeTreeNode* aNode = NULL; if (!(aNode=(SALOMEDSImpl_AttributeTreeNode*)aLabel.FindAttribute(_root->ID()))) return false; + std::list aRefSOs; std::list aNodeSOs; - for (SALOMEDSImpl_AttributeTreeNode* aChildNode=aNode->GetFirst(); aChildNode; aChildNode=aChildNode->GetNext() ) { - SALOMEDSImpl_SObject aSO = SALOMEDSImpl_Study::SObject(aChildNode->Label()); - if (aSO) { - aNodeSOs.push_back(aSO); + for ( SALOMEDSImpl_AttributeTreeNode* aChildNode=aNode->GetFirst(); aChildNode; aChildNode=aChildNode->GetNext() ) { + if ( SALOMEDSImpl_SObject aSO = SALOMEDSImpl_Study::SObject( aChildNode->Label() ) ) { + if ( aChildNode->FindAttribute( SALOMEDSImpl_AttributeReference::GetID() ) ) + aRefSOs.push_back( aSO ); + else + aNodeSOs.push_back( aSO ); } } - if (aNodeSOs.empty()) return false; - - //sort items by names in ascending/descending order - theAscendingOrder ? aNodeSOs.sort( AscSortSOs() ) : aNodeSOs.sort( DescSortSOs() ); - - std::list::iterator it; - for (it=aNodeSOs.begin(); it!=aNodeSOs.end(); ++it) { - AppendTo(aNode->GetSObject(), *it); + if ( aRefSOs.empty() && aNodeSOs.empty() ) return false; + + //sort items by names in ascending/descending order + std::list::iterator it; + if ( !aRefSOs.empty() ) { + theAscendingOrder ? aRefSOs.sort( AscSortSOs() ) : aRefSOs.sort( DescSortSOs() ); + for ( it = aRefSOs.begin(); it != aRefSOs.end(); ++it ) { + AppendTo( theObject, *it ); + } + } + if ( !aNodeSOs.empty() ) { + theAscendingOrder ? aNodeSOs.sort( AscSortSOs() ) : aNodeSOs.sort( DescSortSOs() ); + for ( it = aNodeSOs.begin(); it != aNodeSOs.end(); ++it ) { + AppendTo( theObject, *it ); + } } return true;