当前位置: 首页>>代码示例>>C++>>正文


C++ SoNode类代码示例

本文整理汇总了C++中SoNode的典型用法代码示例。如果您正苦于以下问题:C++ SoNode类的具体用法?C++ SoNode怎么用?C++ SoNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SoNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

SoMaterial *
SoToVRMLActionP::find_or_create_material(void)
{
  SoMaterial * mat = NULL;
  SoGroup * tail = this->get_current_tail();

  int num = tail->getNumChildren();
  while (--num >= 0 && mat == NULL) {
    SoNode * node = tail->getChild(num);
    if (node->isOfType(SoMaterial::getClassTypeId())) {
      mat = coin_assert_cast<SoMaterial*>(node);
    }
  }
  if (mat == NULL) {
    mat = new SoMaterial;
    tail->addChild(mat);
  }
  return mat;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:19,代码来源:SoToVRMLAction.cpp

示例2: QVariant

void SceneModel::setNode(QModelIndex index, SoNode* node)
{
    this->setData(index, QVariant(QString::fromLatin1(node->getTypeId().getName())));
    if (node->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) {
        SoGroup *group = static_cast<SoGroup*>(node);
        // insert SoGroup icon
        this->insertColumns(0,2,index);
        this->insertRows(0,group->getNumChildren(), index);
        for (int i=0; i<group->getNumChildren();i++) {
            SoNode* child = group->getChild(i);
            setNode(this->index(i, 0, index), child);
            // See ViewProviderDocumentObject::updateData
            QByteArray name(child->getName());
            name = QByteArray::fromPercentEncoding(name);
            this->setData(this->index(i, 1, index), QVariant(QString::fromUtf8(name)));
        }
    }
    // insert icon
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:19,代码来源:SceneInspector.cpp

示例3:

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;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:20,代码来源:SoIntersectionDetectionAction.cpp

示例4:

/*!
  Returns the indexth node in path.
*/
SoNode *
SoLightPath::getNode(const int index) const
{
#if COIN_DEBUG && 1 // debug
  if (index < 0 || index >= this->indices.getLength()) {
    SoDebugError::postInfo("SoLightPath::getNode",
                           "index %d out of bounds", index);
  }
#endif // debug

  SoNode *node = this->headnode;
  for (int i = 1; i < index; i++) {
    int childidx = this->indices[i];
    SoChildList *children = node->getChildren();
    node = NULL;
    if (children == NULL || childidx < 0 || childidx >= children->getLength()) break;
    node = (*children)[childidx];
  }
  return node;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:23,代码来源:SoLightPath.cpp

示例5: sscanf

int
ModList::findToken(const SoPath *path)
{
    SoNode	*node = NULL;
    char	*str = NULL;
    int		id = -1;
    int		i;
    char	c;

    for (i = path->getLength() - 1; i >= 0; --i) {
        node = path->getNode(i);
        str = (char *)(node->getName().getString());
        if (strlen(str) && str[0] == theModListId) {
	    sscanf(str, "%c%d", &c, &id);
	    break;
	}
    }

    return id;
}
开发者ID:DundalkIT,项目名称:pcp,代码行数:20,代码来源:modlist.cpp

示例6: 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 );

}
开发者ID:mblancomuriel,项目名称:tonatiuh,代码行数:23,代码来源:NodeNameDelegate.cpp

示例7: getSceneGraph

/*!
  Set the node which is top of the scene graph we're managing.  The \a
  sceneroot node reference count will be increased by 1, and any
  previously set scene graph top node will have it's reference count
  decreased by 1.

  \sa getSceneGraph()
*/
void
SoSceneManager::setSceneGraph(SoNode * const sceneroot)
{
  // Don't unref() until after we've set up the new root, in case the
  // old root == the new sceneroot. (Just to be that bit more robust.)
  SoNode * oldroot = PRIVATE(this)->scene;
  
  PRIVATE(this)->scene = sceneroot;

  PRIVATE(this)->rendermanager->setSceneGraph(sceneroot);
  PRIVATE(this)->eventmanager->setSceneGraph(sceneroot);

  if (PRIVATE(this)->scene) {
    PRIVATE(this)->scene->ref();
    this->setCamera(PRIVATE(this)->searchForCamera(PRIVATE(this)->scene));
  } else {
    this->setCamera(NULL);
  }
  
  if (oldroot) oldroot->unref();
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:29,代码来源:SoSceneManager.cpp

示例8: assert

void
SoGuiTranslation::doAction(SoAction * action)
{
  // SoDebugError::postInfo("SoGuiTranslation::doAction", "invoked by %s", action->getTypeId().getName().getString());
  int i;
  SoGuiPane * pane = NULL;
  const SoFullPath * path = (const SoFullPath *) action->getCurPath();
  for ( i = path->getLength() - 1; (i >= 0) && (pane == NULL); i-- ) {
    SoNode * node = path->getNode(i);
    assert(node);
    if ( node->isOfType(SoGuiPane::getClassTypeId()) ) pane = (SoGuiPane *) node;
  }
  if ( pane == NULL ) {
    SoDebugError::postInfo("SoGuiTranslation::doAction", "SoGuiTranslation only works below an SoGuiPane node");
    return;
  }
  SoModelMatrixElement::translateBy(action->getState(), this,
                                    this->translation.getValue());

//  pane->moveBy(action->getState(), this->translation.getValue());
}
开发者ID:googleknight,项目名称:Coin3D,代码行数:21,代码来源:Translation.cpp

示例9:

SoNode * InventorViewer::getIntStr(const std::string& sscanfStr, const SoPath * path, std::string& extStr, int& extNum, int& pathIdx)
{
    if (path->getLength()==0) return NULL;
    for (int i = path->getLength() - 1; i >= 0;  --i)
    {
        SoNode * n = path->getNode(i);
        std::string name = n->getName().getString();
        
        //ROS_INFO("Path[%i]: %s, type %s",i,name.c_str(),n->getTypeId().getName().getString());

        char ln[1000];
        int num;
        if (sscanf(name.c_str(), sscanfStr.c_str(), &num, ln) < 2) continue;
        // ROS_INFO("num: %i rest: %s\n",num,ln);
        extStr = ln; //urdf2inventor::helpers::getFilename(ln); // take only the name after the last '/'
        extNum = num;
        pathIdx = i;
        return n;
    }
    return NULL;
}
开发者ID:JenniferBuehler,项目名称:urdf-tools-pkgs,代码行数:21,代码来源:InventorViewer.cpp

示例10: 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();
        }
    }
}
开发者ID:SparkyCola,项目名称:FreeCAD,代码行数:40,代码来源:SoFCSelectionAction.cpp

