| 70 | } |
| 71 | |
| 72 | void SceneGraph::setRoot(const IMapRootNodePtr& newRoot) |
| 73 | { |
| 74 | if (_root == newRoot) |
| 75 | { |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | _undoEventHandler.disconnect(); |
| 80 | |
| 81 | if (_root) |
| 82 | { |
| 83 | // "Uninstantiate" the whole scene |
| 84 | UninstanceSubgraphWalker walker(*this); |
| 85 | _root->traverse(walker); |
| 86 | } |
| 87 | |
| 88 | _root = newRoot; |
| 89 | |
| 90 | // Refresh the space partition class |
| 91 | _spacePartition = std::make_shared<Octree>(); |
| 92 | |
| 93 | if (_root) |
| 94 | { |
| 95 | // New root not NULL, "instantiate" the whole scene |
| 96 | GraphPtr self = shared_from_this(); |
| 97 | InstanceSubgraphWalker instanceWalker(self); |
| 98 | _root->traverse(instanceWalker); |
| 99 | |
| 100 | _undoEventHandler = _root->getUndoSystem().signal_undoEvent().connect( |
| 101 | sigc::mem_fun(this, &SceneGraph::onUndoEvent) |
| 102 | ); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | void SceneGraph::onUndoEvent(IUndoSystem::EventType type, const std::string& operationName) |
| 107 | { |
no test coverage detected