void InternalPortModel::updateOutputPortColor(void)
{
    if(type == OUTPUTD)
    {
        strColor = COLOR_NOMAL;
        std::vector<ArrowModel*>::iterator itr;
        for(itr=sourceArrows.begin(); itr<sourceArrows.end(); itr++)
            if((*itr)->getDestination() &&
                Glib::RefPtr<InternalPortModel>::cast_dynamic((*itr)->getDestination()))
            {
                InputData* inp = Glib::RefPtr<InternalPortModel>::cast_dynamic((*itr)->getDestination())->getInput();
                if(inp && (string(inp->getName()) != "*") &&
                   !compareString(output->getName(), inp->getName()))
                {
                    strColor = COLOR_MISMATCH;
                    break;
                }
            }
        poly->property_fill_color().set_value(strColor.c_str());
    }
}
Exemple #2
0
void ModuleWindow::updateWidget()
{
    Module* m_pModule = ModuleWindow::m_pModule;
    m_refTreeModel->clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
    Gtk::TreeModel::Row cchildrow;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pModule->getName();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Version";
    row[m_Columns.m_col_value] = m_pModule->getVersion();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pModule->getDescription();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Parameters";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->argumentCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam();
        childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getDescription();
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Authors";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->authorCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getAuthorAt(i).getName();
        childrow[m_Columns.m_col_value] = m_pModule->getAuthorAt(i).getEmail();
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Inputs";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->inputCount(); i++)
    {
        InputData in = m_pModule->getInputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Type";
        childrow[m_Columns.m_col_value] = in.getName();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Port";
        cchildrow[m_Columns.m_col_value] = in.getPort();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = in.getDescription();

        childrow = *(m_refTreeModel->append(childrow.children()));
        childrow[m_Columns.m_col_name] = "Required";
        childrow[m_Columns.m_col_value] = (in.isRequired())?"Yes":"No";
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Outputs";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->outputCount(); i++)
    {
        OutputData out = m_pModule->getOutputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Type";
        childrow[m_Columns.m_col_value] = out.getName();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Port";
        cchildrow[m_Columns.m_col_value] = out.getPort();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = out.getDescription();
    }

}
void PropertiesTable::showModuleTab(Module *mod)
{
    modules.clear();
    disconnect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int)));
    disconnect(moduleProperties,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onModItemDoubleClicked(QTreeWidgetItem*,int)));

    currentApplication = NULL;
    currentModule = mod;
    propertiesTab->clear();
    propertiesTab->addTab(moduleProperties,"Module Properties");
    propertiesTab->addTab(moduleDescription,"Description");
    moduleProperties->clear();
    moduleDescription->clear();

    appProperties->hide();
    moduleProperties->show();
    moduleDescription->show();

    modName = new QTreeWidgetItem(moduleProperties,QStringList() << "Name" << mod->getName());
    modNode = new QTreeWidgetItem(moduleProperties,QStringList() << "Node");
    modStdio = new QTreeWidgetItem(moduleProperties,QStringList() << "Stdio" << mod->getStdio());
    modWorkDir = new QTreeWidgetItem(moduleProperties,QStringList() << "Workdir" << mod->getWorkDir());
    modPrefix = new QTreeWidgetItem(moduleProperties,QStringList() << "Prefix" << mod->getBasePrefix());
    modDeployer = new QTreeWidgetItem(moduleProperties,QStringList() << "Deployer");
    modParams = new QTreeWidgetItem(moduleProperties,QStringList() << "Parameters" << mod->getParam());

    lastPrefix = mod->getBasePrefix();

    modStdio->setFlags(modStdio->flags() | Qt::ItemIsEditable);
    modWorkDir->setFlags(modWorkDir->flags() | Qt::ItemIsEditable);
    modPrefix->setFlags(modPrefix->flags() | Qt::ItemIsEditable);

    moduleProperties->addTopLevelItem(modName);
    moduleProperties->addTopLevelItem(modNode);
    moduleProperties->addTopLevelItem(modStdio);
    moduleProperties->addTopLevelItem(modWorkDir);
    moduleProperties->addTopLevelItem(modPrefix);
    moduleProperties->addTopLevelItem(modDeployer);
    moduleProperties->addTopLevelItem(modParams);

    if(deployerCombo){
        delete deployerCombo;
        deployerCombo = NULL;
    }

    if(nodeCombo){
        delete nodeCombo;
        nodeCombo = NULL;
    }
    deployerCombo = new QComboBox();
    nodeCombo = new QComboBox();

    deployerCombo->setEditable(true);
    nodeCombo->setEditable(true);

    if(compareString(mod->getBroker(),"yarpdev")){
        deployerCombo->addItem("yarpdev");
    }else if(compareString(mod->getBroker(),"icubmoddev")){
        deployerCombo->addItem("icubmoddev");
    }else{
        deployerCombo->addItem("local");
        deployerCombo->addItem("yarprun");
    }

    if(strlen(mod->getBroker())){
        deployerCombo->setCurrentText(mod->getBroker());
    }else if(compareString(mod->getHost(),"localhost")){
        deployerCombo->setCurrentText("local");
    }
    if(mod->getNeedDeployer()){
        deployerCombo->setEditable(false);
    }


    nodeCombo->addItem(mod->getHost());
    if(QString(mod->getHost()) != "localhost"){
        nodeCombo->addItem("localhost");
    }
    ResourcePContainer resources = manager->getKnowledgeBase()->getResources();
    for(ResourcePIterator itr=resources.begin(); itr!=resources.end(); itr++){
        Computer* comp = dynamic_cast<Computer*>(*itr);
        if(comp && !compareString(comp->getName(), "localhost")){
            nodeCombo->addItem(comp->getName());
        }
    }
    connect(nodeCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map()));
    connect(nodeCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map()));
    paramsSignalMapper->setMapping(nodeCombo,nodeCombo);

    connect(deployerCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map()));
    connect(deployerCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map()));
    paramsSignalMapper->setMapping(deployerCombo,deployerCombo);




     /*****************************/
     // Populate paramters
     for(int i=0;i<mod->argumentCount();i++){
         Argument a = mod->getArgumentAt(i);
         QTreeWidgetItem *it = new QTreeWidgetItem(modParams,QStringList() << a.getParam());
         QComboBox *paramCombo = new QComboBox();
         paramCombo->setEditable(true);
         paramCombo->addItem(a.getValue());
         if(strcmp(a.getDefault(),a.getValue()) != 0 ){
            paramCombo->addItem(a.getDefault());
         }
         moduleProperties->setItemWidget(it,1,paramCombo);
         connect(paramCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map()));
         connect(paramCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map()));
         paramsSignalMapper->setMapping(paramCombo,paramCombo);
     }
     /*****************************/

    moduleProperties->setItemWidget(modDeployer,1,deployerCombo);
    moduleProperties->setItemWidget(modNode,1,nodeCombo);
    modParams->setExpanded(true);


    QTreeWidgetItem *nameItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Name" << mod->getName());
    QTreeWidgetItem *versionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Version" << mod->getVersion());
    QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Description" << mod->getDescription());
    QTreeWidgetItem *parametersItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Parameters");
    for(int i=0;i<mod->argumentCount();i++){
        Argument a = mod->getArgumentAt(i);
        QTreeWidgetItem *it = new QTreeWidgetItem(parametersItem,QStringList() << a.getParam() << a.getDescription());

    }

    QTreeWidgetItem *authorsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Authors" );
    for(int i=0;i<mod->authorCount();i++){
        Author a = mod->getAuthorAt(i);
        QTreeWidgetItem *it = new QTreeWidgetItem(authorsItem,QStringList() << a.getName() << a.getEmail());
    }

    QTreeWidgetItem *inputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Inputs" );
    for(int i=0;i<mod->inputCount();i++){
        InputData a = mod->getInputAt(i);

        QTreeWidgetItem *type = new QTreeWidgetItem(inputsItem,QStringList() << "Type" << a.getName());
        QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
        QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription());
        QTreeWidgetItem *req = new QTreeWidgetItem(type,QStringList() << "Required" << (a.isRequired() ? "yes" : "no"));
        Q_UNUSED(port);
        Q_UNUSED(desc);
        Q_UNUSED(req);
    }

    QTreeWidgetItem *outputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Outputs" );
    for(int i=0;i<mod->outputCount();i++){
        OutputData a = mod->getOutputAt(i); //TODO controllare

        QTreeWidgetItem *type = new QTreeWidgetItem(outputsItem,QStringList() << "Type" << a.getName());
        QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
        QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription());
        Q_UNUSED(port);
        Q_UNUSED(desc);
    }

    moduleDescription->addTopLevelItem(nameItem);
    moduleDescription->addTopLevelItem(versionItem);
    moduleDescription->addTopLevelItem(descriptionItem);
    moduleDescription->addTopLevelItem(parametersItem);
    moduleDescription->addTopLevelItem(authorsItem);
    moduleDescription->addTopLevelItem(inputsItem);
    moduleDescription->addTopLevelItem(outputsItem);

    connect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int)));
    connect(moduleProperties,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onModItemDoubleClicked(QTreeWidgetItem*,int)));

}
Exemple #4
0
void ModuleWindow::updateWidget()
{
    Module* m_pModule = ModuleWindow::m_pModule;
    m_refTreeModel->clear();


    size_t width = 20;
    for(int i=0; i<m_pModule->inputCount(); i++)
    {
        if(strlen(m_pModule->getInputAt(i).getPort()) > width)
            width = strlen(m_pModule->getInputAt(i).getPort());
    }
    for(int i=0; i<m_pModule->outputCount(); i++)
    {
        if(strlen(m_pModule->getOutputAt(i).getPort()) > width)
            width = strlen(m_pModule->getOutputAt(i).getPort());
    }
    width *= 8;

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
    Gtk::TreeModel::Row cchildrow;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pModule->getName();
    row[m_Columns.m_col_width] = width;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Version";
    row[m_Columns.m_col_value] = m_pModule->getVersion();
    row[m_Columns.m_col_width] = width;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pModule->getDescription();
    row[m_Columns.m_col_width] = width;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Parameters";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;

    for(int i=0; i<m_pModule->argumentCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam();
        childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getDescription();
        childrow[m_Columns.m_col_width] = width;

    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Authors";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;

    //char buff[64];
    for(int i=0; i<m_pModule->authorCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        //sprintf(buff, "%d", i+1);
        childrow[m_Columns.m_col_name] = m_pModule->getAuthorAt(i).getName();
        childrow[m_Columns.m_col_value] = m_pModule->getAuthorAt(i).getEmail();
        childrow[m_Columns.m_col_width] = width;
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Inputs";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;
    for(int i=0; i<m_pModule->inputCount(); i++)
    {
        InputData in = m_pModule->getInputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Port";
        childrow[m_Columns.m_col_value] = in.getPort();
        childrow[m_Columns.m_col_width] = width;

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Type";
        cchildrow[m_Columns.m_col_value] = in.getName();
        cchildrow[m_Columns.m_col_width] = width;


        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = in.getDescription();
        cchildrow[m_Columns.m_col_width] = width;

        childrow = *(m_refTreeModel->append(childrow.children()));
        childrow[m_Columns.m_col_name] = "Required";
        childrow[m_Columns.m_col_value] = (in.isRequired())?"Yes":"No";
        childrow[m_Columns.m_col_width] = 200;
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Outputs";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;
    for(int i=0; i<m_pModule->outputCount(); i++)
    {
        OutputData out = m_pModule->getOutputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Port";
        childrow[m_Columns.m_col_value] = out.getPort();
        childrow[m_Columns.m_col_width] = width;

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Type";
        cchildrow[m_Columns.m_col_value] = out.getName();
        cchildrow[m_Columns.m_col_width] = width;

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = out.getDescription();
        cchildrow[m_Columns.m_col_width] = width;
    }

}
Exemple #5
0
bool yarp::manager::exportDotGraph(Graph& graph, const char* szFileName)
{
    ofstream dot;
    dot.open(szFileName);
    if(!dot.is_open())
        return false;

    dot<<"digraph G {"<<endl;
    dot<<"rankdir=LR;"<<endl;
    dot<<"ranksep=0.0;"<<endl;
    dot<<"nodesep=0.2;"<<endl;

    for(GraphIterator itr=graph.begin(); itr!=graph.end(); itr++)
    {
        switch((*itr)->getType()) {
        case MODULE: {
            Module* mod = (Module*)(*itr);
            dot<<"\""<<mod->getLabel()<<"\"";
            dot<<" [label=\""<< mod->getName()<<"\"";
            dot<<" shape=component, color=midnightblue, fillcolor=lightslategrey, peripheries=1, style=filled, penwidth=2];"<<endl;
            for(int i=0; i<mod->sucCount(); i++)
            {
                Link l = mod->getLinkAt(i);
                InputData* in = (InputData*)l.to();
                dot<<"\""<<mod->getLabel()<<"\" -> ";
                dot<<"\""<<in->getLabel()<<"\"";
                if(!l.isVirtual())
                    dot<<" [label=\"\"];"<<endl;
                else
                    dot<<" [label=\"\" style=dashed];"<<endl;

            }

            break;
        }
        case INPUTD: {
            InputData* in = (InputData*)(*itr);
            dot<<"\""<<in->getLabel()<<"\"";
            if(in->withPriority())
            {
                dot<<" [color=red, fillcolor=lightgrey, peripheries=1, style=filled";
                dot<<" label=\""<< in->getName()<<"\\n"<<in->getPort()<<"\"];"<<endl;
            }
            else
            {
                dot<<" [color=black, fillcolor=lightgrey, peripheries=1, style=filled";
                dot<<" label=\""<< in->getName()<<"\\n"<<in->getPort()<<"\"];"<<endl;
            }
            for(int i=0; i<in->sucCount(); i++)
            {
                Link l = in->getLinkAt(i);
                OutputData* out = (OutputData*)l.to();
                dot<<"\""<<in->getLabel()<<"\" -> ";
                dot<<"\""<<out->getLabel()<<"\"";
                if(!l.isVirtual())
                    dot<<" [label=\""<<l.weight()<<"\"];"<<endl;
                else
                    dot<<" [label=\""<<l.weight()<<"\" style=dashed];"<<endl;
            }

            break;
        }
        case OUTPUTD: {
            OutputData* out = (OutputData*)(*itr);
            dot<<"\""<<out->getLabel()<<"\"";
            dot<<" [color=black, fillcolor=wheat, peripheries=1, style=filled";
            dot<<" label=\""<< out->getName()<<"\\n"<<out->getPort()<<"\"];"<<endl;
            for(int i=0; i<out->sucCount(); i++)
            {
                Link l = out->getLinkAt(i);
                Module* mod = (Module*)l.to();
                dot<<"\""<<out->getLabel()<<"\" -> ";
                dot<<"\""<<mod->getLabel()<<"\"";
                dot<<" [label=\"\" arrowhead=none];"<<endl;
            }

            break;
        }

        case APPLICATION: {
            Application* app = (Application*)(*itr);
            dot<<"\""<<app->getLabel()<<"\"";
            dot<<" [shape=folder, color=darkgreen, fillcolor=darkseagreen, peripheries=1, style=filled, penwidth=2";
            dot<<" label=\""<<app->getLabel()<<"\""<<"];"<<endl;
            for(int i=0; i<app->sucCount(); i++)
            {
                Link l = app->getLinkAt(i);
                Module* mod = (Module*)l.to();
                dot<<"\""<<app->getLabel()<<"\" -> ";
                dot<<"\""<<mod->getLabel()<<"\"";
                if(!l.isVirtual())
                    dot<<" [label=\"\"];"<<endl;
                else
                    dot<<" [label=\"\" style=dashed];"<<endl;
            }
            break;
        }

        case RESOURCE: {
            GenericResource* res = (GenericResource*)(*itr);
            dot<<"\""<<res->getLabel()<<"\"";
            if(res->owner())
                dot<<" [shape=rect, color=black, fillcolor=salmon, peripheries=1, style=filled ";
            else
                dot<<" [shape=house, color=maroon, fillcolor=indianred, peripheries=1, style=filled, penwidth=2";
            dot<<" label=\""<<res->getName()<<"\""<<"];"<<endl;
            for(int i=0; i<res->sucCount(); i++)
            {
                Link l = res->getLinkAt(i);
                Node* prov = l.to();
                dot<<"\""<<res->getLabel()<<"\" -> ";
                dot<<"\""<<prov->getLabel()<<"\"";
                dot<<" [label=\""<<l.weight()<<"\"];"<<endl;
            }

            break;
        }

        default:
            break;
        };
    }

    dot<<GRAPH_LEGEND;
    dot<<"}"<<endl;
    dot.close();
    return true;
}