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


C++ NodePtr类代码示例

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


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

示例1: EQ_TS_THREAD

void FullMasterCM::addSlave( Command& command, NodeMapObjectReplyPacket& reply )
{
    EQ_TS_THREAD( _cmdThread );
    EQASSERT( command->type == PACKETTYPE_CO_NODE );
    EQASSERT( command->command == CMD_NODE_MAP_OBJECT );

    NodePtr node = command.getNode();
    const NodeMapObjectPacket* packet = command.get< NodeMapObjectPacket >();
    const uint128_t requested  = packet->requestedVersion;
    const uint32_t instanceID = packet->instanceID;

    Mutex mutex( _slaves );
    EQASSERT( _version != VERSION_NONE );
    _checkConsistency();

    // add to subscribers
    ++_slavesCount[ node->getNodeID() ];
    _slaves->push_back( node );
    stde::usort( *_slaves );

    if( requested == VERSION_NONE ) // no data to send
    {
        _sendEmptyVersion( node, instanceID, _version );
        reply.version = _version;
        return;
    }

    const uint128_t oldest = _instanceDatas.front()->os.getVersion();
    uint128_t start = (requested == VERSION_OLDEST || requested < oldest ) ?
                          oldest : requested;
    uint128_t end = _version;
    const bool useCache = packet->masterInstanceID == _object->getInstanceID();

#ifndef NDEBUG
    if( requested != VERSION_OLDEST && requested < start )
        EQINFO << "Mapping version " << start
               << " instead of requested version " << requested << std::endl;
#endif

    reply.version = start;
    reply.useCache = packet->useCache && useCache;

    if( reply.useCache )
    {
        if( packet->minCachedVersion <= start && 
            packet->maxCachedVersion >= start )
        {
#ifdef EQ_INSTRUMENT_MULTICAST
            _hit += packet->maxCachedVersion + 1 - start;
#endif
            start = packet->maxCachedVersion + 1;
        }
        else if( packet->maxCachedVersion == end )
        {
            end = EQ_MAX( start, packet->minCachedVersion - 1 );
#ifdef EQ_INSTRUMENT_MULTICAST
            _hit += _version - end;
#endif
        }
        // TODO else cached block in the middle, send head and tail elements
    }

#if 0
    EQLOG( LOG_OBJECTS )
        << *_object << ", instantiate on " << node->getNodeID() << " with v"
        << ((requested == VERSION_OLDEST) ? oldest : requested) << " ("
        << requested << ") sending " << start << ".." << end << " have "
        << _version - _nVersions << ".." << _version << " "
        << _instanceDatas.size() << std::endl;
#endif
    EQASSERT( start >= oldest );

    // send all instance datas from start..end
    InstanceDataDeque::iterator i = _instanceDatas.begin();
    while( i != _instanceDatas.end() && (*i)->os.getVersion() < start )
        ++i;

    for( ; i != _instanceDatas.end() && (*i)->os.getVersion() <= end; ++i )
    {
        InstanceData* data = *i;
        EQASSERT( data );
        data->os.sendMapData( node, instanceID );

#ifdef EQ_INSTRUMENT_MULTICAST
        ++_miss;
#endif
    }

#ifdef EQ_INSTRUMENT_MULTICAST
    if( _miss % 100 == 0 )
        EQINFO << "Cached " << _hit << "/" << _hit + _miss
               << " instance data transmissions" << std::endl;
#endif
}
开发者ID:oliver-e,项目名称:Equalizer,代码行数:94,代码来源:fullMasterCM.cpp

示例2: get_shorten_path

        Path get_shorten_path(GameMap &gmap, const NodePtr &src, const NodePtr &dest)
        {
            OpenSet open_set;
            CloseSet closed_set;
            Path _tmpPath;
            bool found = false;
            NodePtr cur_node;
            NodePtr next_node;
            NodesMap nodes_map;

            // add to OPEN_SET
            open_set.insert(make_pair<unsigned long, Coordinate>(src->get_f(),src->get_coordinate()));
            nodes_map.insert(make_pair<Coordinate,NodePtr>(src->get_coordinate(), src));

            while (!open_set.empty() && !found)
            {
                cur_node = nodes_map[open_set.begin()->second];

                closed_set.insert(cur_node->get_coordinate());
                open_set.erase(find_if(open_set.begin(), open_set.end(),\
                                       boost::lambda::bind(&OpenSet::value_type::second,boost::lambda::_1) == \
                                       cur_node->get_coordinate()));

                if (cur_node->get_coordinate() == dest->get_coordinate())
                {
                    // arrived
                    found = true;
                    // re-path;
                    NodePtr _res_tmp = cur_node;
                    while (_res_tmp != NULL)
                    {
                        _tmpPath.push_front(_res_tmp);
                        _res_tmp = _res_tmp->get_parent();
                    }
                    break;
                    // open_set
                }

                AdjNodes adjnode_set = gmap.get_adjnodes(cur_node->get_coordinate());
                AdjNodes::iterator it = adjnode_set.begin();
                for (; it != adjnode_set.end(); ++it)
                {
                    // can't get through, like wall;
                    // already in closed set;
                    // ignore it;
                    if (!gmap.can_get_through(*it) || \
                        closed_set.count(*it) != 0)
                    {
                        continue;
                    }

                    unsigned long new_g = cur_node->get_g() + gmap.get_steps(*it);
                    bool better = false;
                    OpenSet::iterator fit = find_if(open_set.begin(), open_set.end(), 
                        boost::lambda::bind(&OpenSet::value_type::second,\
                        boost::lambda::_1)== (*it)); 
                    if (fit == open_set.end())
                    {
                        better = true;
                    }
                    else
                    {
                        if (new_g < nodes_map[fit->second]->get_g())
                        {
                            better = true;
                        }
                    }

                    if (better)
                    {
                        NodePtr _tmp(new Node(*it));

                        _tmp->set_g(new_g);
                        _tmp->set_f(gmap.get_distance(*it, dest->get_coordinate()));
                        _tmp->set_parent(cur_node);
                        open_set.insert(make_pair<unsigned long,Coordinate>(_tmp->get_f(),*it));

                        // update 
                        nodes_map[*it] = _tmp;
                    }
                } // for

            } // while

            return _tmpPath;
        }
