Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
.
[graphlib.git] / test / hello.cpp
1 /*
2  * Pour compiler
3  * =============
4  *
5  * 1. Créer le fichier hello.pro :
6  *      +------------------------------------------------------------+
7  *      |TARGET = hello                                              |
8  *      |CONFIG += qt debug                                          |
9  *      |SOURCES += hello.cc                                         |
10  *      +------------------------------------------------------------+
11  *
12  * 2. Créer le fichier Makefile avec la commande :
13  *      $ qmake -makefile hello.pro
14  *    ou tout simplement :
15  *      $ qmake -makefile
16  *
17  * 3. Compiler avec la commande :
18  *      $ make hello
19  *    ou tou simplement :
20  *      $ make
21  */
22
23
24 #include <QApplication>
25 #include <DrawingArea.h>
26 #include <DrawingThread.h>
27 #include <DrawingWindow.h>
28
29 #include <iostream>
30
31 int main_drawing_thread(DrawingArea &a)
32 {
33     std::cout << "[ " << a.width() << " x " << a.height() << " ]\n";
34
35     int c = 0;
36     int y = 0;
37     int h = a.height();
38     int w = a.width();
39     int count = 10;
40     while (1) {
41 //         std::cerr << "loooooooooooooooooooooop "
42 //                   << y << " (" << c << ")\n";
43         a.setColor(c, c, c);
44         for (int yy = y; yy < y + 10; yy++)
45             for (int x = 0; x < w; x++)
46                 a.drawPoint(x, yy);
47         if ((y += 10) >= h) {
48             y = 0;
49             c = !c;
50             if (!--count) break;
51             std::cerr << "loooooooooooooooooooooop "
52                       << y << " (" << c << ")\n";
53         }
54     }
55     return 0;
56 }
57
58 int main(int argc, char *argv[])
59 {
60     QApplication application(argc, argv);
61     DrawingArea drawingArea(800, 600);
62     DrawingWindow drawingWindow(drawingArea);
63     DrawingThread drawingThread(drawingArea, main_drawing_thread);
64
65     drawingWindow.show();
66     drawingThread.start();
67
68     return application.exec();
69 }