本文整理汇总了C++中SoSearchAction::apply方法的典型用法代码示例。如果您正苦于以下问题:C++ SoSearchAction::apply方法的具体用法?C++ SoSearchAction::apply怎么用?C++ SoSearchAction::apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoSearchAction
的用法示例。
在下文中一共展示了SoSearchAction::apply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doAction
void SoFCIndexedFaceSet::doAction(SoAction * action)
{
if (action->getTypeId() == Gui::SoGLSelectAction::getClassTypeId()) {
SoNode* node = action->getNodeAppliedTo();
if (!node) return; // on no node applied
// The node we have is the parent of this node and the coordinate node
// thus we search there for it.
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setSearchingAll(false);
sa.setType(SoCoordinate3::getClassTypeId(), 1);
sa.apply(node);
SoPath * path = sa.getPath();
if (!path) return;
// make sure we got the node we wanted
SoNode* coords = path->getNodeFromTail(0);
if (!(coords && coords->getTypeId().isDerivedFrom(SoCoordinate3::getClassTypeId())))
return;
startSelection(action);
renderSelectionGeometry(static_cast<SoCoordinate3*>(coords)->point.getValues(0));
stopSelection(action);
}
else if (action->getTypeId() == Gui::SoVisibleFaceAction::getClassTypeId()) {
SoNode* node = action->getNodeAppliedTo();
if (!node) return; // on no node applied
// The node we have is the parent of this node and the coordinate node
// thus we search there for it.
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setSearchingAll(false);
sa.setType(SoCoordinate3::getClassTypeId(), 1);
sa.apply(node);
SoPath * path = sa.getPath();
if (!path) return;
// make sure we got the node we wanted
SoNode* coords = path->getNodeFromTail(0);
if (!(coords && coords->getTypeId().isDerivedFrom(SoCoordinate3::getClassTypeId())))
return;
startVisibility(action);
renderVisibleFaces(static_cast<SoCoordinate3*>(coords)->point.getValues(0));
stopVisibility(action);
}
inherited::doAction(action);
}
示例2: findFrontRootOfType
SoNode* ViewProviderDocumentObject::findFrontRootOfType(const SoType& type) const
{
// first get the document this object is part of and get its GUI counterpart
App::Document* pAppDoc = pcObject->getDocument();
Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc);
SoSearchAction searchAction;
searchAction.setType(type);
searchAction.setInterest(SoSearchAction::FIRST);
// search in all view providers for the node type
std::vector<App::DocumentObject*> obj = pAppDoc->getObjects();
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
const ViewProvider* vp = pGuiDoc->getViewProvider(*it);
// Ignore 'this' view provider. It could also happen that vp is 0, e.g. when
// several objects have been added to the App::Document before notifying the
// Gui::Document
if (!vp || vp == this)
continue;
SoSeparator* front = vp->getFrontRoot();
//if (front && front->getTypeId() == type)
// return front;
if (front) {
searchAction.apply(front);
SoPath* path = searchAction.getPath();
if (path)
return path->getTail();
}
}
return 0;
}
示例3: LightManip
void LightManip(SoSeparator * root)
{
SoInput in;
in.setBuffer((void *)scenegraph, std::strlen(scenegraph));
SoSeparator * _root = SoDB::readAll( &in );
if ( _root == NULL ) return; // Shouldn't happen.
root->addChild(_root);
root->ref();
const char * pointlightnames[3] = { "RedLight", "GreenLight", "BlueLight" };
SoSearchAction sa;
for (int i = 0; i < 3; i++) {
sa.setName( pointlightnames[i] );
sa.setInterest( SoSearchAction::FIRST );
sa.setSearchingAll( false );
sa.apply( root );
SoPath * path = sa.getPath();
if ( path == NULL) return; // Shouldn't happen.
SoPointLightManip * manip = new SoPointLightManip;
manip->replaceNode( path );
}
}
示例4: isVisibleFace
bool isVisibleFace(int faceIndex, const SbVec2f& pos, Gui::View3DInventorViewer* viewer)
{
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getSoRenderManager()->getCamera());
root->addChild(vp->getRoot());
SoSearchAction searchAction;
searchAction.setType(PartGui::SoBrepFaceSet::getClassTypeId());
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.apply(root);
SoPath* selectionPath = searchAction.getPath();
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
rp.setNormalizedPoint(pos);
rp.apply(selectionPath);
root->unref();
SoPickedPoint* pick = rp.getPickedPoint();
if (pick) {
const SoDetail* detail = pick->getDetail();
if (detail && detail->isOfType(SoFaceDetail::getClassTypeId())) {
int index = static_cast<const SoFaceDetail*>(detail)->getPartIndex();
if (faceIndex != index)
return false;
SbVec3f dir = viewer->getViewDirection();
const SbVec3f& nor = pick->getNormal();
if (dir.dot(nor) > 0)
return false; // bottom side points to user
return true;
}
}
return false;
}
示例5: getLocalResources
void ViewProviderVRMLObject::getLocalResources(SoNode* node, std::list<std::string>& resources)
{
// search for SoVRMLInline files
SoSearchAction sa;
sa.setType(SoVRMLInline::getClassTypeId());
sa.setInterest(SoSearchAction::ALL);
sa.setSearchingAll(true);
sa.apply(node);
const SoPathList & pathlist = sa.getPaths();
for (int i = 0; i < pathlist.getLength(); i++ ) {
SoPath * path = pathlist[i];
SoVRMLInline * vrml = static_cast<SoVRMLInline*>(path->getTail());
const SbString& url = vrml->getFullURLName();
if (url.getLength() > 0) {
// add the resource file if not yet listed
if (std::find(resources.begin(), resources.end(), url.getString()) == resources.end()) {
resources.push_back(url.getString());
}
// if the resource file could be loaded check if it references further resources
if (vrml->getChildData()) {
getLocalResources(vrml->getChildData(), resources);
}
}
}
// search for SoVRMLImageTexture, ... files
getResourceFile<SoVRMLImageTexture >(node, resources);
getResourceFile<SoVRMLMovieTexture >(node, resources);
getResourceFile<SoVRMLScript >(node, resources);
getResourceFile<SoVRMLBackground >(node, resources);
getResourceFile<SoVRMLAudioClip >(node, resources);
getResourceFile<SoVRMLAnchor >(node, resources);
}
示例6:
void
SoXipImageOverlayManager::updateSliceMap()
{
// Removes all the previous entries
mSliceMap.clear();
SoSearchAction sa;
sa.setInterest( SoSearchAction::ALL );
sa.setType( SoXipShapeList::getClassTypeId() );
sa.setSearchingAll( TRUE );
sa.apply( mShapeSwitch );
SoPathList paths = sa.getPaths();
for( int i = 0; i < paths.getLength(); ++ i )
{
SbString label = ((SoXipShapeList *) paths[i]->getTail())->label.getValue().getString();
int sliceIndex;
if( sscanf( label.getString(), "%d", &sliceIndex ) != 1 )
{
SoDebugError::post( __FILE__, "Invalid label found '%s'", label.getString() );
continue ;
}
mSliceMap[ sliceIndex ] = (SoXipShapeList *) paths[i]->getTail();
}
}
示例7: ASSERT
void
IfWeeder::weedMaterial(SoNode *root, IfWeederMaterialEntry *entry)
{
// If the material affects no shapes at all, get rid of it. This
// can happen when vertex property nodes are used.
if (entry->shapes.getLength() == 0) {
SoSearchAction sa;
sa.setNode(entry->material);
sa.setInterest(SoSearchAction::ALL);
sa.apply(root);
for (int i = 0; i < sa.getPaths().getLength(); i++) {
SoPath *path = sa.getPaths()[i];
SoSeparator *parent = (SoSeparator *) path->getNodeFromTail(1);
int index = path->getIndexFromTail(0);
ASSERT(parent->isOfType(SoSeparator::getClassTypeId()));
ASSERT(parent->getChild(index) == entry->material);
parent->removeChild(index);
}
}
// Remove all material values from the material node that are
// not used by any dependent shapes. Adjust the indices in the
// dependent shapes accordingly.
removeDuplicateMaterials(entry);
// Now remove all material values that are not used by any
// dependent shapes. Again, adjust the indices in the dependent
// shapes.
removeUnusedMaterials(entry);
}
示例8: getPointOnRay
SoPickedPoint* ViewProvider::getPointOnRay(const SbVec2s& pos, const View3DInventorViewer* viewer) const
{
//first get the path to this node and calculate the current transformation
SoSearchAction sa;
sa.setNode(pcRoot);
sa.setSearchingAll(true);
sa.apply(viewer->getSoRenderManager()->getSceneGraph());
if (!sa.getPath())
return nullptr;
SoGetMatrixAction gm(viewer->getSoRenderManager()->getViewportRegion());
gm.apply(sa.getPath());
SoTransform* trans = new SoTransform;
trans->setMatrix(gm.getMatrix());
trans->ref();
// build a temporary scenegraph only keeping this viewproviders nodes and the accumulated
// transformation
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getSoRenderManager()->getCamera());
root->addChild(trans);
root->addChild(pcRoot);
//get the picked point
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
rp.setPoint(pos);
rp.setRadius(viewer->getPickRadius());
rp.apply(root);
root->unref();
trans->unref();
SoPickedPoint* pick = rp.getPickedPoint();
return (pick ? new SoPickedPoint(*pick) : 0);
}
示例9: getChildByName
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;
}
示例10: createMaterialForPath
void
IfReplacer::replaceMaterials(SoNode *sceneRoot, const SoType &typeToReplace)
{
// Find all nodes of the given type
SoSearchAction sa;
sa.setType(typeToReplace);
sa.setInterest(SoSearchAction::ALL);
sa.apply(sceneRoot);
// Replace the tail of each path with a material. To do this, we
// need to apply an SoCallbackAction to the path to gather the
// material components.
for (int i = 0; i < sa.getPaths().getLength(); i++) {
// Cast the path to a full path, just in case
SoFullPath *path = (SoFullPath *) sa.getPaths()[i];
ASSERT(path->getTail()->isOfType(typeToReplace));
// The path better have at least one group above the material
if (path->getLength() < 2 ||
! path->getNodeFromTail(1)->isOfType(SoGroup::getClassTypeId()))
continue;
// Create a material node that represents the material in
// effect at the tail of the path
SoMaterial *newMaterial = createMaterialForPath(path);
newMaterial->ref();
// Replace the tail node with that material
SoGroup *parent = (SoGroup *) path->getNodeFromTail(1);
parent->replaceChild(path->getTail(), newMaterial);
newMaterial->unref();
}
}
示例11:
IvDragger::IvDragger(QtCoinViewerPtr viewer, ItemPtr pItem, float draggerScale)
{
_selectedItem = pItem;
_viewer = viewer;
_scale = draggerScale;
_penv = viewer->GetEnv();
//_ptext = NULL;
// set some default behavioral options
_checkCollision = false;
_prevtransparency = pItem->GetIvTransparency()->value;
pItem->GetIvTransparency()->value = SoGLRenderAction::SCREEN_DOOR;
if( !!pItem &&(pItem->GetIvRoot() != NULL)) {
_GetBounds(pItem->GetIvRoot(), _ab);
// make the item transparent
SoSearchAction search;
search.setType(SoMaterial::getClassTypeId());
search.setInterest(SoSearchAction::ALL);
search.apply(pItem->GetIvRoot());
for(int i = 0; i < search.getPaths().getLength(); ++i) {
SoPath* path = search.getPaths()[i];
SoMaterial* pmtrl = (SoMaterial*)path->getTail();
vtransparency.push_back(pmtrl->transparency[0]);
pmtrl->transparency = 0.25f;
}
_vlinkaxes.resize(pItem->GetNumIvLinks());
for(size_t i = 0; i < _vlinkaxes.size(); ++i) {
_vlinkaxes[i] = _CreateAxes(i == 0 ? 1.0f : 0.25f,0.5f);
pItem->GetIvLink(i)->addChild(_vlinkaxes[i]);
}
}
}
示例12: ContainsIvNode
bool Item::ContainsIvNode(SoNode *pNode)
{
SoSearchAction search;
search.setNode(pNode);
search.apply(_ivGeom);
if (search.getPath())
return true;
return false;
}
示例13: ReadScene
OSUInventorScene::OSUInventorScene(char *filename) {
SoSeparator *root = ReadScene(filename);
int numNodes = 0;
SoCallbackAction ca;
SoSearchAction SA;
SA.setType(SoLight::getClassTypeId(), TRUE);
SA.setInterest(SoSearchAction::ALL);
SA.apply(root);
SoPathList &paths = SA.getPaths();
#ifdef DEBUG
cerr << "There are " << paths.getLength() << " lights " << endl;
#endif
int i;
for (i = 0; i < paths.getLength(); i++) {
Lights.append(paths[i]->getTail()->copy());
}
SA.setType(SoCamera::getClassTypeId(), TRUE);
SA.setInterest(SoSearchAction::FIRST);
SA.apply(root);
if (SA.getPath()) {
Camera = (SoCamera *)SA.getPath()->getTail()->copy();
#ifdef DEBUG
cerr << "Found a camera!\n";
#endif
} else
Camera = NULL;
ca.addPreCallback(SoNode::getClassTypeId(), processNodesCB, (void *)
&Objects);
ca.apply(root);
// Now lets find the lights and camera!
//
#ifdef DEBUG
cerr << "There are " << Objects.getLength() << " shape objects left!\n";
#endif
}
示例14: getSoRenderManager
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setCameraType(SoType type)
{
if(!getSoRenderManager()->getCamera()->isOfType(SoPerspectiveCamera::getClassTypeId()) &&
!getSoRenderManager()->getCamera()->isOfType(SoOrthographicCamera::getClassTypeId())) {
Base::Console().Warning("Quarter::setCameraType",
"Only SoPerspectiveCamera and SoOrthographicCamera is supported.");
return;
}
SoType perspectivetype = SoPerspectiveCamera::getClassTypeId();
SbBool oldisperspective = getSoRenderManager()->getCamera()->getTypeId().isDerivedFrom(perspectivetype);
SbBool newisperspective = type.isDerivedFrom(perspectivetype);
if((oldisperspective && newisperspective) ||
(!oldisperspective && !newisperspective)) // Same old, same old..
return;
SoCamera* currentcam = getSoRenderManager()->getCamera();
SoCamera* newcamera = (SoCamera*)type.createInstance();
// Transfer and convert values from one camera type to the other.
if(newisperspective) {
convertOrtho2Perspective((SoOrthographicCamera*)currentcam,
(SoPerspectiveCamera*)newcamera);
}
else {
convertPerspective2Ortho((SoPerspectiveCamera*)currentcam,
(SoOrthographicCamera*)newcamera);
}
getSoRenderManager()->setCamera(newcamera);
getSoEventManager()->setCamera(newcamera);
//if the superscene has a camera we need to replace it too
SoSeparator* superscene = (SoSeparator*) getSoRenderManager()->getSceneGraph();
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setType(SoCamera::getClassTypeId());
sa.apply(superscene);
if(sa.getPath()) {
SoNode* node = sa.getPath()->getTail();
SoGroup* parent = (SoGroup*) sa.getPath()->getNodeFromTail(1);
if(node && node->isOfType(SoCamera::getClassTypeId())) {
parent->replaceChild(node, newcamera);
}
}
};
示例15: GetSoPath
SoPath* TSceneKit::GetSoPath(SoNode * theNode )
{
TSeparatorKit* sunNode = static_cast< TSeparatorKit* > (getPart( "childList[0]", false ) );
if( !sunNode ) return NULL;
TSeparatorKit* rootNode = static_cast< TSeparatorKit* > ( sunNode->getPart( "childList[0]", false ) );
if( !rootNode ) return NULL;
SoSearchAction* coinSearch = new SoSearchAction();
coinSearch->setNode( theNode );
coinSearch->setInterest( SoSearchAction::FIRST );
coinSearch->apply( rootNode );
SoPath* nodePath = coinSearch->getPath( );
return nodePath;
}