开发者ID:imousewyfzml,项目名称:mylibrary,代码行数:86,代码来源:myaStar.cpp

示例3: logic_error

void
GuiAppInstance::createNodeGui(const NodePtr &node,
                              const NodePtr& parentMultiInstance,
                              const CreateNodeArgs& args)
{
    NodeCollectionPtr group = node->getGroup();
    NodeGraph* graph;

    if (group) {
        NodeGraphI* graph_i = group->getNodeGraph();
        assert(graph_i);
        graph = dynamic_cast<NodeGraph*>(graph_i);
        assert(graph);
    } else {
        graph = _imp->_gui->getNodeGraph();
    }
    if (!graph) {
        throw std::logic_error("");
    }

    NodesGuiList selectedNodes = graph->getSelectedNodes();
    NodeGuiPtr nodegui = _imp->_gui->createNodeGUI(node, args);
    assert(nodegui);

    if (parentMultiInstance && nodegui) {
        nodegui->hideGui();


        NodeGuiIPtr parentNodeGui_i = parentMultiInstance->getNodeGui();
        assert(parentNodeGui_i);
        nodegui->setParentMultiInstance( boost::dynamic_pointer_cast<NodeGui>(parentNodeGui_i) );
    }

    bool isViewer = node->isEffectViewerInstance() != 0;
    if (isViewer) {
        _imp->_gui->createViewerGui(node);
    }

    // Must be done after the viewer gui has been created
    _imp->_gui->createNodeViewerInterface(nodegui);


    NodeGroupPtr isGroup = node->isEffectNodeGroup();
    if ( isGroup && isGroup->isSubGraphUserVisible() ) {
        _imp->_gui->createGroupGui(node, args);
    }

    ///Don't initialize inputs if it is a multi-instance child since it is not part of  the graph
    if (!parentMultiInstance) {
        nodegui->initializeInputs();
    }
    
    NodeSerializationPtr serialization = args.getProperty<NodeSerializationPtr >(kCreateNodeArgsPropNodeSerialization);
    if ( !serialization && !isViewer ) {
        ///we make sure we can have a clean preview.
        node->computePreviewImage( getTimeLine()->currentFrame() );
        triggerAutoSave();
    }


    ///only move main instances
    if ( node->getParentMultiInstanceName().empty() && !serialization) {
        bool autoConnect = args.getProperty<bool>(kCreateNodeArgsPropAutoConnect);

        if ( selectedNodes.empty() || serialization) {
            autoConnect = false;
        }
        double xPosHint = serialization ? INT_MIN : args.getProperty<double>(kCreateNodeArgsPropNodeInitialPosition, 0);
        double yPosHint = serialization ? INT_MIN : args.getProperty<double>(kCreateNodeArgsPropNodeInitialPosition, 1);
        if ( (xPosHint != INT_MIN) && (yPosHint != INT_MIN) && (!autoConnect) ) {
            QPointF pos = nodegui->mapToParent( nodegui->mapFromScene( QPointF(xPosHint, yPosHint) ) );
            nodegui->refreshPosition( pos.x(), pos.y(), true );
        } else {
            BackdropGuiPtr isBd = toBackdropGui(nodegui);
            if (!isBd) {
                NodeGuiPtr selectedNode;
                if ( !serialization && (selectedNodes.size() == 1) ) {
                    selectedNode = selectedNodes.front();
                    BackdropGuiPtr isBdGui = toBackdropGui(selectedNode);
                    if (isBdGui) {
                        selectedNode.reset();
                    }
                }
                nodegui->getDagGui()->moveNodesForIdealPosition(nodegui, selectedNode, autoConnect);
            }
        }
    }
} // createNodeGui
开发者ID:Kthulhu,项目名称:Natron,代码行数:88,代码来源:GuiAppInstance.cpp

示例4: getMaskBit

    //-------------------------------------------------------------------------
    bool Node::walk(WalkSink &inWalker, const FilterList *inFilterList) const
    {
      // walks the tree in a non-recursive way to protect the stack from overflowing

      ULONG mask = ZS_INTERNAL_XML_FILTER_BIT_MASK_ALL;
      if (inFilterList)
      {
        mask = 0;
        for (FilterList::const_iterator iter = inFilterList->begin(); iter != inFilterList->end(); ++iter)
        {
          mask = mask | getMaskBit(*iter);
        }
      }

      NodePtr startChild = toNode();
      NodePtr child = startChild;
      bool allowChildren = true;
      while (child)
      {
        NodePtr nextSibling = child->getNextSibling();  // just in case the current element was orphaned
        NodePtr nextParent = child->getParent();

        bool doContinue = false;
        while (allowChildren) // using as a scope rather than as a loop
        {
          if (0 != (mask & getMaskBit(child->getNodeType())))
          {
            bool result = false;
            switch (child->getNodeType())
            {
              case NodeType::Document:      result = inWalker.onDocumentEnter(child->toDocument()); break;
              case NodeType::Element:       result = inWalker.onElementEnter(child->toElement()); break;
              case NodeType::Attribute:     result = inWalker.onAttribute(child->toAttribute()); break;
              case NodeType::Text:          result = inWalker.onText(child->toText()); break;
              case NodeType::Comment:       result = inWalker.onComment(child->toComment()); break;
              case NodeType::Declaration:   result = inWalker.onDeclarationEnter(child->toDeclaration()); break;
              case NodeType::Unknown:       result = inWalker.onUnknown(child->toUnknown()); break;
            }
            if (result)
              return true;

            if ((child->getNextSibling() != nextSibling) ||
                (child->getParent() != nextParent)) {
              // the node was orphaned, do not process its children anymore
              break;
            }
          }

          AttributePtr attribute;

          if (child->isElement())
          {
            ElementPtr element = child->toElement();
            attribute = element->getFirstAttribute();
          }
          else if (child->isDeclaration())
          {
            DeclarationPtr declaration = child->toDeclaration();
            attribute = declaration->getFirstAttribute();
          }

          // walk the attributes
          if (attribute)
          {
            if (0 != (mask & getMaskBit(attribute->getNodeType())))
            {
              while (attribute)
              {
                NodePtr next = attribute->getNextSibling(); // need to do this in advanced in case the attribute is orphaned

                if (inWalker.onAttribute(attribute))
                  return true;

                if (!next)
                  break;

                attribute = next->toAttribute();
              }
            }
          }

          if (child->getFirstChild())
          {
            child = child->getFirstChild();
            doContinue = true;
            break;
          }
          break;  // not really intending to loop
        }

        if (doContinue)
          continue;

        if ((child->isDeclaration()) &&
            (0 != (mask & ZS_INTERNAL_XML_FILTER_BIT_DECLARATION)))
        {
          // reached the exit point for the declaration
          if (inWalker.onDeclarationExit(child->toDeclaration()))
            return true;
//.........这里部分代码省略.........
开发者ID:openpeer,项目名称:zsLib,代码行数:101,代码来源:zsLib_XMLNode.cpp

示例5: toNodeGroup

bool
Project::restoreGroupFromSerialization(const SERIALIZATION_NAMESPACE::NodeSerializationList & serializedNodes,
                                       const NodeCollectionPtr& group,
                                       std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > >* createdNodesOut)
{
    bool mustShowErrorsLog = false;

    NodeGroupPtr isGrp = toNodeGroup(group);

    QString groupName;
    if (isGrp) {
        groupName = QString::fromUtf8( isGrp->getNode()->getLabel().c_str() );
    } else {
        groupName = tr("top-level");
    }
    group->getApplication()->updateProjectLoadStatus( tr("Creating nodes in group: %1").arg(groupName) );


    std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > > createdNodes;



    // Loop over all node serialization and create them first
    for (SERIALIZATION_NAMESPACE::NodeSerializationList::const_iterator it = serializedNodes.begin(); it != serializedNodes.end(); ++it) {

        NodePtr node = appPTR->createNodeForProjectLoading(*it, group);
        if (!node) {
            QString text( tr("ERROR: The node %1 version %2.%3"
                             " was found in the script but does not"
                             " exist in the loaded plug-ins.")
                         .arg( QString::fromUtf8( (*it)->_pluginID.c_str() ) )
                         .arg((*it)->_pluginMajorVersion).arg((*it)->_pluginMinorVersion) );
            appPTR->writeToErrorLog_mt_safe(tr("Project"), QDateTime::currentDateTime(), text);
            mustShowErrorsLog = true;
            continue;
        } else {
            if (node->getPluginID() == PLUGINID_NATRON_STUB) {
                // If the node could not be created and we made a stub instead, warn the user
                QString text( tr("WARNING: The node %1 (%2 version %3.%4) "
                                 "was found in the script but the plug-in could not be found. It has been replaced by a pass-through node instead.")
                             .arg( QString::fromUtf8( (*it)->_nodeScriptName.c_str() ) )
                             .arg( QString::fromUtf8( (*it)->_pluginID.c_str() ) )
                             .arg((*it)->_pluginMajorVersion)
                             .arg((*it)->_pluginMinorVersion));
                appPTR->writeToErrorLog_mt_safe(tr("Project"), QDateTime::currentDateTime(), text);
                mustShowErrorsLog = true;
            } else if ( (*it)->_pluginMajorVersion != -1 && (node->getMajorVersion() != (int)(*it)->_pluginMajorVersion) ) {
                // If the node has a IOContainer don't do this check: when loading older projects that had a
                // ReadOIIO node for example in version 2, we would now create a new Read meta-node with version 1 instead
                QString text( tr("WARNING: The node %1 (%2 version %3.%4) "
                                 "was found in the script but was loaded "
                                 "with version %5.%6 instead.")
                             .arg( QString::fromUtf8( (*it)->_nodeScriptName.c_str() ) )
                             .arg( QString::fromUtf8( (*it)->_pluginID.c_str() ) )
                             .arg((*it)->_pluginMajorVersion)
                             .arg((*it)->_pluginMinorVersion)
                             .arg( node->getPlugin()->getPropertyUnsafe<unsigned int>(kNatronPluginPropVersion, 0) )
                             .arg( node->getPlugin()->getPropertyUnsafe<unsigned int>(kNatronPluginPropVersion, 1) ) );
                appPTR->writeToErrorLog_mt_safe(tr("Project"), QDateTime::currentDateTime(), text);
            }
        }

        assert(node);

        createdNodes.push_back(std::make_pair(node, *it));

    } // for all node serialization


    group->getApplication()->updateProjectLoadStatus( tr("Restoring graph links in group: %1").arg(groupName) );


    // Connect the nodes together
    for (std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > >::const_iterator it = createdNodes.begin(); it != createdNodes.end(); ++it) {


        // Loop over the inputs map
        // This is a map <input label, input node name>
        //
        // When loading projects before Natron 2.2, the inputs contain both masks and inputs.
        //

        restoreInputs(it->first, it->second->_inputs, createdNodes, false /*isMasks*/);

        // After Natron 2.2, masks are saved separatly
        restoreInputs(it->first, it->second->_masks, createdNodes, true /*isMasks*/);

    } // for (std::list< NodeSerializationPtr >::const_iterator it = serializedNodes.begin(); it != serializedNodes.end(); ++it) {


    if (createdNodesOut) {
        *createdNodesOut = createdNodes;
    }
    // If we created all sub-groups recursively, then we are in the top-level group. We may now restore all links
    if (!group->getApplication()->isCreatingNode()) {

        // Now that we created all nodes. There may be cross-graph link(s) and they can only be truely restored now.
        restoreLinksRecursive(group, serializedNodes, createdNodesOut);
    }

//.........这里部分代码省略.........
开发者ID:kcotugno,项目名称:Natron,代码行数:101,代码来源:ProjectPrivate.cpp

示例6: main

int main(int argc, char **argv)
{
    osgInit(argc,argv);

    // GLUT init
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    
    int id=glutCreateWindow("OpenSG");
    
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    GLUTWindowPtr gwin=GLUTWindow::create();
    gwin->setId(id);
    gwin->init();

    // create the scene
//    NodePtr scene = makeTorus(.5, 2, 16, 16);
    NodePtr scene = Node::create();
    beginEditCP(scene);
    scene->setCore(Group::create());
    endEditCP(scene);

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);
    
    DisplayFilterForegroundPtr fg = DisplayFilterForeground::create();

    beginEditCP(fg);
    // add filter
    endEditCP(fg);

    // take the viewport
    ViewportPtr vp = gwin->getPort(0);

    beginEditCP(vp);
    vp->editMFForegrounds()->push_back(fg);    
    endEditCP  (vp);

    colorFilterPtr = ColorDisplayFilter::create();
    distortionFilterPtr = DistortionDisplayFilter::create();
    resolutionFilterPtr = ResolutionDisplayFilter::create();

    beginEditCP(colorFilterPtr);
    beginEditCP(resolutionFilterPtr);
    beginEditCP(distortionFilterPtr);
    beginEditCP(fg);
    colorFilterPtr->setMatrix(osg::Matrix(0,0,1,0,
                                          1,0,0,0,
                                          0,1,0,0,
                                          0,0,0,1));
    resolutionFilterPtr->setDownScale(0.25);

    distortionFilterPtr->setColumns(2);
    distortionFilterPtr->setRows(2);
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(0,.5));
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(.5,0));
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(.5,1));
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(1,.5));
    
    fg->editMFFilter()->push_back(colorFilterPtr);
    fg->editMFFilter()->push_back(resolutionFilterPtr);
    fg->editMFFilter()->push_back(distortionFilterPtr);

    endEditCP(distortionFilterPtr);
    endEditCP(colorFilterPtr);
    endEditCP(resolutionFilterPtr);
    endEditCP(fg);

    for(UInt32 a=1 ; a<argc ;a++)
    {
        NodePtr file = SceneFileHandler::the().read(argv[a],0);
        if(file != NullFC)
            scene->addChild(file);
        else
            std::cerr << "Couldn't load file, ignoring " << argv[a] << std::endl;
    }
	if ( scene->getNChildren() == 0 )
	{
        scene->addChild(makeTorus( .5, 2, 16, 16 ));
//        scene->addChild(makeBox(.6,.6,.6,5,5,5));
    }

    // show the whole scene
    mgr->showAll();
    
    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:100,代码来源:testDisplayFilter.cpp

