Line Class Reference

Power line element. More...

#include <Line.h>

Inheritance diagram for Line:
Branch PowerElement Element

Public Member Functions

 Line (wxString name)
 
virtual bool Contains (wxPoint2DDouble position) const
 Checks if the element contains a position. More...
 
virtual void Draw (wxPoint2DDouble translation, double scale) const
 Draw the element. More...
 
virtual void Move (wxPoint2DDouble position)
 Move the element other position. More...
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement. More...
 
virtual void MoveNode (Element *parent, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving. More...
 
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. More...
 
virtual wxCursor GetBestPickboxCursor () const
 Get the best cursor to shown to the user when the mouse is above a pickbox. More...
 
virtual ElementGetCopy ()
 Get a the element copy. More...
 
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. More...
 
virtual bool Intersects (wxRect2DDouble rect) const
 Check if the element's rect intersects other rect. More...
 
virtual void MovePickbox (wxPoint2DDouble position)
 Move the pickbox. More...
 
virtual bool PickboxContains (wxPoint2DDouble position)
 Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated. More...
 
virtual void AddPoint (wxPoint2DDouble point)
 Add point to the list of points that connect the element to the bus. More...
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu. More...
 
virtual wxString GetTipText () const
 Get the tip text. More...
 
virtual void RemoveNode (wxPoint2DDouble point)
 
virtual void AddNode (wxPoint2DDouble point)
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node. More...
 
virtual void CalculateBoundaries (wxPoint2DDouble &leftUp, wxPoint2DDouble &rightBottom) const
 Calculate the element boundaries. More...
 
virtual void SetPowerFlowDirection (PowerFlowDirection pfDirection)
 Set the direction of the power flow. More...
 
virtual bool ShowForm (wxWindow *parent, Element *element)
 Show element data form. More...
 
virtual LineElectricalData GetElectricalData () const
 
virtual LineElectricalData GetPUElectricalData (double systemBasePower)
 
virtual void SetElectricalData (LineElectricalData electricalData)
 
virtual void SetNominalVoltage (std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
 Set nominal voltage of the element. More...
 
virtual void SetPointList (std::vector< wxPoint2DDouble > pointList)
 Set the list of points that connect the element to the bus. More...
 
- Public Member Functions inherited from Branch
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement. More...
 
virtual void RemoveParent (Element *parent)
 Remove a parent. More...
 
virtual void UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
virtual void UpdateSwitchesPosition ()
 
virtual void UpdateSwitches ()
 Update the switch position.
 
- Public Member Functions inherited from PowerElement
 PowerElement ()
 Constructor.
 
 ~PowerElement ()
 Destructor.
 
virtual wxPoint2DDouble GetSwitchPoint (Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
 Get the correct switch position. More...
 
virtual bool SwitchesContains (wxPoint2DDouble position) const
 Check if switch contains position. More...
 
virtual void DrawSwitches () const
 Draw switch.
 
virtual void CalculatePowerFlowPts (std::vector< wxPoint2DDouble > edges)
 Calculate the points of the power flow arrows. More...
 
virtual void DrawPowerFlowPts () const
 Draw power flow arrows.
 
virtual void SetSwitchingData (SwitchingData data)
 Set the switching data of the element. More...
 
virtual SwitchingData GetSwitchingData ()
 Returns the switching data of the element. More...
 
virtual PowerFlowDirection GetPowerFlowDirection () const
 Return the direction of the power flow. More...
 
virtual bool GetPlotData (ElementPlotData &plotData)
 Fill the plot data. More...
 
virtual bool HaveDynamicEvent () const
 Check if the power element have dynamic event. More...
 
virtual void SetDynamicEvent (bool dynEvent=true)
 Set if the power element have dynamic event. More...
 
virtual double GetValueFromUnit (double value, ElectricalUnit valueUnit)
 
- Public Member Functions inherited from Element
 Element ()
 Constructor.
 
virtual ~Element ()
 Destructor.
 
void SetDragging (bool dragging=true)
 Set if the element are being dragged. More...
 
void SetHeight (double height)
 Set element height. More...
 
void SetPosition (const wxPoint2DDouble position)
 Set the element position and update the rectangle. More...
 
void SetSelected (bool selected=true)
 Set element selection. More...
 
void SetWidth (double width)
 Set element width. More...
 
void SetAngle (double angle)
 Set element angle. More...
 
void ShowPickbox (bool showPickbox=true)
 Set if the pickbox is shown. More...
 
void SetBorderSize (double borderSize)
 Set the size of the border (shown in selected elements). More...
 
bool SetOnline (bool online=true)
 Set if the element is online or offline. More...
 
wxRect2DDouble GetRect () const
 Get the element rectangle. More...
 
wxPoint2DDouble GetPosition () const
 Get the element position. More...
 
bool IsDragging () const
 Checks if the element is being dragged. More...
 
double GetHeight () const
 Get the element height. More...
 
bool IsSelected () const
 Checks if the element is selected. More...
 
double GetWidth () const
 Get the element width. More...
 
double GetAngle () const
 Get the element angle. More...
 
double GetRotationAngle () const
 Get the angle of rotation. More...
 
bool IsPickboxShown () const
 Checks if the pickbox is shown. More...
 
bool IsOnline () const
 Checks if the element is online or offline. More...
 
virtual std::vector< wxPoint2DDouble > GetPointList () const
 Get the list of points that connect the element to bus. More...
 
virtual void AddParent (Element *parent)
 Add a parent to the element. More...
 
virtual void SetID (int id)
 Set the element ID. More...
 
virtual int GetID () const
 Get the element ID. More...
 
virtual void AddChild (Element *child)
 Add a child to the child list. More...
 
virtual void RemoveChild (Element *child)
 Remove a child from the list. More...
 
virtual void ReplaceChild (Element *oldChild, Element *newChild)
 Replace a child from the list. More...
 
virtual void Rotate (bool clockwise=true)
 Rotate the element. More...
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent. More...
 
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. More...
 
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. More...
 
virtual bool RotatedRectanglesIntersects (wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
 Check if two roteted rectangles intersect. More...
 
virtual void DrawCircle (wxPoint2DDouble position, double radius, int numSegments, GLenum mode=GL_LINE_LOOP) const
 Draw a circle. More...
 
virtual void DrawArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, GLenum mode=GL_LINE_LOOP) const
 
virtual void DrawRectangle (wxPoint2DDouble position, double width, double height, GLenum mode=GL_QUADS) const
 Draw rectangle. More...
 
virtual void DrawRectangle (wxPoint2DDouble *points, GLenum mode=GL_QUADS) const
 Draw rectangle. More...
 
virtual void DrawTriangle (std::vector< wxPoint2DDouble > points, GLenum mode=GL_TRIANGLES) const
 Draw a triangle. More...
 
virtual void DrawPoint (wxPoint2DDouble position, double size) const
 Draw a point. More...
 
virtual void DrawLine (std::vector< wxPoint2DDouble > points, GLenum mode=GL_LINE_STRIP) const
 Draw line. More...
 
virtual void DrawPickbox (wxPoint2DDouble position) const
 Draw pickbox. More...
 
virtual wxPoint2DDouble RotateAtPosition (wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
 Rotate a point as element position being the origin. More...
 
virtual std::vector< Element * > GetParentList () const
 Get the parent list. More...
 
virtual std::vector< Element * > GetChildList () const
 Get the Child list. More...
 
virtual void GeneralMenuItens (wxMenu &menu)
 Insert general itens to context menu. More...
 
virtual double PointToLineDistance (wxPoint2DDouble point, int *segmentNumber=NULL) const
 Calculate the distance between a line (formed by point list) and a point. More...
 

Protected Member Functions

void UpdatePowerFlowArrowsPosition ()
 

Protected Attributes

LineElectricalData m_electricalData
 
- Protected Attributes inherited from Branch
bool m_inserted = false
 
- Protected Attributes inherited from PowerElement
SwitchingData m_swData
 
std::vector< std::vector< wxPoint2DDouble > > m_powerFlowArrow
 
PowerFlowDirection m_pfDirection = PF_NONE
 
OpenGLColour m_busColour
 
OpenGLColour m_onlineElementColour
 
OpenGLColour m_offlineElementColour
 
OpenGLColour m_closedSwitchColour
 
OpenGLColour m_openedSwitchColour
 
OpenGLColour m_powerFlowArrowColour
 
OpenGLColour m_dynamicEventColour
 
bool m_dynEvent = false
 
- Protected Attributes inherited from Element
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
 
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
 
OpenGLColour m_selectionColour
 

Additional Inherited Members

- 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. More...
 
static bool IntFromString (wxWindow *parent, wxString strValue, int &value, wxString errorMsg)
 Convert a string to int. Show a error message if the conversion fail. More...
 
static wxString StringFromDouble (double value, int minDecimal=1)
 Convert a double value to string. More...
 

Detailed Description

Power line element.

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

Definition at line 59 of file Line.h.

Member Function Documentation

◆ AddParent()

bool Line::AddParent ( Element parent,
wxPoint2DDouble  position 
)
virtual

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.

Parameters
parentElement parent.
positionNode position in the parent.

Reimplemented from Element.

Definition at line 136 of file Line.cpp.

◆ AddPoint()

void Line::AddPoint ( wxPoint2DDouble  point)
virtual

Add point to the list of points that connect the element to the bus.

Parameters
pointPoint to be added.

Reimplemented from Branch.

Definition at line 234 of file Line.cpp.

◆ CalculateBoundaries()

void Line::CalculateBoundaries ( wxPoint2DDouble &  leftUp,
wxPoint2DDouble &  rightBottom 
) const
virtual

Calculate the element boundaries.

Parameters
leftUpTop-left position of the element.
rightBottomBottom-right position of the element.

Reimplemented from Element.

Definition at line 335 of file Line.cpp.

◆ Contains()

bool Line::Contains ( wxPoint2DDouble  position) const
virtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Reimplemented from Branch.

Definition at line 39 of file Line.cpp.

◆ Draw()

void Line::Draw ( wxPoint2DDouble  translation,
double  scale 
) const
virtual

Draw the element.

Parameters
translationTranslation of the system.
scaleScale of the system.

Reimplemented from Branch.

Definition at line 47 of file Line.cpp.

◆ GetBestPickboxCursor()

virtual wxCursor Line::GetBestPickboxCursor ( ) const
inlinevirtual

Get the best cursor to shown to the user when the mouse is above a pickbox.

Returns
Cursor.

Reimplemented from Branch.

Definition at line 71 of file Line.h.

◆ GetContextMenu()

bool Line::GetContextMenu ( wxMenu &  menu)
virtual

Get the element contex menu.

Parameters
menumenu that will be inserted the element itens.
Returns
True if was possible to build the menu, false otherwise.

Reimplemented from Branch.

Definition at line 289 of file Line.cpp.

◆ GetCopy()

Element * Line::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 499 of file Line.cpp.

◆ GetTipText()

wxString Line::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 506 of file Line.cpp.

◆ Intersects()

bool Line::Intersects ( wxRect2DDouble  rect) const
virtual

Check if the element's rect intersects other rect.

Parameters
rectRect to check intersection.

Reimplemented from Branch.

Definition at line 203 of file Line.cpp.

◆ Move()

void Line::Move ( wxPoint2DDouble  position)
virtual

Move the element other position.

Parameters
positionPosition that the element will be moved. Use StartMove(wxPoint2DDouble position) before start moving.

Reimplemented from Branch.

Definition at line 116 of file Line.cpp.

◆ MoveNode()

void Line::MoveNode ( Element parent,
wxPoint2DDouble  position 
)
virtual

Move a node. StartMove(wxPoint2DDouble position) before start moving.

Parameters
parentNode's parent.
positionNew node position.

Reimplemented from Branch.

Definition at line 247 of file Line.cpp.

◆ MovePickbox()

void Line::MovePickbox ( wxPoint2DDouble  position)
virtual

Move the pickbox.

Parameters
positionposition that the pickbox will be moved.

Reimplemented from Branch.

Definition at line 210 of file Line.cpp.

◆ PickboxContains()

bool Line::PickboxContains ( wxPoint2DDouble  position)
virtual

Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.

Parameters
positionPosition to be checked.
Returns
True if the element constains the pickbox, false otherwise.

Reimplemented from Branch.

Definition at line 222 of file Line.cpp.

◆ RotateNode()

void Line::RotateNode ( Element parent,
bool  clockwise = true 
)
virtual

Rotate a node.

Parameters
parentNode's parent.
clockwiseTrue to rotate clockwise, false to rotate counter-clockwise.

Reimplemented from Branch.

Definition at line 478 of file Line.cpp.

◆ SetNodeParent()

bool Line::SetNodeParent ( Element parent)
virtual

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.

Parameters
parentNode parent.
Returns
True if was possible to set the parent.

Reimplemented from Branch.

Definition at line 369 of file Line.cpp.

◆ SetNominalVoltage()

void Line::SetNominalVoltage ( std::vector< double >  nominalVoltage,
std::vector< ElectricalUnit nominalVoltageUnit 
)
virtual

Set nominal voltage of the element.

Parameters
nominalVoltageValue of the nominal voltage.
nominalVoltageUnitUnit of the nominal voltage.

Reimplemented from PowerElement.

Definition at line 361 of file Line.cpp.

◆ SetPointList()

void Line::SetPointList ( std::vector< wxPoint2DDouble >  pointList)
virtual

Set the list of points that connect the element to the bus.

Parameters
pointListList of points.

Reimplemented from Element.

Definition at line 492 of file Line.cpp.

◆ SetPowerFlowDirection()

void Line::SetPowerFlowDirection ( PowerFlowDirection  pfDirection)
virtual

Set the direction of the power flow.

Parameters
pfDirectionPower flow direction.

Reimplemented from PowerElement.

Definition at line 449 of file Line.cpp.

◆ ShowForm()

bool Line::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 350 of file Line.cpp.

◆ StartMove()

void Line::StartMove ( wxPoint2DDouble  position)
virtual

Update the element attributes related to the movement.

Parameters
positionStart move position.

Reimplemented from Branch.

Definition at line 241 of file Line.cpp.


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