Skip to content

Commit

Permalink
[GUI] Add ConstraintAttachButtonSetting (#4601)
Browse files Browse the repository at this point in the history
* Add ConstraintAttachButtonSetting to allow configuraiton of lagrangian based mouse interaction directly in the scene

* add example scene and remove alias

* Add comment to the class declaration in the header

* Added comment into the scene file

* Update Sofa/GUI/Component/src/sofa/gui/component/ConstraintAttachButtonSetting.h

Co-authored-by: Alex Bilger <[email protected]>

* Update Sofa/GUI/Component/src/sofa/gui/component/ConstraintAttachButtonSetting.cpp

Co-authored-by: Alex Bilger <[email protected]>

---------

Co-authored-by: Alex Bilger <[email protected]>
Co-authored-by: Frederick Roy <[email protected]>
  • Loading branch information
3 people authored Apr 1, 2024
1 parent 1df6701 commit 7d4f1e2
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sofa/GUI/Component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(HEADER_FILES
${SOFAGUICOMPONENT_SOURCE_DIR}/AddRecordedCameraButtonSetting.h
${SOFAGUICOMPONENT_SOURCE_DIR}/AttachBodyButtonSetting.h
${SOFAGUICOMPONENT_SOURCE_DIR}/FixPickedParticleButtonSetting.h
${SOFAGUICOMPONENT_SOURCE_DIR}/ConstraintAttachButtonSetting.h
${SOFAGUICOMPONENT_SOURCE_DIR}/performer/AddRecordedCameraPerformer.h
${SOFAGUICOMPONENT_SOURCE_DIR}/performer/AttachBodyPerformer.h
${SOFAGUICOMPONENT_SOURCE_DIR}/performer/AttachBodyPerformer.inl
Expand Down Expand Up @@ -37,6 +38,7 @@ set(SOURCE_FILES
${SOFAGUICOMPONENT_SOURCE_DIR}/AddRecordedCameraButtonSetting.cpp
${SOFAGUICOMPONENT_SOURCE_DIR}/AttachBodyButtonSetting.cpp
${SOFAGUICOMPONENT_SOURCE_DIR}/FixPickedParticleButtonSetting.cpp
${SOFAGUICOMPONENT_SOURCE_DIR}/ConstraintAttachButtonSetting.cpp
${SOFAGUICOMPONENT_SOURCE_DIR}/performer/AddRecordedCameraPerformer.cpp
${SOFAGUICOMPONENT_SOURCE_DIR}/performer/AttachBodyPerformer.cpp
${SOFAGUICOMPONENT_SOURCE_DIR}/performer/ComponentMouseInteraction.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/******************************************************************************
* 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 Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser 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 <sofa/gui/component/ConstraintAttachButtonSetting.h>
#include <sofa/core/visual/VisualParams.h>
#include <sofa/core/ObjectFactory.h>

namespace sofa::gui::component
{

int ConstraintAttachButtonSettingClass = core::RegisterObject("Attach an object to the mouse using lagrangian multiplier")
.add< ConstraintAttachButtonSetting >();



} // namespace sofa::gui::component
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/******************************************************************************
* 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 Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser 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 <sofa/gui/component/config.h>

#include <sofa/core/objectmodel/ConfigurationSetting.h>
#include <sofa/component/setting/MouseButtonSetting.h>

namespace sofa::gui::component
{

/*****
* This component modifies the mouse picking behavior in the GUI
* and set it at the beginning to Lagrangian-based contraints
* It doesn't have any parameter because its only presence is sufficient.
*****/
class SOFA_GUI_COMPONENT_API ConstraintAttachButtonSetting: public sofa::component::setting::MouseButtonSetting
{
public:
SOFA_CLASS(ConstraintAttachButtonSetting,MouseButtonSetting);
std::string getOperationType() override {return "ConstraintAttach";}

};

} // namespace sofa::gui::component
1 change: 1 addition & 0 deletions examples/Demos/fallingBeamLagrangianCollision.scn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</Node>

<VisualStyle displayFlags="showForceFields"/>
<ConstraintAttachButtonSetting/> <!-- The presence of this component sets the mouse interaction to Lagrangian-based constraints at the GUI launch -->
<FreeMotionAnimationLoop />
<GenericConstraintSolver maxIterations="200" tolerance="1.0e-8"/>
<CollisionPipeline name="Pipeline" />
Expand Down

0 comments on commit 7d4f1e2

Please sign in to comment.