diff --git a/sleepyhead/Graphs/gGraph.cpp b/sleepyhead/Graphs/gGraph.cpp index e72c61bd..042eeaf5 100644 --- a/sleepyhead/Graphs/gGraph.cpp +++ b/sleepyhead/Graphs/gGraph.cpp @@ -164,8 +164,6 @@ gGraph::gGraph(gGraphView *graphview, QString title, QString units, int height, invalidate_yAxisImage = true; invalidate_xAxisImage = true; - m_quad = new gVertexBuffer(64, GL_QUADS); - m_quad->forceAntiAlias(true); m_enforceMinY = m_enforceMaxY = false; m_showTitle = true; m_printing = false; @@ -179,7 +177,6 @@ gGraph::~gGraph() } m_layers.clear(); - delete m_quad; timer->stop(); disconnect(timer, 0, 0, 0); @@ -247,7 +244,6 @@ void gGraph::drawGLBuf() m_layers[i]->drawGLBuf(linesize); } - m_quad->draw(); } void gGraph::setDay(Day *day) { @@ -389,16 +385,7 @@ void gGraph::paint(QPainter &painter, int originX, int originY, int width, int h if (isPinned()) { // Fill the background on pinned graphs - - // m_graphview->quads->add(originX+left,originY+top, originX+width-right,originY+top, originX+width-right,originY+height-bottom, originX+left,originY+height-bottom, 0xffffffff); painter.fillRect(originX + left, originY + top, width - right, height - bottom - top, QBrush(QColor(Qt::white))); -// glBegin(GL_QUADS); -// glColor4f(1.0, 1.0, 1.0, 1.0); // Gradient End -// glVertex2i(originX + left, originY + top); -// glVertex2i(originX + width - right, originY + top); -// glVertex2i(originX + width - right, originY + height - bottom); -// glVertex2i(originX + left, originY + height - bottom); -// glEnd(); } for (int i = 0; i < m_layers.size(); i++) { diff --git a/sleepyhead/Graphs/gGraph.h b/sleepyhead/Graphs/gGraph.h index 56a6d399..fe7b264d 100644 --- a/sleepyhead/Graphs/gGraph.h +++ b/sleepyhead/Graphs/gGraph.h @@ -344,7 +344,6 @@ class gGraph : public QObject short m_group; short m_lastx23; Day *m_day; - gVertexBuffer *m_quad; bool m_enforceMinY, m_enforceMaxY; bool m_showTitle; bool m_printing; diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index bbe455aa..2690d50a 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -1304,7 +1304,7 @@ bool gGraphView::renderGraphs(QPainter &painter) // lines->setSize(linesize); - // DrawTextQue(); + DrawTextQue(painter); //glDisable(GL_TEXTURE_2D); //glDisable(GL_DEPTH_TEST); diff --git a/sleepyhead/Graphs/gSegmentChart.cpp b/sleepyhead/Graphs/gSegmentChart.cpp index c865bbd6..2f24cf2e 100644 --- a/sleepyhead/Graphs/gSegmentChart.cpp +++ b/sleepyhead/Graphs/gSegmentChart.cpp @@ -118,7 +118,6 @@ void gSegmentChart::paint(QPainter &painter, gGraph &w, int left, int top, int w // length of this segment in degrees float len = 360.0 / float(m_total) * float(data); - qDebug() << m_names[m]; // Setup the shiny radial gradient painter.setRenderHint(QPainter::Antialiasing); @@ -141,18 +140,18 @@ void gSegmentChart::paint(QPainter &painter, gGraph &w, int left, int top, int w painter.drawPie(pierect, -sum * 16.0, -len * 16.0); - if (len > 10) { - float angle = (sum+90.0) + len/2.0; - double tpx = (start_px + width/2) + (sin(angle * (M_PI / 180.0)) * (radius / 1.7)); - double tpy = (start_py + height/2) + (cos(angle * (M_PI / 180.0)) * (radius / 1.7)); + // Draw text labels if they fit + if (len > 20) { + float angle = (sum+90.0) + len / 2.0; + double tpx = (pierect.x() + pierect.width()/2) + (sin((180 - angle) * (M_PI / 180.0)) * (radius / 1.65)); + double tpy = (pierect.y() + pierect.height()/2) + (cos((180 - angle) * (M_PI / 180.0)) * (radius / 1.65)); QString txt = m_names[m]; //QString::number(floor(100.0/m_total*data),'f',0)+"%"; int x, y; GetTextExtent(txt, x, y); // antialiasing looks like crap here.. painter.setPen(QColor(Qt::black)); - painter.drawText(tpx - (x / 2.0), (tpy - y / 2.0), txt); - //painter.drawText(txt, tpx - (x / 2.0), (tpy + y / 2.0), 0, Qt::black, defaultfont,false); + painter.drawText(tpx - (x / 2.0), tpy+3, txt); } sum += len;