Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
.
[graphlib.git] / test / hello.cpp
index 453faea..d18128a 100644 (file)
  */
 
 
-#include <QApplication>
-#include <QImage>
-#include <QLabel>
-#include <QPaintEvent>
-#include <QPainter>
-#include <QPixmap>
-#include <QThread>
-#include <Qt>
-
-#include <cmath>
+#include <DrawingArea.h>
+#include <MainDrawingThread.h>
+
 #include <iostream>
-#include <string>
 
-//============================================================
-// DrawingAreaInterface
+int main_drawing_thread(int argc, char **argv)
+{
+    // >>> insert main drawing code here <<<
+    std::cout << "[" << argc << "]\n";
+    for (int i = 0; i < argc; i++)
+        std::cout << "  <" << argv[i] << ">\n";
+    while (true) {
+        sleep(1);
+        std::cout << '.' << std::flush;
+    }
 
-class DrawingAreaInterface {
-public:
-    static const int DEFAULT_WIDTH = 640;
-    static const int DEFAULT_HEIGHT = 480;
+    return 0;
+}
 
-    virtual ~DrawingAreaInterface() { }
+MAIN_DRAWING_THREAD(main_drawing_thread);
 
-    virtual void setColor(float red, float green, float blue) = 0;
-    virtual void drawPoint(int x, int y) = 0;
-    virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
-    
-    virtual void wait() = 0;
-    virtual void waitAll() = 0;
-};
+//============================================================
+
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+#if 0
 
 //============================================================
 // WindowCore
@@ -251,7 +250,7 @@ float Imax = 1.3;
 
 int maxiter = 100;
 
-int main(int argc, char *argv[])
+void DrawingThread::run()
 {
     int x, y;                   /* le pixel considéré */
     float cr, ci;               /* le complexe correspondant */
@@ -261,7 +260,7 @@ int main(int argc, char *argv[])
     float rouge, vert, bleu;
     int i;
 
-    QtDrawingArea fen(argc, argv, larg, haut);
+    //    QtDrawingArea fen(argc, argv, larg, haut);
 
     pr = (Rmax - Rmin) / larg;
     pi = (Imax - Imin) / larg;
@@ -305,51 +304,9 @@ int main(int argc, char *argv[])
             ci += pi;
         }
         cr += pr;
-        fen.flush();
+        //        fen.flush();
     }
-    fen.wait();
+    //    fen.wait();
 }
-#if 0
-    int err = 0;
-    std::cerr << err++;
-    for (int x = 0; x < fen.width(); x++) 
-        for (int y = 0; y < fen.height(); y++)
-            float dx = x;
-            float dy = y;
-            float r = sqrt(dx * dx + dy * dy) / fen.width();
-            dx = fen.width() - 1 - x;
-            float g = sqrt(dx * dx + dy * dy) / fen.width();
-            dx = fen.width() / 2 - x;
-            dy = fen.height() - y;
-            float b = sqrt(dx * dx + dy * dy) / fen.height();
-            if (r > 1.0)  r = 1.0;
-            if (g > 1.0)  g = 1.0;
-            if (b > 1.0)  b = 1.0;
-            fen.setColor(r, g, b);
-            fen.drawPoint(x, y);
-        }
-    std::cerr << err++;
-    fen.flush();
-    std::cerr << err++;
-    fen.setColor(0.0, 0.0, 1.0);
-    for (int x = 0; x < 10; x++)
-        for (int y = 0; y < 10; y++)
-            fen.drawPoint(x, y);
-    std::cerr << err++;
-    fen.flush();
-    std::cerr << err++;
-    fen.setColor(0.0, 0.0, 0.0);
-    for (int z = 100; z <= 300; z += 4) {
-        fen.drawLine(150, 150, z, 100);
-        fen.drawLine(150, 150, z, 300);
-        fen.drawLine(150, 150, 100, z);
-        fen.drawLine(150, 150, 300, z);
-    }
-    std::cerr << "OOOO\n";
-    QtDrawingArea fen2;
-    fen.wait();
-    std::cerr << "qwewet\n";
 
-    fen.waitAll();
-}
 #endif