bool PlugHandle::connectPlug(PlugHandle other) { #ifdef QT_DEBUG Q_ASSERT(m_isValid); #else if(!m_isValid){ return false; } #endif if(m_plug->getDirection() == PlugDirection::OUT){ return m_plug->getNode()->getScene()->createEdge(m_plug, other.data()) != nullptr; } else { return m_plug->getNode()->getScene()->createEdge(other.data(), m_plug) != nullptr; } }
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; }