Salome HOME
0022289: EDF 2623 GEOM: Make "MakePipeWithDifferentsSections" available from GUI...
[modules/geom.git] / src / GEOMBase / GEOMBase.cxx
index 6b1d06ea5f216775e508958f72e05122195f6629..5bcc54e35effee8a3c1d411773ba31731adc73e1 100644 (file)
@@ -876,3 +876,33 @@ void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object )
     }
   }
 }
+
+//================================================================
+// Function : synchronize
+// Purpose  : 
+//================================================================
+void GEOMBase::Synchronize( QList<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right )
+{
+  // 1. remove items from the "left" list that are not in the "right" list
+  QMutableListIterator<GEOM::GeomObjPtr> it1( left );
+  while ( it1.hasNext() ) {
+    GEOM::GeomObjPtr o1 = it1.next();
+    bool found = false;
+    QMutableListIterator<GEOM::GeomObjPtr> 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<GEOM::GeomObjPtr> it2( left );
+    while ( it2.hasNext() && !found )
+      found = o1 == it2.next();
+    if ( !found )
+      left << o1;
+  }
+}