示例7: solution

    typename ThetaStar<ProblemType, Hasher>::SolutionPtr ThetaStar<ProblemType, Hasher>::operator() ( const ProblemType& problem )
    {
        SolutionPtr solution(nullptr);
        this->visits = 0;
        this->maxNodesInMemory = 0;

        NodePtr initialStateNode = this->createNode( problem.initialState() );

        this->fringe->push(initialStateNode);

        //clock_t begin = clock();

        while( !solution && !this->fringe->empty() )
        {
            if(this->fringe->size() + this->closedList.size() > this->maxNodesInMemory)
                this->maxNodesInMemory = this->fringe->size() + this->closedList.size();
            this->visits++;

            NodePtr currentNode = this->fringe->pop();
            this->notifyNodeVisitListeners(currentNode);

            if( problem.isGoal( currentNode->getState() ) )
            {
                solution = SolutionPtr(new SolutionType(currentNode));
                continue;
            }

            std::pair<const State*, NodePtr> entry(&currentNode->getState(), currentNode);
            this->closedList.insert(entry);
            this->notifyNodeClosureListeners(currentNode);

            std::list<NodePtr>&& successors = this->expand(currentNode, problem);

            for(NodePtr node: successors) {
                auto nodeIt = this->closedList.find(&node->getState());

                if(nodeIt == this->closedList.end()) {

                    if(node->hasParent()) {

                        if(node->getParent()->hasParent()) {
                            auto grandParent = node->getParent()->getParent();

                            auto actionAndCost = (*lineOfSight)(node->getState(), grandParent->getState());
                            if(actionAndCost.first != nullptr) {
                                node->setParent(grandParent, *actionAndCost.first, actionAndCost.second);
                            }
                        }
                    }

                    this->fringe->push(node);
                }
            }
        }

        //clock_t end = clock();

        //double timeSpend = (double)(end - begin) / CLOCKS_PER_SEC;
        //std::cout << "Spent " << timeSpend << " seconds on " << visit << " visits (" << visit/timeSpend << " n/s)" << std::endl;

        this->cleanUp();
        return solution;
    }
