2 * Copyright (c) 2016 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
44 #if defined(DEBUG_ENABLED)
45 static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
49 * Debug helper function.
51 void PrintNodes( const Node& node, BufferIndex updateBufferIndex, int level )
53 const Vector3& position = node.GetPosition(updateBufferIndex);
54 const Vector3& scale = node.GetScale(updateBufferIndex);
55 const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
56 const Quaternion& rotation = node.GetOrientation(updateBufferIndex);
59 rotation.ToAxisAngle(axis, angle);
61 std::string nodeName= DALI_LOG_GET_OBJECT_STRING((&node));
64 std::ostringstream oss;
65 std::ios_base::fmtflags mask = oss.flags();
66 mask &= ~std::ios_base::scientific;
67 mask |= std::ios_base::fixed;
68 oss << std::setprecision(2) << std::setiosflags(mask)
69 << std::setw(level*2) << std::setfill(' ') << "";
70 oss << "Node " << nodeName << " " << &node
71 << " Position (" << position.x << ", " << position.y << ", " << position.z << ")"
72 << " WorldPosition (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
73 << " Orientation (" << Degree(angle).degree << "degrees <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
74 << " Scale (" << scale.x << ", " << scale.y << ", " << scale.z << ")"
77 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", oss.str().c_str());
81 std::ostringstream oss;
82 std::ios_base::fmtflags mask = oss.flags();
83 mask &= ~std::ios_base::scientific;
84 mask |= std::ios_base::fixed;
85 oss << std::setprecision(2) << std::setiosflags(mask)
86 << std::setw(level*2) << std::setfill(' ') << "";
88 std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level*2);
89 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", trafoMatrix.c_str());
94 for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter )
96 PrintNodes(**iter, updateBufferIndex, level);
100 void PrintNodeTree( const Node& node, BufferIndex bufferIndex, std::string indentation )
102 std::cout << "Node " << &node
103 << " \"" << node.mDebugString << "\""
104 << " Origin: " << node.GetParentOrigin()
105 << " Anchor: " << node.GetAnchorPoint()
106 << " Size: " << node.GetSize(bufferIndex)
107 << " Pos: " << node.GetPosition(bufferIndex)
108 << " Ori: " << node.GetOrientation(bufferIndex)
109 << " Scale: " << node.GetScale(bufferIndex)
110 << " Color: " << node.GetColor(bufferIndex)
111 << " Visible: " << node.IsVisible(bufferIndex)
112 << " World Pos: " << node.GetWorldPosition(bufferIndex)
113 << " World Ori: " << node.GetWorldOrientation(bufferIndex)
114 << " World Scale: " << node.GetWorldScale(bufferIndex)
115 << " World Color: " << node.GetWorldColor(bufferIndex)
116 << " World Matrix: " << node.GetWorldMatrix(bufferIndex)
119 for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
121 std::cout << indentation << "|" << std::endl
122 << indentation << "---->";
124 std::string nextIndent = indentation;
125 if ( (iter + 1) != node.GetChildren().End() )
134 PrintNodeTree(**iter, bufferIndex, nextIndent);