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

Shunt capactior power element. More...

#include <Capacitor.h>

Inheritance diagram for Capacitor:
Collaboration diagram for Capacitor:

Public Member Functions

 Capacitor (wxString name)
 
virtual Element * GetCopy ()
 Get a the element copy.
 
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 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 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, wxWindow *workspace=nullptr)
 Show element data form.
 
virtual CapacitorElectricalData GetElectricalData ()
 
virtual CapacitorElectricalData GetPUElectricalData (double systemPowerBase)
 
virtual void SetElectricalData (CapacitorElectricalData 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 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 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 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 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 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

CapacitorElectricalData 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
 

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 DrawDCGround (wxPoint2DDouble position, wxGraphicsContext *gc) const
 
void DrawDCGround (wxPoint2DDouble position, wxDC &dc) const
 

Detailed Description

Shunt capactior 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 Capacitor.h.

Constructor & Destructor Documentation

◆ Capacitor() [1/2]

Capacitor::Capacitor ( )

Definition at line 21 of file Capacitor.cpp.

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

◆ Capacitor() [2/2]

Capacitor::Capacitor ( wxString  name)

Definition at line 25 of file Capacitor.cpp.

25 : Shunt() {
26 m_elementType = TYPE_CAPACITOR;
27 m_electricalData.name = name;
28}

◆ ~Capacitor()

Capacitor::~Capacitor ( )

Definition at line 30 of file Capacitor.cpp.

30{}

Member Function Documentation

◆ AddParent()

bool Capacitor::AddParent ( Element *  parent,
wxPoint2DDouble  position,
bool  isOpening = false 
)
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 32 of file Capacitor.cpp.

33{
34 if (parent) {
35 m_parentList.push_back(parent);
36 parent->AddChild(this);
37 wxPoint2DDouble parentPt =
38 parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
39 parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
40 parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back.
41
42 m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
43 m_width = 40;
44 m_height = 30;
45 m_rect = wxRect2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0, m_width, m_height);
46
47 m_pointList.push_back(parentPt);
48 m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position));
49 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0 - 10.0));
50 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0));
51
52 m_inserted = true;
53
54 wxRect2DDouble genRect(0, 0, 0, 0);
55 m_switchRect.push_back(genRect); // Push a general rectangle.
57
58 return true;
59 }
60 return false;
61}
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:189
double GetAngle() const
Get the element angle.
Definition Element.h:214
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
Rotate a point as element position being the origin.
Definition Element.cpp:298
virtual void AddChild(Element *child)
Add a child to the child list.
Definition Element.cpp:581
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 Capacitor::Contains ( wxPoint2DDouble  position) const
virtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Reimplemented from Shunt.

Definition at line 298 of file Capacitor.cpp.

299{
300 wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
301 return m_rect.Contains(ptR);
302}
Here is the call graph for this function:

◆ DrawDC() [1/2]

void Capacitor::DrawDC ( GUIColour *  guiColour,
wxPoint2DDouble  translation,
double  scale,
wxDC &  dc 
) const
virtual

Draw the element using wxDC.

Parameters
guiColourColours of the system defined in properties.
translationTranslation of the system.
scaleScale of the system.
dcDevice context.

Reimplemented from Element.

Definition at line 202 of file Capacitor.cpp.