示例11: wa

osgDB::ReaderWriter::WriteResult
ReaderWriterIV::writeNode(const osg::Node& node, const std::string& fileName,
                          const osgDB::ReaderWriter::Options* /*options*/) const
{
    // accept extension
    std::string ext = osgDB::getLowerCaseFileExtension(fileName);
    if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
    bool useVRML1 = !isInventorExtension(osgDB::getFileExtension(fileName));

    OSG_NOTICE << "osgDB::ReaderWriterIV::writeNode() Writing file "
                             << fileName.data() << std::endl;

    // Convert OSG graph to Inventor graph
    ConvertToInventor osg2iv;
    osg2iv.setVRML1Conversion(useVRML1);
    (const_cast<osg::Node*>(&node))->accept(osg2iv);
    SoNode *ivRoot = osg2iv.getIvSceneGraph();
    if (ivRoot == NULL)
        return WriteResult::ERROR_IN_WRITING_FILE;
    ivRoot->ref();

    // Change prefix according to VRML spec:
    // Node names must not begin with a digit, and must not contain spaces or
    // control characters, single or double quote characters, backslashes, curly braces,
    // the sharp (#) character, the plus (+) character or the period character.
    if (useVRML1)
      SoBase::setInstancePrefix("_");

    // Write Inventor graph to file
    SoOutput out;
    out.setHeaderString((useVRML1) ? "#VRML V1.0 ascii" : "#Inventor V2.1 ascii");
    if (!out.openFile(fileName.c_str()))
        return WriteResult::ERROR_IN_WRITING_FILE;
    SoWriteAction wa(&out);
    wa.apply(ivRoot);
    ivRoot->unref();

    return WriteResult::FILE_SAVED;
}
开发者ID:LaurensVoerman,项目名称:OpenSceneGraph,代码行数:39,代码来源:ReaderWriterIV.cpp

