24#include "../../editors/ControlEditor.h"
26ControlElementContainer::ControlElementContainer()
30ControlElementContainer::~ControlElementContainer()
46void ControlElementContainer::FillContainer(
ControlEditor* editor)
49 m_ctrlElementsList = editor->GetControlElementList();
50 m_cLineList = editor->GetConnectionLineList();
52 for (
auto& cElement : m_ctrlElementsList) {
54 m_constantList.push_back(constant);
57 m_exponentialList.push_back(exponential);
59 else if (
Gain* gain =
dynamic_cast<Gain*
>(cElement.get())) {
60 m_gainList.push_back(gain);
63 m_ioControlList.push_back(ioControl);
65 else if (
Limiter* limiter =
dynamic_cast<Limiter*
>(cElement.get())) {
66 m_limiterList.push_back(limiter);
69 m_multiplierList.push_back(multiplier);
72 m_rateLimiterList.push_back(rateLimiter);
74 else if (
Sum* sum =
dynamic_cast<Sum*
>(cElement.get())) {
75 m_sumList.push_back(sum);
78 m_tfList.push_back(tf);
80 else if (
Divider* divider =
dynamic_cast<Divider*
>(cElement.get())) {
81 m_dividerList.push_back(divider);
84 m_mathExprList.push_back(mathExpr);
89void ControlElementContainer::ClearContainer()
92 m_constantList.clear();
93 m_exponentialList.clear();
95 m_ioControlList.clear();
96 m_limiterList.clear();
97 m_multiplierList.clear();
98 m_rateLimiterList.clear();
101 m_dividerList.clear();
102 m_mathExprList.clear();
105void ControlElementContainer::FillContainer(std::vector< std::shared_ptr<ControlElement> > controlElementList,
106 std::vector< std::shared_ptr<ConnectionLine> > connectionLineList)
109 m_ctrlElementsList = controlElementList;
110 m_cLineList = connectionLineList;
112 for (
auto it = controlElementList.begin(), itEnd = controlElementList.end(); it != itEnd; ++it) {
114 m_constantList.push_back(constant);
117 m_exponentialList.push_back(exponential);
119 else if (
Gain* gain =
dynamic_cast<Gain*
>(it->get())) {
120 m_gainList.push_back(gain);
123 m_ioControlList.push_back(ioControl);
126 m_limiterList.push_back(limiter);
129 m_multiplierList.push_back(multiplier);
132 m_rateLimiterList.push_back(rateLimiter);
134 else if (
Sum* sum =
dynamic_cast<Sum*
>(it->get())) {
135 m_sumList.push_back(sum);
138 m_tfList.push_back(tf);
141 m_dividerList.push_back(divider);
144 m_mathExprList.push_back(mathExpr);
149void ControlElementContainer::GetContainerCopy(std::vector< std::shared_ptr<ControlElement> >& controlElementList,
150 std::vector< std::shared_ptr<ConnectionLine> >& connectionLineList)
152 controlElementList.clear();
153 connectionLineList.clear();
155 std::map<Element*, Element*> cLineMap;
156 std::map<Element*, Element*> cElementMap;
159 for (
auto& cLine : m_cLineList) {
161 connectionLineList.emplace_back(copyLine);
162 cLineMap[cLine.get()] = copyLine;
166 std::map<Node*, Node*> nodeMap;
167 for (
auto& cElement : m_ctrlElementsList) {
169 cElementMap[cElement.get()] = copyElement;
170 controlElementList.emplace_back(copyElement);
172 std::vector<Node*> nodeListCopy;
173 for (
Node* node : copyElement->GetNodeList()) {
174 Node* copyNode = node->GetCopy();
175 nodeMap[node] = copyNode;
176 nodeListCopy.push_back(copyNode);
178 copyElement->SetNodeList(nodeListCopy);
182 for (
auto& copyElement : controlElementList) {
184 for (
Element* child : copyElement->GetChildList()) {
185 auto it = cLineMap.find(child);
186 if (it != cLineMap.end())
190 for (
auto& copyLine : connectionLineList) {
192 for (
Node* node : copyLine->GetNodeList()) {
193 auto it = nodeMap.find(node);
194 if (it != nodeMap.end())
195 copyLine->ReplaceNode(node, it->second);
199 for (
Element* parent : copyLine->GetParentList()) {
200 auto it = cElementMap.find(parent);
201 if (it != cElementMap.end())
205 Element* parentLine =
static_cast<Element*
>(copyLine->GetParentLine());
206 auto it = cLineMap.find(parentLine);
207 if (it != cLineMap.end())
208 copyLine->SetParentLine(
static_cast<ConnectionLine*
>(it->second));
210 copyLine->SetParentLine(
nullptr);
213 for (
Element* child : copyLine->GetChildList()) {
214 auto it = cLineMap.find(child);
216 if (it != cLineMap.end())
Base class of a control element. Provide general methods to other control classes.
Connection between two control elements or other connection line and an element.
A control element that provides a constant value.
Control element that divides two inputs.
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
virtual void ReplaceParent(Element *oldParent, Element *newParent)
Replace a parent.
virtual void ReplaceChild(Element *oldChild, Element *newChild)
Replace a child from the list.
Generates an output following an exponential function.
Provide an output multiplying the input by a constant.
Provides the communication with the power element.
Limits the input value by superior and inferior values.
A generic math expression block that can perform math and conditional operations with the inputs.
Node of a control element. This class manages the user interaction with the connection and control el...
Limits the rising and/or falling rate.
Sum the all inputs (can choose the input signal).
Calculates the time response by a frequency domain transfer function.