SoNodeList Renderer::getChildByName(SoSeparator * ivRoot, SbName & childName,
                                            SoType targetType, int maxResultsExpected)
{
    assert(ivRoot);
    SoNodeList resultList;

    SoSearchAction sa;
    sa.setSearchingAll(true);

    sa.setType(targetType, true);
    sa.setInterest( SoSearchAction::ALL);
    sa.setName(childName);
    sa.setFind(SoSearchAction::NAME);
    sa.apply(ivRoot);

    SoPathList &pathList = sa.getPaths();
    int numPaths = pathList.getLength();
    if (numPaths > maxResultsExpected)
    {
        //DBGA(this->className() << "::getChildByName::Found too many children of node: "
        //     << ivRoot->getName().getString()  << " with name: "
        //     <<childName.getString() << " " );
        //DBGA(this->className() << "::getChildByName:: Expected:" << maxResultsExpected
        //     << " Found:" << numPaths);
        //resultList.append(static_cast<SoNode *>(NULL));
        return resultList;
    }

    for(int i = 0; i < numPaths; ++i)
    {
        resultList.append(pathList[i]->getTail());
    }
    return resultList;
}
Exemple #2
0
/*!
  Finds all nodes with \a name and appends them to the \a l nodelist.
  Returns the number of nodes with the specified name.

  \sa SoBase::setName()
*/
int
SoNode::getByName(const SbName & name, SoNodeList & l)
{
  SoBaseList bl;
  int nr = SoBase::getNamedBases(name, bl, SoNode::getClassTypeId());
  for (int i=0; i < nr; i++) l.append((SoNode *)bl[i]);
  return nr;
}
void 
SoXipImageOverlayManager::saveOverlays()
{
	if( mImageData )
	{
		SoNodeList overlays;
		for( int i = 0; i < mShapeSwitch->getNumChildren(); ++ i )
		{
			SoXipShapeList* shapeList = (SoXipShapeList *) mShapeSwitch->getChild(i);
			if( !shapeList )
			{
				SoDebugError::post( __FILE__, "Warning. Should not have NULL pointer in list of overlays" );
				continue ;
			}

			if( shapeList->getNumChildren() )
				overlays.append( shapeList );
		}

		SbString overlayStr = XipOverlayUtils::saveOverlaysToString( overlays );
		mImageData->setProperty( "overlays", overlayStr );
	}
}