diff --git a/bt_editor/bt_editor_base.cpp b/bt_editor/bt_editor_base.cpp index 29609aab..92934878 100644 --- a/bt_editor/bt_editor_base.cpp +++ b/bt_editor/bt_editor_base.cpp @@ -1,6 +1,9 @@ #include "bt_editor_base.h" #include #include +#include +#include +#include "XML_utilities.hpp" void AbsBehaviorTree::clear() { @@ -208,6 +211,28 @@ const NodeModels &BuiltinNodeModels() groot_model = bt_model; out.insert( { QString::fromStdString(model_name), std::move(groot_model) }); } + + QString fileName = "custommed.xml"; + if (QFileInfo::exists(fileName)) { + QFile file(fileName); + file.open(QIODevice::ReadOnly); + QString xml_text; + QTextStream in(&file); + while (!in.atEnd()) { + xml_text += in.readLine(); + } + + QDomDocument document; + if (document.setContent(xml_text)) { + for (const auto &it : ReadTreeNodesModel(document.documentElement())) { + const auto &model_name = it.first; + if (model_name == "SubTree" || model_name == "SubTreePlus") { + continue; + } + out.insert({model_name, std::move(it.second)}); + } + } + } return out; }(); diff --git a/bt_editor/graphic_container.cpp b/bt_editor/graphic_container.cpp index 6bdd5c5e..d88cf73a 100644 --- a/bt_editor/graphic_container.cpp +++ b/bt_editor/graphic_container.cpp @@ -482,7 +482,7 @@ void GraphicContainer::createMorphSubMenu(QtNodes::Node &node, QMenu* nodeMenu) } else { - std::vector v;; + std::vector v; v.insert(v.end(), names_in_category.begin(), names_in_category.end()); std::sort(v.begin(), v.end()); for(auto& name: v) @@ -597,7 +597,10 @@ void GraphicContainer::onConnectionContextMenu(QtNodes::Connection &connection, submenu->setEnabled(false); } else{ - for(auto& name: model_names) + std::vector v; + v.insert(v.end(), model_names.begin(), model_names.end()); + std::sort(v.begin(), v.end()); + for(auto& name: v) { auto action = new QAction(name, submenu); submenu->addAction(action);