Skip to content

Component is the new controller#606

Open
bakpaul wants to merge 9 commits intosofa-framework:masterfrom
bakpaul:26_04_introduce_component_binding
Open

Component is the new controller#606
bakpaul wants to merge 9 commits intosofa-framework:masterfrom
bakpaul:26_04_introduce_component_binding

Conversation

@bakpaul
Copy link
Copy Markdown
Contributor

@bakpaul bakpaul commented Apr 9, 2026

While working on prefabs we have a new type of python object that is to be stored in the graph, so it needs to inherit from BaseComponent somehow. The dirty way to do this was to inherit from Controller which doesn't make sens as it is not meant to be actively doing something.

At first I only wanted to make a python class named Component until I realized that it was meaningless without an ability to override handleEvent. Looking at that I realized that BaseContoller is nothing more than a BaseObject. So merging both makes sense.

This PR keeps the old Controller implementation, just replaced the name to Component and added both to the python bindings. Therefore, such as in the actual core of SOFA, we have controllers and components which are basically the same but named differently

@bakpaul
Copy link
Copy Markdown
Contributor Author

bakpaul commented Apr 23, 2026

@damienmarchal could you make a review on that PR ?

Copy link
Copy Markdown
Contributor

@epernod epernod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very important suggestion....

Comment thread bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Component.cpp
Comment thread bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Component.h
Comment thread bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Component.inl
Comment thread bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Component_doc.h
@hugtalbot
Copy link
Copy Markdown
Contributor

sounds like the name of the next blockbuster movie

"Component is the new controller"

{
static auto componentClass =
R"(
Overridable class for user interaction on SOFA Components
Copy link
Copy Markdown
Contributor

@damienmarchal damienmarchal Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reference to "user interaction" was appropriate for "controller" but not to a BaseComponent binding which have a more wider use case scope.

Some update of the doc are thus needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ! I just did it.

Comment thread bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Component.h Outdated
@damienmarchal
Copy link
Copy Markdown
Contributor

@damienmarchal could you make a review on that PR ?
@bakpaul ok

Inherting from BaseComponent (or BaseObject) to extend them in python is a valid move.

You are right that the SofaPython3 API for Controller was actually not following the c++ Controller's API and it is thus more generic... so it fit to inhert from BaseComponent forwarding the event's in a generic way.

Looks ok so.

=> Actually there is also work to do on making the Sofa.Node binding overridable.

@bakpaul bakpaul force-pushed the 26_04_introduce_component_binding branch from d48f5a5 to 8b4b20b Compare April 28, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants