Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager-debug.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 // CLASS HEADER
18 #include <dali/internal/update/manager/update-manager-debug.h>
19
20 // EXTERNAL INCLUDES
21 #include <sstream>
22 #include <iomanip>
23 #include <ios>
24
25 // INTERNAL INCLUDES
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>
31
32 namespace Dali
33 {
34
35 namespace Internal
36 {
37
38 namespace SceneGraph
39 {
40
41 #if defined(DEBUG_ENABLED)
42 static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
43 #endif
44
45 /**
46  * Debug helper function.
47  */
48 void PrintNodes( const Node& node, BufferIndex updateBufferIndex, int level )
49 {
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);
55   Vector3 axis;
56   float angle;
57   rotation.ToAxisAngle(axis, angle);
58   angle = angle * 180.0f / Math::PI;
59
60   std::string nodeName= DALI_LOG_GET_OBJECT_STRING((&node));
61
62   {
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 << ")"
74         << std::endl;
75
76     DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s", oss.str().c_str());
77   }
78
79   {
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(' ') << "";
86
87     std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level*2);
88     DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s", trafoMatrix.c_str());
89   }
90
91   ++level;
92
93   for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter )
94   {
95     PrintNodes(**iter, updateBufferIndex, level);
96   }
97 #endif // DEBUG_ENABLED
98 }
99
100 void PrintNodeTree( const Node& node, BufferIndex bufferIndex, std::string indentation )
101 {
102 #if defined(DEBUG_ENABLED)
103
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)
119             << std::endl;
120
121   for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
122   {
123     std::cout << indentation << "|" << std::endl
124               << indentation << "---->";
125
126     std::string nextIndent = indentation;
127     if ( (iter + 1) != node.GetChildren().End() )
128     {
129       nextIndent += "|    ";
130     }
131     else
132     {
133       nextIndent += "     ";
134     }
135
136     PrintNodeTree(**iter, bufferIndex, nextIndent);
137   }
138
139 #endif // DEBUG_ENABLED
140 }
141
142 } // SceneGraph
143
144 } // Internal
145
146 } // Dali