void HierarchyTreeNode::PrepareRemoveFromSceneInformation() { if (!GetParent()) { this->redoParentNode = NULL; this->redoPreviousNode = NULL; return; } this->redoParentNode = GetParent(); this->redoPreviousNode = NULL; HierarchyTreeNode* parentNode = GetParent(); // Look for the Redo Node in the Children List, and remember the previous one. // This is needed to restore the previous node position in case of Redo. for (List<HierarchyTreeNode*>::const_iterator iter = parentNode->GetChildNodes().begin(); iter != parentNode->GetChildNodes().end(); iter ++) { if ((*iter == this) && (iter != parentNode->GetChildNodes().begin())) { iter --; this->redoPreviousNode = (*iter); break; } } }
void ChangeNodeHeirarchy::StorePreviousParents() { for (HierarchyTreeNode::HIERARCHYTREENODESIDLIST::iterator iter = items.begin(); iter != items.end(); ++iter) { HierarchyTreeNode* node = HierarchyTreeController::Instance()->GetTree().GetNode((*iter)); if (!node) { continue; } HierarchyTreeNode* parentNode = node->GetParent(); if (!parentNode) { continue; } HierarchyTreeNode::HIERARCHYTREENODEID addAfter = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY; HierarchyTreeNode::HIERARCHYTREENODEID lastId = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY; const HierarchyTreeNode::HIERARCHYTREENODESLIST& childs = parentNode->GetChildNodes(); for (HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator citer = childs.begin(); citer != childs.end(); ++citer) { if (node == (*citer)) addAfter = lastId; lastId = (*citer)->GetId(); } // The Previous Parents are stored in the "item ID - parent ID" map. this->previousParents.insert(std::make_pair(*iter, PreviousState(parentNode->GetId(), addAfter))); } }