From c6c3ff70bfceac839af471c11fc8aa04060517b0 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Mon, 15 May 2017 21:50:48 -0300 Subject: Control test and sync generator control implemented Text buggy when opens --- Project/ControlElementContainer.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Project/ControlElementContainer.cpp') diff --git a/Project/ControlElementContainer.cpp b/Project/ControlElementContainer.cpp index e461529..f8accdc 100644 --- a/Project/ControlElementContainer.cpp +++ b/Project/ControlElementContainer.cpp @@ -50,6 +50,29 @@ void ControlElementContainer::ClearContainer() void ControlElementContainer::FillContainer(std::vector controlElementList, std::vector connectionLineList) { + ClearContainer(); m_ctrlElementsList = controlElementList; m_cLineList = connectionLineList; + + for(auto it = controlElementList.begin(), itEnd = controlElementList.end(); it != itEnd; ++it) { + if(Constant* constant = dynamic_cast(*it)) { + m_constantList.push_back(constant); + } else if(Exponential* exponential = dynamic_cast(*it)) { + m_exponentialList.push_back(exponential); + } else if(Gain* gain = dynamic_cast(*it)) { + m_gainList.push_back(gain); + } else if(IOControl* ioControl = dynamic_cast(*it)) { + m_ioControlList.push_back(ioControl); + } else if(Limiter* limiter = dynamic_cast(*it)) { + m_limiterList.push_back(limiter); + } else if(Multiplier* multiplier = dynamic_cast(*it)) { + m_multiplierList.push_back(multiplier); + } else if(RateLimiter* rateLimiter = dynamic_cast(*it)) { + m_rateLimiterList.push_back(rateLimiter); + } else if(Sum* sum = dynamic_cast(*it)) { + m_sumList.push_back(sum); + } else if(TransferFunction* tf = dynamic_cast(*it)) { + m_tfList.push_back(tf); + } + } } -- cgit From 1158ce068e3b5b391604270bf10c52d0d2f7f4db Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 16 May 2017 19:07:49 -0300 Subject: Sync generator control fixed --- Project/ControlElementContainer.cpp | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'Project/ControlElementContainer.cpp') 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 control } } } + +void ControlElementContainer::GetContainerCopy(std::vector& controlElementList, + std::vector& 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((*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(oldElement->GetCopy()); + controlElementList.push_back(copy); + // Copy nodes. + std::vector nodeList = copy->GetNodeList(); + std::vector 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(*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); + } + } + } + } +} -- cgit