开发者ID:LinusVanElswijk,项目名称:GraphSearchLibrary,代码行数:63,代码来源:ThetaStar.hpp

示例8: k

void
ProgressPanel::startTask(const NodePtr& node,
                         const int firstFrame,
                         const int lastFrame,
                         const int frameStep,
                         const bool canPause,
                         const bool canCancel,
                         const QString& message,
                         const boost::shared_ptr<ProcessHandler>& process)
{
    assert(QThread::currentThread() == qApp->thread());
    if (!node) {
        return;
    }
    assert((canPause && firstFrame != INT_MIN && lastFrame != INT_MAX) || !canPause);
    
    ProgressTaskInfoPtr task;
    {
        
        QMutexLocker k(&_imp->tasksMutex);
        task = _imp->findTask(node);
    }
    if (task) {
        task->cancelTask(false, 1);
        removeTaskFromTable(task);
    }
    

    
    QMutexLocker k(&_imp->tasksMutex);
    
    task.reset(new ProgressTaskInfo(this,
                            node,
                            firstFrame,
                            lastFrame,
                            frameStep,
                            canPause,
                            canCancel,
                            message, process));
    
    
    if (canPause || node->getEffectInstance()->isOutput()) {
        task->createItems();
        QTimer::singleShot(NATRON_DISPLAY_PROGRESS_PANEL_AFTER_MS, this, SLOT(onShowProgressPanelTimerTriggered()));
    }
    
    if (process) {
        connectProcessSlots(task.get(), process.get());
    }
    if (!process) {
        if (node->getEffectInstance()->isOutput()) {
            OutputEffectInstance* isOutput = dynamic_cast<OutputEffectInstance*>(node->getEffectInstance().get());
            if (isOutput) {
                RenderEngine* engine = isOutput->getRenderEngine();
                assert(engine);
                QObject::connect(engine,SIGNAL(frameRendered(int,double)), task.get(), SLOT(onRenderEngineFrameComputed(int,double)));
                QObject::connect(engine, SIGNAL(renderFinished(int)), task.get(), SLOT(onRenderEngineStopped(int)));
                QObject::connect(task.get(),SIGNAL(taskCanceled()),engine,SLOT(abortRendering_Blocking()));
            }
        }
    }
开发者ID:JamesLinus,项目名称:Natron,代码行数:61,代码来源:ProgressPanel.cpp

示例9: QDialog

PickKnobDialog::PickKnobDialog(DockablePanel* panel,
                               QWidget* parent)
    : QDialog(parent)
    , _imp( new PickKnobDialogPrivate(panel) )
{
    NodeSettingsPanel* nodePanel = dynamic_cast<NodeSettingsPanel*>(panel);

    assert(nodePanel);
    if (!nodePanel) {
        throw std::logic_error("PickKnobDialog::PickKnobDialog()");
    }
    NodeGuiPtr nodeGui = nodePanel->getNodeGui();
    NodePtr node = nodeGui->getNode();
    NodeGroupPtr isGroup = node->isEffectNodeGroup();
    NodeCollectionPtr collec = node->getGroup();
    NodeGroupPtr isCollecGroup = toNodeGroup(collec);
    NodesList collectNodes = collec->getNodes();
    for (NodesList::iterator it = collectNodes.begin(); it != collectNodes.end(); ++it) {
        if ((*it)->isActivated() && (*it)->getNodeGui() && ( (*it)->getKnobs().size() > 0 ) ) {
            _imp->allNodes.push_back(*it);
        }
    }
    if (isCollecGroup) {
        _imp->allNodes.push_back( isCollecGroup->getNode() );
    }
    if (isGroup) {
        NodesList groupnodes = isGroup->getNodes();
        for (NodesList::iterator it = groupnodes.begin(); it != groupnodes.end(); ++it) {
            if ( (*it)->getNodeGui() &&
                (*it)->isActivated() &&
                ( (*it)->getKnobs().size() > 0 ) ) {
                _imp->allNodes.push_back(*it);
            }
        }
    }
    QStringList nodeNames;
    for (NodesList::iterator it = _imp->allNodes.begin(); it != _imp->allNodes.end(); ++it) {
        QString name = QString::fromUtf8( (*it)->getLabel().c_str() );
        nodeNames.push_back(name);
    }
    nodeNames.sort();

    _imp->mainLayout = new QGridLayout(this);
    _imp->selectNodeLabel = new Label( tr("Node:") );
    _imp->nodeSelectionCombo = new CompleterLineEdit(nodeNames, nodeNames, false, this);
    _imp->nodeSelectionCombo->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Input the name of a node in the current project."), NATRON_NAMESPACE::WhiteSpaceNormal) );
    _imp->nodeSelectionCombo->setFocus(Qt::PopupFocusReason);

    _imp->knobSelectionCombo = new ComboBox(this);
    QObject::connect( _imp->knobSelectionCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onKnobComboIndexChanged(int)) );
    QString useAliasTt = NATRON_NAMESPACE::convertFromPlainText(tr("If checked, an alias of the selected parameter will be created, coyping entirely its state. "
                                                           "Only the script-name, label and tooltip will be editable.\n"
                                                           "For choice parameters this will also "
                                                           "dynamically refresh the menu entries when the original parameter's menu is changed.\n"
                                                           "When unchecked, a simple expression will be set linking the two parameters, but things such as dynamic menus "
                                                           "will be disabled."), NATRON_NAMESPACE::WhiteSpaceNormal);
    _imp->useAliasLabel = new Label(tr("Make Alias:"), this);
    _imp->useAliasLabel->setToolTip(useAliasTt);
    _imp->useAliasCheckBox = new QCheckBox(this);
    _imp->useAliasCheckBox->setToolTip(useAliasTt);
    _imp->useAliasCheckBox->setChecked(true);

    QObject::connect( _imp->nodeSelectionCombo, SIGNAL(itemCompletionChosen()), this, SLOT(onNodeComboEditingFinished()) );

    _imp->destPageLabel = new Label(tr("Page:"), this);
    QString pagett = NATRON_NAMESPACE::convertFromPlainText(tr("Select the page into which the parameter will be created."), NATRON_NAMESPACE::WhiteSpaceNormal);
    _imp->destPageLabel->setToolTip(pagett);
    _imp->destPageCombo = new ComboBox(this);
    _imp->destPageCombo->setToolTip(pagett);
    QObject::connect( _imp->destPageCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onPageComboIndexChanged(int)) );
    const KnobsVec& knobs = node->getKnobs();
    for (std::size_t i = 0; i < knobs.size(); ++i) {
        if ( knobs[i]->isUserKnob() ) {
            KnobPagePtr isPage = toKnobPage(knobs[i]);
            if (isPage) {
                _imp->pages.push_back(isPage);
                _imp->destPageCombo->addItem( QString::fromUtf8( isPage->getName().c_str() ) );
            } else {
                KnobGroupPtr isGrp = toKnobGroup(knobs[i]);
                if (isGrp) {
                    _imp->groups.push_back(isGrp);
                }
            }
        }
    }
    if (_imp->destPageCombo->count() == 0) {
        _imp->destPageLabel->hide();
        _imp->destPageCombo->hide();
    }


    _imp->groupLabel = new Label(tr("Group:"), this);
    QString grouptt = NATRON_NAMESPACE::convertFromPlainText(tr("Select the group into which the parameter will be created."), NATRON_NAMESPACE::WhiteSpaceNormal);
    _imp->groupCombo = new ComboBox(this);
    _imp->groupLabel->setToolTip(grouptt);
    _imp->groupCombo->setToolTip(grouptt);
    onPageComboIndexChanged(0);

    _imp->buttons = new DialogButtonBox(QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel),
                                         Qt::Horizontal, this);
