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
26 #include <DrawingArea.h>
27 #include <DrawingThread.h>
28 #include <DrawingWindow.h>
29
30 #include <iostream>
31
32 int main_drawing_thread(DrawingArea &a)
33 {
34     std::cout << "[ " << a.width() << " x " << a.height() << " ]\n";
35
36     int c = 0;
37     int y = 0;
38     while (1) {
39         std::cerr << "loooooooooooooooooooooop "
40                   << y << " (" << c << ")\n";
41         a.setColor(c, c, c);
42         for (int yy = y; yy < y + 10; yy++)
43             for (int x = 0; x < a.width(); x++)
44                 a.drawPoint(x, yy);
45         if ((y += 10) >= a.height()) {
46             y = 0;
47             c = !c;
48         }
49         sleep(1);
50     }
51     return 0;
52 }
53
54 int main(int argc, char *argv[])
55 {
56     QApplication application(argc, argv);
57     DrawingArea drawingArea(800, 600);
58     DrawingWindow drawingWindow(drawingArea);
59     DrawingThread drawingThread(drawingArea, main_drawing_thread);
60
61     drawingWindow.show();
62     drawingThread.start();
63
64     return application.exec();
65 }