[Bf-blender-cvs] [735b26053ee] master: Outliner: Add debugging utility to print an elements path
Julian Eisel
noreply at git.blender.org
Thu Aug 4 15:57:16 CEST 2022
Commit: 735b26053eecd3df7679c16b69910f3c65cfc808
Author: Julian Eisel
Date: Thu Aug 4 15:33:51 2022 +0200
Branches: master
https://developer.blender.org/rB735b26053eecd3df7679c16b69910f3c65cfc808
Outliner: Add debugging utility to print an elements path
No user visible changes expected.
Adds a function that prints the "path" of an element, that is, the
ancestor elements starting from the root, separated by slashes. This can
be useful for debugging. The function isn't used.
===================================================================
M source/blender/editors/space_outliner/tree/tree_element.cc
M source/blender/editors/space_outliner/tree/tree_element.hh
===================================================================
diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc
index 5ad8ae0220a..0ee610a91f2 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element.cc
@@ -4,6 +4,9 @@
* \ingroup spoutliner
*/
+#include <string>
+#include <string_view>
+
#include "DNA_anim_types.h"
#include "DNA_listBase.h"
#include "DNA_space_types.h"
@@ -111,6 +114,17 @@ std::optional<BIFIconID> AbstractTreeElement::getIcon() const
return {};
}
+void AbstractTreeElement::print_path()
+{
+ std::string path = legacy_te_.name;
+
+ for (TreeElement *parent = legacy_te_.parent; parent; parent = parent->parent) {
+ path = parent->name + std::string_view("/") + path;
+ }
+
+ std::cout << path << std::endl;
+}
+
void AbstractTreeElement::uncollapse_by_default(TreeElement *legacy_te)
{
if (!TREESTORE(legacy_te)->used) {
diff --git a/source/blender/editors/space_outliner/tree/tree_element.hh b/source/blender/editors/space_outliner/tree/tree_element.hh
index a3598e7740b..fc6211f20ea 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element.hh
@@ -74,6 +74,16 @@ class AbstractTreeElement {
*/
virtual std::optional<BIFIconID> getIcon() const;
+ /**
+ * Debugging helper: Print effective path of this tree element, constructed out of the
+ * #TreeElement.name of each element. E.g.:
+ * - Lorem
+ * - ipsum dolor sit
+ * - amet
+ * will print: Lorem/ipsum dolor sit/amet.
+ */
+ void print_path();
+
/**
* Expand this tree element if it is displayed for the first time (as identified by its
* tree-store element).
More information about the Bf-blender-cvs
mailing list