Power System Platform  2026w10a-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 (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)
 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.
 
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 (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
 
wxColour m_selectionColour
 

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 235 of file Sum.cpp.

236{
237 Node* newNode = new Node(wxPoint2DDouble(0, 0), Node::NodeType::NODE_IN, m_borderSize);
238 newNode->SetAngle(m_angle);
239 m_nodeList.insert(m_nodeList.end() - 1, newNode);
240}

◆ 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 ( wxPoint2DDouble  translation,
double  scale,
wxGraphicsContext *  gc 
) const
virtual

Draw the element using GDI+.

Parameters
translationTranslation of the system.
scaleScale of the system.
gcGraphics context

Reimplemented from Element.

Definition at line 119 of file Sum.cpp.

120{
121 if (m_selected) {
122 gc->SetPen(*wxTRANSPARENT_PEN);
123 gc->SetBrush(wxBrush(m_selectionColour));
124 double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
125 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);
126 }
127 gc->SetPen(*wxBLACK_PEN);
128 gc->SetBrush(*wxWHITE_BRUSH);
129 gc->DrawRectangle(m_position.m_x - m_width / 2, m_position.m_y - m_height / 2, m_width, m_height);
130
131 // Plot signals.
132 gc->SetPen(wxPen(wxColour(0, 0, 0, 255), 2));
133 gc->SetBrush(*wxTRANSPARENT_BRUSH);
134 wxPoint2DDouble signalOffset[4];
135 wxPoint2DDouble sigmaOffset;
136 if (m_angle == 0.0) {
137 signalOffset[0] = wxPoint2DDouble(6, 0);
138 signalOffset[1] = wxPoint2DDouble(12, 0);
139 signalOffset[2] = wxPoint2DDouble(9, -3);
140 signalOffset[3] = wxPoint2DDouble(9, 3);
141 sigmaOffset = wxPoint2DDouble(6, 0);
142 }
143 else if (m_angle == 90.0) {
144 signalOffset[0] = wxPoint2DDouble(-3, 9);
145 signalOffset[1] = wxPoint2DDouble(3, 9);
146 signalOffset[2] = wxPoint2DDouble(0, 6);
147 signalOffset[3] = wxPoint2DDouble(0, 12);
148 sigmaOffset = wxPoint2DDouble(0, 6);
149 }
150 else if (m_angle == 180.0) {
151 signalOffset[0] = wxPoint2DDouble(-6, 0);
152 signalOffset[1] = wxPoint2DDouble(-12, 0);
153 signalOffset[2] = wxPoint2DDouble(-9, -3);
154 signalOffset[3] = wxPoint2DDouble(-9, 3);
155 sigmaOffset = wxPoint2DDouble(-6, 0);
156 }
157 else if (m_angle == 270.0) {
158 signalOffset[0] = wxPoint2DDouble(-3, -9);
159 signalOffset[1] = wxPoint2DDouble(3, -9);
160 signalOffset[2] = wxPoint2DDouble(0, -6);
161 signalOffset[3] = wxPoint2DDouble(0, -12);
162 sigmaOffset = wxPoint2DDouble(0, -6);
163 }
164 for (unsigned int i = 0; i < m_nodeList.size() - 1; ++i) {
165 wxPoint2DDouble hLine[2];
166 hLine[0] = m_nodeList[i]->GetPosition() + signalOffset[0];
167 hLine[1] = m_nodeList[i]->GetPosition() + signalOffset[1];
168 gc->StrokeLines(2, hLine);
169 if (m_signalList[i] == SIGNAL_POSITIVE) {
170 wxPoint2DDouble vLine[2];
171 vLine[0] = m_nodeList[i]->GetPosition() + signalOffset[2];
172 vLine[1] = m_nodeList[i]->GetPosition() + signalOffset[3];
173 gc->StrokeLines(2, vLine);
174 }
175 }
176
177 // Plot sigma.
178 gc->SetPen(wxPen(wxColour(0, 77, 255, 255), 2));
179 wxPoint2DDouble sigma[5];
180 sigma[0] = m_position + wxPoint2DDouble(4, 9) + sigmaOffset;
181 sigma[1] = m_position + wxPoint2DDouble(-6, 9) + sigmaOffset;
182 sigma[2] = m_position + wxPoint2DDouble(0, 0) + sigmaOffset;
183 sigma[3] = m_position + wxPoint2DDouble(-6, -9) + sigmaOffset;
184 sigma[4] = m_position + wxPoint2DDouble(4, -9) + sigmaOffset;
185 gc->StrokeLines(5, sigma);
186
187 gc->SetPen(*wxTRANSPARENT_PEN);
188 gc->SetBrush(*wxBLACK_BRUSH);
189 DrawDCNodes(gc);
190}

◆ GetCopy()

Element * Sum::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 323 of file Sum.cpp.

324{
325 Sum* copy = new Sum(m_elementID);
326 *copy = *this;
327 return copy;
328}
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 348 of file Sum.cpp.

349{
350 if (!OpenCADProperties(elementNode)) return false;
351 if (!OpenControlNodes(elementNode)) return false;
352
353 m_signalList.clear();
354 auto signsNode = elementNode->first_node("Signs");
355 auto sign = signsNode->first_node("Value");
356 while (sign) {
357 long value;
358 wxString(sign->value()).ToCLong(&value);
359 m_signalList.push_back(static_cast<Sum::Signal>(value));
360 sign = sign->next_sibling("Value");
361 }
362
363 StartMove(m_position);
364 UpdatePoints();
365
366 return true;
367}
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.

◆ RemoveInNode()

void Sum::RemoveInNode ( )

