qtthreadedcanvas.h 1.42 KB
Newer Older
1
2
3
4
#ifndef QTTHREADEDCANVAS_H__
#define QTTHREADEDCANVAS_H__

#include "tgt/qt/qtcanvas.h"
5
#include "tgt/types.h"
6
7
8
9

namespace tgt {

    /**
schultezub's avatar
schultezub committed
10
     * Subclass of QtCanvas that supports multi-threading.
11
     */
12
    class TGT_API QtThreadedCanvas : public tgt::QtCanvas {
13
14
15
16
17
18
19
    public:
        QtThreadedCanvas(
            const std::string& title = "",
            const tgt::ivec2& size = tgt::ivec2(tgt::GLCanvas::DEFAULT_WINDOW_WIDTH, tgt::GLCanvas::DEFAULT_WINDOW_HEIGHT),
            const tgt::GLCanvas::Buffers buffers = tgt::GLCanvas::RGBADD,
            QWidget* parent = 0, bool shared = false, Qt::WFlags f = 0, char* name = 0);

20
        virtual ~QtThreadedCanvas();
21

22
23
24
        // override Qt events so that they don't interfere with the threading.
        void resizeEvent(QResizeEvent *event) {
            sizeChanged(ivec2(event->size().width(), event->size().height()));
25
        }
26
27
28
29
30
31
32
33

        /**
         * If you manually want to cause a paint-event, use this function. It will call paintGL()
         * via updateGL(). This will cause immediate repainting.
         */
        virtual void repaint();

    protected:
34
35
36
37
38
        // override Qt events so that they don't interfere with the threading.
        virtual void paintEvent(QPaintEvent *event);

        // override the paint method so that it doesn't interfere with the threading.
        virtual void paint();
39
40
41
42
43
44

    };

}

#endif // QTTHREADEDCANVAS_H__