Power System Platform  2026w34a-beta
Loading...
Searching...
No Matches
Shunt Class Reference

Abstract class for shunt power elements. More...

#include <Shunt.h>

Inheritance diagram for Shunt:
Collaboration diagram for Shunt:

Public Member Functions

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 void Move (wxPoint2DDouble position)
 Move the element other position.
 
virtual void AlignToGrid (double gridSize=20.0) override
 
virtual void MoveNode (Element *element, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving.
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement.
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node.
 
virtual void RemoveParent (Element *parent)
 Remove a parent.
 
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement.
 
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 UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
virtual void UpdateSwitchesPosition () override
 
virtual void UpdatePowerFlowArrowsPosition () override
 
- Public Member Functions inherited from PowerElement
 PowerElement ()
 Constructor.
 
virtual ~PowerElement ()
 Destructor.
 
virtual wxPoint2DDouble GetSwitchPoint (Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
 Get the correct switch position.
 
virtual bool SwitchesContains (wxPoint2DDouble position) const
 Check if switch contains position.
 
virtual void UpdateSwitches ()
 Update the switch position.
 
virtual void DrawDCSwitches (GUIColour *guiColour, wxGraphicsContext *gc) const
 Draw switch.
 
virtual void DrawDCSwitches (GUIColour *guiColour, wxDC &dc) const
 
virtual void CalculatePowerFlowPts (std::vector< wxPoint2DDouble > edges)
 Calculate the points of the power flow arrows.
 
virtual void DrawDCPowerFlowPts (GUIColour *guiColour, wxGraphicsContext *gc) const
 Draw power flow arrows.
 
virtual void DrawDCPowerFlowPts (GUIColour *guiColour, wxDC &dc) const
 
virtual void SetNominalVoltage (std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
 Set nominal voltage of the element.
 
virtual void SetSwitchingData (SwitchingData data)
 Set the switching data of the element.
 
virtual SwitchingData GetSwitchingData ()
 Returns the switching data of the element.
 
virtual void SetPowerFlowDirection (PowerFlowDirection pfDirection)
 Set the direction of the power flow.
 
virtual PowerFlowDirection GetPowerFlowDirection () const
 Return the direction of the power flow.
 
virtual bool GetPlotData (ElementPlotData &plotData, PlotStudy study=PlotStudy::STABILITY)
 Fill the plot data.
 
virtual bool HaveDynamicEvent () const
 Check if the power element have dynamic event.
 
virtual void SetDynamicEvent (bool dynEvent=true)
 Set if the power element have dynamic event.
 
virtual double GetValueFromUnit (double value, ElectricalUnit valueUnit) const
 
virtual void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
virtual void SaveSwitchingData (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *electricalNode)
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
virtual bool OpenCADProperties (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
virtual bool OpenSwitchingData (rapidxml::xml_node<> *electricalNode)
 
- 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 std::vector< wxPoint2DDouble > & GetPointListRef ()
 
virtual bool AddParent (Element *parent, wxPoint2DDouble position, bool isOpening=false)
 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 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 (GUIColour *guiColour, wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
 Draw the element using GDI+.
 
virtual void DrawDC (GUIColour *guiColour, 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.
 
void SetParent (Element *parent, int num)
 
void SetChild (Element *child, int num)
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent.
 
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 DrawStabilityEventGC (wxGraphicsContext *gc, wxPoint2DDouble translation, double scale, GUIColour *guiColour, bool rotateAnchor=false, wxPoint2DDouble iconPosition=wxPoint2DDouble(-1, -1)) 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 wxPoint2DDouble GetMoveStartPosition () const
 
virtual wxPoint2DDouble GetMovePosition () const
 
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, wxWindow *workspace=nullptr)
 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)
 

Protected Member Functions

void DrawDCGround (wxPoint2DDouble position, wxGraphicsContext *gc) const
 
void DrawDCGround (wxPoint2DDouble position, wxDC &dc) const
 

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.
 
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 inherited from PowerElement
SwitchingData m_swData
 
std::vector< std::vector< wxPoint2DDouble > > m_powerFlowArrow
 
PowerFlowDirection m_pfDirection = PowerFlowDirection::PF_NONE
 
wxColour m_busColour
 
wxColour m_onlineElementColour
 
wxColour m_offlineElementColour
 
wxColour m_closedSwitchColour
 
wxColour m_openedSwitchColour
 
wxColour m_powerFlowArrowColour
 
wxColour m_dynamicEventColour
 
bool m_dynEvent = false
 
- 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
 

Detailed Description

Abstract class for shunt power elements.

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

Definition at line 31 of file Shunt.h.

Constructor & Destructor Documentation

◆ Shunt()

Shunt::Shunt ( )

Definition at line 20 of file Shunt.cpp.

20: PowerElement() {}
PowerElement()
Constructor.

◆ ~Shunt()

Shunt::~Shunt ( )

Definition at line 21 of file Shunt.cpp.

21{}

Member Function Documentation

◆ AlignToGrid()

void Shunt::AlignToGrid ( double  gridSize = 20.0)
overridevirtual

Reimplemented from Element.

Definition at line 46 of file Shunt.cpp.

47{
48 if (gridSize <= 0.0)
49 gridSize = 20.0;
50
51 // 1. Align m_position to the grid.
52 wxPoint2DDouble oldPosition = m_position;
53
54 wxPoint2DDouble newPosition(
55 std::round(oldPosition.m_x / gridSize) * gridSize,
56 std::round(oldPosition.m_y / gridSize) * gridSize);
57
58 wxPoint2DDouble delta = newPosition - oldPosition;
59
60 m_position = newPosition;
61 SetPosition(m_position);
62
63 // 2. Move the shunt geometry together with m_position.
64 // Point 0 = bus connection.
65 // Point 1 = switch.
66 // Point 2+ = shunt geometry.
67 //
68 // Point 0 is not moved here because it must be aligned with the bus in the next step.
69 for (size_t i = 2; i < m_pointList.size(); ++i) {
70 m_pointList[i] += delta;
71 }
72
73 // 3. Align the bus connection point (m_pointList[0]) with the reference point (m_pointList[2]).
74 //
75 // The alignment is completely independent of m_angle.
76 // m_pointList[2] determines the position along the bus.
77 if (!m_parentList.empty() &&
78 m_parentList[0] &&
79 m_pointList.size() >= 3) {
80
81 Element* bus = m_parentList[0];
82 wxPoint2DDouble p2 = m_pointList[2];
83
84 // Transform p2 to the local coordinate system of the bus.
85 wxPoint2DDouble p2Delta(p2.m_x - bus->GetPosition().m_x, p2.m_y - bus->GetPosition().m_y);
86 wxPoint2DDouble p2Local = bus->RotateLocal(p2Delta, -bus->GetAngle());
87
88 // The new connection point is located at the same longitudinal position as p2 and exactly on the center line of the bus.
89 wxPoint2DDouble candidateLocal(p2Local.m_x, 0.0);
90
91 // The candidate must remain within the length of the bus.
92 double halfWidth = bus->GetWidth() / 2.0 + 2.0;
93
94 if (std::abs(candidateLocal.m_x) <= halfWidth) {
95
96 // Transform the candidate back to global coordinates.
97 wxPoint2DDouble candidate = bus->GetPosition() + bus->RotateLocal(candidateLocal, bus->GetAngle());
98 m_pointList[0] = candidate;
99 }
100 }
101 else if (!m_pointList.empty()) {
102
103 // No parent: simply snap the connection point to the grid.
104 m_pointList[0].m_x = std::round(m_pointList[0].m_x / gridSize) * gridSize;
105 m_pointList[0].m_y = std::round(m_pointList[0].m_y / gridSize) * gridSize;
106 }
107
108 // 4. Update dependent geometry.
109 UpdateSwitchesPosition();
110 UpdatePowerFlowArrowsPosition();
111}
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:115
double GetWidth() const
Get the element width.
Definition Element.h:209
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:189
double GetAngle() const
Get the element angle.
Definition Element.h:214
void SetPosition(const wxPoint2DDouble position)
Set the element position and update the rectangle.
Definition Element.cpp:33

◆ Contains()

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

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Implements Element.

Reimplemented in Capacitor, EMTElement, HarmCurrent, and Inductor.

Definition at line 37 of file Shunt.h.

37{ return m_rect.Contains(position); }

◆ DrawDCGround() [1/2]

void Shunt::DrawDCGround ( wxPoint2DDouble  position,
wxDC &  dc 
) const
protected

Definition at line 256 of file Shunt.cpp.

257{
258 wxPoint groundPts[8];
259 wxPoint2DDouble p;
260
261 p = position;
262 groundPts[0] = RotateAround(p, m_position, m_angle);
263 p = position + wxPoint2DDouble(0, 10);
264 groundPts[1] = RotateAround(p, m_position, m_angle);
265 p = position + wxPoint2DDouble(-10, 10);
266 groundPts[2] = RotateAround(p, m_position, m_angle);
267 p = position + wxPoint2DDouble(10, 10);
268 groundPts[3] = RotateAround(p, m_position, m_angle);
269 p = position + wxPoint2DDouble(-6, 15);
270 groundPts[4] = RotateAround(p, m_position, m_angle);
271 p = position + wxPoint2DDouble(6, 15);
272 groundPts[5] = RotateAround(p, m_position, m_angle);
273 p = position + wxPoint2DDouble(-3, 20);
274 groundPts[6] = RotateAround(p, m_position, m_angle);
275 p = position + wxPoint2DDouble(3, 20);
276 groundPts[7] = RotateAround(p, m_position, m_angle);
277
278 dc.DrawLines(2, &groundPts[0]);
279 dc.DrawLines(2, &groundPts[2]);
280 dc.DrawLines(2, &groundPts[4]);
281 dc.DrawLines(2, &groundPts[6]);
282}

◆ DrawDCGround() [2/2]

void Shunt::DrawDCGround ( wxPoint2DDouble  position,
wxGraphicsContext *  gc 
) const
protected

Definition at line 238 of file Shunt.cpp.

239{
240 std::vector<wxPoint2DDouble> groundPts;
241 groundPts.push_back(position);
242 groundPts.push_back(position + wxPoint2DDouble(0, 10));
243 groundPts.push_back(position + wxPoint2DDouble(-10, 10));
244 groundPts.push_back(position + wxPoint2DDouble(10, 10));
245 groundPts.push_back(position + wxPoint2DDouble(-6, 15));
246 groundPts.push_back(position + wxPoint2DDouble(6, 15));
247 groundPts.push_back(position + wxPoint2DDouble(-3, 20));
248 groundPts.push_back(position + wxPoint2DDouble(3, 20));
249
250 gc->StrokeLines(2, &groundPts[0]);
251 gc->StrokeLines(2, &groundPts[2]);
252 gc->StrokeLines(2, &groundPts[4]);
253 gc->StrokeLines(2, &groundPts[6]);
254}

◆ Intersects()

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

Check if the element's rect intersects other rect.

Parameters
rectRect to check intersection.

Implements Element.

Reimplemented in Capacitor, EMTElement, HarmCurrent, and Inductor.

Definition at line 38 of file Shunt.h.

38{ return m_rect.Intersects(rect); }
Here is the caller graph for this function:

◆ Move()

void Shunt::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 Element.

Definition at line 33 of file Shunt.cpp.

34{
35 SetPosition(m_movePos + position - m_moveStartPt);
36 for (int i = 2; i < (int)m_pointList.size(); i++) {
37 m_pointList[i] = m_movePts[i] + position - m_moveStartPt;
38 }
39 if (!m_parentList[0]) {
40 m_pointList[0] = m_movePts[0] + position - m_moveStartPt;
41 }
42 UpdateSwitchesPosition();
43 UpdatePowerFlowArrowsPosition();
44}
Here is the call graph for this function:

◆ MoveNode()

void Shunt::MoveNode ( Element *  parent,
wxPoint2DDouble  position 
)
virtual

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

Parameters
parentNode's parent.
positionNew node position.

Reimplemented from Element.

Definition at line 113 of file Shunt.cpp.

114{
115 if (element) {
116 if (element == m_parentList[0]) {
117 m_pointList[0] = m_movePts[0] + position - m_moveStartPt;
118 }
119 }
120 else {
121 if (m_activeNodeID == 1) {
122 m_pointList[0] = m_movePts[0] + position - m_moveStartPt;
123 if (m_parentList[0]) {
124 m_parentList[0]->RemoveChild(this);
125 m_parentList[0] = nullptr;
126 m_online = false;
127 }
128 }
129 }
130
131 // Recalculate switches positions
132 UpdateSwitchesPosition();
133 UpdatePowerFlowArrowsPosition();
134}

◆ NodeContains()

bool Shunt::NodeContains ( wxPoint2DDouble  position)
virtual

Check if a node contains a point. If contains, set the attributes related to node movement.

Parameters
positionPosition tested.
Returns
True if at least one node contains the position, false otherwise.

Reimplemented from Element.

Definition at line 153 of file Shunt.cpp.

154{
155 wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize,
156 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize);
157
158 if (nodeRect.Contains(position)) {
159 m_activeNodeID = 1;
160 return true;
161 }
162
163 m_activeNodeID = 0;
164 return false;
165}

◆ RemoveParent()

void Shunt::RemoveParent ( Element *  parent)
virtual

Remove a parent.

Parameters
parentParent to be removed.

Reimplemented from Element.

Definition at line 143 of file Shunt.cpp.

144{
145 if (parent == m_parentList[0]) {
146 m_parentList[0] = nullptr;
147 m_online = false;
148 UpdateSwitchesPosition();
149 UpdatePowerFlowArrowsPosition();
150 }
151}

◆ RotateNode()

void Shunt::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 Element.

Definition at line 211 of file Shunt.cpp.

212{
213 double rotAngle = m_rotationAngle;
214 if (!clockwise) rotAngle = -m_rotationAngle;
215
216 if (parent == m_parentList[0]) {
217 m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle);
218 UpdateSwitchesPosition();
219 UpdatePowerFlowArrowsPosition();
220 }
221}
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
Rotate a point as element position being the origin.
Definition Element.cpp:298
Here is the call graph for this function:

◆ SetNodeParent()

bool Shunt::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 Element.

Definition at line 167 of file Shunt.cpp.

168{
169 if (parent && m_activeNodeID != 0) {
170 wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize,
171 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize);
172
173 if (parent->Intersects(nodeRect)) {
174 m_parentList[0] = parent;
175
176 // Centralize the node on bus.
177 wxPoint2DDouble parentPt =
178 parent->RotateAtPosition(m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position.
179 parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
180 parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle());
181 m_pointList[0] = parentPt;
182
183 UpdateSwitchesPosition();
184 UpdatePowerFlowArrowsPosition();
185 return true;
186 }
187 else {
188 m_parentList[0] = nullptr;
189 m_online = false;
190 }
191 }
192 return false;
193}
virtual bool Intersects(wxRect2DDouble rect) const =0
Check if the element's rect intersects other rect.
Here is the call graph for this function:

◆ StartMove()

void Shunt::StartMove ( wxPoint2DDouble  position)
virtual

Update the element attributes related to the movement.

Parameters
positionStart move position.

Reimplemented from Element.

Definition at line 136 of file Shunt.cpp.

137{
138 m_moveStartPt = position;
139 m_movePts = m_pointList;
140 m_movePos = m_position;
141}

◆ UpdateNodes()

void Shunt::UpdateNodes ( )
virtual

Update the nodes according to the parents. If a parent is removed, use this method.

Reimplemented from Element.

Definition at line 195 of file Shunt.cpp.

196{
197 if (m_parentList[0]) {
198 wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize,
199 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize);
200
201 if (!m_parentList[0]->Intersects(nodeRect)) {
202 m_parentList[0]->RemoveChild(this);
203 m_parentList[0] = nullptr;
204 m_online = false;
205 UpdateSwitchesPosition();
206 UpdatePowerFlowArrowsPosition();
207 }
208 }
209}
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
Definition Shunt.h:38
Here is the call graph for this function:

