![]() |
Power System Platform
2026w11a-beta
|
Base class of all elements of the program. This class is responsible for manage graphical and his data. More...
#include <Element.h>

Public Member Functions | |
| 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 bool | Contains (wxPoint2DDouble position) const =0 |
| Checks if the element contains a position. | |
| virtual bool | Intersects (wxRect2DDouble rect) const =0 |
| Check if the element's rect intersects other rect. | |
| virtual Element * | GetCopy () |
| Get a the element copy. | |
| 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, wxGraphicsContext *gc) const |
| Draw the element using GDI+. | |
| virtual void | DrawDC (wxPoint2DDouble translation, double scale, wxDC &dc) const |
| Draw the element using wxDC. | |
| virtual void | Rotate (bool clockwise=true) |
| Rotate the element. | |
| 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 | StartMove (wxPoint2DDouble position) |
| Update the element attributes related to the movement. | |
| virtual void | Move (wxPoint2DDouble position) |
| Move the element other position. | |
| 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 ¢er, 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 ¢er, 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 bool | ShowForm (wxWindow *parent, Element *element) |
| Show element data form. | |
| 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. | |
| virtual rapidxml::xml_node * | SaveElement (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementListNode) |
| virtual bool | OpenElement (rapidxml::xml_node<> *elementNode) |
| void | SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode) |
| bool | OpenCADProperties (rapidxml::xml_node<> *elementNode) |
Static Public Member Functions | |
| 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 Attributes | |
| 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 |
Base class of all elements of the program. This class is responsible for manage graphical and his data.
| Element::Element | ( | ) |
Constructor.
Definition at line 27 of file Element.cpp.
|
inlinevirtual |
|
virtual |
Add a child to the child list.
| child | New child. |
Definition at line 494 of file Element.cpp.

|
inlinevirtual |
|
inlinevirtual |
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.
Reimplemented in Bus, Capacitor, EMTElement, HarmCurrent, Inductor, Line, Load, Machines, Transformer, and Text.
Definition at line 239 of file Element.h.
|
inlinevirtual |
|
virtual |
Calculate the element boundaries.
| leftUp | Top-left position of the element. |
| rightBottom | Bottom-right position of the element. |
Reimplemented in Line.
Definition at line 406 of file Element.cpp.

|
pure virtual |
Checks if the element contains a position.
| position | Position to be checked. |
Implemented in ConnectionLine, Constant, Exponential, Gain, IOControl, Limiter, MathExpression, MathOperation, RateLimiter, Sum, TransferFunction, Branch, Bus, Capacitor, EMTElement, HarmCurrent, Inductor, Line, Machines, Shunt, Transformer, and Text.

|
static |
Get a double value from a string. Show a error message if the conversion fail.
| parent | Message box parent. |
| strValue | String value to be converted. |
| value | Double value converted. |
| errorMsg | Error message. |
Definition at line 433 of file Element.cpp.
|
inlinevirtual |
Draw the element using wxDC.
| translation | Translation of the system. |
| scale | Scale of the system. |
| dc | Device context. |
Reimplemented in Bus, Capacitor, EMTElement, HarmCurrent, Inductor, Line, Load, Machines, and Transformer.
Definition at line 311 of file Element.h.
|
inlinevirtual |
Draw the element using GDI+.
| translation | Translation of the system. |
| scale | Scale of the system. |
| gc | Graphics context |
Reimplemented in ConnectionLine, Constant, Exponential, Gain, IOControl, Limiter, MathExpression, MathOperation, RateLimiter, Sum, TransferFunction, Bus, Capacitor, EMTElement, HarmCurrent, Inductor, Line, Load, Machines, and Transformer.
Definition at line 304 of file Element.h.
|
virtual |
Definition at line 185 of file Element.cpp.
|
virtual |
Definition at line 199 of file Element.cpp.
|
virtual |
Draw a circle using device context.
| position | Circle position. |
| radius | Circle radius |
| numSegments | Num of segments of the circle. |
| gl | Device context. |
Definition at line 168 of file Element.cpp.

