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

Shunt Harmonic Corrent Source. More...

#include <HarmCurrent.h>

Inheritance diagram for HarmCurrent:
Collaboration diagram for HarmCurrent:

Public Member Functions

 HarmCurrent (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 HarmCurrentElectricalData GetElectricalData ()
 
virtual HarmCurrentElectricalData GetPUElectricalData (double systemPowerBase, double voltage)
 
virtual void SetElectricalData (HarmCurrentElectricalData 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

std::vector< wxPoint2DDouble > m_triangPts
 
HarmCurrentElectricalData 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

Shunt Harmonic Corrent Source.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
22/04/2019

Definition at line 23 of file HarmCurrent.h.

Constructor & Destructor Documentation

◆ HarmCurrent() [1/2]

HarmCurrent::HarmCurrent ( )

Definition at line 5 of file HarmCurrent.cpp.

5: Shunt() {}
Abstract class for shunt power elements.
Definition Shunt.h:32

◆ HarmCurrent() [2/2]

HarmCurrent::HarmCurrent ( wxString  name)

Definition at line 9 of file HarmCurrent.cpp.

9: Shunt() { m_electricalData.name = name; }

◆ ~HarmCurrent()

HarmCurrent::~HarmCurrent ( )

Definition at line 7 of file HarmCurrent.cpp.

7{}

Member Function Documentation

◆ AddParent()

bool HarmCurrent::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 18 of file HarmCurrent.cpp.

19{
20 if (parent) {
21 m_parentList.push_back(parent);
22 parent->AddChild(this);
23 wxPoint2DDouble parentPt =
24 parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
25 parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
26 parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back.
27
28 m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
29 m_width = 40;
30 m_height = 60;
31 m_rect = wxRect2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0, m_width, m_height);
32
33 m_pointList.push_back(parentPt);
34 m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position));
35 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0 - 10.0));
36 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0));
37
38 m_triangPts.push_back(wxPoint2DDouble(-5, -15));
39 m_triangPts.push_back(wxPoint2DDouble(5, -15));
40 m_triangPts.push_back(wxPoint2DDouble(0.0, -30.0));
41
42 m_inserted = true;
43
44 wxRect2DDouble genRect(0, 0, 0, 0);
45 m_switchRect.push_back(genRect); // Push a general rectangle.
47
48 return true;
49 }
50 return false;
51}
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 HarmCurrent::Contains ( wxPoint2DDouble  position) const
virtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Reimplemented from Shunt.

Definition at line 278 of file HarmCurrent.cpp.

279{
280 wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
281 return m_rect.Contains(ptR);
282}
Here is the call graph for this function:

◆ DrawDC() [1/2]

void HarmCurrent::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 202 of file HarmCurrent.cpp.

