Salome HOME
PAL17233: Projection 2D doesn't work (bis)
[modules/geom.git] / src / GroupGUI / GroupGUI_GroupDlg.cxx
index 8333a1ed3d3012790661d281b3f8fd294d3239d5..e5a61aa2ce3c3f0e799b704a1bc93594255c4fd1 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.salome-platform.org or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -217,6 +217,8 @@ bool GroupGUI_GroupDlg::ClickOnApply()
       initName();
       myIdList->clear();
     }
+  else
+    activateSelection();
   return true;
 }
 
@@ -327,15 +329,36 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
       
       GEOM::ListOfGO anObjects;
       GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
+
       GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
-      for (int i = 0; i < anObjects.length(); i++) {
-        TopoDS_Shape aShape;
-        if ( GEOMBase::GetShape(anObjects[i], aShape, getShapeType()) ) {
-          CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, anObjects[i] );
-          if ( anIndex >= 0 )
-            aMapIndex.Add( anIndex );
-        }
-      }
+      GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+
+      for (int i = 0; i < anObjects.length(); i++) 
+       {
+         GEOM::GEOM_Object_var aGeomObj = anObjects[i];
+         GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
+         TopoDS_Shape aShape;
+         if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) ) 
+           {
+             aSubObjects->length(1);
+             aSubObjects[0] = aGeomObj;
+           }
+         else if (aGeomObj->GetType() == GEOM_GROUP)
+           aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
+         else
+           continue;
+
+         for (int i = 0; i < aSubObjects->length(); i++) 
+           {
+             TopoDS_Shape aShape;
+             if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) ) 
+               {
+                 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
+                 if ( anIndex >= 0 )
+                   aMapIndex.Add( anIndex );
+               }
+           }
+       }
       
       if ( !myMainObj->_is_nil() )
        localSelection( myMainObj, getShapeType() );
@@ -430,15 +453,36 @@ void GroupGUI_GroupDlg::add()
   if ( !aMapIndex.Extent() ) {
     GEOM::ListOfGO anObjects;
     GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
+    
     GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
-    for (int i = 0; i < anObjects.length(); i++) {
-      TopoDS_Shape aShape;
-      if ( GEOMBase::GetShape(anObjects[i], aShape, getShapeType()) ) {
-        CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, anObjects[i] );
-        if ( anIndex >= 0 )
-          aMapIndex.Add( anIndex );
+    GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+    
+    for (int i = 0; i < anObjects.length(); i++) 
+      {
+       GEOM::GEOM_Object_var aGeomObj = anObjects[i];
+       GEOM::ListOfGO_var aSubObjects  = new GEOM::ListOfGO();
+       TopoDS_Shape aShape;
+       if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) ) 
+         {
+           aSubObjects->length(1);
+           aSubObjects[0] = aGeomObj;
+         }
+       else if (aGeomObj->GetType() == GEOM_GROUP)
+         aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
+       else
+         break;
+       
+       for (int i = 0; i < aSubObjects->length(); i++) 
+         {
+         TopoDS_Shape aShape;
+         if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) ) 
+           {
+             CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
+             if ( anIndex >= 0 )
+               aMapIndex.Add( anIndex );
+           }
+       }
       }
-    }
   }
 
   if ( aMapIndex.Extent() >= 1 ) {
@@ -553,29 +597,60 @@ void GroupGUI_GroupDlg::updateState()
 
   // try to find out and process the object browser selection
   if ( !aMapIndex.Extent() && !CORBA::is_nil( myMainObj ) ) {
-    isAdd = true;
     GEOM::ListOfGO anObjects;
     GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
+    
     GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
-    for (int i = 0; i < anObjects.length(); i++) {
-      TopoDS_Shape aShape;
-      if ( GEOMBase::GetShape(anObjects[i], aShape, getShapeType()) ) {
-        CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, anObjects[i] );
-        if ( anIndex >= 0 )
-          aMapIndex.Add( anIndex );
-        else
-          isAdd = false;
-      }
-      else
-        isAdd = false;
-
-      if ( !isAdd ) {
-        aMapIndex.Clear();
-        break;
-      }
-    }
+    GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+
+     isAdd = true;
+     
+     for (int i = 0; i < anObjects.length(); i++) 
+       {
+        GEOM::GEOM_Object_var aGeomObj = anObjects[i];
+        GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
+        TopoDS_Shape aShape;
+        if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) ) 
+          {
+            aSubObjects->length(1);
+            aSubObjects[0] = aGeomObj;
+          }
+        else if (aGeomObj->GetType() == GEOM_GROUP)
+          aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
+        else
+          {
+            aMapIndex.Clear();
+            break;
+          }
+        
+        for (int i = 0; i < aSubObjects->length(); i++) 
+          {
+            TopoDS_Shape aShape;
+            aSubObjects[i];
+            if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) ) 
+              {
+                CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
+                if ( anIndex >= 0 )
+                  aMapIndex.Add( anIndex );
+                else
+                  isAdd = false;
+              }
+            else
+              isAdd = false;
+            
+            if ( !isAdd ) {
+              aMapIndex.Clear();
+              break;
+            }
+          }
+        
+        if ( !isAdd ) {
+          aMapIndex.Clear();
+          break;
+        }
+       }
   }
-
+  
   isAdd = aMapIndex.Extent() > 0;
 
   myAddBtn->setEnabled( !myEditCurrentArgument && !CORBA::is_nil( myMainObj ) && isAdd );
@@ -606,8 +681,10 @@ void GroupGUI_GroupDlg::highlightSubShapes()
     return;
 
   Standard_Boolean isOk;
+  char* objIOR = GEOMBase::GetIORFromObject( myMainObj );
   Handle(GEOM_AISShape) aSh =
-    GEOMBase::ConvertIORinGEOMAISShape( GEOMBase::GetIORFromObject( myMainObj ), isOk, true );
+    GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
+  free( objIOR );
   if ( !isOk || aSh.IsNull() )
     return;
 
@@ -703,7 +780,9 @@ bool GroupGUI_GroupDlg::execute( ObjectList& objects )
 
   SalomeApp_Study* study = getStudy();
   if ( study ) {
-    string IOR = GEOMBase::GetIORFromObject( aGroup );
+    char* objIOR = GEOMBase::GetIORFromObject( aGroup );
+    string IOR( objIOR );
+    free( objIOR );
     if ( IOR != "" ) {
       _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
       if ( SO ) {
@@ -732,3 +811,4 @@ GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj
   }
   return aFatherObj._retn();
 }
+