2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 #include <dali/internal/update/manager/update-manager-debug.h>
26 #include <dali/integration-api/debug.h>
27 #include <dali/public-api/common/constants.h>
28 #include <dali/public-api/math/degree.h>
29 #include <dali/public-api/math/radian.h>
30 #include <dali/public-api/math/vector2.h>
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 #if defined(DEBUG_ENABLED)
51 const Vector3& position = node.GetPosition(updateBufferIndex);
52 const Vector3& scale = node.GetScale(updateBufferIndex);
53 const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
54 const Quaternion& rotation = node.GetRotation(updateBufferIndex);
57 rotation.ToAxisAngle(axis, angle);
58 angle = angle * 180.0f / Math::PI;
60 std::string nodeName= DALI_LOG_GET_OBJECT_STRING((&node));
63 std::ostringstream oss;
64 std::ios_base::fmtflags mask = oss.flags();
65 mask &= ~std::ios_base::scientific;
66 mask |= std::ios_base::fixed;
67 oss << std::setprecision(2) << std::setiosflags(mask)
68 << std::setw(level*2) << std::setfill(' ') << "";
69 oss << "Node " << nodeName << " " << &node
70 << " Pos (" << position.x << ", " << position.y << ", " << position.z << ")"
71 << " FullPos (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
72 << " Rot (" << angle << "deg <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
73 << " Scale (" << scale.x << ", " << scale.y << ", " << scale.z << ")"
76 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s", oss.str().c_str());
80 std::ostringstream oss;
81 std::ios_base::fmtflags mask = oss.flags();
82 mask &= ~std::ios_base::scientific;
83 mask |= std::ios_base::fixed;
84 oss << std::setprecision(2) << std::setiosflags(mask)
85 << std::setw(level*2) << std::setfill(' ') << "";
87 std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level*2);
88 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s", trafoMatrix.c_str());
93 for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter )
95 PrintNodes(**iter, updateBufferIndex, level);
97 #endif // DEBUG_ENABLED
100 void PrintNodeTree( const Node& node, BufferIndex bufferIndex, std::string indentation )
102 #if defined(DEBUG_ENABLED)
104 std::cout << "Node " << &node
105 << " \"" << node.mDebugString << "\""
106 << " Origin: " << node.GetParentOrigin()
107 << " Anchor: " << node.GetAnchorPoint()
108 << " Size: " << node.GetSize(bufferIndex)
109 << " Pos: " << node.GetPosition(bufferIndex)
110 << " Rot: " << node.GetRotation(bufferIndex)
111 << " Scale: " << node.GetScale(bufferIndex)
112 << " Color: " << node.GetColor(bufferIndex)
113 << " Visible: " << node.IsVisible(bufferIndex)
114 << " World Pos: " << node.GetWorldPosition(bufferIndex)
115 << " World Rot: " << node.GetWorldRotation(bufferIndex)
116 << " World Scale: " << node.GetWorldScale(bufferIndex)
117 << " World Color: " << node.GetWorldColor(bufferIndex)
118 << " World Matrix: " << node.GetWorldMatrix(bufferIndex)
121 for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
123 std::cout << indentation << "|" << std::endl
124 << indentation << "---->";
126 std::string nextIndent = indentation;
127 if ( (iter + 1) != node.GetChildren().End() )
136 PrintNodeTree(**iter, bufferIndex, nextIndent);
139 #endif // DEBUG_ENABLED