diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-12-06 20:27:20 -0200 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-12-06 20:27:20 -0200 |
commit | f5bb978b22c881dc61663d8ac660cc2778a842bb (patch) | |
tree | 7d3615b15a7aac4de928bd6811a4407f7a2eb47b /Project/Text.cpp | |
parent | e266f5811403beea13c9cc5399c55db4a34fdd3c (diff) | |
download | PSP.git-f5bb978b22c881dc61663d8ac660cc2778a842bb.tar.gz PSP.git-f5bb978b22c881dc61663d8ac660cc2778a842bb.tar.xz PSP.git-f5bb978b22c881dc61663d8ac660cc2778a842bb.zip |
Text update under implementation
Diffstat (limited to 'Project/Text.cpp')
-rw-r--r-- | Project/Text.cpp | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/Project/Text.cpp b/Project/Text.cpp index 2d8e85c..7082e17 100644 --- a/Project/Text.cpp +++ b/Project/Text.cpp @@ -12,8 +12,13 @@ #include "Inductor.h" #include "Capacitor.h" -Text::Text() : Element() { SetText(m_text); } -Text::Text(wxPoint2DDouble position) : Element() +Text::Text() + : Element() +{ + SetText(m_text); +} +Text::Text(wxPoint2DDouble position) + : Element() { SetText(m_text); SetPosition(position); @@ -29,22 +34,22 @@ bool Text::Contains(wxPoint2DDouble position) const void Text::Draw(wxPoint2DDouble translation, double scale) { wxScreenDC dc; - + // Draw selection rectangle - + // Push the current matrix on stack. glPushMatrix(); // Rotate the matrix around the object position. glTranslated(m_position.m_x, m_position.m_y, 0.0); glRotated(m_angle, 0.0, 0.0, 1.0); glTranslated(-m_position.m_x, -m_position.m_y, 0.0); - + if(m_selected) { glColor4d(0.0, 0.5, 1.0, 0.5); - DrawRectangle(m_position + wxPoint2DDouble(m_borderSize / 2.0, m_borderSize / 2.0), m_rect.m_width, - m_rect.m_height); + DrawRectangle( + m_position + wxPoint2DDouble(m_borderSize / 2.0, m_borderSize / 2.0), m_rect.m_width, m_rect.m_height); } - + // Draw text (layer 2) glColor4d(0.0, 0.0, 0.0, 1.0); @@ -53,7 +58,7 @@ void Text::Draw(wxPoint2DDouble translation, double scale) glString.consolidate(&dc); glString.bind(); glString.render(m_position.m_x, m_position.m_y); - + glPopMatrix(); } @@ -67,7 +72,7 @@ void Text::SetText(wxString text) { m_text = text; - // Generate a glString to get the text size. + // Creating a glString to get the text size. wxGLString glString(m_text); glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); wxScreenDC dc; @@ -76,6 +81,9 @@ void Text::SetText(wxString text) m_width = glString.getWidth(); m_height = glString.getheight(); + + // Update text rectangle. + SetPosition(m_position); } void Text::Rotate(bool clockwise) @@ -101,40 +109,58 @@ bool Text::ShowForm(wxWindow* parent, std::vector<Element*> elementList) void Text::UpdateText(double systemPowerBase) { switch(m_elementType) { + case TYPE_NONE: + break; case TYPE_BUS: { Bus* bus = (Bus*)m_element; if(bus) { + BusElectricalData data = bus->GetEletricalData(); switch(m_dataType) { case DATA_NAME: { SetText(bus->GetEletricalData().name); - wxLogMessage(m_text); + } break; + case DATA_VOLTAGE: { + double baseVoltage = data.nominalVoltage; + if(data.nominalVoltageUnit == UNIT_kV) baseVoltage *= 1e3; + double voltage = std::abs(data.voltage); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(voltage, m_decimalPlaces) + _(" p.u.")); + } break; + case UNIT_V: { + SetText(wxString::FromDouble(voltage * baseVoltage, m_decimalPlaces) + _(" V")); + } break; + case UNIT_kV: { + SetText(wxString::FromDouble(voltage * baseVoltage / 1e3, m_decimalPlaces) + _(" kV")); + } break; + } } break; } } } break; case TYPE_SYNC_GENERATOR: { - + } break; case TYPE_LINE: { - + } break; case TYPE_TRANSFORMER: { - + } break; case TYPE_LOAD: { - + } break; case TYPE_SYNC_MOTOR: { - + } break; case TYPE_IND_MOTOR: { - + } break; case TYPE_CAPACITOR: { - + } break; case TYPE_INDUCTOR: { - + } break; } } |