Exemplo n.º 1
0
bool NodeCtrl::togglePlugDirection(const QString & name)
{
    PlugHandle plug = m_node.getPlug(name);
    if (!plug.isValid() || !plug.toggleDirection()) {
        return false;
    }
    Q_ASSERT(m_plugs.contains(plug));
    Q_ASSERT(m_plugs[plug].size() == 0);
    return true;
}
Exemplo n.º 2
0
bool PlugHandle::disconnectPlug(PlugHandle other)
{
#ifdef QT_DEBUG
    Q_ASSERT(m_isValid && other.isValid());
#else
    if(!m_isValid || !other.isValid()){
        return false;
    }
#endif
    PlugEdge* edge;
    Scene* scene = m_plug->getNode()->getScene();
    if(m_plug->getDirection() == PlugDirection::OUT){
        edge = scene->getEdge(m_plug, other.data());
    } else {
        edge = scene->getEdge(other.data(), m_plug);
    }
    if(!edge){
        return false;
    }
    scene->removeEdge(edge);
    return true;
}
Exemplo n.º 3
0
relarank::PlugHandle NodeCtrl::addPlug(const QString & name, bool incoming)
{
    PlugHandle
    newPlug;
    if (incoming) {
        newPlug = m_node.createIncomingPlug(name);
    } else {
        newPlug = m_node.createOutgoingPlug(name);
    }
    Q_ASSERT(newPlug.isValid());
    m_plugs.insert(newPlug, QList < PlugHandle > ());
    return newPlug;
}
Exemplo n.º 4
0
bool NodeCtrl::removePlug(const QString & name)
{
    // get the plug that is about to be removed
    PlugHandle plug = m_node.getPlug(name);
    if (!plug.isValid() || !plug.isRemovable()) {
        return false;
    }
    // remove all references to the plug
    Q_ASSERT(m_plugs.contains(plug));
    Q_ASSERT(m_plugs[plug].size() == 0);
    m_plugs.remove(plug);
    // remove the plug
    bool result = plug.remove();
    Q_ASSERT(result);
    return result;
}
Exemplo n.º 5
0
QString NodeCtrl::renamePlug(const QString & oldName, const QString & newName)
{
    if (newName == oldName) {
        return oldName;
    }
    PlugHandle plug = m_node.getPlug(oldName);
    if (!plug.isValid()) {
        // return the empty string if there is no plug by the given name
        return "";
    }
    // disconnect all connected plugs
    if (plug.isIncoming()) {
        for (PlugHandle otherPlug : m_plugs.value(plug)) {
            m_manager->getCtrlForHandle(otherPlug.getNode())->
            outputDisconnected(otherPlug, plug);
        }
    } else {
        for (PlugHandle otherPlug : m_plugs.value(plug)) {
            m_manager->getCtrlForHandle(otherPlug.getNode())->
            inputDisconnected(otherPlug, plug);
        }
    }
    // rename the plug
    QString actualName = plug.rename(newName);
    // reconnect other plugs
    if (plug.isIncoming()) {
        for (PlugHandle otherPlug : m_plugs.value(plug)) {
            m_manager->getCtrlForHandle(otherPlug.getNode())->
            outputConnected(otherPlug, plug);
        }
    } else {
        for (PlugHandle otherPlug : m_plugs.value(plug)) {
            m_manager->getCtrlForHandle(otherPlug.getNode())->
            inputConnected(otherPlug, plug);
        }
    }
    return actualName;
}