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) {
57 ConnectionLine* cLine =
static_cast<ConnectionLine*
>(*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];
84 Divider* copy =
new Divider(*
this);
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;
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.
virtual Element * GetCopy()
Get a the element copy.
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.