summaryrefslogtreecommitdiffstats
path: root/Project/ControlElementContainer.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-16 19:07:49 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-16 19:07:49 -0300
commit1158ce068e3b5b391604270bf10c52d0d2f7f4db (patch)
tree7e9b770ede3c0592f631b9e6982be55d2173ea04 /Project/ControlElementContainer.cpp
parentc6c3ff70bfceac839af471c11fc8aa04060517b0 (diff)
downloadPSP.git-1158ce068e3b5b391604270bf10c52d0d2f7f4db.tar.gz
PSP.git-1158ce068e3b5b391604270bf10c52d0d2f7f4db.tar.xz
PSP.git-1158ce068e3b5b391604270bf10c52d0d2f7f4db.zip
Sync generator control fixed
Diffstat (limited to 'Project/ControlElementContainer.cpp')
-rw-r--r--Project/ControlElementContainer.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/Project/ControlElementContainer.cpp b/Project/ControlElementContainer.cpp
index f8accdc..edfe684 100644
--- a/Project/ControlElementContainer.cpp
+++ b/Project/ControlElementContainer.cpp
@@ -76,3 +76,62 @@ void ControlElementContainer::FillContainer(std::vector<ControlElement*> control
}
}
}
+
+void ControlElementContainer::GetContainerCopy(std::vector<ControlElement*>& controlElementList,
+ std::vector<ConnectionLine*>& connectionLineList)
+{
+ controlElementList.clear();
+ connectionLineList.clear();
+
+ // Copy connection lines
+ for(auto it = m_cLineList.begin(), itEnd = m_cLineList.end(); it != itEnd; ++it) {
+ ConnectionLine* copy = static_cast<ConnectionLine*>((*it)->GetCopy());
+ connectionLineList.push_back(copy);
+ }
+
+ // Copy elements (exept connection line).
+ int nodeID = 0;
+ for(auto it = m_ctrlElementsList.begin(), itEnd = m_ctrlElementsList.end(); it != itEnd; ++it) {
+ Element* oldElement = *it;
+ ControlElement* copy = static_cast<ControlElement*>(oldElement->GetCopy());
+ controlElementList.push_back(copy);
+ // Copy nodes.
+ std::vector<Node*> nodeList = copy->GetNodeList();
+ std::vector<Node*> nodeListCopy;
+ for(auto itN = nodeList.begin(), itEndN = nodeList.end(); itN != itEndN; ++itN) {
+ Node* node = *itN;
+ node->SetID(nodeID);
+ Node* copyNode = new Node();
+ *copyNode = *node;
+ nodeListCopy.push_back(copyNode);
+ nodeID++;
+ }
+ copy->SetNodeList(nodeListCopy);
+
+ // Replace children to copies.
+ auto childList = copy->GetChildList();
+ for(auto itC = childList.begin(), itEndC = childList.end(); itC != itEndC; ++itC) {
+ ConnectionLine* child = static_cast<ConnectionLine*>(*itC);
+ // Replace child's parent to copy.
+ for(auto itCL = connectionLineList.begin(), itEndCL = connectionLineList.end(); itCL != itEndCL; ++itCL) {
+ ConnectionLine* copyLine = *itCL;
+ if(copyLine->GetID() == child->GetID()) {
+ // Replace node.
+ nodeList = child->GetNodeList();
+ for(auto itN = nodeList.begin(), itEndN = nodeList.end(); itN != itEndN; ++itN) {
+ Node* node = *itN;
+ for(auto itCN = nodeListCopy.begin(), itEndCN = nodeListCopy.end(); itCN != itEndCN; ++itCN) {
+ Node* nodeCopy = *itCN;
+ if(node->GetID() == nodeCopy->GetID()) {
+ copyLine->ReplaceNode(node, nodeCopy);
+ break;
+ }
+ }
+ }
+ copyLine->ReplaceParent(oldElement, copy);
+ copy->ReplaceChild(child, copyLine);
+ }
+ }
+ }
+ }
+}