Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
Inductor Class Reference

Inductor shunt power element. More...

#include <Inductor.h>

Inheritance diagram for Inductor:
Collaboration diagram for Inductor:

Public Member Functions

 Inductor (wxString name)
 
virtual ElementGetCopy ()
 Get a the element copy.
 
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 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 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 Rotate (bool clockwise=true)
 Rotate the element.
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual bool ShowForm (wxWindow *parent, Element *element)
 Show element data form.
 
virtual InductorElectricalData GetElectricalData ()
 
virtual InductorElectricalData GetPUElectricalData (double systemPowerBase)
 
virtual void SetElectricalData (InductorElectricalData electricalData)
 
virtual rapidxml::xml_node * SaveElement (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementListNode)
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
- Public Member Functions inherited from Shunt
virtual void Move (wxPoint2DDouble position)
 Move the element other position.
 
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.
 
- 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 (wxGraphicsContext *gc) const
 Draw switch.
 
virtual void DrawDCSwitches (wxDC &dc) const
 
virtual void CalculatePowerFlowPts (std::vector< wxPoint2DDouble > edges)
 Calculate the points of the power flow arrows.
 
virtual void DrawDCPowerFlowPts (wxGraphicsContext *gc) const
 Draw power flow arrows.
 
virtual void DrawDCPowerFlowPts (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)
 
virtual void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
virtual void SaveSwitchingData (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *electricalNode)
 
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 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 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 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.
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode)
 
void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenCADProperties (rapidxml::xml_node<> *elementNode)
 

Protected Attributes

InductorElectricalData m_electricalData
 
- 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
 
wxColour 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.
 
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 Shunt
void UpdateSwitchesPosition ()
 
void UpdatePowerFlowArrowsPosition ()
 
void DrawDCGround (wxPoint2DDouble position, wxGraphicsContext *gc) const
 
void DrawDCGround (wxPoint2DDouble position, wxDC &dc) const
 

Detailed Description

Inductor shunt power element.

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

Definition at line 38 of file Inductor.h.

Constructor & Destructor Documentation

◆ Inductor() [1/2]

Inductor::Inductor ( )

Definition at line 21 of file Inductor.cpp.

21 : Shunt()
22{
23 m_elementType = TYPE_INDUCTOR;
24}
Abstract class for shunt power elements.
Definition Shunt.h:32

◆ Inductor() [2/2]

Inductor::Inductor ( wxString  name)

Definition at line 26 of file Inductor.cpp.

26 : Shunt()
27{
28 m_elementType = TYPE_INDUCTOR;
29 m_electricalData.name = name;
30}

◆ ~Inductor()

Inductor::~Inductor ( )

Definition at line 32 of file Inductor.cpp.

32{}

Member Function Documentation

◆ AddParent()

bool Inductor::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 34 of file Inductor.cpp.

