+ dirty(r);
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::fillRect(int x1, int y1, int x2, int y2)
+{
+ painter->setBrush(getColor());
+ 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(getColor());
+ drawCircle(x, y, r);
+ painter->setBrush(Qt::NoBrush);
+}
+
+void DrawingWindow::drawText(int x, int y, const char *text, int flags)
+{
+ QRect r(image->rect());
+ switch (flags & Qt::AlignHorizontal_Mask) {
+ case Qt::AlignRight:
+ r.setRight(x);
+ break;
+ case Qt::AlignHCenter:
+ if (x < width / 2)
+ r.setLeft(2 * x - width + 1);
+ else
+ r.setRight(2 * x);
+ break;
+ default:
+ r.setLeft(x);
+ }
+ switch (flags & Qt::AlignVertical_Mask) {
+ case Qt::AlignBottom:
+ r.setBottom(y);
+ break;
+ case Qt::AlignVCenter:
+ if (y < height / 2)
+ r.setTop(2 * y - height + 1);
+ else
+ r.setBottom(2 * y);
+ break;
+ default:
+ r.setTop(y);
+ }
+ safeLock(imageMutex);
+ painter->drawText(r, flags, text, &r);
+ dirty(r);
+ safeUnlock(imageMutex);
+}
+
+void DrawingWindow::drawTextBg(int x, int y, const char *text, int flags)
+{
+ painter->setBackgroundMode(Qt::OpaqueMode);
+ drawText(x, y, text, flags);
+ painter->setBackgroundMode(Qt::TransparentMode);
+}
+
+unsigned int DrawingWindow::getPointColor(int x, int y)
+{
+ return image->pixel(x, y);
+}
+
+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)));