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

Method createMorphSubMenu

bt_editor/graphic_container.cpp:462–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460
461
462void GraphicContainer::createMorphSubMenu(QtNodes::Node &node, QMenu* nodeMenu)
463{
464 auto bt_model = dynamic_cast<BehaviorTreeDataModel*>( node.nodeDataModel() );
465 const QString category ( QString::fromStdString( toStr( bt_model->nodeType()) ));
466
467 auto names_in_category = _model_registry->registeredModelsByCategory( category );
468 names_in_category.erase( node.nodeDataModel()->name() );
469
470 QMenu* morph_submenu = nodeMenu->addMenu("Morph into...");
471
472 if( names_in_category.size() == 0)
473 {
474 morph_submenu->setEnabled(false);
475 }
476 else
477 {
478 for(auto& name: names_in_category)
479 {
480 auto action = new QAction(name, morph_submenu);
481 morph_submenu->addAction(action);
482
483 connect( action, &QAction::triggered, this, [this, &node, name]
484 {
485 substituteNode( &node, name);
486 undoableChange();
487 });
488 }
489 }
490}
491
492void GraphicContainer::createSmartRemoveAction(QtNodes::Node &node, QMenu* node_menu)
493{

Callers

nothing calls this directly

Calls 4

toStrFunction · 0.85
nodeTypeMethod · 0.80
nameMethod · 0.80

Tested by

no test coverage detected