2 * Copyright (c) 2014 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>
42 #if defined(DEBUG_ENABLED)
43 static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
47 * Debug helper function.
49 void PrintNodes( const Node& node, BufferIndex updateBufferIndex, int level )
51 #if defined(DEBUG_ENABLED)
52 const Vector3& position = node.GetPosition(updateBufferIndex);
53 const Vector3& scale = node.GetScale(updateBufferIndex);
54 const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
55 const Quaternion& rotation = node.GetOrientation(updateBufferIndex);
58 rotation.ToAxisAngle(axis, angle);
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 << " Position (" << position.x << ", " << position.y << ", " << position.z << ")"
71 << " WorldPosition (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
72 << " Orientation (" << Degree(angle).degree << "degrees <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
73 << " Scale (" << scale.x << ", " << scale.y << ", " << scale.z << ")"
76 DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", 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\n", 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 << " Ori: " << node.GetOrientation(bufferIndex)
111 << " Scale: " << node.GetScale(bufferIndex)
112 << " Color: " << node.GetColor(bufferIndex)
113 << " Visible: " << node.IsVisible(bufferIndex)
114 << " World Pos: " << node.GetWorldPosition(bufferIndex)
115 << " World Ori: " << node.GetWorldOrientation(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