void toggleScribe osg Group parent osg Node node planetInfo inf if par

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
void toggleScribe(osg::Group* parent, osg::Node* node, planetInfo inf ) {
if (!parent || !node) return;
std::cout<<" node is "<< node->getName() <<std::endl;
std::cout<<" parent "<<parent->className()<<std::endl;
wm->removeChild(_info);
osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
if (!parentAsScribe)
{
// pick
osgFX::Scribe* scribe = new osgFX::Scribe();
scribe->addChild(node);
parent->replaceChild(node,scribe);
_info = new Notebook("n1");
_info->attachMoveCallback();
_info->setOrigin(50.0f, 100.0f);
_info->getLabel()->getText()->setText(inf.name, osgText::String::ENCODING_UTF8);
_info->getLabel()->setWidth(500.0f);
wm->addChild(_info);
}
else
{
// unpick
osg::Node::ParentList parentList = parentAsScribe->getParents();
for(osg::Node::ParentList::iterator itr=parentList.begin();
itr!=parentList.end();
++itr)
{
(*itr)->replaceChild(parentAsScribe,node);
}
}
}