]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0020479: EDF 1116 GEOM: Create a group, "Add" button is inactive but "Select all...
authordmv <dmv@opencascade.com>
Tue, 27 Oct 2009 10:34:46 +0000 (10:34 +0000)
committerdmv <dmv@opencascade.com>
Tue, 27 Oct 2009 10:34:46 +0000 (10:34 +0000)
src/GEOMImpl/GEOMImpl_IShapesOperations.cxx
src/GroupGUI/GroupGUI_GroupDlg.cxx

index cb173b0c40cc46bb2984dbae25224f6764764b41..0eff72be42edf32abe30c13291f1afba82afe87e 100644 (file)
@@ -941,7 +941,7 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs
   } else {
     TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType));
     for (; exp.More(); exp.Next())
-      if (!exp.Current().IsSame(aShape) && mapShape.Add(exp.Current()))
+      if (mapShape.Add(exp.Current()))
        listShape.Append(exp.Current());
   }
 
index 65daf0124a42277f08290598c5eb7097c9c25a6b..a1cc0bdb98b436fe8c1d2a2913af4546586ecc39 100644 (file)
@@ -614,49 +614,50 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
     return;
 
   GEOM::ListOfLong_var aSubShapes;
-  GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
-  aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
-  if ( aSubShapes->length() > 0) {
-    //   if ( !myPlaceCheckBox->isChecked() )
-    if ( subSelectionWay() == ALL_SUBSHAPES )
-      {
-        myIdList->clear();
-        
-        if ( !aShOp->IsDone() )
-          return;
-      }
-    else
-      {
-        aSubShapes = new GEOM::ListOfLong();
-        aSubShapes->length( myMain2InPlaceIndices.Extent() );
-        TColStd_DataMapIteratorOfDataMapOfIntegerInteger m2ip( myMain2InPlaceIndices );
-        for ( int i = 0; m2ip.More(); i++, m2ip.Next() )
-          aSubShapes[ i ] = m2ip.Key();
-      }
-    bool isBlocked = myIdList->signalsBlocked();
-    myIdList->blockSignals( true );
-    
-    for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) {
-      CORBA::Long anIndex = aSubShapes[i];
-      if ( anIndex < 0 )
-        continue;
+
+  //   if ( !myPlaceCheckBox->isChecked() )
+  if ( subSelectionWay() == ALL_SUBSHAPES )
+    {
+      if ( !myIsShapeType )
+        return;
+      myIdList->clear();
+      GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+      aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
       
-      QListWidgetItem* anItem = 0;
-      QString text = QString( "%1" ).arg( anIndex );
-      if ( !myInPlaceObj->_is_nil() ) {
-        QList<QListWidgetItem*> found = myIdList->findItems( text, Qt::MatchExactly );
-        if ( found.count() ) anItem = found[0];
-      }
-      if ( !anItem ) {
-        anItem = new QListWidgetItem( text );
-        myIdList->addItem( anItem );
-      }
-      anItem->setSelected( true );
+      if ( !aShOp->IsDone() )
+        return;
     }
-
-    myIdList->blockSignals( isBlocked );
-    highlightSubShapes();
+  else
+    {
+      aSubShapes = new GEOM::ListOfLong();
+      aSubShapes->length( myMain2InPlaceIndices.Extent() );
+      TColStd_DataMapIteratorOfDataMapOfIntegerInteger m2ip( myMain2InPlaceIndices );
+      for ( int i = 0; m2ip.More(); i++, m2ip.Next() )
+        aSubShapes[ i ] = m2ip.Key();
+    }
+  bool isBlocked = myIdList->signalsBlocked();
+  myIdList->blockSignals( true );
+  
+  for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) {
+    CORBA::Long anIndex = aSubShapes[i];
+    if ( anIndex < 0 )
+      continue;
+    
+    QListWidgetItem* anItem = 0;
+    QString text = QString( "%1" ).arg( anIndex );
+    if ( !myInPlaceObj->_is_nil() ) {
+      QList<QListWidgetItem*> found = myIdList->findItems( text, Qt::MatchExactly );
+      if ( found.count() ) anItem = found[0];
+    }
+    if ( !anItem ) {
+      anItem = new QListWidgetItem( text );
+      myIdList->addItem( anItem );
+    }
+    anItem->setSelected( true );
   }
+  
+  myIdList->blockSignals( isBlocked );
+  highlightSubShapes();
 }
 
 //=================================================================================
@@ -680,6 +681,17 @@ void GroupGUI_GroupDlg::add()
       aSelMgr->selectedSubOwners( aMap );
       if ( aMap.Size() == 1 )
         aMapIndex = LightApp_SelectionMgr::MapEntryOfMapOfInteger::Iterator( aMap ).Value();
+      else { // selected the same subshape as the main object
+        SALOME_ListIO aSelList;
+        TColStd_IndexedMapOfInteger aMap;
+        aSelMgr->selectedObjects(aSelList);
+        if (aSelList.Extent() == 1) {
+          Standard_Boolean aRes = Standard_False;
+          GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
+          if ( aSelectedObject->_is_equivalent(myMainObj) )
+            aMapIndex.Add(1); // add index of the only subshape of selected type
+        }
+      }
     }
   }
   GEOM::ListOfGO anObjects;
@@ -859,6 +871,22 @@ void GroupGUI_GroupDlg::updateState()
       aSelMgr->selectedSubOwners( aMap );
       if ( aMap.Size() == 1 )
         aMapIndex = LightApp_SelectionMgr::MapEntryOfMapOfInteger::Iterator( aMap ).Value();
+      else { // selected the same subshape as the main object
+        SALOME_ListIO aSelList;
+        aSelMgr->selectedObjects(aSelList);
+        if (aSelList.Extent() == 1) {
+          myBusy = true;
+          Standard_Boolean aRes = Standard_False;
+          GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
+          if ( aSelectedObject->_is_equivalent(myMainObj) ) {
+            aMapIndex.Add(1); // add index of the only subshape of selected type
+            TColStd_MapOfInteger anIds; // higlight selected index
+            anIds.Add(1);
+            aSelMgr->AddOrRemoveIndex(aSelList.First(), anIds, false);
+          }
+          myBusy = false;
+        }
+      }
     }
   }