Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7685d7d263553bd2db2957f88a086f194063a2ec
[graphlib.git] / DrawingWindow.h
1 #ifndef DRAWING_WINDOW_H
2 #define DRAWING_WINDOW_H
3
4 #include <QThread>
5 #include <QWidget>
6 #include <Qt>
7
8 class DrawingWindowPrivate;
9
10 class DrawingWindow: public QWidget {
11 public:
12     typedef void (*ThreadFunction)(DrawingWindow &);
13
14     static const int DEFAULT_WIDTH = 640;
15     static const int DEFAULT_HEIGHT = 480;
16
17     DrawingWindow(ThreadFunction fun,
18                   int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
19     DrawingWindow(QWidget *parent,
20                   ThreadFunction fun,
21                   int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
22     DrawingWindow(QWidget *parent, Qt::WindowFlags flags,
23                   ThreadFunction fun,
24                   int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
25
26     ~DrawingWindow();
27
28     const int width;
29     const int height;
30
31     void setColor(float red, float green, float blue);
32     void setBgColor(float red, float green, float blue);
33
34     void clearGraph();
35
36     void drawPoint(int x, int y);
37     void drawLine(int x1, int y1, int x2, int y2);
38     void drawRect(int x1, int y1, int x2, int y2);
39
40     void sleep(unsigned long secs);
41     void msleep(unsigned long msecs);
42     void usleep(unsigned long usecs);
43
44 protected:
45     void closeEvent(QCloseEvent *ev);
46     void paintEvent(QPaintEvent *ev);
47     void showEvent(QShowEvent *ev);
48     void timerEvent(QTimerEvent *ev);
49
50 private:
51     DrawingWindowPrivate * const d;
52
53     friend class DrawingWindowPrivate;
54 };
55
56 #endif // !DRAWING_WINDOW_H