Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2022-08-04 16:33:51 +0300
committerJulian Eisel <julian@blender.org>2022-08-04 16:57:08 +0300
commit735b26053eecd3df7679c16b69910f3c65cfc808 (patch)
tree763611698d46a188a22be5a9bdf47c5458856182 /source/blender/editors/space_outliner
parent2a3e4d8bcd3447ca307108c95b0eeb9ee8bf7323 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.cc14
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.hh10
2 files changed, 24 insertions, 0 deletions
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
@@ -75,6 +75,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).
*