26 for (
auto& node : m_nodeList) if (node) delete node;
43void Divider::DrawDCSymbol(wxGraphicsContext* gc)
const
46 gc->SetPen(wxPen(wxColour(0, 77, 255, 255), 2));
47 gc->SetBrush(*wxTRANSPARENT_BRUSH);
48 wxPoint2DDouble mSymbol[2];
49 mSymbol[0] = m_position + wxPoint2DDouble(-5, 0);
50 mSymbol[1] = m_position + wxPoint2DDouble(5, 0);
51 gc->StrokeLines(2, mSymbol);
53 gc->SetPen(*wxTRANSPARENT_PEN);
54 gc->SetBrush(wxBrush(wxColour(0, 77, 255, 255)));
55 DrawDCCircle(m_position + wxPoint2DDouble(0, -3), 2, 10, gc);
56 DrawDCCircle(m_position + wxPoint2DDouble(0, 3), 2, 10, gc);
59bool Divider::Solve(
double* input,
double timeStep)
62 std::vector<double> inputVector;
63 for(
auto itN = m_nodeList.begin(), itNEnd = m_nodeList.end(); itN != itNEnd; ++itN) {
65 if(node->GetNodeType() != Node::NodeType::NODE_OUT) {
66 if(!node->IsConnected()) {
67 inputVector.push_back(0.0);
69 for(
auto itC = m_childList.begin(), itCEnd = m_childList.end(); itC != itCEnd; ++itC) {
71 auto nodeList = cLine->GetNodeList();
72 for(
auto itCN = nodeList.begin(), itCNEnd = nodeList.end(); itCN != itCNEnd; ++itCN) {
73 Node* childNode = *itCN;
74 if(childNode == node) {
75 inputVector.push_back(cLine->GetValue());
83 if(inputVector.size() != 2)
return false;
86 if(std::abs(inputVector[1]) < 1e-15) {
89 m_output = inputVector[0] / inputVector[1];
101rapidxml::xml_node<>* Divider::SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode)
103 auto elementNode = XMLParser::AppendNode(doc, elementListNode,
"Divider");
104 XMLParser::SetNodeAttribute(doc, elementNode,
"ID", m_elementID);
106 SaveCADProperties(doc, elementNode);
107 SaveControlNodes(doc, elementNode);
112bool Divider::OpenElement(rapidxml::xml_node<>* elementNode)
114 if(!OpenCADProperties(elementNode))
return false;
115 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...