diff --git a/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.cpp b/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.cpp index df44b85895..b1c4709037 100644 --- a/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.cpp +++ b/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.cpp @@ -51,7 +51,7 @@ namespace sofaglfw void SofaGLFWMouseManager::setPickHandler(PickHandler *picker) { pickHandler=picker; - + updateContent(); updateOperation(LEFT, "Attach"); updateOperation(MIDDLE, "Incise"); updateOperation(RIGHT, "Remove"); @@ -65,4 +65,18 @@ namespace sofaglfw } } + void SofaGLFWMouseManager::updateContent() { + const OperationFactory::RegisterStorage ®istry = OperationFactory::getInstance()->registry; + + int idx = 0; + for (OperationFactory::RegisterStorage::const_iterator it = registry.begin(); it != registry.end(); ++it) { + + OperationFactory::GetDescription(it->first) == OperationFactory::GetDescription(usedOperations[LEFT]) ; + OperationFactory::GetDescription(it->first) == OperationFactory::GetDescription(usedOperations[MIDDLE]); + OperationFactory::GetDescription(it->first) == OperationFactory::GetDescription(usedOperations[RIGHT]); + mapIndexOperation.insert(std::make_pair(idx++, it->first)); + } + } + + }// namespace sofaglfw \ No newline at end of file diff --git a/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.h b/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.h index 99a0a67503..c6f138516b 100644 --- a/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.h +++ b/SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include using namespace sofa::gui::common; @@ -38,6 +40,11 @@ class SOFAGLFW_API SofaGLFWMouseManager private: void updateOperation(MOUSE_BUTTON button, const std::string& id); + + void updateContent(); + std::map< int, std::string > mapIndexOperation; + sofa::type::fixed_array< std::string, sofa::gui::common::NONE > usedOperations; + PickHandler* pickHandler; }; diff --git a/SofaImGui/CMakeLists.txt b/SofaImGui/CMakeLists.txt index ce90671465..013bfe55a6 100644 --- a/SofaImGui/CMakeLists.txt +++ b/SofaImGui/CMakeLists.txt @@ -97,10 +97,7 @@ set(HEADER_FILES ${SOFAIMGUI_SOURCE_DIR}/windows/ViewPort.h ${SOFAIMGUI_SOURCE_DIR}/AppIniFile.h ${SOFAIMGUI_SOURCE_DIR}/windows/WindowState.h - - - - + ${SOFAIMGUI_SOURCE_DIR}/windows/viewMouseManager.h ) set(SOURCE_FILES @@ -120,7 +117,7 @@ set(SOURCE_FILES ${SOFAIMGUI_SOURCE_DIR}/windows/ViewPort.cpp ${SOFAIMGUI_SOURCE_DIR}/AppIniFile.cpp ${SOFAIMGUI_SOURCE_DIR}/windows/WindowState.cpp - + ${SOFAIMGUI_SOURCE_DIR}/windows/viewMouseManager.cpp ) diff --git a/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp b/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp index f5100ad84f..4621741db9 100644 --- a/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp +++ b/SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp @@ -76,6 +76,7 @@ #include "windows/Components.h" #include "windows/Settings.h" #include "AppIniFile.h" +#include "windows/viewMouseManager.h" #include "windows/ViewPort.h" #include "windows/WindowState.h" @@ -94,7 +95,8 @@ ImGuiGUIEngine::ImGuiGUIEngine() winManagerLog(helper::system::FileSystem::append(sofaimgui::getConfigurationFolderPath(), std::string("log.txt"))), winManagerSettings(helper::system::FileSystem::append(sofaimgui::getConfigurationFolderPath(), std::string("settings.txt"))), winManagerViewPort(helper::system::FileSystem::append(sofaimgui::getConfigurationFolderPath(), std::string("viewport.txt"))), - firstRunState(helper::system::FileSystem::append(sofaimgui::getConfigurationFolderPath(), std::string("firstrun.txt"))) + firstRunState(helper::system::FileSystem::append(sofaimgui::getConfigurationFolderPath(), std::string("firstrun.txt"))), + winManagerMouse(helper::system::FileSystem::append(sofaimgui::getConfigurationFolderPath(), std::string("mousemanager.txt"))) { } @@ -250,7 +252,7 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI) static constexpr auto windowNameComponents = ICON_FA_LIST " Components"; static constexpr auto windowNameLog = ICON_FA_TERMINAL " Log"; static constexpr auto windowNameSettings = ICON_FA_SLIDERS_H " Settings"; - + static constexpr auto windowNameMouseManager = ICON_FA_MOUSE_POINTER " MouseManager"; if (!*firstRunState.getStatePtr()) { @@ -470,6 +472,8 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI) ImGui::Checkbox(windowNameSettings, winManagerSettings.getStatePtr()); + ImGui::Checkbox(windowNameMouseManager,winManagerMouse.getStatePtr()); + ImGui::EndMenu(); } @@ -538,6 +542,7 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI) isViewportDisplayedForTheFirstTime, lastViewPortPos); + showManagerMouseWindow(windowNameMouseManager,winManagerMouse); /*************************************** * Performances window **************************************/ diff --git a/SofaImGui/src/SofaImGui/ImGuiGUIEngine.h b/SofaImGui/src/SofaImGui/ImGuiGUIEngine.h index 456023b4a1..034f05ecf2 100644 --- a/SofaImGui/src/SofaImGui/ImGuiGUIEngine.h +++ b/SofaImGui/src/SofaImGui/ImGuiGUIEngine.h @@ -48,7 +48,7 @@ class ImGuiGUIEngine : public sofaglfw::BaseGUIEngine ImGuiGUIEngine() ; ~ImGuiGUIEngine() = default; - + void init() override; void initBackend(GLFWwindow*) override; void startFrame(sofaglfw::SofaGLFWBaseGUI*) override; @@ -81,6 +81,7 @@ class ImGuiGUIEngine : public sofaglfw::BaseGUIEngine bool isViewportDisplayedForTheFirstTime{true}; sofa::type::Vec2f lastViewPortPos; + windows::WindowState winManagerMouse; }; } // namespace sofaimgui diff --git a/SofaImGui/src/SofaImGui/windows/viewMouseManager.cpp b/SofaImGui/src/SofaImGui/windows/viewMouseManager.cpp new file mode 100644 index 0000000000..dea618d4a1 --- /dev/null +++ b/SofaImGui/src/SofaImGui/windows/viewMouseManager.cpp @@ -0,0 +1,58 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the Free * +* Software Foundation; either version 2 of the License, or (at your option) * +* any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program. If not, see . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ + +#include "viewMouseManager.h" + +#include "SofaImGui/ImGuiGUIEngine.h" +namespace windows { + struct OperationSettings { + float stiffness = 1.0f; + float arrowSize = 10.0f; + float showFactorSize = 1.0f; + }; + + OperationSettings settings; + int selectedOperation = 0; + + void showManagerMouseWindow(const char* const&windowNameMouseManager,WindowState& winManagerMouse) { + if(*winManagerMouse.getStatePtr()){ + ImGui::Begin(windowNameMouseManager, winManagerMouse.getStatePtr()); + ImGui::Text("Left Button"); + ImGui::BeginGroup(); + + ///todo: get operations descriptions from SofaGlFWMouseManager (update content) + + const char* operations[] = {"Attach an object to the Mouse using a spring force field"}; + ImGui::Combo("Operation", &selectedOperation, operations, IM_ARRAYSIZE(operations)); + + ImGui::SliderFloat("Stiffness", &settings.stiffness, 0.0f, 1000.0f); + ImGui::SliderFloat("Arrow Size", &settings.arrowSize, 0.0f, 10.0f); + ImGui::SliderFloat("Show Factor Size", &settings.showFactorSize, 1.0f, 5.0f); + + ImGui::EndGroup(); + ImGui::End(); + + + } + } + +} \ No newline at end of file diff --git a/SofaImGui/src/SofaImGui/windows/viewMouseManager.h b/SofaImGui/src/SofaImGui/windows/viewMouseManager.h new file mode 100644 index 0000000000..838c78f1ad --- /dev/null +++ b/SofaImGui/src/SofaImGui/windows/viewMouseManager.h @@ -0,0 +1,31 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the Free * +* Software Foundation; either version 2 of the License, or (at your option) * +* any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program. If not, see . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#pragma once +#include "SofaImGui/ImGuiGUIEngine.h" +#include "WindowState.h" + +using namespace sofaimgui; +namespace windows +{ + void showManagerMouseWindow(const char* const&windowNameMouseManager,WindowState &winManagerMouse) ; + +} // namespace sofaimgui