From bc4a1370408c3c224e17750fa07cc78822069ca1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 10 Feb 2025 17:57:31 +0100 Subject: [PATCH] Add new property hint to determine if a scene graph node should focusable (#3508) --- include/openspace/scene/scenegraphnode.h | 1 + src/scene/scenegraphnode.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 79b65fc195..58ea6a2c9a 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -181,6 +181,7 @@ private: properties::StringProperty _guiDisplayName; properties::StringProperty _guiDescription; properties::BoolProperty _useGuiOrdering; + properties::BoolProperty _guiFocusable; properties::FloatProperty _guiOrderingNumber; // Transformation defined by translation, rotation and scale diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 845264b3f6..414b16dd47 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -193,6 +193,15 @@ namespace { openspace::properties::Property::Visibility::Hidden }; + constexpr openspace::properties::Property::PropertyInfo GuiFocusableInfo = { + "IsFocusable", + "Focusable Hint", + "This value serves as a hint to determine if it makes sense to focus the camera " + "on this scene graph node. It only serves as a hint and does not actually " + "prevent the focussing. The default value is `true`.", + openspace::properties::Property::Visibility::Hidden + }; + constexpr openspace::properties::Property::PropertyInfo ShowDebugSphereInfo = { "ShowDebugSphere", "Show Debug Sphere", @@ -330,6 +339,9 @@ namespace { // not display, for example, barycenters std::optional hidden; + // [[codegen::verbatim(GuiFocusableInfo.description)]] + std::optional focusable; + // If this value is specified, the scene graph node will be ordered in // relation to its neighbors in the GUI based on this value, so that nodes // with a higher value appear later in the list. Scene graph nodes with the @@ -396,6 +408,7 @@ ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( if (p.gui->orderingNumber.has_value()) { result->_guiOrderingNumber = *p.gui->orderingNumber; } + result->_guiFocusable = p.gui->focusable.value_or(result->_guiFocusable); } result->_boundingSphere = p.boundingSphere.value_or(result->_boundingSphere); @@ -541,6 +554,7 @@ SceneGraphNode::SceneGraphNode() , _guiDisplayName(GuiNameInfo) , _guiDescription(GuiDescriptionInfo) , _useGuiOrdering(UseGuiOrderInfo, false) + , _guiFocusable(GuiFocusableInfo, true) , _guiOrderingNumber(GuiOrderInfo, 0.f) , _transform { ghoul::mm_unique_ptr( @@ -625,6 +639,7 @@ SceneGraphNode::SceneGraphNode() addProperty(_guiPath); addProperty(_guiOrderingNumber); addProperty(_useGuiOrdering); + addProperty(_guiFocusable); } SceneGraphNode::~SceneGraphNode() {}