35{
36 if (parent) {
37 m_parentList.push_back(parent);
38 parent->AddChild(this);
39 wxPoint2DDouble parentPt =
40 parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
41 parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
42 parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back.
43
44 m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
45 m_width = 20.0;
46 m_height = 70.0;
47 m_rect = wxRect2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0, m_width, m_height);
48
49 m_pointList.push_back(parentPt);
50 m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position));
51 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0 - 10.0));
52 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0));
53
54 m_inserted = true;
55
56 wxRect2DDouble genRect(0, 0, 0, 0);
57 m_switchRect.push_back(genRect); // Push a general rectangle.
59
60 return true;
61 }
62 return false;
63}
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:186
double GetAngle() const
Get the element angle.
Definition Element.h:211
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
Rotate a point as element position being the origin.
Definition Element.cpp:292
virtual void AddChild(Element *child)
Add a child to the child list.
Definition Element.cpp:566
virtual void UpdateSwitches()
Update the switch position.
virtual wxPoint2DDouble GetSwitchPoint(Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
Get the correct switch position.
Here is the call graph for this function:

◆ Contains()

bool Inductor::Contains ( wxPoint2DDouble  position) const
virtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Reimplemented from Shunt.

Definition at line 285 of file Inductor.cpp.

286{
287 wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
288 return m_rect.Contains(ptR);
289}
Here is the call graph for this function:

◆ DrawDC() [1/2]

void Inductor::DrawDC ( wxPoint2DDouble  translation,
double  scale,
wxDC &  dc 
) const
virtual

Draw the element using wxDC.

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

Reimplemented from Element.

Definition at line 193 of file Inductor.cpp.

194{
195 wxColour elementColour;
196 if (m_online) {
197 if (m_dynEvent)
198 elementColour = m_dynamicEventColour;
199 else
200 elementColour = m_onlineElementColour;
201 }
202 else
203 elementColour = m_offlineElementColour;
204
205 std::vector<wxPoint> pointListInt;
206 for (auto& pt : m_pointList) {
207 pointListInt.emplace_back(static_cast<int>(pt.m_x), static_cast<int>(pt.m_y));
208 }
209
210 if (m_inserted) {
211 wxPoint arcPts[3];
212 wxPoint2DDouble p;
213 p = m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0);
214 arcPts[0] = RotateAround(p, m_position, m_angle);
215 p = m_position + wxPoint2DDouble(0, -m_height / 2.0 + 25.0);
216 arcPts[1] = RotateAround(p, m_position, m_angle);
217 p = m_position + wxPoint2DDouble(0, -m_height / 2.0 + 40.0);
218 arcPts[2] = RotateAround(p, m_position, m_angle);
219
220 if (m_selected) {
221 dc.SetPen(wxPen(wxColour(m_selectionColour), 2 + m_borderSize * 2.0));
222 dc.SetBrush(*wxTRANSPARENT_BRUSH);
223
224 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
225
226 DrawDCArc(arcPts[0], 10, 90 - m_angle, 315 - m_angle, dc);
227 DrawDCArc(arcPts[1], 10, 45 - m_angle, 315 - m_angle, dc);
228 DrawDCArc(arcPts[2], 10, 45 - m_angle, 270 - m_angle, dc);
229
230 DrawDCGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 50.0), dc);
231
232 // Draw node selection.
233 dc.SetPen(*wxTRANSPARENT_PEN);
234 dc.SetBrush(wxBrush(wxColour(m_selectionColour)));
235 DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, dc);
236 }
237 // Draw Inductor (layer 2).
238 dc.SetPen(*wxTRANSPARENT_PEN);
239 dc.SetBrush(wxBrush(wxColour(elementColour)));
240 DrawDCCircle(m_pointList[0], 5.0, dc);
241
242 dc.SetPen(wxPen(wxColour(elementColour), 2));
243 dc.SetBrush(*wxTRANSPARENT_BRUSH);
244 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
245
246 DrawDCSwitches(dc);
247
248 dc.SetPen(wxPen(wxColour(elementColour), 2));
249 dc.SetBrush(*wxTRANSPARENT_BRUSH);
250 DrawDCArc(arcPts[0], 10, 90 - m_angle, 315 - m_angle, dc);
251 DrawDCArc(arcPts[1], 10, 45 - m_angle, 315 - m_angle, dc);
252 DrawDCArc(arcPts[2], 10, 45 - m_angle, 270 - m_angle, dc);
253
254 DrawDCGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 50.0), dc);
255 }
256}
virtual void DrawDCCircle(wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
Draw a circle using device context.
Definition Element.cpp:177
virtual void DrawDCSwitches(wxGraphicsContext *gc) const
Draw switch.
Here is the call graph for this function:

◆ DrawDC() [2/2]

void Inductor::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 124 of file Inductor.cpp.

125{
126 wxColour elementColour;
127 if (m_online) {
128 if (m_dynEvent)
129 elementColour = m_dynamicEventColour;
130 else
131 elementColour = m_onlineElementColour;
132 }
133 else
134 elementColour = m_offlineElementColour;
135
136 if (m_inserted) {
137 if (m_selected) {
138 gc->SetPen(wxPen(wxColour(m_selectionColour), 2 + m_borderSize * 2.0));
139 gc->SetBrush(*wxTRANSPARENT_BRUSH);
140
141 gc->StrokeLines(m_pointList.size(), &m_pointList[0]);
142
143 // Push the current matrix on stack.
144 gc->PushState();
145 // Rotate the matrix around the object position.
146 gc->Translate(m_position.m_x, m_position.m_y);
147 gc->Rotate(wxDegToRad(m_angle));
148 gc->Translate(-m_position.m_x, -m_position.m_y);
149
150 DrawDCArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0), 10, 45, 270, 30, gc);
151 DrawDCArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 25.0), 10, 45, 315, 30, gc);
152 DrawDCArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 40.0), 10, 90, 315, 30, gc);
153
154 DrawDCGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 50.0), gc);
155
156 gc->PopState();
157
158 // Draw node selection.
159 gc->SetPen(*wxTRANSPARENT_PEN);
160 gc->SetBrush(wxBrush(wxColour(m_selectionColour)));
161 DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, gc);
162 }
163 // Draw Inductor (layer 2).
164 gc->SetPen(*wxTRANSPARENT_PEN);
165 gc->SetBrush(wxBrush(wxColour(elementColour)));
166 DrawDCCircle(m_pointList[0], 5.0, 10, gc);
167
168 gc->SetPen(wxPen(wxColour(elementColour), 2));
169 gc->SetBrush(*wxTRANSPARENT_BRUSH);
170 gc->StrokeLines(m_pointList.size(), &m_pointList[0]);
171
172 DrawDCSwitches(gc);
173
174 // Push the current matrix on stack.
175 gc->PushState();
176 // Rotate the matrix around the object position.
177 gc->Translate(m_position.m_x, m_position.m_y);
178 gc->Rotate(wxDegToRad(m_angle));
179 gc->Translate(-m_position.m_x, -m_position.m_y);
180
181 gc->SetPen(wxPen(wxColour(elementColour), 2));
182 gc->SetBrush(*wxTRANSPARENT_BRUSH);
183 DrawDCArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0), 10, 45, 270, 10, gc);
184 DrawDCArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 25.0), 10, 45, 315, 10, gc);
185 DrawDCArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 40.0), 10, 90, 315, 10, gc);
186
187 DrawDCGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 50.0), gc);
188
189 gc->PopState();
190 }
191}
Here is the call graph for this function:

