Blender V4.3
deg_builder_stack.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <iomanip>
12#include <ios>
13#include <iostream>
14
15#include "BKE_idtype.hh"
16
17#include "DNA_ID.h"
18#include "DNA_action_types.h"
20#include "DNA_modifier_types.h"
21
22namespace blender::deg {
23
24/* Spacing between adjacent columns, in number of spaces. */
25constexpr int kColumnSpacing = 4;
26
27/* Width of table columns including column padding.
28 * The type column width is a guesstimate based on "Particle Settings" with some extra padding. */
29constexpr int kPrintDepthWidth = 5 + kColumnSpacing;
30constexpr int kPrintTypeWidth = 21 + kColumnSpacing;
31
32namespace {
33
34/* NOTE: Depth column printing is already taken care of. */
35
36void print(std::ostream &stream, const ID *id)
37{
38 const IDTypeInfo *id_type_info = BKE_idtype_get_info_from_id(id);
39 stream << std::setw(kPrintTypeWidth) << id_type_info->name << (id->name + 2) << "\n";
40}
41
42void print(std::ostream &stream, const bConstraint *constraint)
43{
44 stream << std::setw(kPrintTypeWidth) << ("Constraint") << constraint->name << "\n";
45}
46
47void print(std::ostream &stream, const ModifierData *modifier_data)
48{
49 stream << std::setw(kPrintTypeWidth) << ("Modifier") << modifier_data->name << "\n";
50}
51
52void print(std::ostream &stream, const bPoseChannel *pchan)
53{
54 stream << std::setw(kPrintTypeWidth) << ("Pose Channel") << pchan->name << "\n";
55}
56
57} // namespace
58
59void BuilderStack::print_backtrace(std::ostream &stream)
60{
61 const std::ios_base::fmtflags old_flags(stream.flags());
62
63 stream << std::left;
64
65 stream << std::setw(kPrintDepthWidth) << "Depth" << std::setw(kPrintTypeWidth) << "Type"
66 << "Name"
67 << "\n";
68
69 stream << std::setw(kPrintDepthWidth) << "-----" << std::setw(kPrintTypeWidth) << "----"
70 << "----"
71 << "\n";
72
73 int depth = 1;
74 for (const Entry &entry : stack_) {
75 stream << std::setw(kPrintDepthWidth) << depth;
76 ++depth;
77
78 if (entry.id_ != nullptr) {
79 print(stream, entry.id_);
80 }
81 else if (entry.constraint_ != nullptr) {
82 print(stream, entry.constraint_);
83 }
84 else if (entry.modifier_data_ != nullptr) {
85 print(stream, entry.modifier_data_);
86 }
87 else if (entry.pchan_ != nullptr) {
88 print(stream, entry.pchan_);
89 }
90 }
91
92 stream.flags(old_flags);
93}
94
95} // namespace blender::deg
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
Definition idtype.cc:150
ID and Library types, which are fundamental for SDNA.
void print_backtrace(std::ostream &stream)
constexpr int kColumnSpacing
constexpr int kPrintTypeWidth
constexpr int kPrintDepthWidth
const char * name
Definition DNA_ID.h:413