Power System Platform  2026w23a-beta
Loading...
Searching...
No Matches
Sum Class Reference

Sum the all inputs (can choose the input signal). More...

#include <Sum.h>

Inheritance diagram for Sum:
Collaboration diagram for Sum:

Public Types

enum  Signal { SIGNAL_POSITIVE = 0 , SIGNAL_NEGATIVE }
 

Public Member Functions

 Sum (int id)
 
virtual void DrawDC (GUIColour *guiColour, wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
 Draw the element using GDI+.
 
virtual bool Contains (wxPoint2DDouble position) const
 Checks if the element contains a position.
 
virtual bool Intersects (wxRect2DDouble rect) const
 Check if the element's rect intersects other rect.
 
virtual bool ShowForm (wxWindow *parent, Element *element, wxWindow *workspace=nullptr)
 Show element data form.
 
virtual void Rotate (bool clockwise=true)
 Rotate the element.
 
virtual std::vector< Signal > GetSignalList () const
 
virtual void SetSignalList (std::vector< Signal > signalList)
 
virtual bool Solve (double *input, double timeStep)
 
virtual void UpdatePoints ()
 
void AddInNode ()
 
void RemoveInNode ()
 
virtual rapidxml::xml_node * SaveElement (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementListNode)
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode)
 
virtual ElementGetCopy ()
 Get a the element copy.
 
- Public Member Functions inherited from ControlElement
 ControlElement (int id)
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement.
 
virtual void Move (wxPoint2DDouble position)
 Move the element other position.
 
virtual void SetFont (wxFont &font)
 
void SetNodeList (std::vector< Node * > nodeList)
 
std::vector< Node * > GetNodeList () const
 
virtual void DrawDCNodes (wxGraphicsContext *gc) const
 
virtual void ReplaceNode (Node *oldNode, Node *newNode)
 
virtual bool UpdateText ()
 Update the OpenGL text in the element (if present).
 
virtual bool IsSolved () const
 
virtual void SetSolved (bool solved=true)
 
virtual bool Initialize ()
 
virtual double GetOutput () const
 
virtual void SetOutput (double output)
 
- Public Member Functions inherited from Element
 Element ()
 Constructor.
 
virtual ~Element ()
 Destructor.
 
void SetDragging (bool dragging=true)
 Set if the element are being dragged.
 
void SetHeight (double height)
 Set element height.
 
void SetPosition (const wxPoint2DDouble position)
 Set the element position and update the rectangle.
 
void SetSelected (bool selected=true)
 Set element selection.
 
void SetWidth (double width)
 Set element width.
 
void SetAngle (double angle)
 Set element angle.
 
void ShowPickbox (bool showPickbox=true)
 Set if the pickbox is shown.
 
void SetBorderSize (double borderSize)
 Set the size of the border (shown in selected elements).
 
bool SetOnline (bool online=true)
 Set if the element is online or offline.
 
virtual void SetPointList (std::vector< wxPoint2DDouble > pointList)
 Set the list of points that connect the element to the bus.
 
ElementType GetElementType ()
 
wxRect2DDouble GetRect () const
 Get the element rectangle.
 
wxPoint2DDouble GetPosition () const
 Get the element position.
 
bool IsDragging () const
 Checks if the element is being dragged.
 
double GetHeight () const
 Get the element height.
 
bool IsSelected () const
 Checks if the element is selected.
 
double GetWidth () const
 Get the element width.
 
double GetAngle () const
 Get the element angle.
 
double GetRotationAngle () const
 Get the angle of rotation.
 
bool IsPickboxShown () const
 Checks if the pickbox is shown.
 
bool IsOnline () const
 Checks if the element is online or offline.
 
virtual std::vector< wxPoint2DDouble > GetPointList () const
 Get the list of points that connect the element to bus.
 
virtual bool AddParent (Element *parent, wxPoint2DDouble position)
 Add a parent to the element. This method must be used on power elements that connect to a bus, so the parent must be a bus. The element basic points are calculated in this method, so apply this when the element is being inserted.
 
virtual void AddParent (Element *parent)
 Add a parent to the element.
 
virtual void SetID (int id)
 Set the element ID.
 
virtual int GetID () const
 Get the element ID.
 
