MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / createSmartRemoveAction

Method createSmartRemoveAction

bt_editor/graphic_container.cpp:492–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492void GraphicContainer::createSmartRemoveAction(QtNodes::Node &node, QMenu* node_menu)
493{
494 auto *smart_remove = new QAction("Smart Remove ", node_menu);
495 node_menu->addAction(smart_remove);
496
497 NodeState::ConnectionPtrSet conn_in = node.nodeState().connections(PortType::In, 0);
498 NodeState::ConnectionPtrSet conn_out = node.nodeState().connections(PortType::Out, 0);
499
500 if( conn_in.size() != 1 || conn_out.size() == 0 )
501 {
502 smart_remove->setEnabled(false);
503 return;
504 }
505
506 auto parent_node = conn_in.begin()->second->getNode(PortType::Out);
507 auto policy = parent_node->nodeDataModel()->portOutConnectionPolicy(0);
508
509 if( policy == NodeDataModel::ConnectionPolicy::One && conn_out.size() > 1)
510 {
511 smart_remove->setEnabled(false);
512 return;
513 }
514
515 QtNodes::Node* node_ptr = &node;
516 connect( smart_remove, &QAction::triggered,
517 this, [this, node_ptr]()
518 {
519 onSmartRemove(node_ptr);
520 });
521}
522
523void GraphicContainer::onSmartRemove(QtNodes::Node* node)
524{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected