コード例 #1
0
ファイル: treecanvas.cpp プロジェクト: akiernan/gecode
 void
 TreeCanvas::navNextSol(bool back) {
   QMutexLocker locker(&mutex);
   NextSolCursor nsc(currentNode,back,*na);
   PreorderNodeVisitor<NextSolCursor> nsv(nsc);
   nsv.run();
   VisualNode* n = nsv.getCursor().node();
   if (n != root) {
     setCurrentNode(n);
     centerCurrentNode();
   }
 }
コード例 #2
0
    void StateGraphParser::seenmachineinstantiation()
    {
        // TODO : move this code to the ParsedStateMachine builder.

        // Create a full depth copy (including subMachines)
        // if RootMachine, make special copy which fixes attributes such
        // that on subsequent copy() they keep pointing to same var.
        // use shared_ptr to release on throw's below.
        ParsedStateMachinePtr nsc( curmachinebuilder->build( isroot ) );

        // we stored the attributes which are params of nsc
        // in the build operation :
        machineparams_t params = nsc->getParameters();

        // first run over the given parameters to see if they all exist in
        // the context we're instantiating...
        for ( machineparamvalues_t::iterator i = curinstmachineparams.begin(); i != curinstmachineparams.end(); ++i )
        {
            machineparams_t::iterator j = params.find( i->first );
            if ( j == params.end() )
                ORO_THROW( parse_exception_semantic_error( "No parameter \"" + i->first + "\" in this StateMachine." ) );
        }

        for ( machineparams_t::iterator i = params.begin(); i != params.end(); ++i )
        {
            machineparamvalues_t::iterator j = curinstmachineparams.find( i->first );
            if ( j == curinstmachineparams.end() )
                ORO_THROW( parse_exception_semantic_error(
                    "No value given for argument \"" + i->first + "\" in instantiation of this StateMachine." ));
#ifndef ORO_EMBEDDED
            try {
                paraminitcommands.push_back( i->second->getDataSource()->updateAction( j->second.get() ) );
            }
            catch( const bad_assignment& )
                {
                    throw parse_exception_semantic_error("Attempt to initialize parameter '"+i->first+"' with a value which is of a different type." );
                }
#else
            ActionInterface* ret =  i->second->getDataSource()->updateAction( j->second.get());
            if (ret)
                paraminitcommands.push_back( ret );
            else
                return;
#endif
        }

        curinstantiatedmachine = nsc;

        // prepend the commands for initialising the subMachine
        // parameters
        if ( paraminitcommands.size() > 0 )
            {
                CommandComposite* comcom = new CommandComposite;
                for ( std::vector<ActionInterface*>::iterator i = paraminitcommands.begin();
                      i != paraminitcommands.end(); ++i )
                    comcom->add( *i );
                // init the vars as last (if any), so that they can be inited by an expression containing the params :
                if ( curinstantiatedmachine->getInitCommand() )
                    comcom->add( curinstantiatedmachine->getInitCommand() );
                curinstantiatedmachine->setInitCommand( comcom );
            }
        paraminitcommands.clear();

        curmachinebuilder = 0;
        curinstmachineparams.clear();

        // set the TaskContext name to the instance name :
        curinstantiatedmachine->getService()->setName(curinstmachinename );
    }
コード例 #3
0
ファイル: qtgist.cpp プロジェクト: cmears/cp-profiler
/// TODO
void
Gist::on_canvas_statusChanged(VisualNode* n, const Statistics& stats,
                              bool finished) {

    nodeStatInspector->node(execution->getNA(),n,stats,finished); /// for single node stats

    if (!finished) {
        showNodeStats->setEnabled(false);
        // stop-> setEnabled(true);
        // reset->setEnabled(false);

        navNextSol->setEnabled(false);
        navPrevSol->setEnabled(false);

        // searchNext->setEnabled(false);
        // searchAll->setEnabled(false);
        toggleHidden->setEnabled(false);
        hideFailed->setEnabled(false);
        // hideSize->setEnabled(false);

        // labelBranches->setEnabled(false);
        // labelPath->setEnabled(false);

        // toggleStop->setEnabled(false);
        // unstopAll->setEnabled(false);

        center->setEnabled(false); /// ??
        exportPDF->setEnabled(false);
        exportWholeTreePDF->setEnabled(false);
        print->setEnabled(false);
        // printSearchLog->setEnabled(false);

        bookmarkNode->setEnabled(false);
        bookmarksGroup->setEnabled(false);
    } else {
        // stop->setEnabled(false);
        // reset->setEnabled(true);

        if ( (n->isOpen() || n->hasOpenChildren()) && (!n->isHidden()) ) {
            // searchNext->setEnabled(true);
            // searchAll->setEnabled(true);
        } else {
            // searchNext->setEnabled(false);
            // searchAll->setEnabled(false);
        }
        if (n->getNumberOfChildren() > 0) {

            toggleHidden->setEnabled(true);
            hideFailed->setEnabled(true);
            // hideSize->setEnabled(true);
            // unstopAll->setEnabled(true);
        } else {
            toggleHidden->setEnabled(false);
            hideFailed->setEnabled(false);
            // hideSize->setEnabled(false);
            // unhideAll->setEnabled(false);
            // unstopAll->setEnabled(false);
        }

        toggleStop->setEnabled(n->getStatus() == STOP ||
                               n->getStatus() == UNSTOP);

        showNodeStats->setEnabled(true);
        labelPath->setEnabled(true);

        VisualNode* root = n;
        while (!root->isRoot()) {
            root = root->getParent(execution->getNA());
        }
        NextSolCursor nsc(n, false, execution->getNA());

        PreorderNodeVisitor<NextSolCursor> nsv(nsc);
        nsv.run();
        navNextSol->setEnabled(nsv.getCursor().node() != root);

        NextSolCursor psc(n, true, execution->getNA());

        PreorderNodeVisitor<NextSolCursor> psv(psc);
        psv.run();
        navPrevSol->setEnabled(psv.getCursor().node() != root);

        center->setEnabled(true);
        exportPDF->setEnabled(true);
        exportWholeTreePDF->setEnabled(true);
        print->setEnabled(true);
        printSearchLog->setEnabled(true);

        bookmarkNode->setEnabled(true);
        bookmarksGroup->setEnabled(true);
    }
    emit statusChanged(stats,finished);
}