From: akl Date: Thu, 5 Dec 2013 10:21:33 +0000 (+0000) Subject: Fix of INTPAL0052192: TC7.3.0: Show only selected does not work in Explode and Group X-Git-Tag: V7_3_0b1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=274055b2bd2629cfc7563fdb73dd8a984d5de3f9;p=modules%2Fgeom.git Fix of INTPAL0052192: TC7.3.0: Show only selected does not work in Explode and Group dialogs --- diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index 682dec272..1893bbc61 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -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 aSelEntriesMap; + SALOME_ListIteratorOfListIO aSelIt(aSelList); + for ( ; aSelIt.More(); aSelIt.Next() ) { + //fill map + 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::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) { diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx index 2bb576966..a8607a728 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.cxx +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -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 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::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) {