◆ GetContextMenu()

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

Definition at line 270 of file Inductor.cpp.

271{
272 menu.Append(ID_EDIT_ELEMENT, _("Edit Inductor"));
273
274 wxMenu* textMenu = new wxMenu();
275
276 textMenu->Append(ID_TXT_NAME, _("Name"));
277 textMenu->Append(ID_TXT_REACTIVE_POWER, _("Reactive power"));
278 textMenu->SetClientData(menu.GetClientData());
279 menu.AppendSubMenu(textMenu, _("Add text"));
280
281 GeneralMenuItens(menu);
282 return true;
283}
@ ID_EDIT_ELEMENT
Definition Element.h:75
virtual void GeneralMenuItens(wxMenu &menu)
Insert general itens to context menu.
Definition Element.cpp:457
Here is the call graph for this function:

◆ GetCopy()

Element * Inductor::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 326 of file Inductor.cpp.

327{
328 Inductor* copy = new Inductor();
329 *copy = *this;
330 return copy;
331}
Inductor shunt power element.
Definition Inductor.h:39

◆ GetElectricalData()

virtual InductorElectricalData Inductor::GetElectricalData ( )
inlinevirtual

Definition at line 56 of file Inductor.h.

56{ return m_electricalData; }

◆ GetPUElectricalData()

InductorElectricalData Inductor::GetPUElectricalData ( double  systemPowerBase)
virtual

Definition at line 303 of file Inductor.cpp.

304{
305 InductorElectricalData data = m_electricalData;
306 switch (data.reactivePowerUnit) {
308 data.reactivePower = data.reactivePower / systemPowerBase;
309 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
310 } break;
312 data.reactivePower = (data.reactivePower * 1e3) / systemPowerBase;
313 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
314 } break;
316 data.reactivePower = (data.reactivePower * 1e6) / systemPowerBase;
317 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
318 } break;
319 default:
320 break;
321 }
322
323 return data;
324}

◆ GetTipText()

wxString Inductor::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 333 of file Inductor.cpp.

