| 445 | } |
| 446 | |
| 447 | void deleteSelection() |
| 448 | { |
| 449 | std::set<scene::INodePtr> eraseList; |
| 450 | |
| 451 | // Traverse the scene, collecting all selected nodes |
| 452 | GlobalSelectionSystem().foreachSelected([&] (const scene::INodePtr& node) |
| 453 | { |
| 454 | // Check for selected nodes whose parent is not NULL and are not root |
| 455 | if (node->getParent() != NULL && !node->isRoot()) |
| 456 | { |
| 457 | // Found a candidate |
| 458 | eraseList.insert(node); |
| 459 | } |
| 460 | }); |
| 461 | |
| 462 | std::for_each(eraseList.begin(), eraseList.end(), [] (const scene::INodePtr& node) |
| 463 | { |
| 464 | scene::INodePtr parent = node->getParent(); |
| 465 | |
| 466 | // Check for NULL parents. It's possible that both parent and child are in the eraseList |
| 467 | // and the parent has been deleted already. |
| 468 | if (parent) |
| 469 | { |
| 470 | // Remove the childnodes |
| 471 | scene::removeNodeFromParent(node); |
| 472 | |
| 473 | if (!parent->hasChildNodes()) |
| 474 | { |
| 475 | // Remove the parent as well |
| 476 | scene::removeNodeFromParent(parent); |
| 477 | } |
| 478 | } |
| 479 | }); |
| 480 | |
| 481 | SceneChangeNotify(); |
| 482 | } |
| 483 | |
| 484 | void deleteSelectionCmd(const cmd::ArgumentList& args) |
| 485 | { |
no test coverage detected