]> sigrok.org Git - pulseview.git/commitdiff
Made SigView into a QGLWidget
authorJoel Holdsworth <redacted>
Sat, 26 May 2012 08:21:55 +0000 (09:21 +0100)
committerJoel Holdsworth <redacted>
Mon, 3 Sep 2012 12:49:39 +0000 (13:49 +0100)
mainwindow.ui
sigrok-qt2.pro
sigview.cpp
sigview.h

index 566c6dab234241a366a138f630bb5a44610c4ba7..5f11fb2a94b1c1c201455a4141527ce0d6947d9c 100644 (file)
@@ -55,7 +55,7 @@
  <customwidgets>
   <customwidget>
    <class>SigView</class>
-   <extends>QAbstractScrollArea</extends>
+   <extends>QGLWidget</extends>
    <header>sigview.h</header>
   </customwidget>
  </customwidgets>
index ac5ea48ff94582e349b2b457a4c3572b60c4f2d5..7993c93623018f55d7b13b8eb9a0e42bec041eff 100644 (file)
@@ -4,7 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui
+QT       += core gui opengl
 
 TARGET = sigrok-qt2
 TEMPLATE = app
index ac7e76c8fe5185bd7fcd33bd75b7957ecb70e086..c83ea7917064d4dbfc1c8c148df97b9826c267ba 100644 (file)
 #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);
 }
index 318104b9385639f499b4d9e8fbdbeddf2333e04f..d2bdbe4d1839402219dc42a3e8a397aa923b8029 100644 (file)
--- a/sigview.h
+++ b/sigview.h
 #ifndef SIGVIEW_H
 #define SIGVIEW_H
 
-#include <QAbstractScrollArea>
+#include <QtOpenGL/QGLWidget>
+#include <QTimer>
 
-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: