Exemplo n.º 1
0
    // obtain a NodeID
    id_t 
    VASTnet::getUniqueID (int id_group)
    {
        // check if we're relay and allow to give ID
        if (isEntryPoint (_manager->getID ()) == false)
            return NET_ID_UNASSIGNED;

        // id_group cannot be out of range (currently only 4)
        if (id_group < 0 || id_group >= 4)
            return NET_ID_UNASSIGNED;
        
        if (_IDcounter.find (id_group) == _IDcounter.end ())
            _IDcounter[id_group] = NET_ID_RELAY+1;

        // if all available numbers are assigned
        if (_IDcounter[id_group] <= 0 || _IDcounter[id_group] >= 16384)
            return NET_ID_UNASSIGNED;

        else
        {
            Addr &addr = _manager->getAddress ();

            // if we're a relay with public IP
            id_t id = ((id_t)addr.publicIP.host << 32) | ((id_t)addr.publicIP.port << 16) | ((id_t)id_group << 14) | _IDcounter[id_group]++;
            return id;
        }
    }
Exemplo n.º 2
0
void DiagramOperation::updateAppearance()
{
    QPen pen;

    if (isEntryPoint()) {
        pen.setWidth(2);
        pen.setStyle(Qt::DashLine);
    } else {
        pen.setWidth(1);
        pen.setStyle(Qt::SolidLine);
    }

    setPen(pen);
}
Exemplo n.º 3
0
void DiagramOperation::contextMenuEvent(QGraphicsSceneContextMenuEvent * event)
{
    // This code is super brittle, but the whole context menu handling is broken.
    // Seriously, normally you should avoid block-specific code in the MainWindow
    // object, which is already too large.
    //
    // What follows is a hack that selects the "Entry point" menu item if the block
    // really is an entry point.
    QAction * firstAction = myContextMenu->actions().first();
    firstAction->setChecked(isEntryPoint());
    firstAction->setEnabled(true);

    DiagramBlock::contextMenuEvent(event);
}