//.........这里部分代码省略.........
开发者ID:kcotugno,项目名称:Natron,代码行数:101,代码来源:PickKnobDialog.cpp

示例10: main


//.........这里部分代码省略.........
		printf("Please check if the Plugins-path is correctly set to the inVRs-lib directory in the ");
		printf("'final/config/general.xml' config file, e.g.:\n");
		printf("<path name=\"Plugins\" path=\"/home/guest/inVRs/lib\"/>\n");
		return -1;
	}
//----------------------------------------------------------------------------//
// Snippet-2-1 - END                                                          //
//----------------------------------------------------------------------------//

//----------------------------------------------------------------------------//
// Snippet-3-1 - BEGIN                                                        //
//----------------------------------------------------------------------------//
	// generate or load and configure height maps of the used tiles
	HeightMapManager::generateTileHeightMaps();
//----------------------------------------------------------------------------//
// Snippet-3-1 - END                                                          //
//----------------------------------------------------------------------------//

//----------------------------------------------------------------------------//
// Snippet-2-15 - BEGIN                                                       //
//----------------------------------------------------------------------------//
	// generate and configure the SkyBox
	std::string skyPath = Configuration::getPath("Skybox");
	skybox.init(5,5,5, 1000, (skyPath+"lostatseaday/lostatseaday_dn.jpg").c_str(),
		(skyPath+"lostatseaday/lostatseaday_up.jpg").c_str(),
		(skyPath+"lostatseaday/lostatseaday_ft.jpg").c_str(),
		(skyPath+"lostatseaday/lostatseaday_bk.jpg").c_str(),
		(skyPath+"lostatseaday/lostatseaday_rt.jpg").c_str(),
		(skyPath+"lostatseaday/lostatseaday_lf.jpg").c_str());
//----------------------------------------------------------------------------//
// Snippet-2-15 - END                                                         //
//----------------------------------------------------------------------------//

	NodePtr root = Node::create();
	beginEditCP(root);
		root->setCore(Group::create());

//----------------------------------------------------------------------------//
// Snippet-1-3 - BEGIN                                                        //
//----------------------------------------------------------------------------//
		OpenSGSceneGraphInterface* sgIF =
			dynamic_cast<OpenSGSceneGraphInterface*>(OutputInterface::getSceneGraphInterface());
		if (!sgIF) {
			printf("Error: Failed to get OpenSGSceneGraphInterface!\n");
			printf("Please check if the OutputInterface configuration is correct!\n");
			return -1;
		}
		// retrieve root node of the SceneGraphInterface (method is OpenSG specific)
		NodePtr scene = sgIF->getNodePtr();

		root->addChild(scene);
//----------------------------------------------------------------------------//
// Snippet-1-3 - END                                                          //
//----------------------------------------------------------------------------//

//----------------------------------------------------------------------------//
// Snippet-2-16 - BEGIN                                                       //
//----------------------------------------------------------------------------//
		// add the SkyBox to the scene
		root->addChild(skybox.getNodePtr());
//----------------------------------------------------------------------------//
// Snippet-2-16 - END                                                         //
//----------------------------------------------------------------------------//

	endEditCP(root);
开发者ID:flair2005,项目名称:inVRs,代码行数:66,代码来源:MedievalTown.cpp

示例11: TRACE

