| 89 | |
| 90 | |
| 91 | bool |
| 92 | NodeConnectionInteraction:: |
| 93 | tryConnect() const |
| 94 | { |
| 95 | // 1) Check conditions from 'canConnect' |
| 96 | PortIndex portIndex = INVALID; |
| 97 | |
| 98 | TypeConverter converter; |
| 99 | |
| 100 | if (!canConnect(portIndex, converter)) |
| 101 | { |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | // 1.5) If the connection is possible but a type conversion is needed, |
| 106 | // assign a convertor to connection |
| 107 | if (converter) |
| 108 | { |
| 109 | _connection->setTypeConverter(converter); |
| 110 | } |
| 111 | |
| 112 | // 2) Assign node to required port in Connection |
| 113 | PortType requiredPort = connectionRequiredPort(); |
| 114 | _node->nodeState().setConnection(requiredPort, |
| 115 | portIndex, |
| 116 | *_connection); |
| 117 | |
| 118 | // 3) Assign Connection to empty port in NodeState |
| 119 | // The port is not longer required after this function |
| 120 | _connection->setNodeToPort(*_node, requiredPort, portIndex); |
| 121 | |
| 122 | // 4) Adjust Connection geometry |
| 123 | |
| 124 | _node->nodeGraphicsObject().moveConnections(); |
| 125 | |
| 126 | // 5) Poke model to intiate data transfer |
| 127 | |
| 128 | auto outNode = _connection->getNode(PortType::Out); |
| 129 | if (outNode) |
| 130 | { |
| 131 | PortIndex outPortIndex = _connection->getPortIndex(PortType::Out); |
| 132 | outNode->onDataUpdated(outPortIndex); |
| 133 | } |
| 134 | |
| 135 | return true; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | /// 1) Node and Connection should be already connected |
nothing calls this directly
no outgoing calls
no test coverage detected