X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/blobdiff_plain/59e4744b75d5d4f67c6fe21dec20089a7c43cf80..86bb6428e4aeab4b28f5b88809dd642c7c53fb36:/DrawingWindow.cpp diff --git a/DrawingWindow.cpp b/DrawingWindow.cpp index 7c63c86..0cd3633 100644 --- a/DrawingWindow.cpp +++ b/DrawingWindow.cpp @@ -1,9 +1,110 @@ +/* + * Copyright (c) 2007, Arnaud Giersch + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "DrawingWindow.h" #include #include #include #include +/*! \class DrawingWindow + * \brief Fenêtre de dessin. + * + * \author Arnaud Giersch + * \date novembre 2007 + * + * Cette classe décrit un widget Qt permettant d'écrire des + * applications graphiques simples. Pour cela, il faut définir une + * fonction de dessin. Cette fonction ne retourne rien et prend comme + * unique paramètre une référence vers un objet de class + * DrawingWindow. + * + * La fonction devra ensuite être passée en paramètre pour les + * constructeurs de la classe, ainsi que les dimension requises pour + * la fenêtre graphique. Le programme est ensuite compilé comme + * n'importe quel programme Qt. + * + * Concrètement, la fonction sera exécutée dans un nouveau thread, + * tandis que le thread principal s'occupera de la gestion des + * évènements et du rendu dans la fenêtre. + * + * NB. Pour toutes les méthodes de dessin, le coin en haut à gauche + * de la fenêtre a les coordonnées (0, 0). Le coin en bas à droite de + * la fenêtre a les coordonnées (largeur - 1, hauteur - 1), si la + * fenêtre est de dimension largeur × hauteur. + * + * Un appui sur la touche provoque la fermeture de la fenêtre. + * Comme pour la plupart des applications, il est également possible + * de fermer la fenêtre via le gestionnaire de fenêtres. + * + * Il est possible, dans une application, d'ouvrir plusieurs fenêtres, + * avec des fonctions de dessin éventuellement différentes. + * L'application se terminera normalement lorsque la dernière fenêtre + * sera fermée. + */ + +/*! \example hello.cpp + * + * Voir le code source à la fin de la page. Pour compiler et exécuter + * ce programme, il faut : + * + * 1. Créer le fichier \c hello.pro + * + * Pour simplifier, ce fichier contient la liste des fichiers sources + * composant le programme. + * + * \include hello.pro + * + * 2. Créer le fichier \c Makefile avec la commande : + * + * \verbatim qmake-qt4 hello.pro \endverbatim + * ou tout simplement : + * \verbatim qmake-qt4 \endverbatim + * + * 3. Compiler le programme avec la commande : + * + * \verbatim make hello \endverbatim + * ou tout simplement : + * \verbatim make \endverbatim + * + * 4. Exécuter le programme avec la commande : + * + * \verbatim ./exemple \endverbatim + * + * Code source de l'exemple + */ + +/*! \example exemple.cpp + * + * Un exemple un peu plus sophistiqué. + */ + //! Classe de thread. class DrawingThread: public QThread { public: @@ -56,10 +157,8 @@ public: //--- DrawingWindow ---------------------------------------------------- -/*! \class DrawingWindow - * \brief Fenêtre de dessin. - * - * Bla bla bla +/*! \file DrawingWindow.h + * \brief Classe DrawingWindow. */ /*! \typedef DrawingWindow::ThreadFunction