virtual void AddChild (Element *child)
 Add a child to the child list.
 
virtual void RemoveChild (Element *child)
 Remove a child from the list.
 
virtual void ReplaceChild (Element *oldChild, Element *newChild)
 Replace a child from the list.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual void DrawDC (GUIColour *guiColour, wxPoint2DDouble translation, double scale, wxDC &dc) const
 Draw the element using wxDC.
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu.
 
virtual void AddPoint (wxPoint2DDouble point)
 Add point to the list of points that connect the element to the bus.
 
virtual void MoveNode (Element *parent, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving.
 
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement.
 
virtual void UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
void SetParent (Element *parent, int num)
 
void SetChild (Element *child, int num)
 
virtual bool SetNodeParent (Element *parent)
 Set a perent to the node. If all conditions are met, a new parent are added to the element and the points related to the nodes will be calculated.
 
virtual void RemoveParent (Element *parent)
 Remove a parent.
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent.
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node.
 
virtual bool PickboxContains (wxPoint2DDouble position)
 Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.
 
virtual void MovePickbox (wxPoint2DDouble position)
 Move the pickbox.
 
virtual wxCursor GetBestPickboxCursor () const
 Get the best cursor to shown to the user when the mouse is above a pickbox.
 
virtual void ResetPickboxes ()
 Remove the pickboxes.
 
virtual void ResetNodes ()
 Remove the active nodes.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert the element position to screen position.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble position, wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert a generic position to screen position.
 
virtual bool RotatedRectanglesIntersects (wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
 Check if two roteted rectangles intersect.
 
virtual void DrawDCRectangle (wxPoint2DDouble position, double width, double height, double angle, wxDC &dc) const
 Draw a circle.
 
virtual void DrawDCRoundedRectRotated (wxDC &dc, const wxPoint2DDouble &center, double width, double height, double radius, double angleDeg, int arcSegments=8) const
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
 Draw a circle using device context.
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, wxDC &dc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, wxGraphicsContext *gc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, wxDC &dc) const
 
virtual void DrawDCTriangle (std::vector< wxPoint2DDouble > points, wxGraphicsContext *gc) const
 Draw rectangle.
 
virtual void DrawDCTriangle (std::vector< wxPoint > points, wxDC &dc) const
 
virtual void DrawDCPickbox (wxPoint2DDouble position, wxGraphicsContext *gc) const
 Draw a point.
 
virtual wxPoint2DDouble RotateAtPosition (wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
 Rotate a point as element position being the origin.
 
virtual wxPoint2DDouble RotateLocal (wxPoint2DDouble local, double angleDeg) const
 
virtual wxPoint RotateAround (const wxPoint2DDouble &p, const wxPoint2DDouble &center, double angleDeg) const
 
virtual std::vector< Element * > GetParentList () const
 Get the parent list.
 
virtual std::vector< Element * > GetChildList () const
 Get the Child list.
 
virtual void CalculateBoundaries (wxPoint2DDouble &leftUp, wxPoint2DDouble &rightBottom) const
 Calculate the element boundaries.
 
virtual void GeneralMenuItens (wxMenu &menu)
 Insert general itens to context menu.
 
virtual double PointToLineDistance (wxPoint2DDouble point, int *segmentNumber=nullptr) const
 Calculate the distance between a line (formed by point list) and a point.
 
bool IsInserted () const
 Check if the element is properly inserted in the workspace.
 
void SetInserted (bool inserted=true)
 Set if the element is properly inserted in the workspace.
 
void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenCADProperties (rapidxml::xml_node<> *elementNode)
 

Protected Attributes

std::vector< Signal > m_signalList
 
- Protected Attributes inherited from ControlElement
std::vector< Node * > m_nodeList
 
bool m_solved = false
 
double m_output = 0.0
 
- Protected Attributes inherited from Element
ElementType m_elementType = ElementType::TYPE_NONE
 
int m_elementID = 0
 
std::vector< Element * > m_parentList
 
std::vector< Element * > m_childList
 
wxRect2DDouble m_rect
 
wxPoint2DDouble m_position
 
double m_width = 0.0
 
double m_height = 0.0
 
double m_angle = 0.0
 
double m_borderSize = 2.0
 
double m_rotationAngle = 45.0
 
double m_switchSize = 10.0
 
std::vector< wxRect2DDouble > m_switchRect
 
bool m_selected = false
 
bool m_dragging = false
 
bool m_showPickbox = false
 
bool m_inserted = false
 
int m_activePickboxID = ID_PB_NONE
 
int m_activeNodeID = 0
 
std::vector< wxPoint2DDouble > m_pointList
 
std::vector< wxPoint2DDouble > m_movePts
 
wxPoint2DDouble m_moveStartPt
 
wxPoint2DDouble m_movePos
 
bool m_online = true
 

Additional Inherited Members

- Static Public Member Functions inherited from ControlElement
static ControlElementGetControlElementFromID (std::vector< std::shared_ptr< ControlElement > > elementList, int id)
 
- Static Public Member Functions inherited from Element
static bool DoubleFromString (wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
 Get a double value from a string. Show a error message if the conversion fail.
 
static bool IntFromString (wxWindow *parent, wxString strValue, int &value, wxString errorMsg)
 Convert a string to int. Show a error message if the conversion fail.
 
static wxString StringFromDouble (double value, int minDecimal=1, int maxDecimals=13)
 Convert a double value to string.
 
- Protected Member Functions inherited from ControlElement
void SaveControlNodes (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenControlNodes (rapidxml::xml_node<> *elementNode)
 

Detailed Description

Sum the all inputs (can choose the input signal).

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
06/10/2017

Definition at line 33 of file Sum.h.

Member Enumeration Documentation

◆ Signal

enum Sum::Signal

Definition at line 36 of file Sum.h.

36{ SIGNAL_POSITIVE = 0, SIGNAL_NEGATIVE };

Constructor & Destructor Documentation

◆ Sum()

Sum::Sum ( int  id)

Definition at line 24 of file Sum.cpp.

24 : ControlElement(id)
25{
26 m_width = m_height = 36.0;
27 Node* nodeIn1 = new Node(m_position + wxPoint2DDouble(-m_width / 2, 9 - m_height / 2), Node::NodeType::NODE_IN, m_borderSize);
28 nodeIn1->StartMove(m_position);
29 Node* nodeIn2 =
30 new Node(m_position + wxPoint2DDouble(-m_width / 2, 27 - m_height / 2), Node::NodeType::NODE_IN, m_borderSize);
31 nodeIn2->StartMove(m_position);
32 Node* nodeOut = new Node(m_position + wxPoint2DDouble(m_width / 2, 0), Node::NodeType::NODE_OUT, m_borderSize);
33 nodeOut->SetAngle(180.0);
34 nodeOut->StartMove(m_position);
35 m_nodeList.push_back(nodeIn1);
36 m_nodeList.push_back(nodeIn2);
37 m_nodeList.push_back(nodeOut);
38 m_signalList.push_back(SIGNAL_POSITIVE);
39 m_signalList.push_back(SIGNAL_NEGATIVE);
40
41 UpdatePoints();
42}
Node of a control element. This class manages the user interaction with the connection and control el...

◆ ~Sum()

Sum::~Sum ( )

Definition at line 44 of file Sum.cpp.

45{
46 for (auto& node : m_nodeList) if (node) delete node;
47 m_nodeList.clear();
48}

Member Function Documentation

◆ AddInNode()

void Sum::AddInNode ( )

Definition at line 166 of file Sum.cpp.

167{
168 Node* newNode = new Node(wxPoint2DDouble(0, 0), Node::NodeType::NODE_IN, m_borderSize);
169 newNode->SetAngle(m_angle);
170 m_nodeList.insert(m_nodeList.end() - 1, newNode);
171}

◆ Contains()

virtual bool Sum::Contains ( wxPoint2DDouble  position) const
inlinevirtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Implements Element.

Definition at line 42 of file Sum.h.

42{ return m_rect.Contains(position); }

◆ DrawDC()

void Sum::DrawDC ( GUIColour guiColour,
wxPoint2DDouble  translation,
double  scale,
wxGraphicsContext *  gc 
) const
virtual

Draw the element using GDI+.

Parameters
guiColourColours of the system defined in properties.
translationTranslation of the system.
scaleScale of the system.
gcGraphics context

Reimplemented from Element.

Definition at line 50 of file Sum.cpp.

51{
52 if (m_selected) {
53 gc->SetPen(*wxTRANSPARENT_PEN);
54 gc->SetBrush(wxBrush(guiColour->selection));
55 double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
56 gc->DrawRectangle(m_position.m_x - m_width / 2 - borderSize / 2, m_position.m_y - m_height / 2 - borderSize / 2, m_width + borderSize, m_height + borderSize);
57 }
58 gc->SetPen(wxPen(guiColour->enabled));
59 gc->SetBrush(wxBrush(guiColour->background));
60 gc->DrawRectangle(m_position.m_x - m_width / 2, m_position.m_y - m_height / 2, m_width, m_height);
61
62 // Plot signals.
63 gc->SetPen(wxPen(guiColour->enabled, 2));
64 gc->SetBrush(*wxTRANSPARENT_BRUSH);
65 wxPoint2DDouble signalOffset[4];
66 wxPoint2DDouble sigmaOffset;
67 if (m_angle == 0.0) {
68 signalOffset[0] = wxPoint2DDouble(6, 0);
69 signalOffset[1] = wxPoint2DDouble(12, 0);
70 signalOffset[2] = wxPoint2DDouble(9, -3);
71 signalOffset[3] = wxPoint2DDouble(9, 3);
72 sigmaOffset = wxPoint2DDouble(6, 0);
73 }
74 else if (m_angle == 90.0) {
75 signalOffset[0] = wxPoint2DDouble(-3, 9);
76 signalOffset[1] = wxPoint2DDouble(3, 9);
77 signalOffset[2] = wxPoint2DDouble(0, 6);
78 signalOffset[3] = wxPoint2DDouble(0, 12);
79 sigmaOffset = wxPoint2DDouble(0, 6);
80 }
81 else if (m_angle == 180.0) {
82 signalOffset[0] = wxPoint2DDouble(-6, 0);
83 signalOffset[1] = wxPoint2DDouble(-12, 0);
84 signalOffset[2] = wxPoint2DDouble(-9, -3);
85 signalOffset[3] = wxPoint2DDouble(-9, 3);
86 sigmaOffset = wxPoint2DDouble(-6, 0);
87 }
88 else if (m_angle == 270.0) {
89 signalOffset[0] = wxPoint2DDouble(-3, -9);
90 signalOffset[1] = wxPoint2DDouble(3, -9);
91 signalOffset[2] = wxPoint2DDouble(0, -6);
92 signalOffset[3] = wxPoint2DDouble(0, -12);
93 sigmaOffset = wxPoint2DDouble(0, -6);
94 }
95 for (unsigned int i = 0; i < m_nodeList.size() - 1; ++i) {
96 wxPoint2DDouble hLine[2];
97 hLine[0] = m_nodeList[i]->GetPosition() + signalOffset[0];
98 hLine[1] = m_nodeList[i]->GetPosition() + signalOffset[1];
99 gc->StrokeLines(2, hLine);
100 if (m_signalList[i] == SIGNAL_POSITIVE) {
101 wxPoint2DDouble vLine[2];
102 vLine[0] = m_nodeList[i]->GetPosition() + signalOffset[2];
103 vLine[1] = m_nodeList[i]->GetPosition() + signalOffset[3];
104 gc->StrokeLines(2, vLine);
105 }
106 }
107
108 // Plot sigma.
109 gc->SetPen(wxPen(guiColour->bus, 2));
110 wxPoint2DDouble sigma[5];
111 sigma[0] = m_position + wxPoint2DDouble(4, 9) + sigmaOffset;
112 sigma[1] = m_position + wxPoint2DDouble(-6, 9) + sigmaOffset;
113 sigma[2] = m_position + wxPoint2DDouble(0, 0) + sigmaOffset;
114 sigma[3] = m_position + wxPoint2DDouble(-6, -9) + sigmaOffset;
115 sigma[4] = m_position + wxPoint2DDouble(4, -9) + sigmaOffset;
116 gc->StrokeLines(5, sigma);
117
118 gc->SetPen(*wxTRANSPARENT_PEN);
119 gc->SetBrush(wxBrush(guiColour->enabled));
120 DrawDCNodes(gc);
121}

◆ GetCopy()

Element * Sum::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 254 of file Sum.cpp.

255{
256 Sum* copy = new Sum(*this);
257 return copy;
258}
Sum the all inputs (can choose the input signal).
Definition Sum.h:34

◆ GetSignalList()

virtual std::vector< Signal > Sum::GetSignalList ( ) const
inlinevirtual

Definition at line 47 of file Sum.h.

47{ return m_signalList; }

◆ Intersects()

virtual bool Sum::Intersects ( wxRect2DDouble  rect) const
inlinevirtual

Check if the element's rect intersects other rect.

Parameters
rectRect to check intersection.

Implements Element.

Definition at line 43 of file Sum.h.

43{ return m_rect.Intersects(rect); }

◆ OpenElement()

bool Sum::OpenElement ( rapidxml::xml_node<> *  elementNode)
virtual

Reimplemented from Element.

Definition at line 278 of file Sum.cpp.

279{
280 if (!OpenCADProperties(elementNode)) return false;
281 if (!OpenControlNodes(elementNode)) return false;
282
283 m_signalList.clear();
284 auto signsNode = elementNode->first_node("Signs");
285 auto sign = signsNode->first_node("Value");
286 while (sign) {
287 long value;
288 wxString(sign->value()).ToCLong(&value);
289 m_signalList.push_back(static_cast<Sum::Signal>(value));
290 sign = sign->next_sibling("Value");
291 }
292
293 StartMove(m_position);
294 UpdatePoints();
295
296 return true;
297}
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.

◆ RemoveInNode()

void Sum::RemoveInNode ( )

Definition at line 173 of file Sum.cpp.

174{
175 Node* nodeToRemove = *(m_nodeList.end() - 2);
176 bool foundChild = false;
177 for (auto it = m_childList.begin(), itEnd = m_childList.end(); it != itEnd; ++it) {
178 ControlElement* child = static_cast<ControlElement*>(*it);
179 auto childNodeList = child->GetNodeList();
180 for (auto itN = childNodeList.begin(), itEndN = childNodeList.end(); itN != itEndN; ++itN) {
181 Node* node = *itN;
182 if (node == nodeToRemove) {
183 child->RemoveParent(this);
184 RemoveChild(child);
185 foundChild = true;
186 break;
187 }
188 }
189 if (foundChild) break;
190 }
191 m_nodeList.erase(m_nodeList.end() - 2);
192}
virtual void RemoveChild(Element *child)
Remove a child from the list.
Definition Element.cpp:500
virtual void RemoveParent(Element *parent)
Remove a parent.
Definition Element.h:374

◆ Rotate()

void Sum::Rotate ( bool  clockwise = true)
virtual

Rotate the element.

Parameters
clockwiseTrue to rotate clockwise, false to rotate counter-clockwise.

Reimplemented from Element.

Definition at line 194 of file Sum.cpp.

195{
196 if (clockwise)
197 m_angle += 90.0;
198 else
199 m_angle -= 90.0;
200 if (m_angle >= 360.0)
201 m_angle = 0.0;
202 else if (m_angle < 0)
203 m_angle = 270.0;
204
205 UpdatePoints();
206
207 for (auto it = m_nodeList.begin(), itEnd = m_nodeList.end(); it != itEnd; ++it) {
208 Node* node = *it;
209 node->Rotate(clockwise);
210 }
211}

◆ SaveElement()

rapidxml::xml_node * Sum::SaveElement ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  elementListNode 
)
virtual

Reimplemented from Element.

Definition at line 260 of file Sum.cpp.

261{
262 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Sum");
263 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
264
265 SaveCADProperties(doc, elementNode);
266 SaveControlNodes(doc, elementNode);
267
268 // Element properties
269 auto signsNode = XMLParser::AppendNode(doc, elementNode, "Signs");
270 for (unsigned int i = 0; i < m_signalList.size(); ++i) {
271 auto value = XMLParser::AppendNode(doc, signsNode, "Value");
272 XMLParser::SetNodeValue(doc, value, static_cast<int>(m_signalList[i]));
273 }
274
275 return elementNode;
276}

◆ SetSignalList()

virtual void Sum::SetSignalList ( std::vector< Signal >  signalList)
inlinevirtual

Definition at line 48 of file Sum.h.

48{ m_signalList = signalList; }

◆ ShowForm()

bool Sum::ShowForm ( wxWindow *  parent,
Element element,
wxWindow *  workspace = nullptr 
)
virtual

Show element data form.

Parameters
parentForm parent
elementElement that will be edited.
Returns
True if the form is shown, false otherwise.

Reimplemented from Element.

Definition at line 123 of file Sum.cpp.

124{
125 SumForm sumForm(parent, this);
126 sumForm.CenterOnParent();
127 if (sumForm.ShowModal() == wxID_OK) {
128 return true;
129 }
130 return false;
131}
Form to edit the sum control data.
Definition SumForm.h:33

◆ Solve()

bool Sum::Solve ( double *  input,
double  timeStep 
)
virtual

Reimplemented from ControlElement.

Definition at line 213 of file Sum.cpp.

214{
215 if (!input) {
216 m_output = 0.0;
217 return true;
218 }
219 std::vector<double> inputVector;
220 for (auto itN = m_nodeList.begin(), itNEnd = m_nodeList.end(); itN != itNEnd; ++itN) {
221 Node* node = *itN;
222 if (node->GetNodeType() != Node::NodeType::NODE_OUT) {
223 if (!node->IsConnected()) {
224 inputVector.push_back(0.0);
225 }
226 else {
227 for (auto itC = m_childList.begin(), itCEnd = m_childList.end(); itC != itCEnd; ++itC) {
228 ConnectionLine* cLine = static_cast<ConnectionLine*>(*itC);
229 auto nodeList = cLine->GetNodeList();
230 for (auto itCN = nodeList.begin(), itCNEnd = nodeList.end(); itCN != itCNEnd; ++itCN) {
231 Node* childNode = *itCN;
232 if (childNode == node) {
233 inputVector.push_back(cLine->GetValue());
234 break;
235 }
236 }
237 }
238 }
239 }
240 }
241
242 if (m_signalList.size() != inputVector.size()) return false;
243
244 m_output = 0.0;
245 for (unsigned int i = 0; i < m_signalList.size(); ++i) {
246 if (m_signalList[i] == SIGNAL_POSITIVE)
247 m_output += inputVector[i];
248 else if (m_signalList[i] == SIGNAL_NEGATIVE)
249 m_output -= inputVector[i];
250 }
251 return true;
252}
Connection between two control elements or other connection line and an element.

◆ UpdatePoints()

void Sum::UpdatePoints ( )
virtual

Definition at line 133 of file Sum.cpp.

134{
135 if (m_angle == 0.0 || m_angle == 180.0) {
136 m_height = 18.0 * (m_nodeList.size() - 1);
137 m_width = 36.0;
138 }
139 else {
140 m_width = 18.0 * (m_nodeList.size() - 1);
141 m_height = 42.0;
142 }
143
144 for (int i = 0; i < (int)m_nodeList.size() - 1; ++i) {
145 if (m_angle == 0.0)
146 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 9 + 18 * i - m_height / 2));
147 else if (m_angle == 90.0)
148 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(m_width / 2 - 9 - 18 * i, -m_height / 2));
149 else if (m_angle == 180.0)
150 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(m_width / 2, m_height / 2 - 9 - 18 * i));
151 else if (m_angle == 270.0)
152 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(9 + 18 * i - m_width / 2, m_height / 2));
153 }
154 if (m_angle == 0.0)
155 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(m_width / 2, 0));
156 else if (m_angle == 90.0)
157 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(0, m_height / 2));
158 else if (m_angle == 180.0)
159 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 0));
160 else if (m_angle == 270.0)
161 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(0, -m_height / 2));
162
163 SetPosition(m_position); // Update rect.
164}
void SetPosition(const wxPoint2DDouble position)
Set the element position and update the rectangle.
Definition Element.cpp:33

Member Data Documentation

◆ m_signalList

std::vector<Signal> Sum::m_signalList
protected

Definition at line 61 of file Sum.h.


The documentation for this class was generated from the following files: