26 for (
auto& node : m_nodeList) if (node) delete node;
30void Divider::DrawDCSymbol(
GUIColour* guiColour, wxGraphicsContext* gc)
const
33 gc->SetPen(wxPen(guiColour->bus, 2));
34 gc->SetBrush(*wxTRANSPARENT_BRUSH);
35 wxPoint2DDouble mSymbol[2];
36 mSymbol[0] = m_position + wxPoint2DDouble(-5, 0);
37 mSymbol[1] = m_position + wxPoint2DDouble(5, 0);
38 gc->StrokeLines(2, mSymbol);
40 gc->SetPen(*wxTRANSPARENT_PEN);
41 gc->SetBrush(wxBrush(guiColour->bus));
42 DrawDCCircle(m_position + wxPoint2DDouble(0, -3), 2, 10, gc);
43 DrawDCCircle(m_position + wxPoint2DDouble(0, 3), 2, 10, gc);
46bool Divider::Solve(
double* input,
double timeStep)
49 std::vector<double> inputVector;
50 for(
auto itN = m_nodeList.begin(), itNEnd = m_nodeList.end(); itN != itNEnd; ++itN) {
52 if(node->GetNodeType() != Node::NodeType::NODE_OUT) {
53 if(!node->IsConnected()) {
54 inputVector.push_back(0.0);
56 for(
auto itC = m_childList.begin(), itCEnd = m_childList.end(); itC != itCEnd; ++itC) {
58 auto nodeList = cLine->GetNodeList();
59 for(
auto itCN = nodeList.begin(), itCNEnd = nodeList.end(); itCN != itCNEnd; ++itCN) {
60 Node* childNode = *itCN;
61 if(childNode == node) {
62 inputVector.push_back(cLine->GetValue());
70 if(inputVector.size() != 2)
return false;
73 if(std::abs(inputVector[1]) < 1e-15) {
76 m_output = inputVector[0] / inputVector[1];
88rapidxml::xml_node<>* Divider::SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode)
90 auto elementNode = XMLParser::AppendNode(doc, elementListNode,
"Divider");
91 XMLParser::SetNodeAttribute(doc, elementNode,
"ID", m_elementID);
93 SaveCADProperties(doc, elementNode);
94 SaveControlNodes(doc, elementNode);
99bool Divider::OpenElement(rapidxml::xml_node<>* elementNode)
101 if(!OpenCADProperties(elementNode))
return false;
102 if(!OpenControlNodes(elementNode))
return false;
Connection between two control elements or other connection line and an element.
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.
Control element that divides two inputs.
virtual Element * GetCopy()
Get a the element copy.
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
virtual void DrawDCCircle(wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
Draw a circle using device context.
Abstract class that define the general behavior of math operation control block.
Node of a control element. This class manages the user interaction with the connection and control el...