|
virtual |
Definition at line 180 of file Element.cpp.
|
virtual |
Draw a point.
| position | Point position. |
| size | Point size. |
Draw line.
| points | Line vertices. |
| mode | OpenGl primitive. |
Draw pickbox.
| position | Pickbox position. |
Draw pickbox using direct context.
| position | Pickbox position. |
| gc | Direct context. |
Definition at line 216 of file Element.cpp.

|
virtual |
Draw a circle.
| position | Circle position. |
| radius | Circle radius |
| numSegments | Num of segments of the circle. |
| mode | OpenGl primitive. |
Definition at line 36 of file Element.cpp.

|
virtual |
Definition at line 81 of file Element.cpp.
|
virtual |
Definition at line 210 of file Element.cpp.
|
virtual |
Draw rectangle.
| position | Rectangle position. |
| width | Rectangle width. |
| height | Rectangle height. |
| mode | OpenGl primitive. |
Draw rectangle.
| points | Rectangle vertices. |
| mode | OpenGl primitive. |
Draw a triangle.
| points | Triangle vertices. |
| mode | OpenGl primitive. |
Draw a triangle.
| points | Triangle vertices. |
| gc | Device context. |
Definition at line 204 of file Element.cpp.

|
virtual |
Insert general itens to context menu.
| menu | Menu that will be inserted the general itens. |
Definition at line 388 of file Element.cpp.

|
inline |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Get the element contex menu.
| menu | menu that will be inserted the element itens. |
Reimplemented in Branch, Bus, Capacitor, EMTElement, HarmCurrent, IndMotor, Inductor, Line, Load, SyncGenerator, SyncMotor, and Transformer.
Definition at line 322 of file Element.h.
|
inlinevirtual |
Get a the element copy.
Reimplemented in ConnectionLine, Constant, Divider, Exponential, Gain, IOControl, Limiter, MathExpression, Multiplier, RateLimiter, Sum, TransferFunction, Bus, Capacitor, EMTElement, HarmCurrent, IndMotor, Inductor, Line, Load, SyncGenerator, SyncMotor, Transformer, and Text.
Definition at line 261 of file Element.h.
|
inline |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Get the tip text.
Reimplemented in Bus, Capacitor, EMTElement, HarmCurrent, IndMotor, Inductor, Line, Load, SyncGenerator, SyncMotor, and Transformer.
Definition at line 295 of file Element.h.
|
inline |
|
pure virtual |
Check if the element's rect intersects other rect.
| rect | Rect to check intersection. |
Implemented in ConnectionLine, Constant, Exponential, Gain, IOControl, Limiter, MathExpression, MathOperation, RateLimiter, Sum, TransferFunction, Branch, Bus, Capacitor, EMTElement, HarmCurrent, Inductor, Line, Machines, Shunt, Transformer, and Text.

|
static |
Convert a string to int. Show a error message if the conversion fail.
| parent | Message box parent. |
| strValue | String value to be converted. |
| value | Int value converted. |
| errorMsg | Error message. |
Definition at line 447 of file Element.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Move the element other position.
| position | Position that the element will be moved. Use StartMove(wxPoint2DDouble position) before start moving. |
Reimplemented in ConnectionLine, ControlElement, Gain, Branch, Line, Machines, Shunt, and Transformer.
Definition at line 266 of file Element.cpp.

|
inlinevirtual |
Move a node. StartMove(wxPoint2DDouble position) before start moving.
| parent | Node's parent. |
| position | New node position. |
Reimplemented in Machines, Shunt, Branch, Line, and Transformer.
Definition at line 346 of file Element.h.
|
inlinevirtual |
|
inlinevirtual |
Check if a node contains a point. If contains, set the attributes related to node movement.
| position | Position tested. |
Reimplemented in Branch, Machines, and Shunt.
Definition at line 352 of file Element.h.
| bool Element::OpenCADProperties | ( | rapidxml::xml_node<> * | elementNode | ) |
Definition at line 583 of file Element.cpp.
|
inlinevirtual |
|
inlinevirtual |
Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.
| position | Position to be checked. |
Reimplemented in Branch, Bus, and Line.
Definition at line 391 of file Element.h.
|
virtual |
Calculate the distance between a line (formed by point list) and a point.
| point | origin point. |
| segmentNumber | Sotores the segment number clicked |
Definition at line 529 of file Element.cpp.