203{
204 wxColour elementColour;
205 if (m_online) {
206 if (m_dynEvent)
207 elementColour = m_dynamicEventColour;
208 else
209 elementColour = m_onlineElementColour;
210 }
211 else
212 elementColour = m_offlineElementColour;
213
214 if (m_inserted) {
215 wxPoint arrowPts[2];
216 wxPoint2DDouble p;
217 arrowPts[0] = RotateAround(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0), m_position, m_angle);
218 arrowPts[1] = RotateAround(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0) + wxPoint2DDouble(0, 40), m_position, m_angle);
219
220 std::vector<wxPoint> pointListInt;
221 for (auto& pt : m_pointList) {
222 pointListInt.emplace_back(static_cast<int>(pt.m_x), static_cast<int>(pt.m_y));
223 }
224
225 // Draw Selection (layer 1).
226 if (m_selected) {
227 dc.SetPen(wxPen(wxColour(m_selectionColour), 2 + m_borderSize * 2.0));
228 dc.SetBrush(*wxTRANSPARENT_BRUSH);
229 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
230
231 DrawDCGround(m_position + wxPoint2DDouble(0, 10.0), dc);
232
233 dc.SetPen(*wxTRANSPARENT_PEN);
234 dc.SetBrush(wxBrush(wxColour(m_selectionColour)));
235
236 p = RotateAround(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0 + 20), m_position, m_angle);
237 DrawDCCircle(p, 20.0 + (m_borderSize + 1.5) / scale, dc);
238
239 // Draw node selection.
240 DrawDCCircle(pointListInt[0], 5.0 + m_borderSize / scale, dc);
241 }
242
243 // Draw Harmonic current source (layer 2).
244 dc.SetPen(wxPen(wxColour(elementColour), 2));
245 dc.SetBrush(*wxTRANSPARENT_BRUSH);
246 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
247
248 // Draw node.
249 dc.SetPen(*wxTRANSPARENT_PEN);
250 dc.SetBrush(wxBrush(wxColour(elementColour)));
251 DrawDCCircle(pointListInt[0], 5.0, dc);
252
253 DrawDCSwitches(dc);
254
255 wxPoint triangPts[3];
256
257 //std::vector<wxPoint2DDouble> triangPts;
258 for (int i = 0; i < 3; i++) {
259 p = m_triangPts[i] + m_position;
260 triangPts[i] = RotateAround(p, m_position, m_angle);
261 }
262
263 dc.SetPen(wxPen(wxColour(elementColour), 2));
264 dc.SetBrush(*wxWHITE_BRUSH);
265 p = RotateAround(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0 + 20), m_position, m_angle);
266 DrawDCCircle(p, 20.0, dc);
267
268 dc.SetPen(*wxTRANSPARENT_PEN);
269 dc.SetBrush(wxBrush(wxColour(elementColour)));
270 dc.DrawPolygon(3, triangPts);
271
272 dc.SetPen(wxPen(wxColour(elementColour), 2));
273 dc.DrawLines(2, arrowPts);
274 DrawDCGround(m_position + wxPoint2DDouble(0, 10.0), dc);
275 }
276}
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 HarmCurrent::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 120 of file HarmCurrent.cpp.

121{
122 wxColour elementColour;
123 if (m_online) {
124 if (m_dynEvent)
125 elementColour = m_dynamicEventColour;
126 else
127 elementColour = m_onlineElementColour;
128 }
129 else
130 elementColour = m_offlineElementColour;
131
132 if (m_inserted) {
133 std::vector<wxPoint2DDouble> arrowPts;
134 arrowPts.push_back(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0));
135 arrowPts.push_back(arrowPts[0] + wxPoint2DDouble(0, 40));
136
137 // Draw Selection (layer 1).
138 if (m_selected) {
139 gc->SetPen(wxPen(wxColour(m_selectionColour), 2 + m_borderSize * 2.0));
140 gc->SetBrush(*wxTRANSPARENT_BRUSH);
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 DrawDCGround(m_position + wxPoint2DDouble(0, 10.0), gc);
151
152 gc->SetPen(*wxTRANSPARENT_PEN);
153 gc->SetBrush(wxBrush(wxColour(m_selectionColour)));
154
155 DrawDCCircle(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0 + 20),
156 20.0 + (m_borderSize + 1.5) / scale, 20, gc);
157
158 gc->PopState();
159
160 // Draw node selection.
161 DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, gc);
162 }
163
164 // Draw Harmonic current source (layer 2).
165 gc->SetPen(wxPen(wxColour(elementColour), 2));
166 gc->SetBrush(*wxTRANSPARENT_BRUSH);
167 gc->StrokeLines(m_pointList.size(), &m_pointList[0]);
168
169 // Draw node.
170 gc->SetPen(*wxTRANSPARENT_PEN);
171 gc->SetBrush(wxBrush(wxColour(elementColour)));
172 DrawDCCircle(m_pointList[0], 5.0, 10, gc);
173
174 DrawDCSwitches(gc);
175
176 std::vector<wxPoint2DDouble> triangPts;
177 for (int i = 0; i < 3; i++) { triangPts.push_back(m_triangPts[i] + m_position); }
178
179 gc->PushState();
180 gc->Translate(m_position.m_x, m_position.m_y);
181 gc->Rotate(wxDegToRad(m_angle));
182 gc->Translate(-m_position.m_x, -m_position.m_y);
183
184 //glColor4dv(elementColour);
185 gc->SetPen(wxPen(wxColour(elementColour), 2));
186 gc->SetBrush(*wxWHITE_BRUSH);
187 DrawDCCircle(wxPoint2DDouble(m_position.m_x, m_position.m_y - m_height / 2.0 + 20), 20, 20, gc);
188
189 gc->SetPen(*wxTRANSPARENT_PEN);
190 gc->SetBrush(wxBrush(wxColour(elementColour)));
191
192 DrawDCTriangle(triangPts, gc);
193
194 gc->SetPen(wxPen(wxColour(elementColour), 2));
195 gc->StrokeLines(arrowPts.size(), &arrowPts[0]);
196 DrawDCGround(m_position + wxPoint2DDouble(0, 10.0), gc);
197
198 gc->PopState();
199 }
200}
virtual void DrawDCTriangle(std::vector< wxPoint2DDouble > points, wxGraphicsContext *gc) const
Draw rectangle.
Definition Element.cpp:237
Here is the call graph for this function:

◆ GetContextMenu()

bool HarmCurrent::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 301 of file HarmCurrent.cpp.

302{
303 menu.Append(ID_EDIT_ELEMENT, _("Edit Harmonic Current Source"));
304 GeneralMenuItens(menu);
305 return true;
306}
@ 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 * HarmCurrent::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 11 of file HarmCurrent.cpp.

12{
13 HarmCurrent* copy = new HarmCurrent();
14 *copy = *this;
15 return copy;
16}
Shunt Harmonic Corrent Source.
Definition HarmCurrent.h:24

◆ GetElectricalData()

virtual HarmCurrentElectricalData HarmCurrent::GetElectricalData ( )
inlinevirtual

Definition at line 41 of file HarmCurrent.h.

41{ return m_electricalData; }

◆ GetPUElectricalData()

HarmCurrentElectricalData HarmCurrent::GetPUElectricalData ( double  systemPowerBase,
double  voltage 
)
virtual

Definition at line 334 of file HarmCurrent.cpp.

335{
336 HarmCurrentElectricalData puData = m_electricalData;
337 double ib = systemPowerBase / (std::sqrt(3.00) * voltage);
338 for (unsigned int i = 0; i < puData.harmonicOrder.size(); ++i) {
339 if (puData.injHarmCurrentUnit[i] == ElectricalUnit::UNIT_A) {
340 puData.injHarmCurrent[i] /= ib;
341 puData.injHarmCurrentUnit[i] = ElectricalUnit::UNIT_PU;
342 }
343 }
344 return puData;
345}

◆ GetTipText()

wxString HarmCurrent::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 308 of file HarmCurrent.cpp.

309{
310 wxString tipText = m_electricalData.name;
311
312 for (unsigned int i = 0; i < m_electricalData.harmonicOrder.size(); ++i) {
313 tipText +=
314 wxString::Format("\nI%dh = %s %s (%s%s)", m_electricalData.harmonicOrder[i],
315 StringFromDouble(m_electricalData.injHarmCurrent[i]),
316 m_electricalData.injHarmCurrentUnit[i] == ElectricalUnit::UNIT_A ? "A" : "p.u.",
317 StringFromDouble(m_electricalData.injHarmAngle[i]), static_cast<wxString>(L'\u00B0'));
318 }
319
320 return tipText;
321}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:533
Here is the call graph for this function:

◆ Intersects()

bool HarmCurrent::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 284 of file HarmCurrent.cpp.

285{
286 return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0);
287}
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 HarmCurrent::OpenElement ( rapidxml::xml_node<> *  elementNode,
std::vector< Element * >  parentList 
)
virtual

Reimplemented from PowerElement.

Definition at line 376 of file HarmCurrent.cpp.