203{
204 wxColour elementColour;
205 if (m_online) {
206 if (m_dynEvent)
207 elementColour = guiColour->eventElement;
208 else
209 elementColour = guiColour->enabled;
210 }
211 else
212 elementColour = guiColour->disable;
213
214 if (m_inserted) {
215 wxPoint2DDouble p;
216 wxPoint capPts[4];
217 p = wxPoint2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0);
218 capPts[0] = RotateAround(p, m_position, m_angle);
219
220 p = wxPoint2DDouble(m_position.m_x + m_width / 2.0, m_position.m_y - m_height / 2.0);
221 capPts[1] = RotateAround(p, m_position, m_angle);
222
223 p = wxPoint2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0 + 10.0);
224 capPts[2] = RotateAround(p, m_position, m_angle);
225 p = wxPoint2DDouble(m_position.m_x + m_width / 2.0, m_position.m_y - m_height / 2.0 + 10.0);
226 capPts[3] = RotateAround(p, m_position, m_angle);
227
228 std::vector<wxPoint> pointListInt;
229 for (auto& pt : m_pointList) {
230 pointListInt.emplace_back(static_cast<int>(pt.m_x), static_cast<int>(pt.m_y));
231 }
232
233 if (m_selected) {
234 dc.SetPen(wxPen(guiColour->selection, 2 + m_borderSize * 2.0));
235 dc.SetBrush(*wxTRANSPARENT_BRUSH);
236
237 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
238
239
240 dc.DrawLines(2, &capPts[0]);
241 dc.DrawLines(2, &capPts[2]);
242
243 DrawDCGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0), dc);
244
245 // Draw node selection.
246 dc.SetPen(*wxTRANSPARENT_PEN);
247 dc.SetBrush(wxBrush(guiColour->selection));
248 DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, dc);
249 }
250 // Draw Capacitor (layer 2).
251 // Draw node.
252 dc.SetPen(*wxTRANSPARENT_PEN);
253 dc.SetBrush(wxBrush(elementColour));
254 DrawDCCircle(m_pointList[0], 5.0, dc);
255
256 dc.SetPen(wxPen(elementColour, 2));
257 dc.SetBrush(*wxTRANSPARENT_BRUSH);
258 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
259
260 DrawDCSwitches(guiColour, dc);
261
262 dc.SetPen(wxPen(elementColour, 2));
263 dc.SetBrush(*wxTRANSPARENT_BRUSH);
264 dc.DrawLines(2, &capPts[0]);
265 dc.DrawLines(2, &capPts[2]);
266
267 DrawDCGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0), dc);
268 }
269}
virtual void DrawDCCircle(wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
Draw a circle using device context.
Definition Element.cpp:173
virtual void DrawDCSwitches(GUIColour *guiColour, wxGraphicsContext *gc) const
Draw switch.
Here is the call graph for this function:

◆ DrawDC() [2/2]

void Capacitor::DrawDC ( GUIColour *  guiColour,
wxPoint2DDouble  translation,
double  scale,
wxGraphicsContext *  gc 
) const
virtual

Draw the element using GDI+.

Parameters
guiColourColours of the system defined in properties.
translationTranslation of the system.
scaleScale of the system.
gcGraphics context

Reimplemented from Element.

Definition at line 124 of file Capacitor.cpp.

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

◆ GetContextMenu()

bool Capacitor::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 283 of file Capacitor.cpp.

284{
285 menu.Append(ID_EDIT_ELEMENT, _("Edit Capacitor"));
286
287 wxMenu* textMenu = new wxMenu();
288
289 textMenu->Append(ID_TXT_NAME, _("Name"));
290 textMenu->Append(ID_TXT_REACTIVE_POWER, _("Reactive power"));
291 textMenu->SetClientData(menu.GetClientData());
292 menu.AppendSubMenu(textMenu, _("Add text"));
293
294 GeneralMenuItens(menu);
295 return true;
296}
@ ID_EDIT_ELEMENT
Definition Element.h:77
virtual void GeneralMenuItens(wxMenu &menu)
Insert general itens to context menu.
Definition Element.cpp:475
Here is the call graph for this function:

◆ GetCopy()

Element * Capacitor::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 343 of file Capacitor.cpp.

344{
345 Capacitor* copy = new Capacitor();
346 *copy = *this;
347 return copy;
348}
Shunt capactior power element.
Definition Capacitor.h:39

◆ GetElectricalData()

virtual CapacitorElectricalData Capacitor::GetElectricalData ( )
inlinevirtual

Definition at line 56 of file Capacitor.h.

56{ return m_electricalData; }

◆ GetPUElectricalData()

CapacitorElectricalData Capacitor::GetPUElectricalData ( double  systemPowerBase)
virtual

Definition at line 320 of file Capacitor.cpp.

321{
322 CapacitorElectricalData data = m_electricalData;
323 switch (data.reactivePowerUnit) {
324 case ElectricalUnit::UNIT_var: {
325 data.reactivePower = data.reactivePower / systemPowerBase;
326 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
327 } break;
328 case ElectricalUnit::UNIT_kvar: {
329 data.reactivePower = (data.reactivePower * 1e3) / systemPowerBase;
330 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
331 } break;
332 case ElectricalUnit::UNIT_Mvar: {
333 data.reactivePower = (data.reactivePower * 1e6) / systemPowerBase;
334 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
335 } break;
336 default:
337 break;
338 }
339
340 return data;
341}

◆ GetTipText()

wxString Capacitor::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 350 of file Capacitor.cpp.

351{
352 wxString tipText = m_electricalData.name;
353
354 // TODO: Avoid reactive power calculation.
355 double reactivePower = m_electricalData.reactivePower;
356 if (!m_online)
357 reactivePower = 0.0;
358 else {
359 std::complex<double> v = static_cast<Bus*>(m_parentList[0])->GetElectricalData().voltage;
360 reactivePower *= std::pow(std::abs(v), 2);
361 }
362 tipText += "\n";
363 tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
364 switch (m_electricalData.reactivePowerUnit) {
365 case ElectricalUnit::UNIT_PU: {
366 tipText += _(" p.u.");
367 } break;
368 case ElectricalUnit::UNIT_var: {
369 tipText += _(" var");
370 } break;
371 case ElectricalUnit::UNIT_kvar: {
372 tipText += _(" kvar");
373 } break;
374 case ElectricalUnit::UNIT_Mvar: {
375 tipText += _(" Mvar");
376 } break;
377 default:
378 break;
379 }
380
381 return tipText;
382}
Node for power elements. All others power elements are connected through this.
Definition Bus.h:87

◆ Intersects()

bool Capacitor::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 304 of file Capacitor.cpp.

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

◆ OpenElement()

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

Reimplemented from PowerElement.

Definition at line 405 of file Capacitor.cpp.

406{
407 if (!OpenCADProperties(elementNode, parentList)) return false;
408
409 auto electricalProp = elementNode->first_node("ElectricalProperties");
410 if (!electricalProp) return false;
411
412 SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
413 m_electricalData.name = electricalProp->first_node("Name")->value();
414 m_electricalData.reactivePower = XMLParser::GetNodeValueDouble(electricalProp, "ReactivePower");
415 m_electricalData.reactivePowerUnit =
416 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ReactivePower", "UnitID"));
417
418 if (!OpenSwitchingData(electricalProp)) return false;
419 if (m_swData.swTime.size() != 0) SetDynamicEvent(true);
420
421 m_inserted = true;
422 return true;
423}
bool SetOnline(bool online=true)
Set if the element is online or offline.
Definition Element.cpp:465
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.
std::vector< double > swTime

◆ Rotate()

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

Rotate the element.

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

Reimplemented from Element.

Definition at line 271 of file Capacitor.cpp.

272{
273 double rotAngle = m_rotationAngle;
274 if (!clockwise) rotAngle = -m_rotationAngle;
275
276 m_angle += rotAngle;
277 if (m_angle >= 360 || m_angle <= -360) m_angle = 0.0;
278 m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle);
279 m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle);
280 UpdateSwitchesPosition();
281}
Here is the call graph for this function:

