Logo AND Algorithmique Numérique Distribuée

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