◆ UpdatePowerFlowArrowsPosition()

void Shunt::UpdatePowerFlowArrowsPosition ( )
overridevirtual

Reimplemented from PowerElement.

Definition at line 284 of file Shunt.cpp.

285{
286 std::vector<wxPoint2DDouble> edges;
287 switch (m_pfDirection) {
289 m_powerFlowArrow.clear();
290 } break;
292 edges.push_back(m_pointList[2]);
293 edges.push_back(m_pointList[1]);
294 } break;
296 edges.push_back(m_pointList[1]);
297 edges.push_back(m_pointList[2]);
298 } break;
299 default:
300 break;
301 }
303}
virtual void CalculatePowerFlowPts(std::vector< wxPoint2DDouble > edges)
Calculate the points of the power flow arrows.

◆ UpdateSwitchesPosition()

void Shunt::UpdateSwitchesPosition ( )
overridevirtual

Reimplemented from PowerElement.

Definition at line 22 of file Shunt.cpp.

23{
24 if (m_parentList[0]) {
25 m_pointList[1] = GetSwitchPoint(m_parentList[0], m_pointList[0], m_pointList[2]);
26 }
27 else {
28 m_pointList[1] = m_pointList[0];
29 }
31}
virtual void UpdateSwitches()
Update the switch position.
virtual wxPoint2DDouble GetSwitchPoint(Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
Get the correct switch position.

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