1 #ifndef DRAWING_WINDOW_H
2 #define DRAWING_WINDOW_H
13 class DrawingWindow: public QWidget {
17 typedef void (*ThreadFunction)(DrawingWindow &);
19 static const int DEFAULT_WIDTH = 640;
20 static const int DEFAULT_HEIGHT = 480;
22 DrawingWindow(ThreadFunction fun,
23 int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
24 DrawingWindow(QWidget *parent,
26 int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
27 DrawingWindow(QWidget *parent, Qt::WindowFlags flags,
29 int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
36 void setColor(float red, float green, float blue);
37 void setColor(const QColor &color);
39 void drawPoint(int x, int y);
40 void drawLine(int x1, int y1, int x2, int y2);
43 void paintEvent(QPaintEvent *ev);
44 void showEvent(QShowEvent *ev);
45 void timerEvent(QTimerEvent *ev);
50 static const int paintInterval = 33;
57 DrawingThread *thread;
66 void initialize(ThreadFunction fun, int width, int height);
72 void setDirtyRect(int x, int y);
73 void setDirtyRect(int x1, int y1, int x2, int y2);
74 void setDirtyRect(const QRect &rect);
78 int DrawingWindow::width() const
80 return image->width();
84 int DrawingWindow::height() const
86 return image->height();
90 void DrawingWindow::lock()
99 void DrawingWindow::unlock()
105 void DrawingWindow::setDirtyRect()
108 dirtyRect.setRect(0, 0, width(), height());
112 void DrawingWindow::setDirtyRect(int x, int y)
114 setDirtyRect(QRect(x, y, 1, 1));
118 void DrawingWindow::setDirtyRect(int x1, int y1, int x2, int y2)
121 r.setCoords(x1, y1, x2, y2);
122 setDirtyRect(r.normalized());
125 #endif // !DRAWING_WINDOW_H