本文整理汇总了C++中SoNode::getTypeId方法的典型用法代码示例。如果您正苦于以下问题:C++ SoNode::getTypeId方法的具体用法?C++ SoNode::getTypeId怎么用?C++ SoNode::getTypeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoNode
的用法示例。
在下文中一共展示了SoNode::getTypeId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filterAcceptsRow
/*!
* Returns true if the \a m_nodetypeList contains the type of the element defined with \a sourceRow and \a sourceParent
*/
bool NodesFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
SceneModel* sceneModel = dynamic_cast< SceneModel* > ( sourceModel() );
QModelIndex index = sceneModel->index(sourceRow, 0, sourceParent);
InstanceNode* nodeInstance = sceneModel->NodeFromIndex( index );
if( !nodeInstance ) return false;
SoNode* node = nodeInstance->GetNode();
if( !node ) return false;
if( node->getTypeId().isDerivedFrom( TSeparatorKit::getClassTypeId() ) ) return ( true );
if( node->getTypeId().isDerivedFrom( TShapeKit::getClassTypeId() ) )
{
if( m_shapeTypeList.count() < 1 ) return ( true );
TShapeKit* shapeKit = static_cast< TShapeKit* >( node );
if(!shapeKit) return ( false );
TShape* shape = static_cast< TShape* >( shapeKit->getPart( "shape", false ) );
if( shape && m_shapeTypeList.contains( shape->getTypeId().getName().getString() ) )
return ( true );
}
return ( false );
}
示例2: 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);
}
示例3: syncCameraCB
static
void syncCameraCB(void * data, SoSensor * s)
{
ManualAlignment* self = reinterpret_cast<ManualAlignment*>(data);
if (!self->myViewer)
return; // already destroyed
SoCamera* cam1 = self->myViewer->getViewer(0)->getSoRenderManager()->getCamera();
SoCamera* cam2 = self->myViewer->getViewer(1)->getSoRenderManager()->getCamera();
if (!cam1 || !cam2)
return; // missing camera
SoNodeSensor* sensor = static_cast<SoNodeSensor*>(s);
SoNode* node = sensor->getAttachedNode();
if (node && node->getTypeId().isDerivedFrom(SoCamera::getClassTypeId())) {
if (node == cam1) {
Private::copyCameraSettings(cam1, self->d->rot_cam1, self->d->pos_cam1,
cam2, self->d->rot_cam2, self->d->pos_cam2);
self->myViewer->getViewer(1)->redraw();
}
else if (node == cam2) {
Private::copyCameraSettings(cam2, self->d->rot_cam2, self->d->pos_cam2,
cam1, self->d->rot_cam1, self->d->pos_cam1);
self->myViewer->getViewer(0)->redraw();
}
}
}
示例4: Exception
/// return the camera definition of the active view
static PyObject *
povViewCamera(PyObject *self, PyObject *args)
{
// no arguments
if (!PyArg_ParseTuple(args, ""))
return NULL;
PY_TRY {
std::string out;
const char* ppReturn=0;
Gui::Application::Instance->sendMsgToActiveView("GetCamera",&ppReturn);
SoNode* rootNode;
SoInput in;
in.setBuffer((void*)ppReturn,std::strlen(ppReturn));
SoDB::read(&in,rootNode);
if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId()))
throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read "
"camera information from ASCII stream....\n");
// root-node returned from SoDB::readAll() has initial zero
// ref-count, so reference it before we start using it to
// avoid premature destruction.
SoCamera * Cam = static_cast<SoCamera*>(rootNode);
Cam->ref();
SbRotation camrot = Cam->orientation.getValue();
SbVec3f upvec(0, 1, 0); // init to default up vector
camrot.multVec(upvec, upvec);
SbVec3f lookat(0, 0, -1); // init to default view direction vector
camrot.multVec(lookat, lookat);
SbVec3f pos = Cam->position.getValue();
float Dist = Cam->focalDistance.getValue();
// making gp out of the Coin stuff
gp_Vec gpPos(pos.getValue()[0],pos.getValue()[1],pos.getValue()[2]);
gp_Vec gpDir(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
lookat *= Dist;
lookat += pos;
gp_Vec gpLookAt(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
gp_Vec gpUp(upvec.getValue()[0],upvec.getValue()[1],upvec.getValue()[2]);
// getting image format
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Raytracing");
int width = hGrp->GetInt("OutputWidth", 800);
int height = hGrp->GetInt("OutputHeight", 600);
// call the write method of PovTools....
out = PovTools::getCamera(CamDef(gpPos,gpDir,gpLookAt,gpUp),width,height);
return Py::new_reference_to(Py::String(out));
} PY_CATCH;
}
示例5: printPath
void printPath(const SoPath* p)
{
for (int i = p->getLength() - 1; i >= 0; --i)
{
SoNode * n = p->getNode(i);
std::string name = n->getName().getString();
ROS_INFO("Path[%i]: %s, type %s",i,name.c_str(),n->getTypeId().getName().getString());
}
}
示例6:
SoNode *
SoToVRMLActionP::search_for_node(SoNode * root, const SbName & name, const SoType & type)
{
SoNodeList mylist;
if (name == SbName::empty()) return NULL;
mylist.truncate(0);
int num = SoNode::getByName(name, mylist);
int cnt = 0;
SoNode * retnode = NULL;
for (int i = 0; i < num; i++) {
SoNode * node = mylist[i];
if (node->getTypeId() == type) {
retnode = node;
cnt++;
}
}
// if there is only one node with that name, return it
if (retnode && cnt == 1) return retnode;
if (!retnode) return NULL;
this->searchaction.setSearchingAll(TRUE);
this->searchaction.setName(name);
this->searchaction.setType(type);
this->searchaction.setInterest(SoSearchAction::LAST);
this->searchaction.setFind(SoSearchAction::TYPE|SoSearchAction::NAME);
#ifdef HAVE_NODEKITS
SbBool old = SoBaseKit::isSearchingChildren();
SoBaseKit::setSearchingChildren(TRUE);
#endif // HAVE_NODEKITS
this->searchaction.apply(root);
SoNode * tail = NULL;
SoFullPath * path = reclassify_cast<SoFullPath*>(this->searchaction.getPath());
if (path) {
tail = path->getTail();
}
this->searchaction.reset();
#ifdef HAVE_NODEKITS
SoBaseKit::setSearchingChildren(old);
#endif // HAVE_NODEKITS
return tail;
}
示例7:
SoCallbackAction::Response
SoIntersectionDetectionAction::PImpl::dragger(SoCallbackAction * action, const SoNode *)
{
if ( !this->draggersenabled ) // dragger setting overrides setting for manipulators
return SoCallbackAction::PRUNE;
#ifdef HAVE_MANIPULATORS
if ( !this->manipsenabled ) {
const SoPath * path = action->getCurPath();
SoNode * tail = path->getTail();
SoType type = tail->getTypeId();
if ( type.isDerivedFrom(SoTransformManip::getClassTypeId()) ||
type.isDerivedFrom(SoClipPlaneManip::getClassTypeId()) ||
type.isDerivedFrom(SoDirectionalLightManip::getClassTypeId()) ||
type.isDerivedFrom(SoPointLightManip::getClassTypeId()) ||
type.isDerivedFrom(SoSpotLightManip::getClassTypeId()) )
return SoCallbackAction::PRUNE;
}
#endif // HAVE_MANIPULATORS
return SoCallbackAction::CONTINUE;
}
示例8: setEditorData
/**
* Takes the name of the selected node and sets to de editor to display it.
*/
void NodeNameDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
const SceneModel* model = static_cast< const SceneModel* >( index.model() );
QString value = model->data(index, Qt::DisplayRole).toString();
QLineEdit *textEdit = static_cast<QLineEdit *>(editor);
SoNode* coinNode = model->NodeFromIndex( index )->GetNode();
QString nodeName;
if ( coinNode->getName() == SbName() )
nodeName = QString( coinNode->getTypeId().getName().getString() );
else
nodeName = QString( coinNode->getName().getString() );
textEdit->setText( nodeName );
}
示例9: if
void
SoBoxSelectionRenderAction::apply(SoPath * path)
{
SoGLRenderAction::apply(path);
SoNode* node = path->getTail();
if (node && node->getTypeId() == SoFCSelection::getClassTypeId()) {
SoFCSelection * selection = (SoFCSelection *) node;
// This happens when dehighlighting the current shape
if (PRIVATE(this)->highlightPath == path) {
PRIVATE(this)->highlightPath->unref();
PRIVATE(this)->highlightPath = 0;
// FIXME: Doing a redraw to remove the shown bounding box causes
// some problems when moving the mouse from one shape to another
// because this will destroy the box immediately
selection->touch(); // force a redraw when dehighlighting
}
else if (selection->isHighlighted() &&
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
selection->style.getValue() == SoFCSelection::BOX) {
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
if (PRIVATE(this)->selectsearch == NULL) {
PRIVATE(this)->selectsearch = new SoSearchAction;
}
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
PRIVATE(this)->selectsearch->apply(selection);
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
if (shapepath) {
SoPathList list;
list.append(shapepath);
PRIVATE(this)->highlightPath = path;
PRIVATE(this)->highlightPath->ref();
this->drawBoxes(path, &list);
}
PRIVATE(this)->selectsearch->reset();
}
}
}
示例10: strlen
// call this callback either from your application level selection CB
// or use it as selection CB
void
InvPlaneMover::selectionCB(void *me, SoPath *sp)
{
InvPlaneMover *mee = static_cast<InvPlaneMover *>(me);
// get the label next to the geometry = tail
int len = sp->getLength();
char objNme[20];
int showFlg = 0;
if (len > 2)
{
SoNode *grp = sp->getNode(len - 2);
if (grp->getTypeId() == SoGroup::getClassTypeId())
{
int gLen = ((SoGroup *)grp)->getNumChildren();
int i;
for (i = 0; i < gLen; ++i)
{
SoNode *lbl = ((SoGroup *)grp)->getChild(i);
if (lbl->getTypeId() == SoLabel::getClassTypeId())
{
char *fbs = (char *)((SoLabel *)lbl)->label.getValue().getString();
size_t l = strlen(fbs);
// make sure that feedbackInfo_ is correctly allocated
if (mee->feedbackInfo_)
{
delete[] mee -> feedbackInfo_;
}
char *tmpStr = new char[l + 1];
strcpy(tmpStr, fbs);
// extract the object name (for feedback-info attached to CuttingSurface)
if (l > 1)
{
strncpy(objNme, &fbs[1], 14);
if (strncmp(objNme, "CuttingSurface", 14) == 0)
showFlg = 1;
// separate feedback-attribute and ignore-attribute
// separator is <IGNORE>
char *tok = strtok(tmpStr, "<IGNORE>");
if (tok)
{
mee->feedbackInfo_ = new char[1 + strlen(tok)];
strcpy(mee->feedbackInfo_, tok);
tok = strtok(NULL, "<IGNORE>");
if (tok)
{
float dum;
int idum;
int retval;
retval = sscanf(tok, "%f%f%f%f%d", &(mee->planeNormal_[0]), &(mee->planeNormal_[1]), &(mee->planeNormal_[2]), &dum, &idum);
if (retval != 5)
{
std::cerr << "InvPlaneMover::selectionCB: sscanf failed" << std::endl;
return;
}
fprintf(stderr, "planeNormal=(%f %f %f)\n",
mee->planeNormal_[0],
mee->planeNormal_[1],
mee->planeNormal_[2]);
mee->setPosition(mee->distOffset_);
}
}
}
delete[] tmpStr;
}
}
}
}
// the handle is shown if the feedback-attribute contains "CuttingSurface"
// ..and if it is not shown at all
if ((!mee->show_) && showFlg)
{
mee->show();
}
}
示例11: activated
void CmdRaytracingWriteCamera::activated(int iMsg)
{
const char* ppReturn=0;
getGuiApplication()->sendMsgToActiveView("GetCamera",&ppReturn);
if (ppReturn) {
std::string str(ppReturn);
if (str.find("PerspectiveCamera") == std::string::npos) {
int ret = QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdRaytracingWriteView","No perspective camera"),
qApp->translate("CmdRaytracingWriteView","The current view camera is not perspective"
" and thus the result of the povray image later might look different to"
" what you expect.\nDo you want to continue?"),
QMessageBox::Yes|QMessageBox::No);
if (ret != QMessageBox::Yes)
return;
}
}
SoInput in;
in.setBuffer((void*)ppReturn,std::strlen(ppReturn));
SoNode* rootNode;
SoDB::read(&in,rootNode);
if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId()))
throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read "
"camera information from ASCII stream....\n");
// root-node returned from SoDB::readAll() has initial zero
// ref-count, so reference it before we start using it to
// avoid premature destruction.
SoCamera * Cam = static_cast<SoCamera*>(rootNode);
Cam->ref();
SbRotation camrot = Cam->orientation.getValue();
SbVec3f upvec(0, 1, 0); // init to default up vector
camrot.multVec(upvec, upvec);
SbVec3f lookat(0, 0, -1); // init to default view direction vector
camrot.multVec(lookat, lookat);
SbVec3f pos = Cam->position.getValue();
float Dist = Cam->focalDistance.getValue();
QStringList filter;
filter << QObject::tr("Povray(*.pov)");
filter << QObject::tr("All Files (*.*)");
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QObject::tr("Export page"), QString(), filter.join(QLatin1String(";;")));
if (fn.isEmpty())
return;
std::string cFullName = (const char*)fn.toUtf8();
// building up the python string
std::stringstream out;
out << "Raytracing.writeCameraFile(\"" << strToPython(cFullName) << "\","
<< "(" << pos.getValue()[0] <<"," << pos.getValue()[1] <<"," << pos.getValue()[2] <<"),"
<< "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," ;
lookat *= Dist;
lookat += pos;
out << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<"),"
<< "(" << upvec.getValue()[0] <<"," << upvec.getValue()[1] <<"," << upvec.getValue()[2] <<") )" ;
doCommand(Doc,"import Raytracing");
doCommand(Gui,out.str().c_str());
// Bring ref-count of root-node back to zero to cause the
// destruction of the camera.
Cam->unref();
}
示例12: updateData
void ViewProviderRobotObject::updateData(const App::Property* prop)
{
Robot::RobotObject* robObj = static_cast<Robot::RobotObject*>(pcObject);
if (prop == &robObj->RobotVrmlFile) {
// read also from file
const char* filename = robObj->RobotVrmlFile.getValue();
QString fn = QString::fromUtf8(filename);
QFile file(fn);
SoInput in;
pcRobotRoot->removeAllChildren();
if (!fn.isEmpty() && file.open(QFile::ReadOnly)) {
QByteArray buffer = file.readAll();
in.setBuffer((void *)buffer.constData(), buffer.length());
SoSeparator * node = SoDB::readAll(&in);
if (node) pcRobotRoot->addChild(node);
pcRobotRoot->addChild(pcTcpRoot);
}
// search for the conection points +++++++++++++++++++++++++++++++++++++++++++++++++
Axis1Node = Axis2Node = Axis3Node = Axis4Node = Axis5Node = Axis6Node = 0;
SoSearchAction searchAction;
SoPath * path;
// Axis 1
searchAction.setName("FREECAD_AXIS1");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis1Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 2
searchAction.setName("FREECAD_AXIS2");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis2Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 3
searchAction.setName("FREECAD_AXIS3");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis3Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 4
searchAction.setName("FREECAD_AXIS4");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis4Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 5
searchAction.setName("FREECAD_AXIS5");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis5Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 6
searchAction.setName("FREECAD_AXIS6");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis6Node = static_cast<SoVRMLTransform *>(node);
}
//.........这里部分代码省略.........
示例13: del
void
InvAnnoManager::selectionCB(void *me, SoPath *selectedObject)
{
InvAnnoManager *mee = static_cast<InvAnnoManager *>(me);
mee->initCheck();
if (!mee->isActive_)
return;
int isAnnoFlg = 0;
int len = selectedObject->getLength();
int ii;
char *selObjNm;
SoNode *obj = NULL;
int objIndex;
int mode = mee->mode_;
// we find out if the selected obj is a InvAnnotationFlag
// and obtain its index from the name of the (sub)-toplevel
// separator node
for (ii = 0; ii < len; ii++)
{
obj = selectedObject->getNode(ii);
char *tmp = (char *)obj->getName().getString();
selObjNm = new char[1 + strlen(tmp)];
char *chNum = new char[1 + strlen(tmp)];
strcpy(selObjNm, tmp);
if (strncmp(selObjNm, "ANNOTATION", 10) == 0)
{
strcpy(chNum, &selObjNm[11]);
int ret = sscanf(chNum, "%d", &objIndex);
if (ret != 1)
{
fprintf(stderr, "InvAnnoManager::selectionCB: sscanf failed\n");
}
isAnnoFlg = 1;
break;
}
}
// we have got an InvAnnoFlag
// and remove it from the scene graph
if (isAnnoFlg == 1)
{
if (obj->getTypeId() == SoSeparator::getClassTypeId())
{
if (mode == InvAnnoManager::EDIT)
{
vector<InvAnnoFlag *>::iterator it, selPos;
// search flag with instance nr = objIndex;
for (it = mee->flags_.begin(); it != mee->flags_.end(); ++it)
{
if ((*it)->getInstance() == objIndex)
{
selPos = it;
break;
}
}
mee->viewer_->createAnnotationEditor(*selPos);
}
if (mode == InvAnnoManager::REMOVE)
{
// deletion of an InvAnnoFlag leads to a proper removal from the
// scene graph by calling InvActiveNode::~InvActiveNode()
bool del(false);
vector<InvAnnoFlag *>::iterator it, remPos;
// search flag with instance nr = objIndex;
for (it = mee->flags_.begin(); it != mee->flags_.end(); ++it)
{
if ((*it)->getInstance() == objIndex)
{
del = true;
remPos = it;
}
}
// delete flag and remove it from flags_
if (del)
{
delete *remPos;
mee->flags_.erase(remPos);
mee->trueNumFlags_--;
mee->deactivate();
mee->sendParameterData();
}
}
}
}
// we create a new flag if anything else is selected
else
{
if (mode != InvAnnoManager::MAKE)
return;
InvAnnoManager *mee = static_cast<InvAnnoManager *>(me);
//.........这里部分代码省略.........