本文整理汇总了C++中SoSearchAction::getPath方法的典型用法代码示例。如果您正苦于以下问题:C++ SoSearchAction::getPath方法的具体用法?C++ SoSearchAction::getPath怎么用?C++ SoSearchAction::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoSearchAction
的用法示例。
在下文中一共展示了SoSearchAction::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
}
};
示例3: 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);
}
示例4: 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 );
}
}
示例5: 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;
}
示例6: return
SoCamera *
QuarterWidgetP::searchForCamera(SoNode * root)
{
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setType(SoCamera::getClassTypeId());
sa.apply(root);
if (sa.getPath()) {
SoNode * node = sa.getPath()->getTail();
if (node && node->isOfType(SoCamera::getClassTypeId())) {
return (SoCamera *) node;
}
}
return NULL;
}
示例7: 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;
}
示例8: ContainsIvNode
bool Item::ContainsIvNode(SoNode *pNode)
{
SoSearchAction search;
search.setNode(pNode);
search.apply(_ivGeom);
if (search.getPath())
return true;
return false;
}
示例9: 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
}
示例10: 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;
}
示例11: _GetMatrix
void IvDragger::_GetMatrix(SbMatrix &matrix, SoNode *root, SoNode *node)
{
SoGetMatrixAction getXform(_viewer.lock()->GetViewer()->getViewportRegion());
// get a path from the root to the node
SoSearchAction mySearchAction;
mySearchAction.setNode(node);
mySearchAction.setInterest(SoSearchAction::FIRST);
mySearchAction.apply(root);
// get the transformation matrix
getXform.apply(mySearchAction.getPath());
matrix = getXform.getMatrix();
}
示例12: return
SoCamera *
SoSceneTextureCubeMapP::findCamera(void)
{
SoSearchAction sa;
sa.setType(SoCamera::getClassTypeId());
sa.setInterest(SoSearchAction::FIRST);
sa.apply(PUBLIC(this)->scene.getValue());
SoPath * path = sa.getPath();
if (path == NULL)
return NULL;
else
return (SoCamera *)path->getTail();
}
示例13: localToParentMatrix
SbMatrix ManipWidget::localToParentMatrix(SoNode *local)
{
SoNode *localRoot = local ? local : this->root;
SoSearchAction sa;
sa.setNode(localRoot);
sa.setInterest(SoSearchAction::FIRST);
sa.apply(inst->getPostCumulativeRoot());
SoPath *p = sa.getPath();
if (p) {
SoGetMatrixAction gma(viewer->getViewportRegion());
gma.apply(p);
return gma.getMatrix();
} else {
throw "ManipWidget::localToParentMatrix -- no path found?";
}
}
示例14: getMatrixAction
void
Shape::getTransform(::rl::math::Transform& transform)
{
SoSearchAction searchAction;
searchAction.setNode(this->shape);
searchAction.apply(this->root);
SbViewportRegion viewportRegion;
SoGetMatrixAction getMatrixAction(viewportRegion);
getMatrixAction.apply(searchAction.getPath());
SbMatrix matrix = getMatrixAction.getMatrix();
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
transform(i, j) = matrix[j][i];
}
}
}
示例15: setRandomColor
void AlignmentGroup::setRandomColor()
{
std::vector<Gui::ViewProviderDocumentObject*>::iterator it;
for (it = this->_views.begin(); it != this->_views.end(); ++it) {
float r = /*(float)rand()/(float)RAND_MAX*/0.0f;
float g = (float)rand()/(float)RAND_MAX;
float b = (float)rand()/(float)RAND_MAX;
if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) {
SoSearchAction searchAction;
searchAction.setType(SoMaterial::getClassTypeId());
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.apply((*it)->getRoot());
SoPath* selectionPath = searchAction.getPath();
if (selectionPath) {
SoMaterial* material = static_cast<SoMaterial*>(selectionPath->getTail());
material->diffuseColor.setValue(r, g, b);
}
}
}
}