377{
378 if (!OpenCADProperties(elementNode, parentList)) return false;
379
380 auto electricalProp = elementNode->first_node("ElectricalProperties");
381 if (!electricalProp) return false;
382
383 SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
384 m_electricalData.name = electricalProp->first_node("Name")->value();
385
386 auto harmCurrentList = electricalProp->first_node("HarmCurrentList");
387 auto harmCurrent = harmCurrentList->first_node("HarmCurrent");
388 while (harmCurrent) {
389 m_electricalData.harmonicOrder.push_back(XMLParser::GetNodeValueInt(harmCurrent, "Order"));
390 m_electricalData.injHarmCurrent.push_back(XMLParser::GetNodeValueDouble(harmCurrent, "InjCurrent"));
391 m_electricalData.injHarmCurrentUnit.push_back(
392 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(harmCurrent, "InjCurrent", "UnitID")));
393 m_electricalData.injHarmAngle.push_back(XMLParser::GetNodeValueDouble(harmCurrent, "Angle"));
394 harmCurrent = harmCurrent->next_sibling("HarmCurrent");
395 }
396
397 m_inserted = true;
398 return true;
399}
ElectricalUnit
Electrical units.
bool SetOnline(bool online=true)
Set if the element is online or offline.
Definition Element.cpp:447

◆ Rotate()

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

Rotate the element.

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

Reimplemented from Element.

Definition at line 289 of file HarmCurrent.cpp.

290{
291 double rotAngle = m_rotationAngle;
292 if (!clockwise) rotAngle = -m_rotationAngle;
293
294 m_angle += rotAngle;
295 if (m_angle >= 360 || m_angle <= -360) m_angle = 0.0;
296 m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle);
297 m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle);
298 UpdateSwitchesPosition();
299}
Here is the call graph for this function:

◆ SaveElement()

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

Reimplemented from Element.

Definition at line 347 of file HarmCurrent.cpp.

348{
349 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "HarmCurrent");
350 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
351
352 SaveCADProperties(doc, elementNode);
353
354 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
355 auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
356 XMLParser::SetNodeValue(doc, isOnline, m_online);
357 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
358 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
359
360 auto harmCurrentDataList = XMLParser::AppendNode(doc, electricalProp, "HarmCurrentList");
361 for (int i = 0; i < static_cast<int>(m_electricalData.harmonicOrder.size()); i++) {
362 auto harmCurrentData = XMLParser::AppendNode(doc, harmCurrentDataList, "HarmCurrent");
363 XMLParser::SetNodeAttribute(doc, harmCurrentData, "ID", i);
364 auto order = XMLParser::AppendNode(doc, harmCurrentData, "Order");
365 XMLParser::SetNodeValue(doc, order, m_electricalData.harmonicOrder[i]);
366 auto injCurrent = XMLParser::AppendNode(doc, harmCurrentData, "InjCurrent");
367 XMLParser::SetNodeValue(doc, injCurrent, m_electricalData.injHarmCurrent[i]);
368 XMLParser::SetNodeAttribute(doc, injCurrent, "UnitID", static_cast<int>(m_electricalData.injHarmCurrentUnit[i]));
369 auto injHarmAngle = XMLParser::AppendNode(doc, harmCurrentData, "Angle");
370 XMLParser::SetNodeValue(doc, injHarmAngle, m_electricalData.injHarmAngle[i]);
371 }
372
373 return elementNode;
374}

◆ SetElectricalData()

virtual void HarmCurrent::SetElectricalData ( HarmCurrentElectricalData  electricalData)
inlinevirtual

Definition at line 43 of file HarmCurrent.h.

43{ m_electricalData = electricalData; }

◆ ShowForm()

bool HarmCurrent::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 323 of file HarmCurrent.cpp.

324{
325 HarmCurrentForm harmCurrentForm(parent, this);
326 harmCurrentForm.SetTitle(_("Harmonic Current Source"));
327 harmCurrentForm.CenterOnParent();
328 if (harmCurrentForm.ShowModal() == wxID_OK) {
329 return true;
330 }
331 return false;
332}

Member Data Documentation

◆ m_electricalData

HarmCurrentElectricalData HarmCurrent::m_electricalData
protected

Definition at line 50 of file HarmCurrent.h.

◆ m_triangPts

std::vector<wxPoint2DDouble> HarmCurrent::m_triangPts
protected

Definition at line 49 of file HarmCurrent.h.


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