◆ SaveElement()

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

Reimplemented from Element.

Definition at line 384 of file Capacitor.cpp.

385{
386 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Capacitor");
387 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
388
389 SaveCADProperties(doc, elementNode);
390
391 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
392 auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
393 XMLParser::SetNodeValue(doc, isOnline, m_online);
394 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
395 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
396 auto reactivePower = XMLParser::AppendNode(doc, electricalProp, "ReactivePower");
397 XMLParser::SetNodeValue(doc, reactivePower, m_electricalData.reactivePower);
398 XMLParser::SetNodeAttribute(doc, reactivePower, "UnitID", static_cast<int>(m_electricalData.reactivePowerUnit));
399
400 SaveSwitchingData(doc, electricalProp);
401
402 return elementNode;
403}

◆ SetElectricalData()

virtual void Capacitor::SetElectricalData ( CapacitorElectricalData  electricalData)
inlinevirtual

Definition at line 58 of file Capacitor.h.

58{ m_electricalData = electricalData; }

◆ ShowForm()

bool Capacitor::ShowForm ( wxWindow *  parent,
Element *  element,
wxWindow *  workspace = nullptr 
)
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 309 of file Capacitor.cpp.

310{
311 ReactiveShuntElementForm capacitorForm(parent, this);
312 capacitorForm.SetTitle(_("Capacitor"));
313 capacitorForm.CenterOnParent();
314 if (capacitorForm.ShowModal() == wxID_OK) {
315 return true;
316 }
317 return false;
318}
Form to edit the reactive shunt element power data.

Member Data Documentation

◆ m_electricalData

CapacitorElectricalData Capacitor::m_electricalData
protected

Definition at line 64 of file Capacitor.h.


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