+//=================================================================================
+// function : showOnlySelected
+// purpose :
+//=================================================================================
+void EntityGUI_SubShapeDlg::showOnlySelected()
+{
+ if (CORBA::is_nil(myObject) || isAllSubShapes())
+ return;
+
+ QPushButton* send = (QPushButton*)sender();
+ if (send == GroupPoints->PushButton4) {
+ activateSelection();
+ return;
+ }
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ GEOM_Displayer* aDisplayer = getDisplayer();
+
+ if (send == GroupPoints->PushButton3) {
+ aDisplayer->Erase(aSelList, /*forced=*/false, /*updateViewer=*/true);
+ }
+ else {
+ // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+ SALOME_View* view = GEOM_Displayer::GetActiveView();
+ if (view) {
+ CORBA::String_var aMainEntry = myObject->GetStudyEntry();
+ 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);
+
+ // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+ if ((TopAbs_ShapeEnum)shapeType() == TopAbs_VERTEX && myIsHiddenMain) {
+ aDisplayer->Display(myObject);
+ }
+ }
+}
+
+//=================================================================================
+// function : getSelectedSubshapes
+// purpose :
+//=================================================================================
+int EntityGUI_SubShapeDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex)
+{
+ theMapIndex.Clear();
+
+ SalomeApp_Application* app = myGeomGUI->getApp();
+ if (!app || myObject->_is_nil())
+ return 0;
+
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ // try to find out and process the global selection
+ // (of not published objects and of published sub-shapes)
+ {
+ SALOME_ListIteratorOfListIO anIter (aSelList);
+ for (int i = 0; anIter.More(); anIter.Next(), i++)
+ {
+ Handle(SALOME_InteractiveObject) anIObj = anIter.Value();
+ QString anEntry = anIObj->getEntry();
+ QString str = "_";
+ int index = anEntry.lastIndexOf(str);
+ if (index > 0) // selection among special preview
+ {
+ anEntry.remove(0, index+1);
+ int anIndex = anEntry.toInt();
+ if (anIndex)
+ theMapIndex.Add(anIndex);
+ }
+ else // selection among published shapes
+ {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!appStudy) return 0;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
+ GEOM::GEOM_Object_var aGeomObj =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
+ TopoDS_Shape aShape;
+ if (GEOMBase::GetShape(aGeomObj, aShape)) {
+ if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == (TopAbs_ShapeEnum)shapeType()) {
+ TopTools_IndexedMapOfShape aMainMap;
+ TopExp::MapShapes(myShape, aMainMap);
+
+ TopExp_Explorer anExp (aShape, (TopAbs_ShapeEnum)shapeType());
+ for (; anExp.More(); anExp.Next()) {
+ TopoDS_Shape aSubShape = anExp.Current();
+ int anIndex = aMainMap.FindIndex(aSubShape);
+ if (anIndex >= 0) {
+ theMapIndex.Add(anIndex);
+ }
+ }
+ }
+ }
+ }
+ } // for aSelList
+ }
+
+ return theMapIndex.Extent();
+}
+
+//=================================================================================
+// function : activateSelection
+// purpose : Activate selection in accordance with myEditCurrentArgument
+//=================================================================================
+void EntityGUI_SubShapeDlg::activateSelection()
+{
+ erasePreview(false);
+
+ // local selection
+ if (!myObject->_is_nil() && !isAllSubShapes())
+ {
+ GEOM_Displayer* aDisplayer = getDisplayer();
+
+ // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+ if ((TopAbs_ShapeEnum)shapeType() == TopAbs_VERTEX) {
+ if (myIsHiddenMain)
+ aDisplayer->Display(myObject);
+ }
+ else {
+ SALOME_View* view = GEOM_Displayer::GetActiveView();
+ if (view) {
+ CORBA::String_var aMainEntry = myObject->GetStudyEntry();
+ Handle(SALOME_InteractiveObject) io =
+ new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
+ if (view->isVisible(io)) {
+ aDisplayer->Erase(myObject, false, false);
+ myIsHiddenMain = true;
+ }
+ }
+ }
+
+ int prevDisplayMode = aDisplayer->SetDisplayMode(0);
+
+ SUIT_ViewWindow* aViewWindow = 0;
+ SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
+ if (activeStudy)
+ aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ if (aViewWindow == 0) return;
+
+ SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
+ if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
+ aViewManager->getType() != SVTK_Viewer::Type())
+ return;
+
+ SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
+ SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
+ if (aView == 0) return;
+
+ //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
+
+ TopTools_IndexedMapOfShape aSubShapesMap;
+ TopExp::MapShapes(myShape, aSubShapesMap);
+ CORBA::String_var aMainEntry = myObject->GetStudyEntry();
+ 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 = anEntryBase + QString("_%1").arg(index);
+
+ SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
+ if (aPrs) {
+ displayPreview(aPrs, true, false); // append, do not update
+ }
+ }
+ aDisplayer->UpdateViewer();
+ aDisplayer->SetDisplayMode(prevDisplayMode);
+ }
+
+ globalSelection(GEOM_ALLSHAPES);
+}
+