[3.0] Clipping API feature in Actor
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager-debug.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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
18 // CLASS HEADER
19 #include <dali/internal/update/manager/update-manager-debug.h>
20
21 // EXTERNAL INCLUDES
22 #include <sstream>
23 #include <iomanip>
24 #include <ios>
25
26 // INTERNAL INCLUDES
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>
32
33 #ifdef DALI_PRINT_UPDATE_INFO
34
35 namespace Dali
36 {
37
38 namespace Internal
39 {
40
41 namespace SceneGraph
42 {
43
44 #if defined(DEBUG_ENABLED)
45 static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
46 #endif
47
48 /**
49  * Debug helper function.
50  */
51 void PrintNodes( const Node& node, BufferIndex updateBufferIndex, int level )
52 {
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);
57   Vector3 axis;
58   Radian angle;
59   rotation.ToAxisAngle(axis, angle);
60
61   std::string nodeName= DALI_LOG_GET_OBJECT_STRING((&node));
62
63   {
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 << ")"
75         << std::endl;
76
77     DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", oss.str().c_str());
78   }
79
80   {
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(' ') << "";
87
88     std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level*2);
89     DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", trafoMatrix.c_str());
90   }
91
92   ++level;
93
94   for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter )
95   {
96     PrintNodes(**iter, updateBufferIndex, level);
97   }
98 }
99
100 void PrintNodeTree( const Node& node, BufferIndex bufferIndex, std::string indentation )
101 {
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)
117             << std::endl;
118
119   for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
120   {
121     std::cout << indentation << "|" << std::endl
122               << indentation << "---->";
123
124     std::string nextIndent = indentation;
125     if ( (iter + 1) != node.GetChildren().End() )
126     {
127       nextIndent += "|    ";
128     }
129     else
130     {
131       nextIndent += "     ";
132     }
133
134     PrintNodeTree(**iter, bufferIndex, nextIndent);
135   }
136 }
137
138 } // SceneGraph
139
140 } // Internal
141
142 } // Dali
143
144 #endif