bool StatCache::handleEvent(const struct inotify_event* event) {
  if (event->mask & IN_Q_OVERFLOW) {
    // The event queue overflowed, so all bets are off.  Start over.
    TRACE(0, "StatCache: event queue overflowed\n");
    reset();
    return true;
  }
  assertx(event->wd != -1);
  NodePtr node = folly::get_default(m_watch2Node, event->wd);
  if (!node.get()) {
    TRACE(1, "StatCache: inotify event (obsolete) %s\n",
             eventToString(event).c_str());
    return false;
  }
  TRACE(1, "StatCache: inotify event for '%s': %s\n",
           node->path().c_str(), eventToString(event).c_str());

  if (event->mask & (IN_MODIFY|IN_ATTRIB)) {
    bool touched = false;
    NodePtr child = node->getChild(event->name, true);
    if (child.get() != nullptr) {
      if ((event->mask & IN_MODIFY) && child->isLink()) {
        // A modified link is logically equivalent to IN_MOVED_FROM.
        child->expirePaths();
        node->removeChild(event->name);
      } else {
        child->touch();
      }
      touched = true;
    }
    child = node->getChild(event->name, false);
    if (child.get() != nullptr) {
      // The follow=false child is equivalent to the follow=true child unless
      // it's a link.  Avoid duplicate invalidations for non-links.
      child->touch(!touched || child->isLink());
    }
  }
  if (event->mask & (IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE)) {
    // The directory itself was modified, so invalidate its cached stat
    // structure.
    node->touch();
    // Recursively invalidate the cached paths rooted at "node/name".
    bool expired = false;
    NodePtr child = node->getChild(event->name, true);
    if (child.get() != nullptr) {
      child->expirePaths();
      expired = true;
    }
    child = node->getChild(event->name, false);
    if (child.get() != nullptr) {
      // The follow=false child is equivalent to the follow=true child unless
      // it's a link.  Avoid duplicate invalidations for non-links.
      child->expirePaths(!expired || child->isLink());
      expired = true;
    }
    if (expired) {
      node->removeChild(event->name);
    }
  }
  if (event->mask & IN_IGNORED) {
    // The kernel removed the directory watch, either as a side effect of
    // directory deletion, or because inotify_rm_watch() was explicitly called
    // during Node destruction.  Delete the corresponding entry from
    // m_watch2Node.  Removal should always succeed here because no other code
    // performs removal.
    m_watch2Node.erase(event->wd);
  }
  return false;
}
开发者ID:facebook,项目名称:hhvm,代码行数:69,代码来源:stat-cache.cpp

示例12: View3D

SceneView::SceneView( const std::string &name )
	:	View3D( name, new GafferScene::ScenePlug() ),
		m_sceneGadget( new SceneGadget )
{

	// add plugs and signal handling for them

	storeIndexOfNextChild( g_firstPlugIndex );

	addChild( new IntPlug( "minimumExpansionDepth", Plug::In, 0, 0, Imath::limits<int>::max(), Plug::Default & ~Plug::AcceptsInputs ) );

	plugSetSignal().connect( boost::bind( &SceneView::plugSet, this, ::_1 ) );

	// set up our gadgets

	viewportGadget()->setPrimaryChild( m_sceneGadget );

	viewportGadget()->keyPressSignal().connect( boost::bind( &SceneView::keyPress, this, ::_1, ::_2 ) );

	m_sceneGadget->baseState()->add( const_cast<IECoreGL::State *>( baseState() ) );
	m_sceneGadget->setContext( getContext() );
	baseStateChangedSignal().connect( boost::bind( &SceneView::baseStateChanged, this ) );

	m_lookThrough = boost::shared_ptr<LookThrough>( new LookThrough( this ) );
	m_grid = boost::shared_ptr<Grid>( new Grid( this ) );
	m_gnomon = boost::shared_ptr<Gnomon>( new Gnomon( this ) );
	m_shadingMode = boost::shared_ptr<ShadingMode>( new ShadingMode( this ) );

	//////////////////////////////////////////////////////////////////////////
	// add a preprocessor which monkeys with the scene before it is displayed.
	//////////////////////////////////////////////////////////////////////////

	NodePtr preprocessor = new Node();
	ScenePlugPtr preprocessorInput = new ScenePlug( "in" );
	preprocessor->addChild( preprocessorInput );

	// add a node for hiding things

	StandardAttributesPtr hide = new StandardAttributes( "hide" );
	hide->attributesPlug()->getChild<ValuePlug>( "visibility" )->getChild<BoolPlug>( "enabled" )->setValue( true );
	hide->attributesPlug()->getChild<ValuePlug>( "visibility" )->getChild<BoolPlug>( "value" )->setValue( false );

	preprocessor->addChild( hide );
	hide->inPlug()->setInput( preprocessorInput );

	PathFilterPtr hideFilter = new PathFilter( "hideFilter" );
	preprocessor->addChild( hideFilter );
	hide->filterPlug()->setInput( hideFilter->outPlug() );

	// add in the node from the ShadingMode

	preprocessor->addChild( m_shadingMode->preprocessor() );
	m_shadingMode->preprocessor()->inPlug()->setInput( hide->outPlug() );

	// make the output for the preprocessor

	ScenePlugPtr preprocessorOutput = new ScenePlug( "out", Plug::Out );
	preprocessor->addChild( preprocessorOutput );
	preprocessorOutput->setInput( m_shadingMode->preprocessor()->outPlug() );

	setPreprocessor( preprocessor );

	// connect up our scene gadget

	m_sceneGadget->setScene( preprocessedInPlug<ScenePlug>() );

}
开发者ID:Eryckz,项目名称:gaffer,代码行数:67,代码来源:SceneView.cpp

