Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
.
[graphlib.git] / DrawingArea.h
index 874de0f..51ff5a8 100644 (file)
@@ -5,9 +5,12 @@
 #include <QImage>
 #include <QObject>
 #include <QPainter>
+#include <QRect>
+#include <QSize>
+#include <QMutex>
 
 class DrawingArea: public QObject {
-    Q_OBJECT
+/*     Q_OBJECT */
 
 public:
     static const int DEFAULT_WIDTH = 640;
@@ -18,6 +21,7 @@ public:
 
     int width() const;
     int height() const;
+    const QSize size() const;
 
     void setColor(const QColor &color);
     void setColor(float red, float green, float blue);
@@ -25,18 +29,72 @@ public:
     void drawPoint(int x, int y);
     void drawLine(int x1, int y1, int x2, int y2);
 
-    const QImage &getImage() const;
+    QImage &getImage();
 
-signals:
-    void update();
+    bool isDirty() const;
+    void setDirty();
+    void setDirty(const QRect &rect);
+    void setClean();
+
+    QRect getDirtyRect() const;
+
+    void lock();
+    void unlock();
 
 private:
     QImage *image;
     QPainter *painter;
-
+    bool dirtyFlag;
+    QRect dirtyRect;
+    QMutex mutex;
 };
 
-#endif // !DRAWING_AREA_H
+inline
+int DrawingArea::width() const
+{
+    return image->width();
+}
+
+inline
+int DrawingArea::height() const
+{
+    return image->height();
+}
 
+inline
+const QSize DrawingArea::size() const
+{
+    return image->size();
+}
 
+inline
+QImage &DrawingArea::getImage()
+{
+    return *image;
+}
 
+inline
+bool DrawingArea::isDirty() const
+{
+    return dirtyFlag;
+}
+
+inline
+QRect DrawingArea::getDirtyRect() const
+{
+    return dirtyRect;
+}
+
+inline
+void DrawingArea::lock()
+{
+    mutex.lock();
+}
+
+inline
+void DrawingArea::unlock()
+{
+    mutex.unlock();
+}
+
+#endif // !DRAWING_AREA_H