diff --git a/sleepyhead/Graphs/gXAxis.cpp b/sleepyhead/Graphs/gXAxis.cpp index 8bd459c1..7e55435c 100644 --- a/sleepyhead/Graphs/gXAxis.cpp +++ b/sleepyhead/Graphs/gXAxis.cpp @@ -64,6 +64,7 @@ void gXAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i //static QString dow[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; + QVector ticks; QPainter painter2; // Only need this for pixmap caching @@ -220,9 +221,9 @@ void gXAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i if (py < start_px) { continue; } if (usepixmap) { - painter2.drawLine(py - left + 20, 0, py - left + 20, mintop - top); + ticks.append(QLine(py - left + 20, 0, py - left + 20, mintop - top)); } else { - painter.drawLine(py, top+2, py, mintop+2); + ticks.append(QLine(py, top+2, py, mintop+2)); } } @@ -234,9 +235,9 @@ void gXAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i px += left; if (usepixmap) { - painter2.drawLine(px - left + 20, 0, px - left + 20, majtop - top); + ticks.append(QLine(px - left + 20, 0, px - left + 20, majtop - top)); } else { - painter.drawLine(px, top+2, px, majtop+2); + ticks.append(QLine(px, top+2, px, majtop+2)); } j = i; @@ -289,15 +290,18 @@ void gXAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i if (py >= left + width) { break; } if (usepixmap) { - painter2.drawLine(py - left + 20, 0, py - left + 20, mintop - top); + ticks.append(QLine(py - left + 20, 0, py - left + 20, mintop - top)); } else { - painter.drawLine(py, top+2, py, mintop+2); + ticks.append(QLine(py, top+2, py, mintop+2)); } } } if (usepixmap) { + painter2.drawLines(ticks); painter2.end(); + } else { + painter.drawLines(ticks); } w.invalidate_xAxisImage = false; diff --git a/sleepyhead/Graphs/gYAxis.cpp b/sleepyhead/Graphs/gYAxis.cpp index 049f02f4..55fe14eb 100644 --- a/sleepyhead/Graphs/gYAxis.cpp +++ b/sleepyhead/Graphs/gYAxis.cpp @@ -106,20 +106,20 @@ void gXGrid::paint(QPainter &painter, gGraph &w, int left, int top, int width, i if (min_ytick >= 1000000) { min_ytick = 100; } + QVector majorlines; + QVector minorlines; for (double i = miny; i <= maxy + min_ytick - 0.00001; i += min_ytick) { ty = (i - miny) * ymult; h = top + height - ty; if (m_show_major_lines && (i > miny)) { - painter.setPen(QPen(m_major_color,1)); - painter.drawLine(left, h, left + width, h); + majorlines.append(QLine(left, h, left + width, h)); } double z = (min_ytick / 4) * ymult; double g = h; - painter.setPen(QPen(m_minor_color,1)); for (int i = 0; i < 3; i++) { g += z; @@ -130,10 +130,14 @@ void gXGrid::paint(QPainter &painter, gGraph &w, int left, int top, int width, i // break; // } if (m_show_minor_lines) {// && (i > miny)) { - painter.drawLine(left, g, left + width, g); + minorlines.append(QLine(left, g, left + width, g)); } } } + painter.setPen(QPen(m_major_color,1)); + painter.drawLines(majorlines); + painter.setPen(QPen(m_minor_color,1)); + painter.drawLines(minorlines); } @@ -355,7 +359,7 @@ void gYAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i min_ytick = 100; } - painter.setPen(m_line_color); + QVector ticks; for (double i = miny; i <= maxy + min_ytick - 0.00001; i += min_ytick) { ty = (i - miny) * ymult; @@ -376,7 +380,7 @@ void gYAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i w.renderText(fd, left + width - 8 - x, (h + (y / 2.0)), 0, m_text_color, defaultfont); - painter.drawLine(left + width - 4, h, left + width, h); + ticks.append(QLine(left + width - 4, h, left + width, h)); double z = (min_ytick / 4) * ymult; double g = h; @@ -386,9 +390,11 @@ void gYAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, i if (g > top + height) { break; } - painter.drawLine(left + width - 3, g, left + width, g); + ticks.append(QLine(left + width - 3, g, left + width, g)); } } + painter.setPen(m_line_color); + painter.drawLines(ticks); } } const QString gYAxis::Format(EventDataType v, int dp)