diff --git a/sleepyhead/Graphs/gFlagsLine.cpp b/sleepyhead/Graphs/gFlagsLine.cpp index ad93da9a..1ea6b806 100644 --- a/sleepyhead/Graphs/gFlagsLine.cpp +++ b/sleepyhead/Graphs/gFlagsLine.cpp @@ -32,10 +32,6 @@ bool gFlagsLabelArea::mouseMoveEvent(QMouseEvent *event, gGraph *graph) gFlagsGroup::gFlagsGroup() { - addVertexBuffer(quads = new gVertexBuffer(512, GL_QUADS)); - addVertexBuffer(lines = new gVertexBuffer(20, GL_LINE_LOOP)); - quads->setAntiAlias(true); - lines->setAntiAlias(false); m_barh = 0; m_empty = true; } @@ -91,7 +87,7 @@ void gFlagsGroup::SetDay(Day *d) m_barh = 0; } -void gFlagsGroup::paint(gGraph &g, int left, int top, int width, int height) +void gFlagsGroup::paint(QPainter &painter, gGraph &g, int left, int top, int width, int height) { if (!m_visible) { return; } @@ -108,23 +104,19 @@ void gFlagsGroup::paint(gGraph &g, int left, int top, int width, int height) if (i & 1) { barcol = COLOR_ALT_BG1; } else { barcol = COLOR_ALT_BG2; } - quads->add(left, linetop, left, linetop + m_barh, left + width - 1, linetop + m_barh, - left + width - 1, linetop, barcol.rgba()); + painter.fillRect(left, linetop, width-1, m_barh, QBrush(barcol)); // Paint the actual flags lvisible[i]->m_rect = QRect(left, linetop, width, m_barh); - lvisible[i]->paint(g, left, linetop, width, m_barh); + lvisible[i]->paint(painter, g, left, linetop, width, m_barh); linetop += m_barh; } - gVertexBuffer *outlines = g.lines(); - outlines->add(left - 1, top, left - 1, top + height, COLOR_Outline.rgba()); - outlines->add(left - 1, top + height, left + width, top + height, COLOR_Outline.rgba()); - outlines->add(left + width, top + height, left + width, top, COLOR_Outline.rgba()); - outlines->add(left + width, top, left - 1, top, COLOR_Outline.rgba()); - - //lines->add(left-1, top, left-1, top+height); - //lines->add(left+width, top+height, left+width, top); + painter.setPen(COLOR_Outline); + painter.drawLine(left - 1, top, left - 1, top + height); + painter.drawLine(left - 1, top + height, left + width, top + height); + painter.drawLine(left + width, top + height, left + width, top); + painter.drawLine(left + width, top, left - 1, top); } bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph) @@ -162,25 +154,16 @@ gFlagsLine::gFlagsLine(ChannelID code, QColor flag_color, QString label, bool al : Layer(code), m_label(label), m_always_visible(always_visible), m_flt(flt), m_flag_color(flag_color) { - addVertexBuffer(quads = new gVertexBuffer(2048, GL_QUADS)); - //addGLBuf(lines=new GLBuffer(flag_color,1024,GL_LINES)); - quads->setAntiAlias(true); - //lines->setAntiAlias(true); - //GetTextExtent(m_label,m_lx,m_ly); - //m_static.setText(m_label);; } gFlagsLine::~gFlagsLine() { - //delete lines; - //delete quads; } -void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height) +void gFlagsLine::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; } if (!m_day) { return; } - lines = w.lines(); double minx; double maxx; @@ -207,9 +190,7 @@ void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height) float bartop = top + 2; float bottom = top + height - 2; - bool verts_exceeded = false; qint64 X, X2, L; - lines->setColor(schema::channel[m_code].defaultColor()); qint64 start; quint32 *tptr; @@ -220,6 +201,11 @@ void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height) qint64 clockdrift = qint64(PROFILE.cpap->clockDrift()) * 1000L; qint64 drift = 0; + QVector vlines; + + QColor color=schema::channel[m_code].defaultColor(); + QBrush brush(color); + for (QList::iterator s = m_day->begin(); s != m_day->end(); s++) { if (!(*s)->enabled()) { continue; @@ -266,17 +252,6 @@ void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height) // Draw Event Flag Bars /////////////////////////////////////////////////////////////////////////// - // Check bounds outside of loop is faster.. - // This will have to be reverted if multithreaded drawing is ever brought back - - int rem = lines->Max() - lines->cnt(); - - if ((np << 1) > rem) { - qDebug() << "gFlagsLine would overfill lines for" << schema::channel[m_code].label(); - np = rem >> 1; - verts_exceeded = true; - } - for (int i = 0; i < np; i++) { X = start + *tptr++; @@ -285,22 +260,12 @@ void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height) } x1 = (X - minx) * xmult + left; - lines->add(x1, bartop, x1, bottom); - - //if (lines->full()) { verts_exceeded=true; break; } + vlines.append(QLine(x1, bartop, x1, bottom)); } } else if (m_flt == FT_Span) { /////////////////////////////////////////////////////////////////////////// // Draw Event Flag Spans /////////////////////////////////////////////////////////////////////////// - quads->setColor(m_flag_color); - int rem = quads->Max() - quads->cnt(); - - if ((np << 2) > rem) { - qDebug() << "gFlagsLine would overfill quads for" << schema::channel[m_code].label(); - np = rem >> 2; - verts_exceeded = true; - } for (; dptr < eptr; dptr++) { X = start + * tptr++; @@ -315,21 +280,14 @@ void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height) x1 = double(X - minx) * xmult + left; x2 = double(X2 - minx) * xmult + left; - quads->add(x2, bartop, x1, bartop, x1, bottom, x2, bottom); - //if (quads->full()) { verts_exceeded=true; break; } - + painter.fillRect(x2, bartop, x1-x2, bottom-bartop, brush); } } - - if (verts_exceeded) { break; } } - - if (verts_exceeded) { break; } } - if (verts_exceeded) { - qWarning() << "maxverts exceeded in gFlagsLine::plot()"; - } + painter.setPen(color); + painter.drawLines(vlines); } bool gFlagsLine::mouseMoveEvent(QMouseEvent *event, gGraph *graph) diff --git a/sleepyhead/Graphs/gFlagsLine.h b/sleepyhead/Graphs/gFlagsLine.h index fc99614d..4ecb92f6 100644 --- a/sleepyhead/Graphs/gFlagsLine.h +++ b/sleepyhead/Graphs/gFlagsLine.h @@ -24,7 +24,7 @@ class gFlagsLabelArea: public gSpacer { public: gFlagsLabelArea(gFlagsGroup *group); - virtual void paint(gGraph &w, int left, int top, int width, int height) { + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { Q_UNUSED(w) Q_UNUSED(left) Q_UNUSED(top) @@ -58,7 +58,7 @@ class gFlagsLine: public Layer virtual ~gFlagsLine(); //! \brief Drawing code to add the flags and span markers to the Vertex buffers. - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! \brief Returns true if should always show this flag, even if it's empty bool isAlwaysVisible() { return m_always_visible; } @@ -82,8 +82,6 @@ class gFlagsLine: public Layer int total_lines, line_num; FlagType m_flt; QColor m_flag_color; - gVertexBuffer *quads; - gVertexBuffer *lines; int m_lx, m_ly; }; @@ -99,7 +97,7 @@ class gFlagsGroup: public LayerGroup virtual ~gFlagsGroup(); //! Draw filled rectangles behind Event Flag's, and an outlines around them all, Calls the individual paint for each gFlagLine - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! Returns the first time represented by all gFlagLine layers, in milliseconds since epoch virtual qint64 Minx(); @@ -124,7 +122,6 @@ class gFlagsGroup: public LayerGroup protected: virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph); - gVertexBuffer *quads, *lines; QVector lvisible; float m_barh; bool m_empty; diff --git a/sleepyhead/Graphs/gFooBar.cpp b/sleepyhead/Graphs/gFooBar.cpp index f852d9bf..1ed83a3e 100644 --- a/sleepyhead/Graphs/gFooBar.cpp +++ b/sleepyhead/Graphs/gFooBar.cpp @@ -29,7 +29,7 @@ gShadowArea::gShadowArea(QColor shadow_color, QColor line_color) gShadowArea::~gShadowArea() { } -void gShadowArea::paint(gGraph &w, int left, int top, int width, int height) +void gShadowArea::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; } @@ -42,19 +42,16 @@ void gShadowArea::paint(gGraph &w, int left, int top, int width, int height) int start_px = left - 1; int end_px = left + width; - //float h=top; - double rmx = w.rmax_x - w.rmin_x; double px = ((1.0 / rmx) * (w.min_x - w.rmin_x)) * width; double py = ((1.0 / rmx) * (w.max_x - w.rmin_x)) * width; - quads->add(start_px, top, start_px, top + height, start_px + px, top + height, start_px + px, top, - m_shadow_color.rgba()); - quads->add(start_px + py, top, start_px + py, top + height, end_px, top + height, end_px, top, - m_shadow_color.rgba()); + painter.fillRect(start_px, top, px, height, QBrush(m_shadow_color)); + painter.fillRect(start_px + py, top, end_px-start_px-py, height, QBrush(m_shadow_color)); - lines->add(start_px + px, top, start_px + py, top, m_line_color.rgba()); - lines->add(start_px + px, top + height + 1, start_px + py, top + height + 1, m_line_color.rgba()); + painter.setPen(m_line_color); + painter.drawLine(start_px + px, top, start_px + py, top); + painter.drawLine(start_px + px, top + height + 1, start_px + py, top + height + 1); } gFooBar::gFooBar(int offset, QColor handle_color, QColor line_color) @@ -64,7 +61,7 @@ gFooBar::gFooBar(int offset, QColor handle_color, QColor line_color) gFooBar::~gFooBar() { } -void gFooBar::paint(gGraph &w, int left, int top, int width, int height) +void gFooBar::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { Q_UNUSED(top); Q_UNUSED(left); diff --git a/sleepyhead/Graphs/gFooBar.h b/sleepyhead/Graphs/gFooBar.h index d424be46..6e625cd9 100644 --- a/sleepyhead/Graphs/gFooBar.h +++ b/sleepyhead/Graphs/gFooBar.h @@ -23,7 +23,7 @@ class gShadowArea: public Layer public: gShadowArea(QColor shadow_color = QColor(40, 40, 40, 40), QColor line_color = Qt::blue); virtual ~gShadowArea(); - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); protected: QColor m_shadow_color; QColor m_line_color; @@ -41,7 +41,7 @@ class gFooBar: public Layer gFooBar(int offset = 10, QColor handle_color = QColor("orange"), QColor line_color = QColor("dark grey")); virtual ~gFooBar(); - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); static const int Margin = 15; protected: int m_offset; diff --git a/sleepyhead/Graphs/gGraph.cpp b/sleepyhead/Graphs/gGraph.cpp index 89711b3a..e72c61bd 100644 --- a/sleepyhead/Graphs/gGraph.cpp +++ b/sleepyhead/Graphs/gGraph.cpp @@ -278,7 +278,7 @@ void gGraph::renderText(QString text, int x, int y, float angle, QColor color, Q m_graphview->AddTextQue(text, x, y, angle, color, font, antialias); } -void gGraph::paint(int originX, int originY, int width, int height) +void gGraph::paint(QPainter &painter, int originX, int originY, int width, int height) { m_rect = QRect(originX, originY, width, height); @@ -295,55 +295,6 @@ void gGraph::paint(int originX, int originY, int width, int height) if (m_showTitle) { int title_x, yh; - /* if (titleImage.isNull()) { - // Render the title to a texture so we don't have to draw the vertical text every time.. - - GetTextExtent("Wy@",x,yh,mediumfont); // This gets a better consistent height. should be cached. - - GetTextExtent(title(),x,y,mediumfont); - - y=yh; - QPixmap tpm=QPixmap(x+4,y+4); - - tpm.fill(Qt::transparent); //empty it - QPainter pmp(&tpm); - - pmp.setRenderHint(QPainter::TextAntialiasing, true); - - QBrush brush2(Qt::black); // text color - pmp.setBrush(brush2); - - pmp.setFont(*mediumfont); - - pmp.drawText(2,y,title()); // draw from the bottom - pmp.end(); - - // convert to QImage and bind to a texture for future use - titleImage=QGLWidget::convertToGLFormat(tpm.toImage().mirrored(false,true)); - titleImageTex=m_graphview->bindTexture(titleImage); - } - y=titleImage.height(); - x=titleImage.width(); //vertical text - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - title_x=y*2; - - glEnable(GL_TEXTURE_2D); - - // Rotate and draw vertical texture containing graph titles - glPushMatrix(); - glTranslatef(marginLeft()+4,originY+height/2+x/2, 0); - glRotatef(-90,0,0,1); - m_graphview->drawTexture(QPoint(0,y/2),titleImageTex); - glPopMatrix(); - - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - - // All that to replace this little, but -hideously- slow line of text.. - */ QFontMetrics fm(*mediumfont); @@ -354,17 +305,17 @@ void gGraph::paint(int originX, int originY, int width, int height) //GetTextExtent(title(),x,y,mediumfont); title_x = yh * 2; - - renderText(title(), marginLeft() + title_x + 4, originY + height / 2 - y / 2, 90, Qt::black, - mediumfont); + QString & txt = title(); + graphView()->AddTextQue(txt, marginLeft() + title_x + 4, originY + height / 2 - y / 2, 90, Qt::black, mediumfont); left += title_x; } else { left = 0; } //#define DEBUG_LAYOUT #ifdef DEBUG_LAYOUT QColor col = Qt::red; - lines()->add(0, originY, 0, originY + height, col); - lines()->add(left, originY, left, originY + height, col); + painter.setPen(col); + painter.drawLine(0, originY, 0, originY + height); + painter.drawLine(left, originY, left, originY + height); #endif int tmp; @@ -392,19 +343,23 @@ void gGraph::paint(int originX, int originY, int width, int height) if (ll->position() == LayerLeft) { ll->m_rect = QRect(originX + left, originY + top, tmp, height - top - bottom); - ll->paint(*this, originX + left, originY + top, tmp, height - top - bottom); + ll->paint(painter, *this, originX + left, originY + top, tmp, height - top - bottom); left += tmp; #ifdef DEBUG_LAYOUT - lines()->add(originX + left - 1, originY, originX + left - 1, originY + height, col); + QColor col = Qt::red; + painter.setPen(col); + painter.drawLine(originX + left - 1, originY, originX + left - 1, originY + height); #endif } if (ll->position() == LayerRight) { right += tmp; ll->m_rect = QRect(originX + width - right, originY + top, tmp, height - top - bottom); - ll->paint(*this, originX + width - right, originY + top, tmp, height - top - bottom); + ll->paint(painter, *this, originX + width - right, originY + top, tmp, height - top - bottom); #ifdef DEBUG_LAYOUT - lines()->add(originX + width - right, originY, originX + width - right, originY + height, col); + QColor col = Qt::red; + painter.setPen(col); + painter.drawLine(originX + width - right, originY, originX + width - right, originY + height); #endif } } @@ -421,14 +376,14 @@ void gGraph::paint(int originX, int originY, int width, int height) if (ll->position() == LayerTop) { ll->m_rect = QRect(originX + left, originY + top, width - left - right, tmp); - ll->paint(*this, originX + left, originY + top, width - left - right, tmp); + ll->paint(painter, *this, originX + left, originY + top, width - left - right, tmp); top += tmp; } if (ll->position() == LayerBottom) { bottom += tmp; ll->m_rect = QRect(originX + left, originY + height - bottom, width - left - right, tmp); - ll->paint(*this, originX + left, originY + height - bottom, width - left - right, tmp); + ll->paint(painter, *this, originX + left, originY + height - bottom, width - left - right, tmp); } } @@ -436,13 +391,14 @@ void gGraph::paint(int originX, int originY, int width, int height) // 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); - 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(); + 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++) { @@ -452,23 +408,22 @@ void gGraph::paint(int originX, int originY, int width, int height) if (ll->position() == LayerCenter) { ll->m_rect = QRect(originX + left, originY + top, width - left - right, height - top - bottom); - ll->paint(*this, originX + left, originY + top, width - left - right, height - top - bottom); + ll->paint(painter, *this, originX + left, originY + top, width - left - right, height - top - bottom); } } if (m_selection.width() > 0 && m_selecting_area) { QColor col(128, 128, 255, 128); - quads()->add(originX + m_selection.x(), originY + top, - originX + m_selection.x() + m_selection.width(), originY + top, col.rgba()); - quads()->add(originX + m_selection.x() + m_selection.width(), originY + height - bottom, - originX + m_selection.x(), originY + height - bottom, col.rgba()); + painter.fillRect(originX + m_selection.x(), originY + top, m_selection.width(), height - bottom - top,QBrush(col)); +// quads()->add(originX + m_selection.x(), originY + top, +// originX + m_selection.x() + m_selection.width(), originY + top, col.rgba()); +// quads()->add(originX + m_selection.x() + m_selection.width(), originY + height - bottom, +// originX + m_selection.x(), originY + height - bottom, col.rgba()); } } QPixmap gGraph::renderPixmap(int w, int h, bool printing) { - QPixmap pm = QPixmap(); - gGraphView *sg = mainwin->snapshotGraph(); if (!sg) { @@ -524,29 +479,14 @@ QPixmap gGraph::renderPixmap(int w, int h, bool printing) float dpr = sg->devicePixelRatio(); sg->setDevicePixelRatio(1); -#ifdef Q_OS_WIN - if (pm.isNull()) { - pm = sg->renderPixmap(w, h, false); - } + QPixmap pm(w,h); - if (pm.isNull()) { // Works, but gives shader warnings - pm = QPixmap::fromImage(sg->pbRenderPixmap(w, h)); - } + QPainter painter(&pm); + painter.fillRect(0,0,w,h,QBrush(QColor(Qt::white))); + sg->renderGraphs(painter); + painter.end(); - if (pm.isNull()) { // crashes on mine, not sure what to do about it - pm = QPixmap::fromImage(sg->fboRenderPixmap(w, h)); - } - -#else - pm = QPixmap::fromImage(sg->fboRenderPixmap(w, h)); - - if (pm.isNull()) { // not sure if this will work with printing - qDebug() << "Had to use PixelBuffer for snapshots\n"; - pm = QPixmap::fromImage(sg->pbRenderPixmap(w, h)); - } - -#endif sg->setDevicePixelRatio(dpr); //sg->doneCurrent(); sg->trashGraphs(); diff --git a/sleepyhead/Graphs/gGraph.h b/sleepyhead/Graphs/gGraph.h index 50aff602..56a6d399 100644 --- a/sleepyhead/Graphs/gGraph.h +++ b/sleepyhead/Graphs/gGraph.h @@ -6,7 +6,7 @@ * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of the Linux * distribution for more details. */ - + #ifndef graphs_ggraph_h #define graphs_ggraph_h @@ -128,7 +128,7 @@ class gGraph : public QObject void drawGLBuf(); //! \brief Returns the Graph's (vertical) title - QString title() { return m_title; } + inline QString & title() { return m_title; } //! \brief Sets the Graph's (vertical) title void setTitle(const QString title) { m_title = title; } @@ -235,7 +235,7 @@ class gGraph : public QObject Day *day() { return m_day; } //! \brief The Layer, layout and title drawing code - virtual void paint(int originX, int originY, int width, int height); + virtual void paint(QPainter &painter, int originX, int originY, int width, int height); //! \brief Gives the supplied data to the main ToolTip object for display void ToolTip(QString text, int x, int y, int timeout = 0); diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index 3ec022d3..bbe455aa 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -101,15 +101,13 @@ void gToolTip::cancel() timer->stop(); } -void gToolTip::paint() //actually paints it. +void gToolTip::paint(QPainter &painter) //actually paints it. { if (!m_visible) { return; } int x = m_pos.x(); int y = m_pos.y(); - QPainter painter(m_graphview); - QRect rect(x, y, 0, 0); painter.setFont(*defaultfont); @@ -152,8 +150,6 @@ void gToolTip::paint() //actually paints it. painter.setFont(*defaultfont); painter.drawText(rect, Qt::AlignCenter, m_text); - - painter.end(); } void gToolTip::timerDone() @@ -219,14 +215,15 @@ void gGraphView::queGraph(gGraph *g, int left, int top, int width, int height) dl_mutex.unlock(); #endif } + void gGraphView::trashGraphs() { - //for (int i=0;i= QT_VERSION_CHECK(5,0,0) - int dpr = devicePixelRatio(); -#endif - - for (int i = 0; i < m_textque_items; i++) { - TextQue &q = m_textque[i]; - painter.setBrush(q.color); - painter.setRenderHint(QPainter::TextAntialiasing, q.antialias); - QFont font = *q.font; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - int fs = font.pointSize(); - - if (fs > 0) { - font.setPointSize(fs * dpr); - } else { - font.setPixelSize(font.pixelSize()*dpr); - } - -#endif - painter.setFont(font); - - if (q.angle == 0) { // normal text - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - painter.drawText(q.x * dpr, q.y * dpr, q.text); -#else - painter.drawText(q.x, q.y, q.text); -#endif - } else { // rotated text - w = painter.fontMetrics().width(q.text); - h = painter.fontMetrics().xHeight() + 2; - - painter.translate(q.x, q.y); - painter.rotate(-q.angle); - painter.drawText(floor(-w / 2.0), floor(-h / 2.0), q.text); - painter.rotate(+q.angle); - painter.translate(-q.x, -q.y); - } - - q.text.clear(); - } - - m_textque_items = 0; -} - -QImage gGraphView::pbRenderPixmap(int w, int h) -{ - QImage pm = QImage(); - QGLFormat pbufferFormat = format(); - QGLPixelBuffer pbuffer(w, h, pbufferFormat, this); - - if (pbuffer.isValid()) { - pbuffer.makeCurrent(); - initializeGL(); - resizeGL(w, h); - glClearColor(255, 255, 255, 255); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - renderGraphs(); - glFlush(); - pm = pbuffer.toImage(); - pbuffer.doneCurrent(); - QPainter painter(&pm); - DrawTextQue(painter); - painter.end(); - } - - return pm; -} - -QImage gGraphView::fboRenderPixmap(int w, int h) -{ - QImage pm = QImage(); - - if (fbo_unsupported) { - return pm; - } - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - float dpr = devicePixelRatio(); - w *= dpr; - h *= dpr; -#endif - - if ((w > max_fbo_width) || (h > max_fbo_height)) { - qWarning() << - "gGraphView::fboRenderPixmap called with dimensiopns exceeding maximum frame buffer object size"; - return pm; - } - - if (!fbo) { - fbo = new QGLFramebufferObject(max_fbo_width, max_fbo_height, - QGLFramebufferObject::Depth); //NoAttachment); - } - - if (fbo && fbo->isValid()) { - makeCurrent(); - - if (fbo->bind()) { - initializeGL(); - resizeGL(w, h); - glClearColor(255, 255, 255, 255); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - renderGraphs(); // render graphs sans text - glFlush(); - fbo->release(); - pm = fbo->toImage().copy(0, max_fbo_height - h, w, h); - doneCurrent(); - - QPainter painter(&pm); - DrawTextQue(painter); //Just use this on mac to - painter.end(); - - } - } else { - delete fbo; - fbo = nullptr; - fbo_unsupported = true; - } - - return pm; -} - gGraphView::gGraphView(QWidget *parent, gGraphView *shared) : QGLWidget(QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::NoOverlay), parent, shared), m_offsetY(0), m_offsetX(0), m_scaleY(1.0), m_scrollbar(nullptr) @@ -504,7 +373,39 @@ bool gGraphView::usePixmapCache() return use_pixmap_cache & PROFILE.appearance->usePixmapCaching(); } +// Render all qued text via QPainter method +void gGraphView::DrawTextQue(QPainter &painter) +{ + int w, h; + for (int i = 0; i < m_textque_items; i++) { + TextQue &q = m_textque[i]; + painter.setPen(q.color); + painter.setRenderHint(QPainter::TextAntialiasing, q.antialias); + QFont font = *q.font; + painter.setFont(font); + + if (q.angle == 0) { // normal text + + painter.drawText(q.x, q.y, q.text); + } else { // rotated text + w = painter.fontMetrics().width(q.text); + h = painter.fontMetrics().xHeight() + 2; + + painter.translate(q.x, q.y); + painter.rotate(-q.angle); + painter.drawText(floor(-w / 2.0), floor(-h / 2.0), q.text); + painter.rotate(+q.angle); + painter.translate(-q.x, -q.y); + } + + q.text.clear(); + } + + m_textque_items = 0; +} + +// Render graphs with QPainter or pixmap caching, depending on preferences void gGraphView::DrawTextQue() { const qint64 expire_after_ms = 4000; // expire string pixmaps after this many milliseconds @@ -600,10 +501,10 @@ void gGraphView::DrawTextQue() w = fm.width(q.text); h = fm.height(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - w *= dpr; - h *= dpr; -#endif +//#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +// w *= dpr; +// h *= dpr; +//#endif rect.setWidth(w); rect.setHeight(h); @@ -618,16 +519,16 @@ void gGraphView::DrawTextQue() imgpainter.setBrush(b); QFont font = *q.font; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - int fs = font.pointSize(); +//#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +// int fs = font.pointSize(); - if (fs > 0) { - font.setPointSize(fs * dpr); - } else { - font.setPixelSize(font.pixelSize()*dpr); - } +// if (fs > 0) { +// font.setPointSize(fs * dpr); +// } else { +// font.setPixelSize(font.pixelSize()*dpr); +// } -#endif +//#endif imgpainter.setFont(font); imgpainter.setRenderHint(QPainter::TextAntialiasing, q.antialias); @@ -645,10 +546,10 @@ void gGraphView::DrawTextQue() int h = pc->image.height(); int w = pc->image.width(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - h /= dpr; - w /= dpr; -#endif +//#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +// h /= dpr; +// w /= dpr; +//#endif if (q.angle != 0) { float xxx = q.x - h - (h / 2); @@ -748,6 +649,8 @@ void gGraphView::addGraph(gGraph *g, short group) // updateScrollBar(); } } + +// Calculate total height of all graphs including spacers float gGraphView::totalHeight() { float th = 0; @@ -760,6 +663,7 @@ float gGraphView::totalHeight() return ceil(th); } + float gGraphView::findTop(gGraph *graph) { float th = -m_offsetY; @@ -772,9 +676,9 @@ float gGraphView::findTop(gGraph *graph) th += m_graphs[i]->height() * m_scaleY + graphSpacer; } - //th-=m_offsetY; return ceil(th); } + float gGraphView::scaleHeight() { float th = 0; @@ -787,6 +691,7 @@ float gGraphView::scaleHeight() return ceil(th); } + void gGraphView::resizeEvent(QResizeEvent *e) { QGLWidget::resizeEvent(e); // This ques a redraw event.. @@ -797,6 +702,7 @@ void gGraphView::resizeEvent(QResizeEvent *e) m_graphs[i]->resize(e->size().width(), m_graphs[i]->height()*m_scaleY); } } + void gGraphView::scrollbarValueChanged(int val) { //qDebug() << "Scrollbar Changed" << val; @@ -847,6 +753,7 @@ void gGraphView::GetRXBounds(qint64 &st, qint64 &et) st = g->rmin_x; et = g->rmax_x; } + void gGraphView::ResetBounds(bool refresh) //short group) { Q_UNUSED(refresh) @@ -901,6 +808,7 @@ void gGraphView::ResetBounds(bool refresh) //short group) updateScale(); } + void gGraphView::GetXBounds(qint64 &st, qint64 &et) { st = m_minx; @@ -938,6 +846,7 @@ void gGraphView::SetXBounds(qint64 minx, qint64 maxx, short group, bool refresh) if (refresh) { redraw(); } } + void gGraphView::updateScale() { float th = totalHeight(); // height of all graphs @@ -1014,33 +923,38 @@ void gGraphView::initializeGL() void gGraphView::resizeGL(int w, int h) { - glViewport(0, 0, w, h); +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + float dpr = devicePixelRatio(); +#else + float dpr = 1; +#endif + + glViewport(0, 0, w / dpr, h / dpr); glMatrixMode(GL_PROJECTION); glLoadIdentity(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - float dpr = devicePixelRatio(); glOrtho(0, w / dpr, h / dpr, 0, -1, 1); -#else - glOrtho(0, w, h, 0, -1, 1); -#endif + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } -void gGraphView::renderCube(float alpha) +void gGraphView::renderCube(QPainter &painter, float alpha) { if (cubeimg.size() == 0) { return; } // glPushMatrix(); float w = width(); float h = height(); + #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) float dpr = devicePixelRatio(); w *= dpr; h *= dpr; #endif + painter.beginNativePainting(); + glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1204,9 +1118,11 @@ void gGraphView::renderCube(float alpha) glLoadIdentity(); // glPopMatrix(); + painter.endNativePainting(); + } -bool gGraphView::renderGraphs() +bool gGraphView::renderGraphs(QPainter &painter) { float px = m_offsetX; float py = -m_offsetY; @@ -1276,12 +1192,12 @@ bool gGraphView::renderGraphs() if (m_showsplitter) { // draw the splitter handle - QColor ca = QColor(128, 128, 128, 255); - backlines->add(0, py + h, w, py + h, ca.rgba()); - ca = QColor(192, 192, 192, 255); - backlines->add(0, py + h + 1, w, py + h + 1, ca.rgba()); - ca = QColor(90, 90, 90, 255); - backlines->add(0, py + h + 2, w, py + h + 2, ca.rgba()); + painter.setPen(QColor(128,128,128,255)); + painter.drawLine(0, py + h, w, py + h); + painter.setPen(QColor(192, 192, 192, 255)); + painter.drawLine(0, py + h + 1, w, py + h + 1); + painter.setPen(QColor(90, 90, 90, 255)); + painter.drawLine(0, py + h + 2, w, py + h + 2); } } @@ -1295,7 +1211,7 @@ bool gGraphView::renderGraphs() for (int i = 0; i < s; i++) { gGraph *g = m_drawlist.at(0); m_drawlist.pop_front(); - g->paint(g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height()); + g->paint(painter, g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height()); } backlines->draw(); @@ -1310,21 +1226,14 @@ bool gGraphView::renderGraphs() // can't draw snapshot text using this DrawTextQue function // TODO: Find a better solution for detecting when in snapshot mode if (m_graphs.size() > 1) { - DrawTextQue(); + DrawTextQue(painter); // Draw a gradient behind pinned graphs - // glEnable(GL_BLEND); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBegin(GL_QUADS); - glColor4f(0.85, 0.85, 1.0, 1.0); // Gradient End - glVertex2f(0, pinned_height); - glVertex2f(0, 0); - glColor4f(1.0, 1.0, 1.0, 1.0); // Gradient start - glVertex2f(width(), 0); - glVertex2f(width(), pinned_height); - glEnd(); + QLinearGradient linearGrad(QPointF(100, 100), QPointF(width() / 2, 100)); + linearGrad.setColorAt(0, QColor(216, 216, 255)); + linearGrad.setColorAt(1, Qt::white); - // glDisable(GL_BLEND); + painter.fillRect(0, 0, width(), pinned_height, QBrush(linearGrad)); } py = 0; // start drawing at top... @@ -1352,12 +1261,12 @@ bool gGraphView::renderGraphs() if (m_showsplitter) { // draw the splitter handle - QColor ca = QColor(128, 128, 128, 255); - backlines->add(0, py + h, w, py + h, ca.rgba()); - ca = QColor(192, 192, 192, 255); - backlines->add(0, py + h + 1, w, py + h + 1, ca.rgba()); - ca = QColor(90, 90, 90, 255); - backlines->add(0, py + h + 2, w, py + h + 2, ca.rgba()); + painter.setPen(QColor(128, 128, 128, 255)); + painter.drawLine(0, py + h, w, py + h); + painter.setPen(QColor(192, 192, 192, 255)); + painter.drawLine(0, py + h + 1, w, py + h + 1); + painter.setPen(QColor(90, 90, 90, 255)); + painter.drawLine(0, py + h + 2, w, py + h + 2); } } @@ -1384,7 +1293,7 @@ bool gGraphView::renderGraphs() for (int i = 0; i < s; i++) { gGraph *g = m_drawlist.at(0); m_drawlist.pop_front(); - g->paint(g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height()); + g->paint(painter, g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height()); } #ifdef ENABLED_THREADED_DRAWING @@ -1393,18 +1302,6 @@ bool gGraphView::renderGraphs() //int elapsed=time.elapsed(); //QColor col=Qt::black; - - backlines->draw(); - - for (int i = 0; i < m_graphs.size(); i++) - { - m_graphs[i]->drawGLBuf(); - } - - quads->draw(); - lines->draw(); - - // lines->setSize(linesize); // DrawTextQue(); @@ -1413,73 +1310,7 @@ bool gGraphView::renderGraphs() return numgraphs > 0; } -void gGraphView::fadeOut() -{ - if (!PROFILE.ExistsAndTrue("AnimationsAndTransitions")) { return; } - //if (m_fadingOut) { - // return; - // } - //if (m_inAnimation) { - // m_inAnimation=false; - // } - //clone graphs to shapshot graphview object, render, and then fade in, before switching back to normal mode - /*gGraphView *sg=mainwin->snapshotGraph(); - sg->trashGraphs(); - sg->setFixedSize(width(),height()); - sg->m_graphs=m_graphs; - sg->showSplitter(); */ - - //bool restart=false; - //if (!m_inAnimation) - // restart=true; - - bool b = m_inAnimation; - m_inAnimation = false; - - previous_day_snapshot = renderPixmap(width(), height(), false); - m_inAnimation = b; - //m_fadingOut=true; - //m_fadingIn=false; - //m_inAnimation=true; - //m_limbo=false; - //m_animationStarted.start(); - // updateGL(); -} -void gGraphView::fadeIn(bool dir) -{ - static bool firstdraw = true; - m_tooltip->cancel(); - - if (firstdraw || !PROFILE.ExistsAndTrue("AnimationsAndTransitions")) { - updateGL(); - firstdraw = false; - return; - } - - if (m_fadingIn) { - m_fadingIn = false; - m_inAnimation = false; - updateGL(); - return; - // previous_day_snapshot=current_day_snapshot; - } - - m_inAnimation = false; - current_day_snapshot = renderPixmap(width(), height(), false); - // qDebug() << current_day_snapshot.depth() << "bit image depth"; - // if (current_day_snapshot.hasAlpha()){ - // qDebug() << "Snapshots are not storing alpha channel needed for texture blending"; - // } - m_inAnimation = true; - - m_animationStarted.start(); - m_fadingIn = true; - m_limbo = false; - m_fadedir = dir; - updateGL(); - -} void gGraphView::paintGL() { @@ -1492,146 +1323,41 @@ void gGraphView::paintGL() redrawtimer->stop(); } - bool something_fun = PROFILE.appearance->animations(); + bool render_cube = PROFILE.appearance->animations(); // do something to if (width() <= 0) { return; } - if (height() <= 0) { return; } - glClearColor(255, 255, 255, 255); - //glClearDepth(1); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + // Create QPainter object, note this is only valid from paintGL events! + QPainter painter(this); - bool numgraphs = true; - const int animTimeout = 200; - float phase = 0; + QRect bgrect(0, 0, width(), height()); + painter.fillRect(bgrect,QBrush(QColor(255,255,255))); - int elapsed = 0; + bool graphs_drawn = true; - if (m_inAnimation || m_fadingIn) { - elapsed = m_animationStarted.elapsed(); + graphs_drawn = renderGraphs(painter); - if (elapsed > animTimeout) { - if (m_fadingOut) { - m_fadingOut = false; - m_animationStarted.start(); - elapsed = 0; - m_limbo = true; - } else if (m_fadingIn) { - m_fadingIn = false; - m_inAnimation = false; // end animation - m_limbo = false; - m_fadingOut = false; - } + if (!graphs_drawn) { // No graphs drawn? + int x, y; + GetTextExtent(m_emptytext, x, y, bigfont); + int tp; - // + if (render_cube && this->isVisible()) { + renderCube(painter); + + tp = height() - (y / 2); } else { - phase = float(elapsed) / float(animTimeout); //percentage of way through animation timeslot - - if (phase > 1.0) { phase = 1.0; } - - if (phase < 0) { phase = 0; } + tp = height() / 2 + y / 2; } - if (m_inAnimation) { - if (m_fadingOut) { - // bindTexture(previous_day_snapshot); - } else if (m_fadingIn) { - //int offset,offset2; - float aphase; - aphase = 1.0 - phase; - /*if (m_fadedir) { // forwards - //offset2=-width(); - //offset=0; - aphase=phase; - phase=1.0-phase; - } else { // backwards - aphase=phase; - phase=phase - //offset=-width(); - //offset2=0;//-width(); - }*/ - //offset=0; offset2=0; - - glEnable(GL_BLEND); - - glDisable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.0); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(aphase, aphase, aphase, aphase); - - bindTexture(previous_day_snapshot); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 1.0f); - glVertex2f(0, 0); - glTexCoord2f(1.0f, 1.0f); - glVertex2f(width(), 0); - glTexCoord2f(1.0f, 0.0f); - glVertex2f(width(), height()); - glTexCoord2f(0.0f, 0.0f); - glVertex2f(0, height()); - glEnd(); - - glColor4f(phase, phase, phase, phase); - // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - bindTexture(current_day_snapshot); - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 1.0f); - glVertex2f(0, 0); - glTexCoord2f(1.0f, 1.0f); - glVertex2f(width(), 0); - glTexCoord2f(1.0f, 0.0f); - glVertex2f(width(), height()); - glTexCoord2f(0.0f, 0.0f); - glVertex2f(0, height()); - glEnd(); - - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, 0); - } - } + // Then display the empty text message + QColor col = Qt::black; + AddTextQue(m_emptytext, (width() / 2) - x / 2, tp, 0.0, col, bigfont); } + DrawTextQue(painter); - // Need a really good condition/excuse to switch this on.. :-} - bool bereallyannoying = false; - - if (!m_inAnimation || (!m_fadingIn)) { - // Not in animation sequence, draw graphs like normal - if (bereallyannoying) { - renderCube(0.7F); - } - - numgraphs = renderGraphs(); - - if (!numgraphs) { // No graphs drawn? - int x, y; - GetTextExtent(m_emptytext, x, y, bigfont); - int tp; - - if (something_fun && this->isVisible()) {// Do something fun instead - if (!bereallyannoying) { - renderCube(); - } - - tp = height() - (y / 2); - } else { - tp = height() / 2 + y / 2; - } - - // Then display the empty text message - QColor col = Qt::black; - AddTextQue(m_emptytext, (width() / 2) - x / 2, tp, 0.0, col, bigfont); - - } - - DrawTextQue(); - } - - m_tooltip->paint(); + m_tooltip->paint(painter); #ifdef DEBUG_EFFICIENCY const int rs = 10; @@ -1660,32 +1386,26 @@ void gGraphView::paintGL() "Kb"; int w, h; - GetTextExtent(ss, w, - h); // this uses tightBoundingRect, which is different on Mac than it is on Windows & Linux. + // this uses tightBoundingRect, which is different on Mac than it is on Windows & Linux. + GetTextExtent(ss, w, h); QColor col = Qt::white; - quads->add(width() - m_graphs[0]->marginRight(), 0, width() - m_graphs[0]->marginRight(), w, - width(), w, width(), 0, col.rgba()); - quads->draw(); - //renderText(0,0,0,ss,*defaultfont); - // int xx=3; + painter.fillRect(width() - m_graphs[0]->marginRight(), 0, m_graphs[0]->marginRight(), w, QBrush(col)); #ifndef Q_OS_MAC // if (usePixmapCache()) xx+=4; else xx-=3; #endif - AddTextQue(ss, width(), w / 2, 90, col, defaultfont); - DrawTextQue(); + AddTextQue(ss, width(), w / 2, 90, QColor(Qt::black), defaultfont); + DrawTextQue(painter); } #endif swapBuffers(); // Dump to screen. - if (this->isVisible()) { - if (m_limbo || m_inAnimation || (something_fun && (bereallyannoying || !numgraphs))) { - redrawtimer->setInterval(1000.0 / 50); - redrawtimer->setSingleShot(true); - redrawtimer->start(); - } + if (this->isVisible() && !graphs_drawn && render_cube) { // keep the cube spinning + redrawtimer->setInterval(1000.0 / 50); // 50 FPS + redrawtimer->setSingleShot(true); + redrawtimer->start(); } } diff --git a/sleepyhead/Graphs/gGraphView.h b/sleepyhead/Graphs/gGraphView.h index b224b744..ac662505 100644 --- a/sleepyhead/Graphs/gGraphView.h +++ b/sleepyhead/Graphs/gGraphView.h @@ -106,8 +106,8 @@ class gToolTip : public QObject */ virtual void display(QString text, int x, int y, int timeout = 0); - //! \brief Queue the actual OpenGL drawing instructions - virtual void paint(); //actually paints it. + //! \brief Draw the tooltip + virtual void paint(QPainter &paint); //actually paints it. //! \brief Close the tooltip early. void cancel(); @@ -226,12 +226,6 @@ class gGraphView : public QGLWidget //! \brief Set a redraw timer for ms milliseconds, clearing any previous redraw timer. void timedRedraw(int ms); - //! \brief Start the animation sequence changing/reloading day data. (fade out) - void fadeOut(); - - //! \brief Start the animation sequence showing new Day's data. (fade in) - void fadeIn(bool dir = false); - //! \brief Call UpdateGL unless animation is in progress void redraw(); @@ -318,18 +312,15 @@ class gGraphView : public QGLWidget //! \brief Trash all graph objects listed (without destroying Graph contents) void trashGraphs(); - //! \brief Use a QGLFrameBufferObject to render to a pixmap - QImage fboRenderPixmap(int w, int h); - - //! \brief Use a QGLPixelBuffer to render to a pixmap - QImage pbRenderPixmap(int w, int h); - //! \brief Enable or disable the Text Pixmap Caching system preference overide void setUsePixmapCache(bool b) { use_pixmap_cache = b; } //! \brief Return whether or not the Pixmap Cache for text rendering is being used. bool usePixmapCache(); + //! \brief Graph drawing routines, returns true if there weren't any graphs to draw + bool renderGraphs(QPainter &painter); + protected: //! \brief Set up the OpenGL basics for the QGLWidget underneath virtual void initializeGL(); @@ -346,9 +337,6 @@ class gGraphView : public QGLWidget //! \brief Calculates the sum of all graph heights, taking scaling into consideration float scaleHeight(); - //! \brief Graph drawing routines, returns true if there weren't any graphs to draw - bool renderGraphs(); - //! \brief Update the OpenGL area when the screen is resized virtual void resizeEvent(QResizeEvent *); @@ -375,7 +363,7 @@ class gGraphView : public QGLWidget void queGraph(gGraph *, int originX, int originY, int width, int height); //! \brief Render the annoying spinning graph empty cube - void renderCube(float alpha = 1); + void renderCube(QPainter &painter, float alpha = 1); Day *m_day; diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index 9c66d81b..14d04510 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -28,10 +28,6 @@ gLineChart::gLineChart(ChannelID code, QColor col, bool square_plot, bool disabl addPlot(code, col, square_plot); m_line_color = col; m_report_empty = false; - addVertexBuffer(lines = new gVertexBuffer(100000, GL_LINES)); - lines->setColor(col); - lines->setAntiAlias(true); - lines->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } gLineChart::~gLineChart() { @@ -156,7 +152,7 @@ EventDataType gLineChart::Maxy() } // Time Domain Line Chart -void gLineChart::paint(gGraph &w, int left, int top, int width, int height) +void gLineChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; @@ -174,7 +170,6 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) top++; - // lines=w.lines(); EventDataType miny, maxy; double minx, maxx; @@ -226,12 +221,12 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) int minz, maxz; // Draw bounding box - gVertexBuffer *outlines = w.lines(); - GLuint blk = QColor(Qt::black).rgba(); - outlines->add(left, top, left, top + height, blk); - outlines->add(left, top + height, left + width, top + height, blk); - outlines->add(left + width, top + height, left + width, top, blk); - outlines->add(left + width, top, left, top, blk); + painter.setPen(QColor(Qt::black)); + painter.drawLine(left, top, left, top + height); + painter.drawLine(left, top + height, left + width, top + height); + painter.drawLine(left + width, top + height, left + width, top); + painter.drawLine(left + width, top, left, top); + width--; height -= 2; @@ -250,12 +245,12 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) int codepoints; - //GLuint color; + painter.setClipRect(left, top, width, height); + painter.setClipping(true); + for (int gi = 0; gi < m_codes.size(); gi++) { ChannelID code = m_codes[gi]; - //m_line_color=m_colors[gi]; - lines->setColor(m_colors[gi]); - //color=m_line_color.rgba(); + painter.setPen(m_colors[gi]); codepoints = 0; @@ -301,8 +296,9 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) total_points += num_points; codepoints += num_points; - const int num_averages = - 20; // Max n umber of samples taken from samples per pixel for better min/max values + + // Max number of samples taken from samples per pixel for better min/max values + const int num_averages = 20; for (int n = 0; n < evec.size(); n++) { // for each segment EventList &el = *evec[n]; @@ -423,22 +419,9 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) double time; EventDataType data; EventDataType gain = el.gain(); - //EventDataType nmult=ymult*gain; - //EventDataType ymin=EventDataType(miny)/gain; - - //const QVector & dat=el.getData(); - //const QVector & tim=el.getTime(); - //quint32 * tptr; - - - //qint64 stime=el.first(); done = false; - // if (!accel) { - lines->setSize(1.5); - // } else lines->setSize(1); - if (el.type() == EVL_Waveform) { // Waveform Plot if (idx > sam) { idx -= sam; } @@ -451,12 +434,6 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) // Accelerated Waveform Plot ////////////////////////////////////////////////////////////////// - // qint64 tmax=(maxx-time)/rate; - // if ((tmax*sam) < siz) { - // siz=idx+tmax*sam; - // done=true; - // } - for (int i = idx; i < siz; i += sam, ptr += sam) { time += rate; // This is much faster than QVector access. @@ -519,21 +496,12 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) // Cap within VertexBuffer capacity, one vertex per line point - int np = (maxz - minz) * 2; +// int np = (maxz - minz) * 2; - int j = lines->Max() - lines->cnt(); - - if (np < j) { - for (int i = minz; i < maxz; i++, drl++) { - ax1 = drl->x(); - ay1 = drl->y(); - lines->unsafe_add(xst + i, yst - ax1, xst + i, yst - ay1); - - //if (lines->full()) break; - } - } else { - qDebug() << "gLineChart full trying to draw" << schema::channel[code].label(); - done = true; + for (int i = minz; i < maxz; i++, drl++) { + ax1 = drl->x(); + ay1 = drl->y(); + painter.drawLine(xst + i, yst - ax1, xst + i, yst - ay1); } } else { // Zoomed in Waveform @@ -541,13 +509,6 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) // Normal Waveform Plot ////////////////////////////////////////////////////////////////// - // Cap within VertexBuffer capacity, one vertex per line point - // int np=((siz-idx)/sam)*2; - // int j=lines->Max()-lines->cnt(); - // if (np > j) { - // siz=j*sam; - // } - // Prime first point data = (*ptr + el.offset()) * gain; lastpx = xst + ((time - minx) * xmult); @@ -563,7 +524,7 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) py = yst - ((data - miny) * ymult); // Same for Y scale, with precomputed gain //py=yst-((data - ymin) * nmult); // Same for Y scale, with precomputed gain - lines->add(lastpx, lastpy, px, py); + painter.drawLine(lastpx, lastpy, px, py); lastpx = px; lastpy = py; @@ -572,10 +533,6 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) done = true; break; } - - if (lines->full()) { - break; - } } } @@ -619,20 +576,12 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) siz -= idx; - // Check if would overflow lines gVertexBuffer int gs = siz << 1; - int j = lines->Max() - lines->cnt(); if (square_plot) { gs <<= 1; } - if (gs > j) { - qDebug() << "Would overflow line points.. increase default VertexBuffer size in gLineChart"; - siz = (j >> square_plot) ? 2 : 1; - done = true; // end after this partial draw.. - } - // Unrolling square plot outside of loop to gain a minor speed improvement. EventStoreType *eptr = dptr + siz; @@ -652,12 +601,15 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) // Cap px to right margin if (px > xst + width) { px = xst + width; } - lines->unsafe_add(lastpx, lastpy, px, lastpy, px, lastpy, px, py); + painter.drawLine(lastpx, lastpy, px, lastpy); + painter.drawLine(px, lastpy, px, py); } else { // Letting the scissor do the dirty work for non horizontal lines // This really should be changed, as it might be cause that weird // display glitch on Linux.. - lines->unsafe_add(lastpx, lastpy, px, lastpy, px, lastpy, px, py); + + painter.drawLine(lastpx, lastpy, px, lastpy); + painter.drawLine(px, lastpy, px, py); } lastpx = px; @@ -685,12 +637,12 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) // Cap px to right margin if (px > xst + width) { px = xst + width; } - lines->unsafe_add(lastpx, lastpy, px, py); + painter.drawLine(lastpx, lastpy, px, py); } else { // Letting the scissor do the dirty work for non horizontal lines // This really should be changed, as it might be cause that weird // display glitch on Linux.. - lines->unsafe_add(lastpx, lastpy, px, py); + painter.drawLine(lastpx, lastpy, px, py); } lastpx = px; @@ -716,17 +668,19 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) int bw = fm.width('X'); int bh = fm.height() / 1.8; - if ((codepoints > 0)) { //(m_codes.size()>1) && + + if ((codepoints > 0)) { QString text = schema::channel[code].label(); int wid, hi; GetTextExtent(text, wid, hi); legendx -= wid; + painter.setClipping(false); w.renderText(text, legendx, top - 4); + legendx -= bw /2; + painter.fillRect(legendx - bw, top - w.marginTop()-2, bh, w.marginTop()+1, QBrush(m_colors[gi])); + painter.setClipping(true); - int tp = top - 5 - bh / 2; - w.quads()->add(legendx - bw, tp + bh / 2, legendx, tp + bh / 2, legendx, tp - bh / 2, legendx - bw, - tp - bh / 2, m_colors[gi].rgba()); - legendx -= bw * 2; + legendx -= bw*2; } } @@ -738,14 +692,8 @@ void gLineChart::paint(gGraph &w, int left, int top, int width, int height) GetTextExtent(msg, x, y, bigfont); //DrawText(w,msg,left+(width/2.0)-(x/2.0),scry-w.GetBottomMargin()-height/2.0+y/2.0,0,Qt::gray,bigfont); } - } else { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - float dpr = w.graphView()->devicePixelRatio(); - lines->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width + 1)*dpr, (height + 1)*dpr); -#else - lines->scissor(left, w.flipY(top + height + 2), width + 1, height + 1); -#endif } + painter.setClipping(false); } @@ -753,17 +701,13 @@ AHIChart::AHIChart(QColor col) : Layer(NoChannel), m_color(col) { m_miny = m_maxy = 0; - addVertexBuffer(lines = new gVertexBuffer(100000, GL_LINES)); - lines->setColor(col); - lines->setAntiAlias(true); - lines->setSize(1.5); } AHIChart::~AHIChart() { } -void AHIChart::paint(gGraph &w, int left, int top, int width, int height) +void AHIChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; @@ -774,12 +718,11 @@ void AHIChart::paint(gGraph &w, int left, int top, int width, int height) } // Draw bounding box - gVertexBuffer *outlines = w.lines(); - GLuint blk = QColor(Qt::black).rgba(); - outlines->add(left, top, left, top + height, blk); - outlines->add(left, top + height, left + width, top + height, blk); - outlines->add(left + width, top + height, left + width, top, blk); - outlines->add(left + width, top, left, top, blk); + painter.setPen(QColor(Qt::black)); + painter.drawLine(left, top, left, top + height); + painter.drawLine(left, top + height, left + width, top + height); + painter.drawLine(left + width, top + height, left + width, top); + painter.drawLine(left + width, top, left, top); width--; height -= 2; @@ -811,7 +754,10 @@ void AHIChart::paint(gGraph &w, int left, int top, int width, int height) double top1 = top + height; bool done = false; - //GLuint color=m_color.rgba(); + painter.setPen(QPen(m_color,1.5)); + painter.setClipRect(left, top, width, height); + painter.setClipping(true); + for (int i = 0; i < m_time.size(); i++) { qint64 ti = m_time[i]; EventDataType v = m_data[i]; @@ -833,7 +779,7 @@ void AHIChart::paint(gGraph &w, int left, int top, int width, int height) } else { px = left + (double(ti - minx) * xmult); py = top1 - (double(v - miny) * ymult); - lines->add(px, py, lastpx, lastpy); + painter.drawLine(px, py, lastpx, lastpy); } lastpx = px; @@ -841,13 +787,7 @@ void AHIChart::paint(gGraph &w, int left, int top, int width, int height) if (done) { break; } } - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - float dpr = w.graphView()->devicePixelRatio(); - lines->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width + 1)*dpr, (height + 1)*dpr); -#else - lines->scissor(left, w.flipY(top + height + 2), width + 1, height + 1); -#endif + painter.setClipping(false); } void AHIChart::SetDay(Day *d) diff --git a/sleepyhead/Graphs/gLineChart.h b/sleepyhead/Graphs/gLineChart.h index cf34b85c..ad79c111 100644 --- a/sleepyhead/Graphs/gLineChart.h +++ b/sleepyhead/Graphs/gLineChart.h @@ -30,7 +30,7 @@ class AHIChart: public Layer ~AHIChart(); //! \brief Draws the precalculated data to the Vertex buffers - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! \brief AHI/hr Calculations are done for this day here. //! This also uses the sliding window method @@ -55,7 +55,6 @@ class AHIChart: public Layer EventDataType m_miny; EventDataType m_maxy; QColor m_color; - gVertexBuffer *lines; }; /*! \class gLineChart @@ -75,7 +74,7 @@ class gLineChart: public Layer virtual ~gLineChart(); //! \brief The drawing code that fills the vertex buffers - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! \brief Set Use Square plots for non EVL_Waveform data void SetSquarePlot(bool b) { m_square_plot = b; } @@ -123,10 +122,6 @@ class gLineChart: public Layer bool m_disable_accel; QColor m_line_color; - gVertexBuffer *lines; - //GLShortBuffer * lines; - //GLShortBuffer * outlines; - //! \brief Used by accelerated waveform plots. Must be >= Screen Resolution (or at least graph width) static const int max_drawlist_size = 10000; diff --git a/sleepyhead/Graphs/gLineOverlay.cpp b/sleepyhead/Graphs/gLineOverlay.cpp index 59d2b8dc..c2e0410b 100644 --- a/sleepyhead/Graphs/gLineOverlay.cpp +++ b/sleepyhead/Graphs/gLineOverlay.cpp @@ -16,30 +16,17 @@ gLineOverlayBar::gLineOverlayBar(ChannelID code, QColor color, QString label, FlagType flt) : Layer(code), m_flag_color(color), m_label(label), m_flt(flt) { - addVertexBuffer(points = new gVertexBuffer(2048, GL_POINTS)); - points->setSize(4); - points->setColor(m_flag_color); - addVertexBuffer(quads = new gVertexBuffer(2048, GL_QUADS)); - //addGLBuf(lines=new GLBuffer(color,1024,GL_LINES)); - points->setAntiAlias(true); - quads->setAntiAlias(true); - quads->setColor(m_flag_color); - //lines->setAntiAlias(true); } gLineOverlayBar::~gLineOverlayBar() { - //delete lines; - //delete quads; - //delete points; } -void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height) +void gLineOverlayBar::paint(QPainter &painter, gGraph &w, int left, int topp, int width, int height) { if (!m_visible) { return; } if (!m_day) { return; } - gVertexBuffer *lines = w.lines(); int start_py = topp; double xx = w.max_x - w.min_x; @@ -56,19 +43,17 @@ void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height double X; double Y; - bool verts_exceeded = false; - m_count = 0; m_sum = 0; m_flag_color = schema::channel[m_code].defaultColor(); - lines->setColor(m_flag_color); - points->setColor(m_flag_color); if (m_flt == FT_Span) { m_flag_color.setAlpha(128); } + painter.setPen(m_flag_color); + EventStoreType raw; quint32 *tptr; @@ -149,16 +134,7 @@ void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height x1 = width + left; } - quads->add(x2, start_py, - x1, start_py, - x1, start_py + height, - x2, start_py + height, - m_flag_color.rgba()); - - if (quads->full()) { - verts_exceeded = true; - break; - } + painter.fillRect(x2, start_py, x1-x2, height, QBrush(m_flag_color)); } } else if (m_flt == FT_Dot) { //////////////////////////////////////////////////////////////////////////// @@ -178,22 +154,15 @@ void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height if ((odt == ODT_Bars) || (xx < 3600000)) { // show the fat dots in the middle - points->add(x1, double(height) / double(yy)*double(-20 - w.min_y) + topp); + painter.setPen(QPen(m_flag_color,4)); + + painter.drawPoint(x1, double(height) / double(yy)*double(-20 - w.min_y) + topp); + painter.setPen(QPen(m_flag_color,1)); - if (points->full()) { - verts_exceeded = true; - break; - } } else { // thin lines down the bottom - lines->add(x1, start_py + 1, x1, start_py + 1 + 12); - - if (lines->full()) { - verts_exceeded = true; - break; - } + painter.drawLine(x1, start_py + 1, x1, start_py + 1 + 12); } - } } else if (m_flt == FT_Bar) { //////////////////////////////////////////////////////////////////////////// @@ -215,20 +184,13 @@ void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height if ((odt == ODT_Bars) || (xx < 3600000)) { z = top; - points->add(x1, top); - lines->add(x1, top, x1, bottom); + painter.setPen(QPen(m_flag_color,4)); + painter.drawPoint(x1, top); + painter.setPen(QPen(m_flag_color,1)); + painter.drawLine(x1, top, x1, bottom); - if (points->full()) { - verts_exceeded = true; - break; - } } else { - lines->add(x1, z, x1, z - 12); - } - - if (lines->full()) { - verts_exceeded = true; - break; + painter.drawLine(x1, z, x1, z - 12); } if (xx < (1800000)) { @@ -238,18 +200,8 @@ void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height } } - if (verts_exceeded) { - break; - } } - if (verts_exceeded) { - break; - } - } - - if (verts_exceeded) { - qWarning() << "exceeded maxverts in gLineOverlay::Plot()"; } } @@ -262,7 +214,7 @@ gLineOverlaySummary::~gLineOverlaySummary() { } -void gLineOverlaySummary::paint(gGraph &w, int left, int top, int width, int height) +void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; } diff --git a/sleepyhead/Graphs/gLineOverlay.h b/sleepyhead/Graphs/gLineOverlay.h index 34476385..da8089ca 100644 --- a/sleepyhead/Graphs/gLineOverlay.h +++ b/sleepyhead/Graphs/gLineOverlay.h @@ -26,7 +26,7 @@ class gLineOverlayBar: public Layer virtual ~gLineOverlayBar(); //! \brief The drawing code that fills the OpenGL vertex GLBuffers - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual EventDataType Miny() { return 0; } virtual EventDataType Maxy() { return 0; } @@ -44,9 +44,6 @@ class gLineOverlayBar: public Layer FlagType m_flt; int m_count; double m_sum; - - gVertexBuffer *quads; - gVertexBuffer *points; }; /*! \class gLineOverlaySummary @@ -58,7 +55,7 @@ class gLineOverlaySummary: public Layer gLineOverlaySummary(QString text, int x, int y); virtual ~gLineOverlaySummary(); - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual EventDataType Miny() { return 0; } virtual EventDataType Maxy() { return 0; } diff --git a/sleepyhead/Graphs/gSegmentChart.cpp b/sleepyhead/Graphs/gSegmentChart.cpp index c4290304..c865bbd6 100644 --- a/sleepyhead/Graphs/gSegmentChart.cpp +++ b/sleepyhead/Graphs/gSegmentChart.cpp @@ -17,12 +17,6 @@ gSegmentChart::gSegmentChart(GraphSegmentType type, QColor gradient_color, QColo m_outline_color(outline_color) { m_empty = true; - addGLBuf(poly = new GLFloatBuffer(4000, GL_POLYGON)); - addGLBuf(lines = new GLFloatBuffer(4000, GL_LINE_LOOP)); - lines->setSize(1); - poly->forceAntiAlias(false); - lines->forceAntiAlias(true); - lines->setAntiAlias(true); } gSegmentChart::~gSegmentChart() { @@ -69,7 +63,7 @@ bool gSegmentChart::isEmpty() return m_empty; } -void gSegmentChart::paint(gGraph &w, int left, int top, int width, int height) +void gSegmentChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; } @@ -83,12 +77,6 @@ void gSegmentChart::paint(gGraph &w, int left, int top, int width, int height) diameter -= 8; float radius = diameter / 2.0; - float j = 0.0; - float sum = 0.0; - float step = 1.0 / 720.0; - float px, py; - float q; - float xmult = float(width) / float(m_total); float ymult = float(height) / float(m_total); @@ -113,9 +101,9 @@ void gSegmentChart::paint(gGraph &w, int left, int top, int width, int height) bool line_first = true; int line_last; - gVertexBuffer *quads = w.quads(); - gVertexBuffer *lines2 = w.lines(); + float sum = -90.0; + painter.setFont(*defaultfont); for (unsigned m = 0; m < size; m++) { data = m_values[m]; @@ -126,62 +114,65 @@ void gSegmentChart::paint(gGraph &w, int left, int top, int width, int height) ///////////////////////////////////////////////////////////////////////////////////// if (m_graph_type == GST_Pie) { QColor &col = schema::channel[m_codes[m % m_colors.size()]].defaultColor(); - j = float(data) / float(m_total); // ratio of this pie slice - // Draw Filling - poly->add(start_px + xoffset, start_py + height - yoffset, m_gradient_color); + // length of this segment in degrees + float len = 360.0 / float(m_total) * float(data); - for (q = sum; q < sum + j; q += step) { - px = start_px + xoffset + sin(q * 2 * M_PI) * radius; - py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius); - poly->add(px, py, col); - } + qDebug() << m_names[m]; + // Setup the shiny radial gradient - q = sum + j; - px = start_px + xoffset + sin(q * 2 * M_PI) * radius; - py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius); - poly->add(px, py, col); + painter.setRenderHint(QPainter::Antialiasing); + QRect pierect(start_px+1, start_py+1, width-2, height-2); - if (m_total != data) { - // Draw the center point first - lines->add(start_px + xoffset, start_py + height - yoffset, m_outline_color); - } + painter.setPen(QPen(col, 0)); + QRadialGradient gradient(pierect.center(), pierect.width()/2, pierect.center()); + gradient.setColorAt(0, Qt::white); + gradient.setColorAt(1, col); - for (q = sum; q < sum + j; q += step) { - px = start_px + xoffset + sin(q * 2 * M_PI) * radius; - py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius); - lines->add(px, py, m_outline_color); - } + // draw filled pie + painter.setBrush(gradient); + painter.setBackgroundMode(Qt::OpaqueMode); + painter.drawPie(pierect, -sum * 16.0, -len * 16.0); - double tpx = start_px + xoffset + sin((sum + (j / 2.0)) * 2 * M_PI) * (radius / 1.7); - double tpy = start_py + height - (yoffset + cos((sum + (j / 2.0)) * 2 * M_PI) * (radius / 1.7)); - q = sum + j; - px = start_px + xoffset + sin(q * 2 * M_PI) * radius; - py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius); - lines->add(px, py, m_outline_color); + // draw outline + painter.setBackgroundMode(Qt::TransparentMode); + painter.setBrush(QBrush(col,Qt::NoBrush)); + painter.setPen(QPen(QColor(Qt::black),1.5)); + painter.drawPie(pierect, -sum * 16.0, -len * 16.0); - if (j > .09) { - QString a = m_names[m]; //QString::number(floor(100.0/m_total*data),'f',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)); + + QString txt = m_names[m]; //QString::number(floor(100.0/m_total*data),'f',0)+"%"; int x, y; - GetTextExtent(a, x, y); - w.renderText(a, tpx - (x / 2.0), (tpy + y / 2.0), 0, Qt::black, defaultfont, - false); // antialiasing looks like crap here.. + 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); } + sum += len; - sum = q; - + } else if (m_graph_type == GST_CandleStick) { ///////////////////////////////////////////////////////////////////////////////////// // CandleStick Chart ///////////////////////////////////////////////////////////////////////////////////// - } else if (m_graph_type == GST_CandleStick) { + QColor &col = m_colors[m % m_colors.size()]; + float bw = xmult * float(data); - quads->add(xp, start_py, xp + bw, start_py, m_gradient_color.rgba()); - quads->add(xp + bw, start_py + height, xp, start_py + height, col.rgba()); + QLinearGradient linearGrad(QPointF(0, 0), QPointF(bw, 0)); + linearGrad.setColorAt(0, col); + linearGrad.setColorAt(1, Qt::white); + painter.fillRect(xp, start_py, bw, height, QBrush(linearGrad)); - lines2->add(xp, start_py, xp + bw, start_py, m_outline_color.rgba()); - lines2->add(xp + bw, start_py + height, xp, start_py + height, m_outline_color.rgba()); + painter.setPen(m_outline_color); + painter.drawLine(xp, start_py, xp + bw, start_py); + painter.drawLine(xp + bw, start_py + height, xp, start_py + height); if (!m_names[m].isEmpty()) { int px, py; @@ -198,12 +189,13 @@ void gSegmentChart::paint(gGraph &w, int left, int top, int width, int height) ///////////////////////////////////////////////////////////////////////////////////// } else if (m_graph_type == GST_Line) { QColor col = Qt::black; //m_colors[m % m_colors.size()]; + painter.setPen(col); float h = (top + height) - (float(data) * ymult); if (line_first) { line_first = false; } else { - lines->add(xp, line_last, xp + line_step, h, col); + painter.drawLine(xp, line_last, xp + line_step, h); xp += line_step; } diff --git a/sleepyhead/Graphs/gSegmentChart.h b/sleepyhead/Graphs/gSegmentChart.h index cdcaabd2..321bdc92 100644 --- a/sleepyhead/Graphs/gSegmentChart.h +++ b/sleepyhead/Graphs/gSegmentChart.h @@ -27,7 +27,7 @@ class gSegmentChart : public Layer virtual ~gSegmentChart(); //! \brief The drawing code that fills the Vertex buffers - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! \brief Pre-fills a buffer with the data needed to draw virtual void SetDay(Day *d); @@ -57,9 +57,6 @@ class gSegmentChart : public Layer QColor m_gradient_color; QColor m_outline_color; bool m_empty; - - // gah.. can't convert these - GLFloatBuffer *poly, *lines; }; /*! \class gTAPGraph diff --git a/sleepyhead/Graphs/gStatsLine.cpp b/sleepyhead/Graphs/gStatsLine.cpp index b3a68220..abaf82e2 100644 --- a/sleepyhead/Graphs/gStatsLine.cpp +++ b/sleepyhead/Graphs/gStatsLine.cpp @@ -17,7 +17,7 @@ gStatsLine::gStatsLine(ChannelID code, QString label, QColor textcolor) : Layer(code), m_label(label), m_textcolor(textcolor) { } -void gStatsLine::paint(gGraph &w, int left, int top, int width, int height) +void gStatsLine::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; } diff --git a/sleepyhead/Graphs/gStatsLine.h b/sleepyhead/Graphs/gStatsLine.h index f79e66e3..02bf490a 100644 --- a/sleepyhead/Graphs/gStatsLine.h +++ b/sleepyhead/Graphs/gStatsLine.h @@ -22,7 +22,7 @@ class gStatsLine : public Layer { public: gStatsLine(ChannelID code, QString label = "", QColor textcolor = Qt::black); - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); void SetDay(Day *d); protected: diff --git a/sleepyhead/Graphs/gSummaryChart.cpp b/sleepyhead/Graphs/gSummaryChart.cpp index 1133e248..3e185c25 100644 --- a/sleepyhead/Graphs/gSummaryChart.cpp +++ b/sleepyhead/Graphs/gSummaryChart.cpp @@ -390,7 +390,7 @@ QColor brighten(QColor color) } -void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) +void SummaryChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { if (!m_visible) { return; } @@ -403,21 +403,13 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) graphtype = pts ? GT_POINTS : GT_LINE; } - if (graphtype == GT_POINTS) { - lines->setSize(4); - } else { - lines->setSize(1.5); - } - - rtop = top; - gVertexBuffer *outlines2 = w.lines(); - // outlines2->setColor(Qt::black); - outlines2->add(left, top, left, top + height, left, top + height, left + width, top + height, - QColor("black").rgba()); - outlines2->add(left + width, top + height, left + width, top, left + width, top, left, top, - QColor("black").rgba()); - //if (outlines->full()) qDebug() << "WTF??? Outlines full in SummaryChart::paint()"; + + painter.setPen(QColor(Qt::black)); + painter.drawLine(left, top, left, top+height); + painter.drawLine(left, top+height, left+width, top+height); + painter.drawLine(left+width, top+height, left+width, top); + painter.drawLine( left+width, top, left, top); qint64 minx = w.min_x, maxx = w.max_x; qint64 xx = maxx - minx; @@ -484,7 +476,6 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) QVector goodcodes; goodcodes.resize(m_goodcodes.size()); - points->setSize(5.0 * dpr); lastdaygood = true; for (int i = 0; i < numcodes; i++) { @@ -534,6 +525,10 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) short px2, py2; const qint64 ms_per_day = 86400000L; + + painter.setClipRect(left, top, width, height); + painter.setClipping(true); + for (qint64 Q = minx; Q <= maxx + ms_per_day; Q += ms_per_day) { zd = Q / ms_per_day; d = m_values.find(zd); @@ -555,7 +550,7 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) //x1-=(barw/2.0); int x2 = px + barw; - if (x1 < left) { x1 = left; } + //if (x1 < left) { x1 = left; } if (x2 > left + width) { x2 = left + width; } @@ -568,10 +563,12 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) col.setAlpha(64); if (graphtype != GT_POINTS) { - quads->add(x1 - 1, top, x1 - 1, top + height, x2, top + height, x2, top, col.rgba()); + painter.fillRect(x1-1, top, barw, height, QBrush(col)); +// quads->add(x1 - 1, top, x1 - 1, top + height, x2, top + height, x2, top, col.rgba()); } else { - quads->add((x1 + barw / 2) - 5, top, (x1 + barw / 2) - 5, top + height, (x2 - barw / 2) + 5, - top + height, (x2 - barw / 2) + 5, top, col.rgba()); + painter.fillRect((x1+barw/2)-5, top, barw, height, QBrush(col)); +// quads->add((x1 + barw / 2) - 5, top, (x1 + barw / 2) - 5, top + height, (x2 - barw / 2) + 5, +// top + height, (x2 - barw / 2) + 5, top, col.rgba()); } } @@ -585,8 +582,8 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) col = QColor("gold"); } - GLuint col1 = col.rgba(); - GLuint col2 = brighten(col).rgba(); + QColor col1 = col; + QColor col2 = brighten(col); //outlines->setColor(Qt::black); int np = d.value().size(); @@ -606,11 +603,18 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) //tmp-=miny; h = tmp * ymult; - quads->add(x1, py, x1, py - h, x2, py - h, x2, py, col1, col2); + QLinearGradient gradient(QPoint(0,0),QPoint(barw,0)); + gradient.setColorAt(0,col1); + gradient.setColorAt(1,col2); + painter.fillRect(x1, py-h, barw, h, QBrush(gradient)); +// quads->add(x1, py, x1, py - h, x2, py - h, x2, py, col1, col2); - if (h > 0 && barw > 2) { - outlines->add(x1, py, x1, py - h, x1, py - h, x2, py - h, QColor("black").rgba()); - outlines->add(x1, py, x2, py, x2, py, x2, py - h, QColor("black").rgba()); + if ((h > 0) && (barw > 2)) { + painter.setPen(QColor(Qt::black)); + painter.drawLine(x1, py, x1, py - h); + painter.drawLine(x1, py - h, x2, py - h); + painter.drawLine(x1, py, x2, py); + painter.drawLine(x2, py, x2, py - h); } totalvalues[0] += hours * tmp; @@ -694,17 +698,23 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) h = tmp * ymult; // height in pixels if (graphtype == GT_BAR) { - GLuint col1 = col.rgba(); - GLuint col2 = brighten(col).rgba(); + QColor col1 = col; + QColor col2 = brighten(col); - quads->add(x1, py, x1, py - h, col1); - quads->add(x2, py - h, x2, py, col2); + QLinearGradient gradient(0,0,barw,h); + gradient.setColorAt(0,col1); + gradient.setColorAt(1,col2); + painter.fillRect(x1, py-h, barw, h, QBrush(gradient)); + +// quads->add(x1, py, x1, py - h, col1); +// quads->add(x2, py - h, x2, py, col2); if (h > 0 && barw > 2) { - outlines->add(x1, py, x1, py - h, x1, py - h, x2, py - h, QColor("black").rgba()); - outlines->add(x1, py, x2, py, x2, py, x2, py - h, QColor("black").rgba()); - - if (outlines->full()) { qDebug() << "WTF??? Outlines full in SummaryChart::paint()"; } + painter.setPen(QColor(Qt::black)); + painter.drawLine(x1, py, x1, py - h); + painter.drawLine(x1, py - h, x2, py - h); + painter.drawLine(x1, py, x2, py); + painter.drawLine(x2, py, x2, py - h); } // if (bar py -= h; @@ -721,19 +731,22 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) if (lastdaygood) { if (lastY[j] != py2) { // vertical line - lines->add(lastX[j], lastY[j], px, py2, col2); + painter.setPen(col2); + painter.drawLine(lastX[j], lastY[j], px, py2); } - lines->add(px - 1, py2, px2 + 1, py2, col1); + painter.setPen(col1); + painter.drawLine(px - 1, py2, px2 + 1, py2); } else { - lines->add(x1 - 1, py2, x2 + 1, py2, col1); + painter.setPen(col1); + painter.drawLine(x1 - 1, py2, x2 + 1, py2); } lastX[j] = px2; lastY[j] = py2; } else if (graphtype == GT_POINTS) { - GLuint col1 = col.rgba(); - GLuint col2 = m_colors[j].rgba(); + QColor col1 = col; + QColor col2 = m_colors[j]; px2 = px + barw; py2 = (top + height - 2) - h; @@ -743,13 +756,16 @@ void SummaryChart::paint(gGraph &w, int left, int top, int width, int height) } if (zd == hl_day) { - points->add(px2 - barw / 2, py2, col2); + painter.setPen(QPen(col2,5)); + painter.drawPoint(px2 - barw / 2, py2); } if (lastdaygood) { - lines->add(lastX[j] - barw / 2, lastY[j], px2 - barw / 2, py2, col2); + painter.setPen(QPen(col2,1)); + painter.drawLine(lastX[j] - barw / 2, lastY[j], px2 - barw / 2, py2); } else { - lines->add(px + barw / 2 - 1, py2, px + barw / 2 + 1, py2, col1); + painter.setPen(QPen(col1,1)); + painter.drawLine(px + barw / 2 - 1, py2, px + barw / 2 + 1, py2); } lastX[j] = px2; @@ -779,16 +795,17 @@ jumpnext: daynum++; //lastQ=Q; } + painter.setClipping(false); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - quads->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width)*dpr, (height + 1)*dpr); - lines->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width + 1)*dpr, (height + 1)*dpr); - outlines->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width)*dpr, (height + 1)*dpr); -#else - lines->scissor(left, w.flipY(top + height + 2), width + 1, height + 2); - outlines->scissor(left, w.flipY(top + height + 2), width, height + 2); - quads->scissor(left, w.flipY(top + height + 2), width, height + 2); -#endif +//#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +// quads->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width)*dpr, (height + 1)*dpr); +// lines->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width + 1)*dpr, (height + 1)*dpr); +// outlines->scissor(left * dpr, w.flipY(top + height + 2)*dpr, (width)*dpr, (height + 1)*dpr); +//#else +// lines->scissor(left, w.flipY(top + height + 2), width + 1, height + 2); +// outlines->scissor(left, w.flipY(top + height + 2), width, height + 2); +// quads->scissor(left, w.flipY(top + height + 2), width, height + 2); +//#endif // Draw Ledgend px = left + width - 3; py = top - 5; @@ -911,8 +928,9 @@ jumpnext: // legendx-=bw/2; int tp = top - 5 - bh / 2; - w.quads()->add(legendx - bw, tp + bh / 2, legendx, tp + bh / 2, legendx, tp - bh / 2, legendx - bw, - tp - bh / 2, m_colors[j].rgba()); + painter.fillRect(legendx - bw, top-w.marginTop()-1, bh, w.marginTop(), QBrush(m_colors[j])); +// w.quads()->add(legendx - bw, tp + bh / 2, legendx, tp + bh / 2, legendx, tp - bh / 2, legendx - bw, +// tp - bh / 2, m_colors[j].rgba()); legendx -= bw * 2; diff --git a/sleepyhead/Graphs/gSummaryChart.h b/sleepyhead/Graphs/gSummaryChart.h index 657eec8d..d69244a6 100644 --- a/sleepyhead/Graphs/gSummaryChart.h +++ b/sleepyhead/Graphs/gSummaryChart.h @@ -34,7 +34,7 @@ class SummaryChart: public Layer virtual ~SummaryChart(); //! \brief Drawing code that fills the Vertex buffers - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! \brief Precalculation code prior to drawing. Day object is not needed here, it's just here for Layer compatability. virtual void SetDay(Day *day = nullptr); diff --git a/sleepyhead/Graphs/gXAxis.cpp b/sleepyhead/Graphs/gXAxis.cpp index 71599701..3e815db3 100644 --- a/sleepyhead/Graphs/gXAxis.cpp +++ b/sleepyhead/Graphs/gXAxis.cpp @@ -55,7 +55,7 @@ gXAxis::gXAxis(QColor col, bool fadeout) gXAxis::~gXAxis() { } -void gXAxis::paint(gGraph &w, int left, int top, int width, int height) +void gXAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { Q_UNUSED(height) QString months[] = { @@ -66,7 +66,7 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) - QPainter painter; // Only need this for pixmap caching + QPainter painter2; // Only need this for pixmap caching // pixmap caching screws font size when printing @@ -80,9 +80,9 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) m_image = QImage(width + 22, height + 4, QImage::Format_ARGB32_Premultiplied); m_image.fill(Qt::transparent); - painter.begin(&m_image); - painter.setPen(Qt::black); - painter.setFont(*defaultfont); + painter2.begin(&m_image); + painter2.setPen(Qt::black); + painter2.setFont(*defaultfont); } double px, py; @@ -187,8 +187,7 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) aligned_start += step; } - gVertexBuffer *lines = w.backlines(); - lines->setColor(Qt::black); + painter.setPen(QColor(Qt::black)); //int utcoff=m_utcfix ? tz_hours : 0; @@ -225,9 +224,9 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) if (py < start_px) { continue; } if (usepixmap) { - painter.drawLine(py - left + 20, 0, py - left + 20, mintop - top); + painter2.drawLine(py - left + 20, 0, py - left + 20, mintop - top); } else { - lines->add(py, top, py, mintop); + painter.drawLine(py, top+2, py, mintop+2); } } @@ -239,8 +238,10 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) px += left; if (usepixmap) { - painter.drawLine(px - left + 20, 0, px - left + 20, majtop - top); - } else { lines->add(px, top, px, majtop); } + painter2.drawLine(px - left + 20, 0, px - left + 20, majtop - top); + } else { + painter.drawLine(px, top+2, px, majtop+2); + } j = i; @@ -281,7 +282,7 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) if ((tx + x) < (left + width)) { if (!usepixmap) { w.renderText(tmpstr, tx, texttop, 0, Qt::black, defaultfont); } - else { painter.drawText(tx - left + 20, texttop - top, tmpstr); } + else { painter2.drawText(tx - left + 20, texttop - top, tmpstr); } } py = px; @@ -292,34 +293,22 @@ void gXAxis::paint(gGraph &w, int left, int top, int width, int height) if (py >= left + width) { break; } if (usepixmap) { - painter.drawLine(py - left + 20, 0, py - left + 20, mintop - top); - } else { lines->add(py, top, py, mintop); } - } - - if (lines->full()) { - qWarning() << "maxverts exceeded in gXAxis::Plot()"; - break; + painter2.drawLine(py - left + 20, 0, py - left + 20, mintop - top); + } else { + painter.drawLine(py, top+2, py, mintop+2); + } } } if (usepixmap) { - painter.end(); - m_image = QGLWidget::convertToGLFormat(m_image); - m_textureID = w.graphView()->bindTexture(m_image, GL_TEXTURE_2D, GL_RGBA, - QGLContext::NoBindOption); - + painter2.end(); } w.invalidate_xAxisImage = false; } if (usepixmap && !m_image.isNull()) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_2D); - w.graphView()->drawTexture(QPoint(left - 20, (top + height) - m_image.height() + 4), m_textureID); - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); + painter.drawImage(QPoint(left - 20, top + height - m_image.height() + 4), m_image); } } diff --git a/sleepyhead/Graphs/gXAxis.h b/sleepyhead/Graphs/gXAxis.h index 9c629d2a..3be5ea78 100644 --- a/sleepyhead/Graphs/gXAxis.h +++ b/sleepyhead/Graphs/gXAxis.h @@ -21,7 +21,7 @@ class gXAxis: public Layer public: gXAxis(QColor col = Qt::black, bool fadeout = true); virtual ~gXAxis(); - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); static const int Margin = 20; // How much room does this take up. (Bottom margin) void SetShowMinorLines(bool b) { m_show_minor_lines = b; } void SetShowMajorLines(bool b) { m_show_major_lines = b; } diff --git a/sleepyhead/Graphs/gYAxis.cpp b/sleepyhead/Graphs/gYAxis.cpp index af276a2f..92696bbf 100644 --- a/sleepyhead/Graphs/gYAxis.cpp +++ b/sleepyhead/Graphs/gYAxis.cpp @@ -34,12 +34,10 @@ gXGrid::gXGrid(QColor col) gXGrid::~gXGrid() { } -void gXGrid::paint(gGraph &w, int left, int top, int width, int height) +void gXGrid::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { int x, y; - gVertexBuffer *stippled, * lines; - EventDataType miny, maxy; if (w.zoomY() == 0 && PROFILE.appearance->allowYAxisScaling()) { @@ -109,16 +107,13 @@ void gXGrid::paint(gGraph &w, int left, int top, int width, int height) min_ytick = 100; } - - stippled = w.backlines(); - lines = w.backlines(); - 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)) { - stippled->add(left, h, left + width, h, m_major_color.rgba()); + painter.setPen(QPen(m_major_color,1,Qt::DashDotDotLine)); + painter.drawLine(left, h, left + width, h); } double z = (min_ytick / 4) * ymult; @@ -134,18 +129,9 @@ void gXGrid::paint(gGraph &w, int left, int top, int width, int height) // break; // } if (m_show_minor_lines) {// && (i > miny)) { - stippled->add(left, g, left + width, g, m_minor_color.rgba()); + painter.setPen(QPen(m_minor_color,1,Qt::DashDotDotLine)); + painter.drawLine(left, g, left + width, g); } - - if (stippled->full()) { - break; - } - } - - if (lines->full() || stippled->full()) { - qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" << - miny << "MaxY =" << maxy << "min_ytick=" << min_ytick; - break; } } } @@ -164,7 +150,7 @@ gYAxis::gYAxis(QColor col) gYAxis::~gYAxis() { } -void gYAxis::paint(gGraph &w, int left, int top, int width, int height) +void gYAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { int x, y; //,yh=0; @@ -371,9 +357,7 @@ void gYAxis::paint(gGraph &w, int left, int top, int width, int height) min_ytick = 100; } - lines = w.backlines(); - - GLuint line_color = m_line_color.rgba(); + painter.setPen(m_line_color); for (double i = miny; i <= maxy + min_ytick - 0.00001; i += min_ytick) { ty = (i - miny) * ymult; @@ -394,7 +378,7 @@ void gYAxis::paint(gGraph &w, int left, int top, int width, int height) w.renderText(fd, left + width - 8 - x, (h + (y / 2.0)), 0, m_text_color, defaultfont); - lines->add(left + width - 4, h, left + width, h, line_color); + painter.drawLine(left + width - 4, h, left + width, h); double z = (min_ytick / 4) * ymult; double g = h; @@ -404,19 +388,7 @@ void gYAxis::paint(gGraph &w, int left, int top, int width, int height) if (g > top + height) { break; } - lines->add(left + width - 3, g, left + width, g, line_color); - - if (lines->full()) { - qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" << - miny << "MaxY =" << maxy << "min_ytick=" << min_ytick; - break; - } - } - - if (lines->full()) { - qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" << - miny << "MaxY =" << maxy << "min_ytick=" << min_ytick; - break; + painter.drawLine(left + width - 3, g, left + width, g); } } } diff --git a/sleepyhead/Graphs/gYAxis.h b/sleepyhead/Graphs/gYAxis.h index 8a23be9e..48801fbf 100644 --- a/sleepyhead/Graphs/gYAxis.h +++ b/sleepyhead/Graphs/gYAxis.h @@ -25,7 +25,7 @@ class gXGrid: public Layer virtual ~gXGrid(); //! \brief Draw the horizontal lines by adding the to the Vertex GLbuffers - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); //! \brief set the visibility status of Major lines void setShowMinorLines(bool b) { m_show_minor_lines = b; } @@ -56,7 +56,7 @@ class gYAxis: public Layer virtual ~gYAxis(); //! \brief Draw the horizontal tickers display - virtual void paint(gGraph &w, int left, int top, int width, int height); + virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); // void SetShowMinorLines(bool b) { m_show_minor_lines=b; } // void SetShowMajorLines(bool b) { m_show_major_lines=b; } @@ -96,7 +96,6 @@ class gYAxis: public Layer QColor m_line_color; QColor m_text_color; - gVertexBuffer *lines; virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph); virtual bool mouseDoubleClickEvent(QMouseEvent *event, gGraph *graph); diff --git a/sleepyhead/Graphs/gspacer.h b/sleepyhead/Graphs/gspacer.h index ec300ad9..ecae2a28 100644 --- a/sleepyhead/Graphs/gspacer.h +++ b/sleepyhead/Graphs/gspacer.h @@ -22,7 +22,7 @@ class gSpacer: public Layer { public: gSpacer(int space = 20); // orientation? - virtual void paint(gGraph &g, int left, int top, int width, int height) { + virtual void paint(QPainter &painter, gGraph &g, int left, int top, int width, int height) { Q_UNUSED(g) Q_UNUSED(left) Q_UNUSED(top) diff --git a/sleepyhead/Graphs/layer.h b/sleepyhead/Graphs/layer.h index 1008664d..6cef346a 100644 --- a/sleepyhead/Graphs/layer.h +++ b/sleepyhead/Graphs/layer.h @@ -119,7 +119,7 @@ class Layer \param int width \param int height */ - virtual void paint(gGraph &gv, int left, int top, int width, int height) = 0; + virtual void paint(QPainter &painter, gGraph &gv, int left, int top, int width, int height) = 0; //! \brief Set the layout position and order for this layer. void setLayout(LayerPosition position, short width, short height, short order);