diff options
Diffstat (limited to 'Project/Gain.cpp')
-rw-r--r-- | Project/Gain.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/Project/Gain.cpp b/Project/Gain.cpp index 98dfa8c..8962bf8 100644 --- a/Project/Gain.cpp +++ b/Project/Gain.cpp @@ -31,7 +31,10 @@ Gain::Gain(int id) : ControlElement(id) m_nodeList.push_back(nodeOut); } -Gain::~Gain() {} +Gain::~Gain() +{ + if(m_glText) delete m_glText; +} void Gain::Draw(wxPoint2DDouble translation, double scale) const { if(m_selected) { @@ -64,22 +67,15 @@ void Gain::Draw(wxPoint2DDouble translation, double scale) const DrawTriangle(m_triPts, GL_LINE_LOOP); // Plot number. - glEnable(GL_TEXTURE_2D); glColor4d(0.0, 0.0, 0.0, 1.0); - m_glStringValue->bind(); if(m_angle == 0.0) - m_glStringValue->render(m_position.m_x - m_width / 2 + m_glStringValue->getWidth() / 2 + 2 + m_borderSize, - m_position.m_y); + m_glText->Draw(m_position + wxPoint2DDouble(-m_width / 2 + m_glText->GetWidth() / 2 + 2 + m_borderSize, 0.0)); else if(m_angle == 90.0) - m_glStringValue->render(m_position.m_x, - m_position.m_y - m_height / 2 + m_glStringValue->getheight() / 2 + 2 + m_borderSize); + m_glText->Draw(m_position + wxPoint2DDouble(0.0, -m_height / 2 + m_glText->GetHeight() / 2 + 2 + m_borderSize)); else if(m_angle == 180.0) - m_glStringValue->render(m_position.m_x + m_width / 2 - m_glStringValue->getWidth() / 2 - 2 - m_borderSize, - m_position.m_y); + m_glText->Draw(m_position + wxPoint2DDouble(m_width / 2 - m_glText->GetWidth() / 2 - 2 - m_borderSize, 0.0)); else if(m_angle == 270.0) - m_glStringValue->render(m_position.m_x, - m_position.m_y + m_height / 2 - m_glStringValue->getheight() / 2 - 2 - m_borderSize); - glDisable(GL_TEXTURE_2D); + m_glText->Draw(m_position + wxPoint2DDouble(0.0, m_height / 2 - m_glText->GetHeight() / 2 - 2 - m_borderSize)); glColor4d(0.0, 0.0, 0.0, 1.0); DrawNodes(); @@ -124,19 +120,13 @@ void Gain::SetValue(double value) else text = StringFromDouble(m_value); - wxFont font(m_fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - wxScreenDC dc; - - if(m_glStringValue) { - delete m_glStringValue; - m_glStringValue = NULL; - } - m_glStringValue = new wxGLString(text); - m_glStringValue->setFont(font); - m_glStringValue->consolidate(&dc); + if(m_glText) + m_glText->SetText(text); + else + m_glText = new OpenGLText(text); - m_width = m_glStringValue->getWidth() + 18 + 2 * m_borderSize; - m_height = m_glStringValue->getheight() + 18 + 2 * m_borderSize; + m_width = m_glText->GetWidth() + 18 + 2 * m_borderSize; + m_height = m_glText->GetHeight() + 18 + 2 * m_borderSize; if(m_width > m_height) m_height = m_width; @@ -195,7 +185,6 @@ Element* Gain::GetCopy() { Gain* copy = new Gain(m_elementID); *copy = *this; - m_glStringValue = NULL; - SetValue(m_value); + copy->m_glText = m_glText->GetCopy(); return copy; } |