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

Method saveToXML

bt_editor/mainwindow.cpp:403–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403QString MainWindow::saveToXML() const
404{
405 QDomDocument doc;
406
407 const char* COMMENT_SEPARATOR = " ////////// ";
408
409 QDomElement root = doc.createElement( "root" );
410 doc.appendChild( root );
411
412 if( _main_tree.isEmpty() == false)
413 {
414 root.setAttribute("main_tree_to_execute", _main_tree.toStdString().c_str());
415 }
416
417 for (auto& it: _tab_info)
418 {
419 auto& container = it.second;
420 auto scene = container->scene();
421
422 auto abs_tree = BuildTreeFromScene(container->scene());
423 auto abs_root = abs_tree.rootNode();
424 if( abs_root->children_index.size() == 1 &&
425 abs_root->model.registration_ID == "Root" )
426 {
427 // mofe to the child of ROOT
428 abs_root = abs_tree.node( abs_root->children_index.front() );
429 }
430
431 QtNodes::Node* root_node = abs_root->graphic_node;
432
433 root.appendChild( doc.createComment(COMMENT_SEPARATOR) );
434 QDomElement root_element = doc.createElement("BehaviorTree");
435
436 root_element.setAttribute("ID", it.first.toStdString().c_str());
437 root.appendChild(root_element);
438
439 RecursivelyCreateXml(*scene, doc, root_element, root_node );
440 }
441 root.appendChild( doc.createComment(COMMENT_SEPARATOR) );
442
443 QDomElement root_models = doc.createElement("TreeNodesModel");
444
445 for(const auto& tree_it: _treenode_models)
446 {
447 const auto& ID = tree_it.first;
448 const auto& model = tree_it.second;
449
450 if( BuiltinNodeModels().count(ID) != 0 )
451 {
452 continue;
453 }
454
455
456 QDomElement node = doc.createElement( QString::fromStdString(toStr(model.type)) );
457
458 if( !node.isNull() )
459 {
460 node.setAttribute("ID", ID);

Callers 1

loadFileMethod · 0.80

Calls 7

BuildTreeFromSceneFunction · 0.85
RecursivelyCreateXmlFunction · 0.85
toStrFunction · 0.85
writePortModelFunction · 0.85
sceneMethod · 0.80
rootNodeMethod · 0.80
nodeMethod · 0.80

Tested by 1

loadFileMethod · 0.64