| 36 | } |
| 37 | |
| 38 | std::vector<Node*> getChildren(const QtNodes::FlowScene &scene, |
| 39 | const Node& parent_node, |
| 40 | bool ordered) |
| 41 | { |
| 42 | std::vector<Node*> children; |
| 43 | |
| 44 | if( parent_node.nodeDataModel()->nPorts(PortType::Out) == 0) |
| 45 | { |
| 46 | return children; |
| 47 | } |
| 48 | |
| 49 | const auto& conn_out = parent_node.nodeState().connections(PortType::Out, 0); |
| 50 | children.reserve( conn_out.size() ); |
| 51 | |
| 52 | for( auto& it: conn_out) |
| 53 | { |
| 54 | auto child_node = it.second->getNode(PortType::In); |
| 55 | if( child_node ) |
| 56 | { |
| 57 | children.push_back( child_node ); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | if( ordered && children.size() > 1) |
| 62 | { |
| 63 | if( scene.layout() == PortLayout::Vertical) |
| 64 | { |
| 65 | std::sort(children.begin(), children.end(), |
| 66 | [&](const Node* a, const Node* b) |
| 67 | { |
| 68 | double pos_a = scene.getNodePosition( *a ).x() + scene.getNodeSize( *a ).width()*0.5; |
| 69 | double pos_b = scene.getNodePosition( *b ).x() + scene.getNodeSize( *b ).width()*0.5; |
| 70 | return pos_a < pos_b; |
| 71 | } ); |
| 72 | } |
| 73 | else{ |
| 74 | std::sort(children.begin(), children.end(), |
| 75 | [&](const Node* a, const Node* b) |
| 76 | { |
| 77 | double pos_a = scene.getNodePosition( *a ).y() + scene.getNodeSize( *a ).height()*0.5; |
| 78 | double pos_b = scene.getNodePosition( *b ).y() + scene.getNodeSize( *b ).height()*0.5; |
| 79 | return pos_a < pos_b; |
| 80 | } ); |
| 81 | } |
| 82 | } |
| 83 | return children; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | //--------------------------------------------------- |
no test coverage detected