diff --git a/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp b/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp index ff1de7d7da..c4aa27239a 100644 --- a/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp +++ b/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp @@ -512,6 +512,9 @@ std::size_t SofaGLFWBaseGUI::runLoop(std::size_t targetNbIterations) m_guiEngine->beforeDraw(glfwWindow); sofaGlfwWindow->draw(m_groot, m_vparams); + + drawSelection(m_vparams); + m_guiEngine->afterDraw(); m_guiEngine->startFrame(this); diff --git a/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp b/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp index 545f28b666..eba3b9f5e6 100644 --- a/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp +++ b/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp @@ -368,7 +368,6 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI) static constexpr auto windowNameMouse = ICON_FA_COMPUTER_MOUSE " Mouse Manager"; static constexpr auto windowNameSettings = ICON_FA_SLIDERS " Settings"; - if (!*firstRunState.getStatePtr()) { resetView(dockspace_id, windowNameSceneGraph, windowNameLog, windowNameViewport); @@ -670,9 +669,9 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI) /*************************************** * Viewport window **************************************/ - showViewPort(groot, windowNameViewport, ini, m_fbo, m_viewportWindowSize, - isMouseOnViewport, winManagerViewPort, baseGUI, - isViewportDisplayedForTheFirstTime, lastViewPortPos); + windows::showViewPort(groot, windowNameViewport, ini, m_fbo, m_viewportWindowSize, + isMouseOnViewport, winManagerViewPort, baseGUI, + isViewportDisplayedForTheFirstTime, lastViewPortPos); /*************************************** @@ -695,7 +694,15 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI) **************************************/ static std::set openedComponents; static std::set focusedComponents; - windows::showSceneGraph(groot, windowNameSceneGraph, openedComponents, focusedComponents, winManagerSceneGraph); + static std::set currentSelection; + windows::showSceneGraph(groot, windowNameSceneGraph, openedComponents, + focusedComponents, currentSelection, + winManagerSceneGraph); + + std::set currentSelectionV; + for(auto component : currentSelection) + currentSelectionV.insert(component); + baseGUI->setCurrentSelection(currentSelectionV); /*************************************** * Display flags window diff --git a/SofaImGui/src/SofaImGui/windows/SceneGraph.cpp b/SofaImGui/src/SofaImGui/windows/SceneGraph.cpp index 6497acce56..f14a5e9925 100644 --- a/SofaImGui/src/SofaImGui/windows/SceneGraph.cpp +++ b/SofaImGui/src/SofaImGui/windows/SceneGraph.cpp @@ -47,6 +47,7 @@ namespace windows const char* const& windowNameSceneGraph, std::set& openedComponents, std::set& focusedComponents, + std::set& currentSelection, WindowState& winManagerSceneGraph) { std::set componentToOpen; @@ -75,7 +76,7 @@ namespace windows std::function showNode; showNode = [&showNode, &treeDepth, expand, collapse, &openedComponents, - &componentToOpen](sofa::simulation::Node* node) + &componentToOpen, ¤tSelection](sofa::simulation::Node* node) { if (node == nullptr) return; if (treeDepth == 0) @@ -168,22 +169,29 @@ namespace windows else { clickedObject = object; + if(!currentSelection.contains(clickedObject)){ + currentSelection.clear(); + currentSelection.insert(clickedObject); + } + else{ + currentSelection.erase(clickedObject); + } } } ImGui::SameLine(); - if (isObjectHighlighted) + bool doHighLight = isObjectHighlighted || currentSelection.contains(object); + if (doHighLight) { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1,1,0,1)); } ImGui::Text(object->getName().c_str()); - ImGui::TableNextColumn(); ImGui::TextDisabled(objectClassName.c_str()); ImGui::PopID(); - if (isObjectHighlighted) + if (doHighLight) { ImGui::PopStyleColor(); } @@ -353,7 +361,6 @@ namespace windows openedComponents.insert(componentToOpen.begin(), componentToOpen.end()); openedComponents.insert(focusedComponents.begin(), focusedComponents.end()); - focusedComponents.clear(); sofa::type::vector toRemove; static std::map resizeWindow; diff --git a/SofaImGui/src/SofaImGui/windows/SceneGraph.h b/SofaImGui/src/SofaImGui/windows/SceneGraph.h index a33b1d0157..9daf7c9781 100644 --- a/SofaImGui/src/SofaImGui/windows/SceneGraph.h +++ b/SofaImGui/src/SofaImGui/windows/SceneGraph.h @@ -42,6 +42,7 @@ namespace windows const char* const& windowNameSceneGraph, std::set& openedComponents, std::set& focusedComponents, + std::set& currentSelection, WindowState& winManagerSceneGraph);