diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-01-05 19:37:42 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-05 19:37:42 -0200 |
commit | 9df133274802731220546d1f9383c213193c8413 (patch) | |
tree | 9c6e2fa2a45d6c6c4c14d8711b2b89066bfb37d7 /Project/Capacitor.cpp | |
parent | c5343c718cf80620c2fc7452a4315f7ddb9e5826 (diff) | |
parent | b6f96ca48bc156898df79deba63d270b393fb150 (diff) | |
download | PSP.git-9df133274802731220546d1f9383c213193c8413.tar.gz PSP.git-9df133274802731220546d1f9383c213193c8413.tar.xz PSP.git-9df133274802731220546d1f9383c213193c8413.zip |
Merge pull request #5 from Thales1330/opt/element-parent-search
Opt element parent search
Diffstat (limited to 'Project/Capacitor.cpp')
-rw-r--r-- | Project/Capacitor.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Project/Capacitor.cpp b/Project/Capacitor.cpp index a4320c9..4f43f05 100644 --- a/Project/Capacitor.cpp +++ b/Project/Capacitor.cpp @@ -15,6 +15,7 @@ bool Capacitor::AddParent(Element* parent, wxPoint2DDouble position) { if(parent) { m_parentList.push_back(parent); + parent->AddChild(this); wxPoint2DDouble parentPt = parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. @@ -112,7 +113,7 @@ void Capacitor::Rotate(bool clockwise) bool Capacitor::GetContextMenu(wxMenu& menu) { - menu.Append(ID_EDIT_CAPACITOR, _("Edit Capacitor")); + menu.Append(ID_EDIT_ELEMENT, _("Edit Capacitor")); GeneralMenuItens(menu); return true; } @@ -169,3 +170,35 @@ Element* Capacitor::GetCopy() *copy = *this; return copy; } + +wxString Capacitor::GetTipText() const +{ + wxString tipText = m_electricalData.name; + + // TODO: Avoid reactive power calculation. + double reactivePower = m_electricalData.reactivePower; + if(m_online) { + std::complex<double> v = static_cast<Bus*>(m_parentList[0])->GetEletricalData().voltage; + reactivePower *= std::pow(std::abs(v), 2); + } + tipText += "\n"; + tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5); + switch(m_electricalData.reactivePowerUnit) { + case UNIT_PU: { + tipText += _(" p.u."); + } break; + case UNIT_VAr: { + tipText += _(" VAr"); + } break; + case UNIT_kVAr: { + tipText += _(" kVAr"); + } break; + case UNIT_MVAr: { + tipText += _(" MVAr"); + } break; + default: + break; + } + + return tipText; +} |