2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/update/manager/update-manager-debug.h>
27 #include <dali/integration-api/debug.h>
28 #include <dali/public-api/common/constants.h>
29 #include <dali/public-api/math/degree.h>
30 #include <dali/public-api/math/radian.h>
31 #include <dali/public-api/math/vector2.h>
33 #ifdef DALI_PRINT_UPDATE_INFO
41 #if defined(DEBUG_ENABLED)
42 static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
46 * Debug helper function.
48 void PrintNodes(const Node& node, BufferIndex updateBufferIndex, int level)
50 const Vector3& position = node.GetPosition(updateBufferIndex);
51 const Vector3& scale = node.GetScale(updateBufferIndex);
52 const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
53 const Quaternion& rotation = node.GetOrientation(updateBufferIndex);
56 rotation.ToAxisAngle(axis, angle);
58 std::string nodeName = DALI_LOG_GET_OBJECT_STRING((&node));
61 std::ostringstream oss;
62 std::ios_base::fmtflags mask = oss.flags();
63 mask &= ~std::ios_base::scientific;
64 mask |= std::ios_base::fixed;
65 oss << std::setprecision(2) << std::setiosflags(mask)
66 << std::setw(level * 2) << std::setfill(' ') << "";
67 oss << "Node " << nodeName << " " << &node
68 << " Position (" << position.x << ", " << position.y << ", " << position.z << ")"
69 << " WorldPosition (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
70 << " Orientation (" << Degree(angle).degree << "degrees <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
71 << " Scale (" << scale.x << ", " << scale.y << ", " << scale.z << ")"
74 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", oss.str().c_str());
78 std::ostringstream oss;
79 std::ios_base::fmtflags mask = oss.flags();
80 mask &= ~std::ios_base::scientific;
81 mask |= std::ios_base::fixed;
82 oss << std::setprecision(2) << std::setiosflags(mask)
83 << std::setw(level * 2) << std::setfill(' ') << "";
85 std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level * 2);
86 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", trafoMatrix.c_str());
91 for(NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
93 PrintNodes(**iter, updateBufferIndex, level);
97 void PrintNodeTree(const Node& node, BufferIndex bufferIndex, std::string indentation)
99 std::cout << "Node " << &node
100 << " \"" << node.mDebugString << "\""
101 << " Origin: " << node.GetParentOrigin()
102 << " Anchor: " << node.GetAnchorPoint()
103 << " Size: " << node.GetSize(bufferIndex)
104 << " Pos: " << node.GetPosition(bufferIndex)
105 << " Ori: " << node.GetOrientation(bufferIndex)
106 << " Scale: " << node.GetScale(bufferIndex)
107 << " Color: " << node.GetColor(bufferIndex)
108 << " Visible: " << node.IsVisible(bufferIndex)
109 << " World Pos: " << node.GetWorldPosition(bufferIndex)
110 << " World Ori: " << node.GetWorldOrientation(bufferIndex)
111 << " World Scale: " << node.GetWorldScale(bufferIndex)
112 << " World Color: " << node.GetWorldColor(bufferIndex)
113 << " World Matrix: " << node.GetWorldMatrix(bufferIndex)
116 for(NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
118 std::cout << indentation << "|" << std::endl
119 << indentation << "---->";
121 std::string nextIndent = indentation;
122 if((iter + 1) != node.GetChildren().End())
131 PrintNodeTree(**iter, bufferIndex, nextIndent);
135 } // namespace SceneGraph
137 } // namespace Internal