| 180 | } |
| 181 | |
| 182 | bool GraphicContainer::containsValidTree() const |
| 183 | { |
| 184 | if( _scene->nodes().empty()) |
| 185 | { |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | auto connections = _scene->connections(); |
| 190 | |
| 191 | std::set<const QtNodes::Node*> nodes_with_input; |
| 192 | std::set<const QtNodes::Node*> nodes_with_output; |
| 193 | |
| 194 | for (const auto& it: _scene->connections()) |
| 195 | { |
| 196 | const QtNodes::Connection* connection = it.second.get(); |
| 197 | auto node = connection->getNode( QtNodes::PortType::In); |
| 198 | if( node ){ |
| 199 | nodes_with_input.insert( node ); |
| 200 | } |
| 201 | node = connection->getNode( QtNodes::PortType::Out); |
| 202 | if( node ){ |
| 203 | nodes_with_output.insert( node ); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | for (const auto& it: _scene->nodes()) |
| 208 | { |
| 209 | const QtNodes::Node* node = it.second.get(); |
| 210 | if( node->nodeDataModel()->nPorts(QtNodes::PortType::In) == 1 ) |
| 211 | { |
| 212 | if( nodes_with_input.find(node) == nodes_with_input.end() ) |
| 213 | { |
| 214 | return false; |
| 215 | } |
| 216 | } |
| 217 | if( node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 1 ) |
| 218 | { |
| 219 | if( nodes_with_output.find(node) == nodes_with_output.end() ) |
| 220 | { |
| 221 | return false; |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | void GraphicContainer::clearScene() |
| 229 | { |
no test coverage detected