Definition at line 242 of file Sum.cpp.

243{
244 Node* nodeToRemove = *(m_nodeList.end() - 2);
245 bool foundChild = false;
246 for (auto it = m_childList.begin(), itEnd = m_childList.end(); it != itEnd; ++it) {
247 ControlElement* child = static_cast<ControlElement*>(*it);
248 auto childNodeList = child->GetNodeList();
249 for (auto itN = childNodeList.begin(), itEndN = childNodeList.end(); itN != itEndN; ++itN) {
250 Node* node = *itN;
251 if (node == nodeToRemove) {
252 child->RemoveParent(this);
253 RemoveChild(child);
254 foundChild = true;
255 break;
256 }
257 }
258 if (foundChild) break;
259 }
260 m_nodeList.erase(m_nodeList.end() - 2);
261}
virtual void RemoveChild(Element *child)
Remove a child from the list.
Definition Element.cpp:567
virtual void RemoveParent(Element *parent)
Remove a parent.
Definition Element.h:371

◆ 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 263 of file Sum.cpp.

264{
265 if (clockwise)
266 m_angle += 90.0;
267 else
268 m_angle -= 90.0;
269 if (m_angle >= 360.0)
270 m_angle = 0.0;
271 else if (m_angle < 0)
272 m_angle = 270.0;
273
274 UpdatePoints();
275
276 for (auto it = m_nodeList.begin(), itEnd = m_nodeList.end(); it != itEnd; ++it) {
277 Node* node = *it;
278 node->Rotate(clockwise);
279 }
280}

◆ SaveElement()

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

Reimplemented from Element.

Definition at line 330 of file Sum.cpp.

331{
332 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Sum");
333 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
334
335 SaveCADProperties(doc, elementNode);
336 SaveControlNodes(doc, elementNode);
337
338 // Element properties
339 auto signsNode = XMLParser::AppendNode(doc, elementNode, "Signs");
340 for (unsigned int i = 0; i < m_signalList.size(); ++i) {
341 auto value = XMLParser::AppendNode(doc, signsNode, "Value");
342 XMLParser::SetNodeValue(doc, value, static_cast<int>(m_signalList[i]));
343 }
344
345 return elementNode;
346}

◆ 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 
)
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 192 of file Sum.cpp.

193{
194 SumForm sumForm(parent, this);
195 sumForm.CenterOnParent();
196 if (sumForm.ShowModal() == wxID_OK) {
197 return true;
198 }
199 return false;
200}
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 282 of file Sum.cpp.

283{
284 if (!input) {
285 m_output = 0.0;
286 return true;
287 }
288 std::vector<double> inputVector;
289 for (auto itN = m_nodeList.begin(), itNEnd = m_nodeList.end(); itN != itNEnd; ++itN) {
290 Node* node = *itN;
291 if (node->GetNodeType() != Node::NodeType::NODE_OUT) {
292 if (!node->IsConnected()) {
293 inputVector.push_back(0.0);
294 }
295 else {
296 for (auto itC = m_childList.begin(), itCEnd = m_childList.end(); itC != itCEnd; ++itC) {
297 ConnectionLine* cLine = static_cast<ConnectionLine*>(*itC);
298 auto nodeList = cLine->GetNodeList();
299 for (auto itCN = nodeList.begin(), itCNEnd = nodeList.end(); itCN != itCNEnd; ++itCN) {
300 Node* childNode = *itCN;
301 if (childNode == node) {
302 inputVector.push_back(cLine->GetValue());
303 break;
304 }
305 }
306 }
307 }
308 }
309 }
310
311 if (m_signalList.size() != inputVector.size()) return false;
312
313 m_output = 0.0;
314 for (unsigned int i = 0; i < m_signalList.size(); ++i) {
315 if (m_signalList[i] == SIGNAL_POSITIVE)
316 m_output += inputVector[i];
317 else if (m_signalList[i] == SIGNAL_NEGATIVE)
318 m_output -= inputVector[i];
319 }
320 return true;
321}
Connection between two control elements or other connection line and an element.

◆ UpdatePoints()

void Sum::UpdatePoints ( )
virtual

Definition at line 202 of file Sum.cpp.

203{
204 if (m_angle == 0.0 || m_angle == 180.0) {
205 m_height = 18.0 * (m_nodeList.size() - 1);
206 m_width = 36.0;
207 }
208 else {
209 m_width = 18.0 * (m_nodeList.size() - 1);
210 m_height = 42.0;
211 }
212
213 for (int i = 0; i < (int)m_nodeList.size() - 1; ++i) {
214 if (m_angle == 0.0)
215 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 9 + 18 * i - m_height / 2));
216 else if (m_angle == 90.0)
217 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(m_width / 2 - 9 - 18 * i, -m_height / 2));
218 else if (m_angle == 180.0)
219 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(m_width / 2, m_height / 2 - 9 - 18 * i));
220 else if (m_angle == 270.0)
221 m_nodeList[i]->SetPosition(m_position + wxPoint2DDouble(9 + 18 * i - m_width / 2, m_height / 2));
222 }
223 if (m_angle == 0.0)
224 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(m_width / 2, 0));
225 else if (m_angle == 90.0)
226 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(0, m_height / 2));
227 else if (m_angle == 180.0)
228 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 0));
229 else if (m_angle == 270.0)
230 m_nodeList[m_nodeList.size() - 1]->SetPosition(m_position + wxPoint2DDouble(0, -m_height / 2));
231
232 SetPosition(m_position); // Update rect.
233}
void SetPosition(const wxPoint2DDouble position)
Set the element position and update the rectangle.
Definition Element.cpp:27

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: