00001 00003 00004 // / 00005 // Projet : Générateur de cylindres généralisés / 00006 // / 00007 // Nom du fichier : window2D.h / 00008 // / 00009 // Creation : 20/11/2005 / 00010 // / 00011 // Description : La classe window2D regroupe l'ensemble des fonctionnalités nécéssaires / 00012 // au dessin de primitives. / 00013 // Les dessins s'effectuent sur des objets Qpainter / 00014 // / 00015 // / 00016 // Auteurs : - Guitteny Fabrice / 00017 // - Idiart Baptiste / 00018 // - Le Goff Erwan / 00019 // / 00021 00022 00023 #ifndef WINDOW2D_H 00024 #define WINDOW2D_H 00025 00026 #include <qwidget.h> 00027 #include <qpainter.h> 00028 #include <qapplication.h> 00029 #include <qmessagebox.h> 00030 00031 #include <stdlib.h> 00032 #include <vector> 00033 #include "math.h" 00034 00035 #include "../primitives/point.h" 00036 #include "../primitives/segment.h" 00037 #include "../primitives/circle.h" 00038 #include "../primitives/bezier.h" 00039 #include "../primitives/bspline.h" 00040 00041 #include "utilities.h" 00042 00043 #include"../qxml/modelml.h" 00044 00045 // nombre maximum de points dans la fenêtre 00046 00047 const int MAXPOINTS = 256; 00048 00049 // résolution de la fenêtre 00050 00051 const int WIDTH = 640; 00052 const int HEIGHT = 640; 00053 00064 00065 // Classe Window2D // 00067 00068 class Window2D : public QWidget 00069 { 00070 00071 private: 00072 00074 vector<QPoint> pointsList; 00075 00077 int typePrimitive; 00078 00080 int nbPoints; 00081 00083 bool down; 00084 00086 vector<Primitive *> primitivesList; 00087 00089 int nbPrimitives; 00090 00092 bool move; 00093 00095 int selectedPoint; 00096 00098 int indexCurrentPoint; 00099 00101 QPoint currentPoint; 00102 00104 vector<Point3D *> lastPointsList; 00105 00107 Point3D origin; 00108 00110 bool toBezier; 00111 00113 bool modification; 00114 00116 int sample; 00117 00118 00119 public: 00120 00122 bool closedShape; 00123 00125 Window2D( QWidget *parent=0, const char *name = 0); 00126 00127 ~Window2D(); 00128 00133 inline vector<Primitive *> getPrimitivesList() {return primitivesList;} 00134 00139 inline int getTypePrimitive() {return typePrimitive;} 00140 00144 inline int getNbPrimitives() {return nbPrimitives;} 00145 00147 inline int getNbPoints() {return nbPoints;} 00148 00152 inline int getSample() {return sample;} 00153 00157 inline void setSample(int s) 00158 { 00159 sample = s; 00160 for (int i = 0; i < nbPrimitives; i++) 00161 primitivesList[i]->setNbSamples(sample); 00162 update(); 00163 } 00164 00166 inline bool isModified() {return modification;} 00167 00171 inline void setTypePrimitive( const int typePrim ) {typePrimitive = typePrim;} 00172 00176 void load(vector<Primitive *> &prim); 00177 00179 void clear(); 00180 00182 void changeCoordinateSystemWindow(); 00183 00185 void changeCoordinateSystemReverseWindow(); 00186 00187 inline void setModified(bool modified = false){modification = modified;} 00188 00189 protected: 00190 00192 void clearVectors(); 00193 00195 void paintEvent( QPaintEvent * ); 00196 void mousePressEvent( QMouseEvent *); 00197 void mouseReleaseEvent( QMouseEvent *); 00198 void mouseMoveEvent( QMouseEvent *); 00199 void closeEvent(QCloseEvent * ); 00200 00201 }; 00202 00203 #endif 00204