| 129 | |
| 130 | |
| 131 | void RecursivelyCreateXml(const FlowScene &scene, QDomDocument &doc, QDomElement& parent_element, const Node *node) |
| 132 | { |
| 133 | |
| 134 | const QtNodes::NodeDataModel* node_model = node->nodeDataModel(); |
| 135 | const std::string model_name = node_model->name().toStdString(); |
| 136 | |
| 137 | const auto* bt_node = dynamic_cast<const BehaviorTreeDataModel*>(node_model); |
| 138 | |
| 139 | QString registration_name = bt_node->registrationName(); |
| 140 | QDomElement element; |
| 141 | |
| 142 | if( BuiltinNodeModels().count(registration_name) != 0) |
| 143 | { |
| 144 | element = doc.createElement( registration_name.toStdString().c_str() ); |
| 145 | } |
| 146 | else{ |
| 147 | element = doc.createElement( QString::fromStdString(toStr(bt_node->nodeType())) ); |
| 148 | element.setAttribute("ID", registration_name.toStdString().c_str() ); |
| 149 | } |
| 150 | |
| 151 | |
| 152 | bool is_subtree_expanded = false; |
| 153 | if( auto subtree = dynamic_cast<const SubtreeNodeModel*>(node_model) ) |
| 154 | { |
| 155 | is_subtree_expanded = subtree->expanded(); |
| 156 | } |
| 157 | |
| 158 | if( bt_node->instanceName() != registration_name ) |
| 159 | { |
| 160 | element.setAttribute("name", bt_node->instanceName().toStdString().c_str() ); |
| 161 | } |
| 162 | |
| 163 | auto port_mapping = bt_node->getCurrentPortMapping(); |
| 164 | for(const auto& port_it: port_mapping) |
| 165 | { |
| 166 | element.setAttribute( port_it.first, port_it.second ); |
| 167 | } |
| 168 | |
| 169 | parent_element.appendChild( element ); |
| 170 | |
| 171 | if( !is_subtree_expanded ) |
| 172 | { |
| 173 | auto node_children = getChildren(scene, *node, true ); |
| 174 | for(const QtNodes::Node* child : node_children) |
| 175 | { |
| 176 | RecursivelyCreateXml(scene, doc, element, child ); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | bool VerifyXML(QDomDocument &doc, |
| 182 | const std::vector<QString>& registered_ID, |
no test coverage detected