示例12: node

/*!
  Make a duplicate of this node and return a pointer to the duplicate.

  If this node is a group node, children are also copied and we return
  a pointer to the root of a full copy of the subgraph rooted here.

  If \a copyconnections is \c TRUE, we also copy the connections to
  fields within this node (and ditto for any children and children's
  children etc).


  Note that this function has been made virtual in Coin, which is not
  the case in the original Open Inventor API. We may change this
  method back into being non-virtual again for major Coin versions
  after this, as it was made virtual more or less by mistake. So
  please don't write application code that depends on SoNode::copy()
  being virtual.

  The reason this method should not be virtual is because this is \e
  not the function the application programmer should override in
  extension nodes if she needs some special behavior during a copy
  operation (like copying the value of internal data not exposed as
  fields).

  For that purpose, override the copyContents() method. Your
  overridden copyContents() method should then \e both copy internal
  data aswell as calling the parent superclass' copyContents() method
  for automatically handling of fields and other common data.
*/
SoNode *
SoNode::copy(SbBool copyconnections) const
{
  // FIXME: "de-virtualize" this method for next major Coin release?
  // See method documentation above. 20011220 mortene.

  SoFieldContainer::initCopyDict();
  SoNode * cp = this->addToCopyDict();
  // ref() to make sure the copy is not destructed while copying
  cp->ref();
  // Call findCopy() to have copyContents() run only once.
#if COIN_DEBUG
  SoNode * cp2 = (SoNode *)SoFieldContainer::findCopy(this, copyconnections);
  assert(cp == cp2);
#else // COIN_DEBUG
  (void) SoFieldContainer::findCopy(this, copyconnections);
#endif
  SoFieldContainer::copyDone();
  // unrefNoDelete() so that we return a copy with reference count 0
  cp->unrefNoDelete();
  return cp;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:51,代码来源:SoNode.cpp

示例13: checkCopy

SoNode *
SoUnknownNode::addToCopyDict() const
//
////////////////////////////////////////////////////////////////////////
{
    // If this node is already in the dictionary, nothing else to do
    SoNode *copy = (SoNode *) checkCopy(this);
    if (copy == NULL) {

	// Create and add a new instance to the dictionary
	copy = new SoUnknownNode;
	copy->ref();
	addCopy(this, copy);		// Adds a ref()
	copy->unrefNoDelete();

	// Recurse on children, if any
	for (int i = 0; i < hiddenChildren.getLength(); i++)
	    hiddenChildren[i]->addToCopyDict();
    }

    return copy;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:22,代码来源:SoUnknownNode.cpp

示例14: enableNotify

void
SoUnknownNode::write(SoWriteAction *action)
//
////////////////////////////////////////////////////////////////////////
{
    int i;

    SbBool saveNotify = enableNotify(FALSE);

    // Remember alternateRep, if set:
    SoNode *alternateRep = NULL;

    if (hasChildren) {
	if (getNumChildren() != 0) {
	    alternateRep = getChild(0);
	    alternateRep->ref();
	}

	// Add hiddenChildren to regular child list temporarily:
	removeAllChildren();
	for (i = 0; i < hiddenChildren.getLength(); i++) {
	    addChild(hiddenChildren[i]);
	}
	// Now write:
	SoGroup::write(action);

	removeAllChildren();
    }
    else {
	SoNode::write(action);
    }

    if (alternateRep != NULL) {
	addChild(alternateRep);
	alternateRep->unref();
    }

    enableNotify(saveNotify);
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:39,代码来源:SoUnknownNode.cpp

示例15: printf

void
SoDebug::writeField(SoField *field)
//
////////////////////////////////////////////////////////////////////////
{
    SoFieldContainer *fc = field->getContainer();

    SbName fieldName;
    fc->getFieldName(field, fieldName);
    printf("Field name is: %s\n", fieldName.getString());
    if (fc->isOfType(SoNode::getClassTypeId())) {
	printf("Field is part of node:\n");

	SoNode *node = (SoNode *)fc;
	node->ref();

	SoWriteAction	wa;
	wa.apply(node);

	node->unrefNoDelete();
    }
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:22,代码来源:SoDebug.cpp


注:本文中的SoNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。