334{
335 wxString tipText = m_electricalData.name;
336
337 // TODO: Avoid reactive power calculation.
338 double reactivePower = m_electricalData.reactivePower;
339 if (!m_online)
340 reactivePower = 0.0;
341 else {
342 std::complex<double> v = static_cast<Bus*>(m_parentList[0])->GetElectricalData().voltage;
343 reactivePower *= std::pow(std::abs(v), 2);
344 }
345 tipText += "\n";
346 tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
347 switch (m_electricalData.reactivePowerUnit) {
349 tipText += _(" p.u.");
350 } break;
352 tipText += _(" var");
353 } break;
355 tipText += _(" kvar");
356 } break;
358 tipText += _(" Mvar");
359 } break;
360 default:
361 break;
362 }
363
364 return tipText;
365}
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86

◆ Intersects()

bool Inductor::Intersects ( wxRect2DDouble  rect) const
virtual

Check if the element's rect intersects other rect.

Parameters
rectRect to check intersection.

Reimplemented from Shunt.

Definition at line 291 of file Inductor.cpp.

291{ return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0); }
virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
Check if two roteted rectangles intersect.
Definition Element.cpp:359
Here is the call graph for this function:

◆ OpenElement()

bool Inductor::OpenElement ( rapidxml::xml_node<> *  elementNode,
std::vector< Element * >  parentList 
)
virtual

Reimplemented from PowerElement.

Definition at line 388 of file Inductor.cpp.

389{
390 if (!OpenCADProperties(elementNode, parentList)) return false;
391
392 auto electricalProp = elementNode->first_node("ElectricalProperties");
393 if (!electricalProp) return false;
394
395 SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
396 m_electricalData.name = electricalProp->first_node("Name")->value();
397 m_electricalData.reactivePower = XMLParser::GetNodeValueDouble(electricalProp, "ReactivePower");
398 m_electricalData.reactivePowerUnit =
399 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ReactivePower", "UnitID"));
400
401 if (!OpenSwitchingData(electricalProp)) return false;
402 if (m_swData.swTime.size() != 0) SetDynamicEvent(true);
403
404 m_inserted = true;
405 return true;
406}
ElectricalUnit
Electrical units.
bool SetOnline(bool online=true)
Set if the element is online or offline.
Definition Element.cpp:447
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.
std::vector< double > swTime

◆ Rotate()

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

Rotate the element.

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

Reimplemented from Element.

Definition at line 258 of file Inductor.cpp.

259{
260 double rotAngle = m_rotationAngle;
261 if (!clockwise) rotAngle = -m_rotationAngle;
262
263 m_angle += rotAngle;
264 if (m_angle >= 360 || m_angle <= -360) m_angle = 0.0;
265 m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle);
266 m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle);
267 UpdateSwitchesPosition();
268}
Here is the call graph for this function:

◆ SaveElement()

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

Reimplemented from Element.

Definition at line 367 of file Inductor.cpp.

368{
369 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Inductor");
370 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
371
372 SaveCADProperties(doc, elementNode);
373
374 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
375 auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
376 XMLParser::SetNodeValue(doc, isOnline, m_online);
377 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
378 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
379 auto reactivePower = XMLParser::AppendNode(doc, electricalProp, "ReactivePower");
380 XMLParser::SetNodeValue(doc, reactivePower, m_electricalData.reactivePower);
381 XMLParser::SetNodeAttribute(doc, reactivePower, "UnitID", static_cast<int>(m_electricalData.reactivePowerUnit));
382
383 SaveSwitchingData(doc, electricalProp);
384
385 return elementNode;
386}

◆ SetElectricalData()

virtual void Inductor::SetElectricalData ( InductorElectricalData  electricalData)
inlinevirtual

Definition at line 58 of file Inductor.h.

58{ m_electricalData = electricalData; }

◆ ShowForm()

bool Inductor::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 292 of file Inductor.cpp.

293{
294 ReactiveShuntElementForm inductorForm(parent, this);
295 inductorForm.SetTitle(_("Inductor"));
296 inductorForm.CenterOnParent();
297 if (inductorForm.ShowModal() == wxID_OK) {
298 return true;
299 }
300 return false;
301}
Form to edit the reactive shunt element power data.

Member Data Documentation

◆ m_electricalData

InductorElectricalData Inductor::m_electricalData
protected

Definition at line 64 of file Inductor.h.


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