|
virtual |
Remove a child from the list.
| child | Child to remove. |
Definition at line 495 of file Element.cpp.
|
inlinevirtual |
Replace a child from the list.
| oldChild | Old child. |
| newChild | New child. |
Definition at line 503 of file Element.cpp.
Replace a parent.
| oldParent | Parent to be replaced. |
| newParent | New parent. |
Definition at line 487 of file Element.cpp.
|
inlinevirtual |
|
inlinevirtual |
Remove the pickboxes.
Definition at line 405 of file Element.h.
|
inlinevirtual |
Rotate the element.
| clockwise | True to rotate clockwise, false to rotate counter-clockwise. |
Reimplemented in Constant, Exponential, Gain, IOControl, Limiter, MathExpression, MathOperation, RateLimiter, Sum, TransferFunction, Bus, Capacitor, EMTElement, HarmCurrent, Inductor, Load, Machines, Transformer, and Text.
Definition at line 316 of file Element.h.
|
virtual |
Definition at line 245 of file Element.cpp.
|
virtual |
Rotate a point as element position being the origin.
| pointToRotate | Point that will be rotated. |
| angle | Angle of rotation. |
| degrees | True if the angle is in degrees, false if radians. |
Definition at line 223 of file Element.cpp.

|
virtual |
Check if two roteted rectangles intersect.
| rect1 | First rect. |
| rect2 | Second rect. |
| angle1 | Rotation algle of first rectangle. |
| angle2 | Rotation angle of second rectangle. |
Definition at line 290 of file Element.cpp.

|
virtual |
Definition at line 233 of file Element.cpp.
|
inlinevirtual |
| void Element::SaveCADProperties | ( | rapidxml::xml_document<> & | doc, |
| rapidxml::xml_node<> * | elementNode | ||
| ) |
Definition at line 566 of file Element.cpp.
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
|
inline |
|
inlinevirtual |
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.
| parent | Node parent. |
Reimplemented in Branch, Line, Machines, Shunt, and Transformer.
Definition at line 366 of file Element.h.
| bool Element::SetOnline | ( | bool | online = true | ) |
Set if the element is online or offline.
| online | True if online, false if offline. |
Definition at line 378 of file Element.cpp.
|
inline |
|
inlinevirtual |
| void Element::SetPosition | ( | const wxPoint2DDouble | position | ) |
Set the element position and update the rectangle.
| position | Position value. |
Definition at line 28 of file Element.cpp.

|
inline |
|
inline |
|
inlinevirtual |
Show element data form.
| parent | Form parent |
| element | Element that will be edited. |
Reimplemented in Constant, Exponential, Gain, IOControl, Limiter, MathExpression, MathOperation, RateLimiter, Sum, TransferFunction, Bus, Capacitor, EMTElement, HarmCurrent, IndMotor, Inductor, Line, Load, SyncGenerator, SyncMotor, and Transformer.
Definition at line 587 of file Element.h.
|
inline |
|
virtual |
Update the element attributes related to the movement.
| position | Start move position. |
Reimplemented in ConnectionLine, ControlElement, Branch, Line, Machines, Shunt, and Transformer.
Definition at line 260 of file Element.cpp.
|
static |
Convert a double value to string.
| value | Value to be converted. |
| minDecimal | Minimum number of decimal places. |
Definition at line 461 of file Element.cpp.

|
inlinevirtual |
|
virtual |
Convert a generic position to screen position.
| position | Position to be converted. |
| translation | System translation. |
| scale | System scale. |
| offsetX | Offset in X axis. |
| offsetY | Offset in Y axis. |
Definition at line 273 of file Element.cpp.
|
virtual |
Convert the element position to screen position.
| translation | System translation. |
| scale | System scale |
| offsetX | Offset in X axis. |
| offsetY | Offset if Y axis. |
Definition at line 267 of file Element.cpp.

|
protected |
|
protected |
|
protected |
|
protected |