+ , width(w)
+ , height(h)
+{
+ initialize(f);
+}
+
+DrawingWindow::~DrawingWindow()
+{
+ delete thread;
+ delete painter;
+ delete image;
+}
+
+void DrawingWindow::setColor(float red, float green, float blue)
+{
+ fgColor.setRgbF(red, green, blue);
+ applyColor();
+}
+
+void DrawingWindow::setColor(const char *name)
+{
+ fgColor.setNamedColor(name);
+ applyColor();
+}
+
+void DrawingWindow::setBgColor(float red, float green, float blue)
+{
+ bgColor.setRgbF(red, green, blue);
+}
+
+void DrawingWindow::setBgColor(const char *name)
+{
+ bgColor.setNamedColor(name);
+}
+
+void DrawingWindow::clearGraph()
+{
+ safeLock(imageMutex);
+ painter->fillRect(image->rect(), bgColor);
+ dirty();
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::drawPoint(int x, int y)
+{
+ safeLock(imageMutex);
+ painter->drawPoint(x, y);
+ dirty(x, y);
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::drawLine(int x1, int y1, int x2, int y2)
+{
+ safeLock(imageMutex);
+ painter->drawLine(x1, y1, x2, y2);
+ dirty(x1, y1, x2, y2);
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::drawRect(int x1, int y1, int x2, int y2)
+{
+ QRect r;
+ r.setCoords(x1, y1, x2 - 1, y2 - 1);
+ r = r.normalized();
+ safeLock(imageMutex);
+ painter->drawRect(r);
+ r.adjust(0, 0, 1, 1);
+ dirty(r);
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::fillRect(int x1, int y1, int x2, int y2)
+{
+ painter->setBrush(fgColor);
+ drawRect(x1, y1, x2, y2);
+ painter->setBrush(Qt::NoBrush);
+}
+
+void DrawingWindow::drawCircle(int x, int y, int r)
+{
+ QRect rect;
+ rect.setCoords(x - r, y - r, x + r - 1, y + r - 1);
+ safeLock(imageMutex);
+ painter->drawEllipse(rect);
+ rect.adjust(0, 0, 1, 1);
+ dirty(rect);
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::fillCircle(int x, int y, int r)
+{
+ painter->setBrush(fgColor);
+ drawCircle(x, y, r);
+ painter->setBrush(Qt::NoBrush);
+}
+
+void DrawingWindow::drawText(int x, int y, const char *text)
+{
+ QRect r(image->rect());
+ r.moveTo(x, y);
+ safeLock(imageMutex);
+ painter->drawText(r, 0, text, &r);
+ dirty(r);
+ safeUnlock(imageMutex);
+}
+
+bool DrawingWindow::sync(unsigned long time)
+{
+ bool synced;
+ safeLock(syncMutex);
+ if (terminateThread) {
+ synced = false;
+ } else {
+ qApp->postEvent(this, new QEvent(QEvent::User));
+ synced = syncCondition.wait(&syncMutex, time);
+ }
+ safeUnlock(syncMutex);
+ return synced;
+}
+
+void DrawingWindow::closeGraph()
+{
+ qApp->postEvent(this, new QEvent(QEvent::Type(QEvent::User + 1)));
+}
+
+void DrawingWindow::sleep(unsigned long secs)
+{
+ DrawingThread::sleep(secs);
+}
+
+void DrawingWindow::msleep(unsigned long msecs)