Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] Mouse Manager window #129

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
46cadc4
[SofaGLFWBaseGUI] Handle Keyboard events
lamriaimen Jun 4, 2024
ceed77d
[SofaGLFWBaseGUI] Remove useless cout and include
lamriaimen Jun 4, 2024
bde7cfc
[SofaGLFWBaseGUI] Remove useless declarations
lamriaimen Jun 4, 2024
069c556
Update SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.h
lamriaimen Jun 5, 2024
143572e
Update SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp
lamriaimen Jun 5, 2024
c23057f
Update SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp
lamriaimen Jun 5, 2024
2f59119
Update SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp
lamriaimen Jun 5, 2024
f09f9d4
cleaning
alxbilger Jun 5, 2024
0a9aa68
revert useless changes
alxbilger Jun 5, 2024
eaa8aa9
Resolve conflicts
lamriaimen Jun 24, 2024
229b022
update
lamriaimen Jun 25, 2024
8bf3dd8
Merge branch 'master' into gui.mouse
lamriaimen Jul 23, 2024
1d49525
update
lamriaimen Jul 23, 2024
73ea06d
update
lamriaimen Jul 23, 2024
a9e0de8
first result
lamriaimen Jul 29, 2024
ab4a5d3
everything works (not clean)
lamriaimen Jul 30, 2024
3d49b31
mouse interaction (clean)
lamriaimen Jul 31, 2024
73d61ae
mouse interaction (clean)
lamriaimen Jul 31, 2024
b559fca
cleaning
lamriaimen Aug 1, 2024
43b2bd2
handling merges
lamriaimen Aug 1, 2024
4441c0d
handling merge fix bug
lamriaimen Aug 1, 2024
a9a2e2e
fix bugs
lamriaimen Aug 1, 2024
e96f2a8
reverse indents and remove unnecessary declarations
lamriaimen Aug 1, 2024
7b08a86
reverse indentation
lamriaimen Aug 1, 2024
0594e93
merge commmit
lamriaimen Aug 2, 2024
57dba6c
fix indentation
lamriaimen Aug 2, 2024
4291c8e
fix indentation
lamriaimen Aug 2, 2024
9a4b134
fix indentation
lamriaimen Aug 2, 2024
978e23e
fix indentation
lamriaimen Aug 2, 2024
947e1cb
fix indentation
lamriaimen Aug 2, 2024
20f9154
Merge branch 'master' into gui.mouse
lamriaimen Aug 5, 2024
0ceedb3
update
lamriaimen Aug 5, 2024
f3474bd
Update SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.cpp
lamriaimen Aug 5, 2024
398f279
reverting calling OpenGL2 api
fredroy Aug 6, 2024
00e4ae2
apply some changes
lamriaimen Aug 6, 2024
15733a3
Merge remote-tracking branch 'origin/gui.mouse' into gui.mouse
lamriaimen Aug 6, 2024
a6f1e1c
apply some changes
lamriaimen Aug 6, 2024
5d7f0ab
update
lamriaimen Aug 6, 2024
7387591
update
lamriaimen Aug 6, 2024
41e7631
update
lamriaimen Aug 7, 2024
b94406d
update to use m_vprams methods
lamriaimen Aug 7, 2024
a604c73
fix indentation issues
lamriaimen Aug 7, 2024
ff81cf6
start
lamriaimen Aug 7, 2024
66c2c3d
update
lamriaimen Aug 8, 2024
3e36a7f
update
lamriaimen Aug 8, 2024
1e6a3dc
update
lamriaimen Aug 8, 2024
c053db7
update
lamriaimen Aug 9, 2024
c98866a
update
lamriaimen Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace sofaglfw
void SofaGLFWMouseManager::setPickHandler(PickHandler *picker)
{
pickHandler=picker;

updateContent();
updateOperation(LEFT, "Attach");
updateOperation(MIDDLE, "Incise");
updateOperation(RIGHT, "Remove");
Expand All @@ -65,4 +65,18 @@ namespace sofaglfw
}
}

void SofaGLFWMouseManager::updateContent() {
const OperationFactory::RegisterStorage &registry = 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
7 changes: 7 additions & 0 deletions SofaGLFW/src/SofaGLFW/SofaGLFWMouseManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <sofa/gui/common/PickHandler.h>
#include <sofa/gui/common/BaseViewer.h>
#include <sofa/gui/common/MouseOperations.h>
#include <sofa/gui/common/PickHandler.h>
#include <memory>


using namespace sofa::gui::common;
Expand All @@ -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;
};

Expand Down
7 changes: 2 additions & 5 deletions SofaImGui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)


Expand Down
9 changes: 7 additions & 2 deletions SofaImGui/src/SofaImGui/ImGuiGUIEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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")))
{
}

Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -470,6 +472,8 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI)

ImGui::Checkbox(windowNameSettings, winManagerSettings.getStatePtr());

ImGui::Checkbox(windowNameMouseManager,winManagerMouse.getStatePtr());

ImGui::EndMenu();
}

Expand Down Expand Up @@ -538,6 +542,7 @@ void ImGuiGUIEngine::startFrame(sofaglfw::SofaGLFWBaseGUI* baseGUI)
isViewportDisplayedForTheFirstTime, lastViewPortPos);


showManagerMouseWindow(windowNameMouseManager,winManagerMouse);
/***************************************
* Performances window
**************************************/
Expand Down
3 changes: 2 additions & 1 deletion SofaImGui/src/SofaImGui/ImGuiGUIEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ImGuiGUIEngine : public sofaglfw::BaseGUIEngine

ImGuiGUIEngine() ;
~ImGuiGUIEngine() = default;

void init() override;
void initBackend(GLFWwindow*) override;
void startFrame(sofaglfw::SofaGLFWBaseGUI*) override;
Expand Down Expand Up @@ -81,6 +81,7 @@ class ImGuiGUIEngine : public sofaglfw::BaseGUIEngine

bool isViewportDisplayedForTheFirstTime{true};
sofa::type::Vec2f lastViewPortPos;
windows::WindowState winManagerMouse;
};

} // namespace sofaimgui
58 changes: 58 additions & 0 deletions SofaImGui/src/SofaImGui/windows/viewMouseManager.cpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: [email protected] *
******************************************************************************/

#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();


}
}

}
31 changes: 31 additions & 0 deletions SofaImGui/src/SofaImGui/windows/viewMouseManager.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: [email protected] *
******************************************************************************/
#pragma once
#include "SofaImGui/ImGuiGUIEngine.h"
#include "WindowState.h"

using namespace sofaimgui;
namespace windows
{
void showManagerMouseWindow(const char* const&windowNameMouseManager,WindowState &winManagerMouse) ;

} // namespace sofaimgui
Loading