fixed: stay with old cmake qt link setup (policy CMP0020)
[opensg.git] / Source / System / GraphOp / OSGConvertInlineGraphOp.cpp
blob81a27583a3aa1ef6f37724e73b9f5b5f424adbea
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2008 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #include "OSGConvertInlineGraphOp.h"
40 #include "OSGGraphOpFactory.h"
41 #include "OSGAction.h"
42 #include "OSGInline.h"
43 #include "OSGGroup.h"
44 #include "OSGVisitSubTree.h"
46 #include <set>
48 #include <boost/bind.hpp>
50 /*! \class OSG::ConvertInlineGraphOp
51 \ingroup GrpSystemNodeCoresDrawablesGeometry
53 replaces inline cores by group cores and move the inline root
54 node to parent node.
57 OSG_BEGIN_NAMESPACE
59 namespace
61 static bool registerOp(void)
63 GraphOpRefPtr newOp = ConvertInlineGraphOp::create();
65 GraphOpFactory::the()->registerOp(newOp);
66 return true;
69 static OSG::StaticInitFuncWrapper registerOpWrapper(registerOp);
70 } // namespace
72 const char *ConvertInlineGraphOp::getClassname(void)
74 return "ConvertInlineGraphOp";
77 ConvertInlineGraphOp::ConvertInlineGraphOp(const char* name) :
78 Inherited (name ),
79 _bTreeCloneShared(false)
81 // nothing to do
84 ConvertInlineGraphOpTransitPtr ConvertInlineGraphOp::create(void)
86 return ConvertInlineGraphOpTransitPtr(new ConvertInlineGraphOp);
89 GraphOpTransitPtr ConvertInlineGraphOp::clone(void)
91 return GraphOpTransitPtr(new ConvertInlineGraphOp);
94 void ConvertInlineGraphOp::setParams(const std::string params)
96 ParamSet ps(params);
98 ps("treecloneshared", _bTreeCloneShared);
100 std::string out = ps.getUnusedParams();
101 if(out.length())
103 FWARNING(("ConvertInlineGraphOp doesn't have parameters '%s'.\n",
104 out.c_str()));
108 std::string ConvertInlineGraphOp::usage(void)
110 return
111 "ConvertInline: replaces inline core by group/visit sub tree core.\n"
112 "Params: name (type, default)\n"
113 " treeCloneShared (bool, false): clone tree if inline core is shared,"
114 " default : use VisitSubTree\n";
119 ConvertInlineGraphOp::~ConvertInlineGraphOp(void)
121 // nothing to do
125 Action::ResultE ConvertInlineGraphOp::traverseEnter(Node * const node)
127 if(isInExcludeList(node))
128 return Action::Skip;
130 Inline *pInline = dynamic_cast<Inline *>(node->getCore());
132 if(pInline == NULL)
133 return Action::Continue;
135 if(pInline->getMFParents()->size() > 1)
137 if(_bTreeCloneShared == false)
139 VisitSubTreeUnrecPtr pVS = VisitSubTree::create();
141 pVS->setSubTreeRoot(pInline->getRoot());
143 node->setCore(pVS);
145 else
147 NodeUnrecPtr pClone = cloneTree(pInline->getRoot());
149 node->addChild(pClone);
151 node->setCore(Group::create());
153 // fprintf(stderr, "multi parent inline not handled\n");
156 return Action::Continue;
158 else
160 pInline->moveRootTo(node);
162 node->setCore(Group::create());
165 return Action::Continue;
168 Action::ResultE ConvertInlineGraphOp::traverseLeave(
169 Node * const node,
170 Action::ResultE res )
172 return Action::Continue;
175 OSG_END_NAMESPACE