Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
removed class DrawingWindowPrivate
[graphlib.git] / DrawingWindow.h
index 4ad8b94..79544dc 100644 (file)
@@ -1,10 +1,16 @@
 #ifndef DRAWING_WINDOW_H
 #define DRAWING_WINDOW_H
 
+#include <QBasicTimer>
+#include <QColor>
+#include <QImage>
+#include <QMutex>
+#include <QRect>
+#include <QWaitCondition>
 #include <QWidget>
 #include <Qt>
 
-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