1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2008 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSCENEGRAPHUTILS_H_
40 #define _OSGSCENEGRAPHUTILS_H_
42 #include "OSGConfig.h"
43 #include "OSGFieldContainer.h"
44 #include "OSGAction.h"
49 #include <boost/bind.hpp>
53 //---------------------------------------------------------------------------
55 //---------------------------------------------------------------------------
57 /*! \ingroup GrpSystemFieldContainerUtils
58 \ingroup GrpLibOSGSystem
62 class OSG_SYSTEM_DLLMAPPING SceneGraphPrinter
64 /*========================== PUBLIC =================================*/
68 /*---------------------------------------------------------------------*/
72 typedef SceneGraphPrinter Self
;
74 typedef boost::function
<void (SceneGraphPrinter
*,
75 NodeCore
* )> CorePrintFunction
;
78 /*---------------------------------------------------------------------*/
79 /*! \name Constructors/Destructor */
82 SceneGraphPrinter(Node
*root
);
85 /*---------------------------------------------------------------------*/
89 void printDownTree(std::ostream
&os
);
90 void printUpTree (std::ostream
&os
);
93 /*---------------------------------------------------------------------*/
94 /*! \name Core Print Function */
97 void addPrintFunc(const FieldContainerType
&fcTpye
,
98 const CorePrintFunction
&printFunc
);
99 void subPrintFunc(const FieldContainerType
&fcTpye
);
101 void incIndent (void);
102 void decIndent (void);
103 std::ostream
&indentStream(void);
104 std::ostream
&getStream (void);
105 Node
* getCurrNode (void);
108 /*========================= PROTECTED ===============================*/
112 typedef std::map
<UInt32
, CorePrintFunction
> PrintFuncMap
;
113 typedef PrintFuncMap::iterator PrintFuncMapIt
;
114 typedef PrintFuncMap::const_iterator PrintFuncMapConstIt
;
118 std::ostream
*_pStream
;
120 PrintFuncMap _printFuncMap
;
122 Action::ResultE
traverseEnter(Node
*node
);
123 Action::ResultE
traverseLeave(Node
*node
, Action::ResultE res
);
125 /*=========================== PRIVATE ===============================*/
129 SceneGraphPrinter(const SceneGraphPrinter
&other
);
130 void operator =(const SceneGraphPrinter
&rhs
);
133 /*! \ingroup GrpBaseFieldContainerNodes
136 template<class CoreT
>
137 void collectCoresByType(Node
*pRoot
,
138 std::vector
<CoreT
*> &result
);
142 #include "OSGSceneGraphUtils.inl"
144 #endif // _OSGSCENEGRAPHUTILS_H_