Salome HOME
Fix of INTPAL0052192: TC7.3.0: Show only selected does not work in Explode and Group
authorakl <akl@opencascade.com>
Thu, 5 Dec 2013 10:21:33 +0000 (10:21 +0000)
committerakl <akl@opencascade.com>
Thu, 5 Dec 2013 10:21:33 +0000 (10:21 +0000)
 dialogs

src/EntityGUI/EntityGUI_SubShapeDlg.cxx
src/GroupGUI/GroupGUI_GroupDlg.cxx

index 682dec2728befbf7073affbe6b75edb3cce22d7b..1893bbc617a287d2ee8f253a6262f2d1803f23f7 100644 (file)
@@ -589,10 +589,58 @@ void EntityGUI_SubShapeDlg::showOnlySelected()
       Handle(SALOME_InteractiveObject) io =
         new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
       if (view->isVisible(io)) myIsHiddenMain = true;
-    }
 
-    aDisplayer->EraseAll(/*forced = false, updateViewer = true*/);
-    aDisplayer->Display(aSelList, true);
+      //keep the selected entry and IO in the map for checking
+      std::map<QString, Handle(SALOME_InteractiveObject)> aSelEntriesMap;
+      SALOME_ListIteratorOfListIO aSelIt(aSelList);
+      for ( ; aSelIt.More(); aSelIt.Next() ) {
+        //fill map <entry, io>
+        Handle(SALOME_InteractiveObject) anSelIO = aSelIt.Value();
+        aSelEntriesMap[anSelIO->getEntry()] = anSelIO;
+      }
+      //get the displayed sub-shapes
+      SALOME_ListIO displayed;
+      view->GetVisible(displayed);
+      // Erase all, except the selected shapes
+      std::map<QString, Handle(SALOME_InteractiveObject)>::const_iterator 
+        aSelDispIter = aSelEntriesMap.end();
+      SALOME_ListIteratorOfListIO aDispIt( displayed );
+      for ( ; aDispIt.More(); aDispIt.Next() ) {
+        Handle(SALOME_InteractiveObject) anIO = aDispIt.Value();
+        aSelDispIter = aSelEntriesMap.find( anIO->getEntry() );
+        if ( aSelDispIter != aSelEntriesMap.end() ) {
+          //sub-shape is selected, so erase it's record from map to keep in it not displayed, but selected sub-shapes only
+          aSelEntriesMap.erase(aSelDispIter);
+        } else {
+          //sub-shape is not in the map of selected, then erase it from view
+          aDisplayer->Erase( anIO, /*forced = */false, /*updateViewer = */false );
+        }
+      }
+      
+      if ( !aSelEntriesMap.empty() ) {
+        // Build a presentation of the selected, but not displayed sub-shapes
+        TopTools_IndexedMapOfShape aSubShapesMap;
+        TopExp::MapShapes(myShape, aSubShapesMap);
+        QString anEntryBase = aMainEntry.in();
+
+        TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
+        for (; anExp.More(); anExp.Next())
+        {
+          TopoDS_Shape aSubShape = anExp.Current();
+          int index = aSubShapesMap.FindIndex(aSubShape);
+          QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
+          if ( aSelEntriesMap.find( anEntry ) == aSelEntriesMap.end() ) {
+            //skip not selected sub-shapes
+            continue;
+          }
+          SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, view);
+          if (aPrs) {
+            displayPreview(aPrs, true, false); // append, do not update
+          }
+        }
+      }
+      aDisplayer->UpdateViewer();
+    }
 
     // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
     if ((TopAbs_ShapeEnum)shapeType() == TopAbs_VERTEX && myIsHiddenMain) {
index 2bb5769667a73c2719de2d4c2c54ea4199fa6879..a8607a72805ae9f494335061c670e7a76700c02a 100644 (file)
@@ -674,10 +674,57 @@ void GroupGUI_GroupDlg::showOnlySelected()
       Handle(SALOME_InteractiveObject) io =
         new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
       if (view->isVisible(io)) myIsHiddenMain = true;
-    }
+      
+      //keep the selected entry and IO in the map for checking
+      std::map<QString, Handle(SALOME_InteractiveObject)> aSelEntriesMap;
+      SALOME_ListIteratorOfListIO aSelIt(aSelList);
+      for ( ; aSelIt.More(); aSelIt.Next() ) {
+        Handle(SALOME_InteractiveObject) anSelIO = aSelIt.Value();
+        aSelEntriesMap[anSelIO->getEntry()] = anSelIO;
+      }
+      //get the displayed sub-shapes
+      SALOME_ListIO displayed;
+      view->GetVisible(displayed);
+      // Erase all, except the selected sub-shapes
+      std::map<QString, Handle(SALOME_InteractiveObject)>::const_iterator 
+        aSelDispIter = aSelEntriesMap.end();
+      SALOME_ListIteratorOfListIO aDispIt( displayed );
+      for ( ; aDispIt.More(); aDispIt.Next() ) {
+        Handle(SALOME_InteractiveObject) anIO = aDispIt.Value();
+        aSelDispIter = aSelEntriesMap.find( anIO->getEntry() );
+        if ( aSelDispIter != aSelEntriesMap.end() ) {
+          //sub-shape is selected, so erase it's record from map to keep in it not displayed, but selected sub-shapes only
+          aSelEntriesMap.erase(aSelDispIter);
+        } else {
+          //sub-shape is not in the map of selected, then erase it from view
+          aDisplayer->Erase( anIO, /*forced = */false, /*updateViewer = */false );
+        }
+      }
+
+      if ( !aSelEntriesMap.empty() ) {
+        // Build a presentation of the selected, but not displayed sub-shapes
+        TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
+        TopTools_IndexedMapOfShape aSubShapesMap;
+        TopExp::MapShapes(aMainShape, aSubShapesMap);
+        QString anEntryBase = aMainEntry.in();
 
-    aDisplayer->EraseAll(/*forced = false, updateViewer = true*/);
-    aDisplayer->Display(aSelList, true);
+        TopExp_Explorer anExp (aMainShape, getShapeType());
+        for (; anExp.More(); anExp.Next()) {
+          TopoDS_Shape aSubShape = anExp.Current();
+          int index = aSubShapesMap.FindIndex(aSubShape);
+          QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
+          if ( aSelEntriesMap.find( anEntry ) == aSelEntriesMap.end() ) {
+            //skip not selected sub-shapes
+            continue;
+          }
+          SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, view);
+          if (aPrs) {
+            displayPreview(aPrs, true, false); // append, do not update
+          }
+        }
+      }
+      aDisplayer->UpdateViewer();
+    }
 
     // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
     if (getShapeType() == TopAbs_VERTEX && myIsHiddenMain) {