X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/blobdiff_plain/2ecf02eeb3c25c56ad5de3a340fd7fd8ebdfa679..b07bb1122bca0acd87b8183b4426334bbffd6ea4:/DrawingWindow.h diff --git a/DrawingWindow.h b/DrawingWindow.h index 4ad8b94..79544dc 100644 --- a/DrawingWindow.h +++ b/DrawingWindow.h @@ -1,10 +1,16 @@ #ifndef DRAWING_WINDOW_H #define DRAWING_WINDOW_H +#include +#include +#include +#include +#include +#include #include #include -class DrawingWindowPrivate; +class DrawingThread; class DrawingWindow: public QWidget { public: @@ -57,9 +63,39 @@ protected: void timerEvent(QTimerEvent *ev); private: - DrawingWindowPrivate * const d; + static const int paintInterval = 33; - friend class DrawingWindowPrivate; + QBasicTimer timer; + QMutex imageMutex; + QMutex syncMutex; + QWaitCondition syncCondition; + bool terminateThread; + int lockCount; + + QImage *image; + QPainter *painter; + + QColor fgColor; + QColor bgColor; + + bool dirtyFlag; + QRect dirtyRect; + + DrawingThread *thread; + + void initialize(ThreadFunction f); + + void applyColor(); + + void safeLock(QMutex &mutex); + void safeUnlock(QMutex &mutex); + + void dirty(); + void dirty(int x, int y); + void dirty(int x1, int y1, int x2, int y2); + void dirty(const QRect &rect); + + void mayUpdate(); }; #endif // !DRAWING_WINDOW_H