3737#include < sofa/component/visual/LineAxis.h>
3838#include < sofa/gui/common/BaseGUI.h>
3939#include " SceneGraph.h"
40+ #include < sofa/simulation/DeactivatedNodeVisitor.h>
4041
4142namespace windows
4243{
4344
4445 bool drawExpandableObject (sofa::core::objectmodel::Base * obj, bool isNodeHighlighted, const char * icon, const ImVec4 objectColor, std::set<sofa::core::objectmodel::Base*>& componentToOpen, const std::set<sofa::core::objectmodel::Base*>& currentSelection, sofa::core::objectmodel::Base* &clickedObject)
4546 {
4647 const auto & objName = obj->getName ();
48+ auto * node = dynamic_cast <sofa::simulation::Node*>(obj);
4749
4850 ImGui::PushStyleColor (ImGuiCol_Text, objectColor);
4951
@@ -71,6 +73,23 @@ namespace windows
7173 }
7274 }
7375
76+ if (ImGui::BeginPopupContextItem ())
77+ {
78+ ImGui::Text (" %s" , obj->getPathName ().c_str ());
79+ if (node)
80+ {
81+ const auto isActivated = node->is_activated .getValue ();
82+ if (ImGui::MenuItem (isActivated ? " Deactivate Node" : " Activate Node" ))
83+ {
84+ node->setActive (!isActivated);
85+
86+ sofa::simulation::DeactivationVisitor v (sofa::core::execparams::defaultInstance (), !isActivated);
87+ node->executeVisitor (&v);
88+ }
89+ }
90+ ImGui::EndPopup ();
91+ }
92+
7493 ImGui::SameLine ();
7594 // Now actually write the name
7695 bool doHighLight = isNodeHighlighted || ((clickedObject == obj) != currentSelection.contains (obj));
@@ -79,6 +98,11 @@ namespace windows
7998 ImGui::PushStyleColor (ImGuiCol_Text, ImVec4 (1 ,1 ,0 ,1 ));
8099 }
81100
101+ if (node && !node->isActive ())
102+ {
103+ ImGui::PushStyleColor (ImGuiCol_Text, ImVec4 (1 ,0 ,0 ,1 ));
104+ }
105+
82106 ImGui::SetCursorPosX (XPos);
83107
84108 ImGui::Text (" %s" , obj->getName ().c_str ());
@@ -87,12 +111,14 @@ namespace windows
87111 ImGui::PopStyleColor ();
88112 }
89113
90- ImGui::TableNextColumn ();
91- ImGui::TextDisabled (" %s" , obj->getClassName ().c_str ());
92- if (isNodeHighlighted)
114+ if (node && !node->isActive ())
93115 {
94116 ImGui::PopStyleColor ();
95117 }
118+
119+ ImGui::TableNextColumn ();
120+ ImGui::TextDisabled (" %s" , obj->getClassName ().c_str ());
121+
96122 ImGui::PopStyleColor ();
97123
98124 ImGui::PopID ();
0 commit comments