From: Joel Holdsworth Date: Sat, 26 May 2012 08:21:55 +0000 (+0100) Subject: Made SigView into a QGLWidget X-Git-Tag: pulseview-0.1.0~354 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d7002724cbeb77486c2d5a0ccad2c2a1f14cbf36;p=pulseview.git Made SigView into a QGLWidget --- diff --git a/mainwindow.ui b/mainwindow.ui index 566c6dab..5f11fb2a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -55,7 +55,7 @@ SigView - QAbstractScrollArea + QGLWidget
sigview.h
diff --git a/sigrok-qt2.pro b/sigrok-qt2.pro index ac5ea48f..7993c936 100644 --- a/sigrok-qt2.pro +++ b/sigrok-qt2.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui +QT += core gui opengl TARGET = sigrok-qt2 TEMPLATE = app diff --git a/sigview.cpp b/sigview.cpp index ac7e76c8..c83ea791 100644 --- a/sigview.cpp +++ b/sigview.cpp @@ -21,6 +21,32 @@ #include "sigview.h" SigView::SigView(QWidget *parent) : - QAbstractScrollArea(parent) + QGLWidget(parent) { + setMouseTracking(true); +} + +void SigView::initializeGL() +{ + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_COLOR_MATERIAL); + glEnable(GL_BLEND); + glEnable(GL_POLYGON_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glClearColor(1.0, 1.0, 1.0, 0); +} + +void SigView::resizeGL(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, height, 0, -1, 1); + glMatrixMode(GL_MODELVIEW); +} + +void SigView::paintGL() +{ + glClear(GL_COLOR_BUFFER_BIT); } diff --git a/sigview.h b/sigview.h index 318104b9..d2bdbe4d 100644 --- a/sigview.h +++ b/sigview.h @@ -21,14 +21,23 @@ #ifndef SIGVIEW_H #define SIGVIEW_H -#include +#include +#include -class SigView : public QAbstractScrollArea +class SigView : public QGLWidget { Q_OBJECT public: explicit SigView(QWidget *parent = 0); - + +protected: + + void initializeGL(); + + void resizeGL(int width, int height); + + void paintGL(); + signals: public slots: