X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMBase%2FGEOMBase.cxx;h=5bcc54e35effee8a3c1d411773ba31731adc73e1;hb=a045068b34d9356949da48806f31c191b48309c2;hp=6b1d06ea5f216775e508958f72e05122195f6629;hpb=7ae8deaad2f74602d532756382b0b536bb14e557;p=modules%2Fgeom.git diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 6b1d06ea5..5bcc54e35 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -876,3 +876,33 @@ void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object ) } } } + +//================================================================ +// Function : synchronize +// Purpose : +//================================================================ +void GEOMBase::Synchronize( QList& left, QList& right ) +{ + // 1. remove items from the "left" list that are not in the "right" list + QMutableListIterator it1( left ); + while ( it1.hasNext() ) { + GEOM::GeomObjPtr o1 = it1.next(); + bool found = false; + QMutableListIterator it2( right ); + while ( it2.hasNext() && !found ) + found = o1 == it2.next(); + if ( !found ) + it1.remove(); + } + // 2. add items from the "right" list that are not in the "left" list (to keep selection order) + it1 = right; + while ( it1.hasNext() ) { + GEOM::GeomObjPtr o1 = it1.next(); + bool found = false; + QMutableListIterator it2( left ); + while ( it2.hasNext() && !found ) + found = o1 == it2.next(); + if ( !found ) + left << o1; + } +}