示例13: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // GLUT init
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    int winid = glutCreateWindow("OpenSG CGFX Shader");

    // the connection between GLUT and OpenSG
    _gwin = GLUTWindow::create();
    _gwin->setId(winid);
    _gwin->setSize( 800, 800 );
    _gwin->init();

    // init callbacks
    glutSetWindow(winid);
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    const char *effectFile = "BumpGlossedShiny.fx";

    if(argc > 1)
    {
        effectFile = argv[1];
    }

    _cgfxmat = CGFXMaterial::create();
    beginEditCP(_cgfxmat);
        _cgfxmat->setEffectFile(effectFile);
        // this multipass technique leads to a render bug, I have no idea what's wrong :-(
        //_cgfxmat->setTechnique(1);
    endEditCP(_cgfxmat);

    ChunkMaterialPtr mat2 = ChunkMaterial::create();
    MaterialChunkPtr matc = MaterialChunk::create();
    beginEditCP(matc);
        matc->setDiffuse(Color4f(1, 0, 0, 1));
    endEditCP(matc);
    beginEditCP(mat2);
        mat2->addChunk(matc);
        //mat2->addChunk(texc);
    endEditCP(mat2);

    // create root node
    _scene = Node::create();

    GeometryPtr geo1 = makeLatLongSphereGeo(50, 50, 1.0f);
    
    OSG::calcVertexTangents(geo1, 0, Geometry::TexCoords1FieldId, Geometry::TexCoords2FieldId);

    beginEditCP( geo1, Geometry::MaterialFieldMask);
        geo1->setMaterial(_cgfxmat);
    endEditCP(geo1, Geometry::MaterialFieldMask);

    NodePtr sphere1 = Node::create();
    beginEditCP(sphere1, Node::CoreFieldMask);
        sphere1->setCore(geo1);
    endEditCP(sphere1, Node::CoreFieldMask);

    TransformPtr trans1 = Transform::create();
    beginEditCP(trans1);
        trans1->getMatrix().setTranslate(-2 , 0, 0);
    endEditCP(trans1);
    NodePtr transn1 = Node::create();
    beginEditCP(transn1);
        transn1->setCore(trans1);
        transn1->addChild(sphere1);
    beginEditCP(transn1);

    //
    GeometryPtr geo2 = makeLatLongSphereGeo(50, 50, 1.0f);
    
    beginEditCP( geo2, Geometry::MaterialFieldMask);
        geo2->setMaterial(mat2);
    endEditCP(geo2, Geometry::MaterialFieldMask);

    NodePtr sphere2 = Node::create();
    beginEditCP(sphere2, Node::CoreFieldMask);
        sphere2->setCore(geo2);
    endEditCP(sphere2, Node::CoreFieldMask);

    TransformPtr trans2 = Transform::create();
    beginEditCP(trans2);
        trans2->getMatrix().setTranslate(2 , 0, 0);
    endEditCP(trans2);
    NodePtr transn2 = Node::create();
    beginEditCP(transn2);
        transn2->setCore(trans2);
        transn2->addChild(sphere2);
    beginEditCP(transn2);

    beginEditCP(_scene);
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testCGFXMaterial.cpp

示例14: addChildNode

void Node::addChildNode(NodePtr pNode)
{
    auto pair = std::make_pair(pNode->getName(), pNode);
    this->childNodes.insert(pair);
}
开发者ID:GlennJDev,项目名称:forlorn-melody,代码行数:5,代码来源:Node.cpp

示例15: keyboard

void keyboard(unsigned char k, int x, int y)
{
    switch(k)
    {
        case 27:
        {
            OpenSGDeformActionManager::Destroy();
            osgExit();
            exit(0);
        }
        case '1':
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
            break;
        }
        case '2':
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
            break;
        }
        case '3':
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            break;
        }
        case '5':
        {
            chairIndex = (chairIndex + 1) % 6;
            model = chairNodes[chairIndex];
            cout << "Selected model is: ";
            if (getName(model))
                cout << getName(model);
            cout << " " << model << endl;
            break;
        }
        case '6':
        {
            ax *= -1;
            break;
        }
        case '7':
        {
            if (ax < 0)
                ax = -1;
            else
                ax = 1;
            break;
        }
        case '8':
        {
            if (ax < 0)
                ax = -2;
            else
                ax = 2;
            break;
        }
        case '9':
        {
            if (ax < 0)
                ax = -3;
            else
                ax = 3;
            break;
        }
        case 'p':
        {
#if OSG_MAJOR_VERSION >= 2
			traverse(scene, boost::bind(printSceneGraph,_1));
#else
            traverse(scene, osgTypedFunctionFunctor1CPtrRef
                <Action::ResultE, NodePtr>(printSceneGraph));
#endif 
            break;
        }
        case 'h':
        {
            printUsage();
            break;
        }
        case 'i':
        {
            gmtl::AABoxf aabb;
            osgdam = OpenSGDeformActionManager::GetInstance();
            if (osgdam != 0)
            {
                osgdam->insertLattice(model, 2, 2, 2, 3);
            }
            break;
        }
        case 'j':
        {
            osgdam = OpenSGDeformActionManager::GetInstance();
            if(osgdam != 0)
            {
                gmtl::AABoxf aabb;
                Pnt3f aabbMin, aabbMax;
#if OSG_MAJOR_VERSION >= 2
				model->editVolume(true).getBounds(aabbMin, aabbMax);
#else
				model->getVolume(true).getBounds(aabbMin, aabbMax);
//.........这里部分代码省略.........
开发者ID:flair2005,项目名称:inVRs,代码行数:101,代码来源:main.cpp


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