[20] | 1 | /******************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* this class creates the application windows : */ |
---|
| 4 | /* - the main window where composants are drawn, */ |
---|
| 5 | /* - the parameters window, */ |
---|
| 6 | /* - and the informations window. */ |
---|
| 7 | /* */ |
---|
| 8 | /******************************************************/ |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | #ifndef WINDOW_H |
---|
| 12 | #define WINDOW_H |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | #include <iostream> |
---|
[21] | 16 | #include <cmath> |
---|
| 17 | #include <sstream> |
---|
[20] | 18 | #include <qstring.h> |
---|
| 19 | #include <qapplication.h> |
---|
| 20 | #include <qmetaobject.h> |
---|
| 21 | #include <qmenu.h> |
---|
| 22 | #include <qmenubar.h> |
---|
| 23 | #include <qmainwindow.h> |
---|
| 24 | #include <qwidget.h> |
---|
| 25 | #include <qboxlayout.h> |
---|
| 26 | #include <qpainter.h> |
---|
| 27 | #include <qcolor.h> |
---|
| 28 | #include <qlabel.h> |
---|
| 29 | #include <qstatusbar.h> |
---|
| 30 | #include <qpushbutton.h> |
---|
| 31 | #include <qmessagebox.h> |
---|
| 32 | #include <qlineedit.h> |
---|
| 33 | #include <qwindowsstyle.h> |
---|
| 34 | #include <qplastiquestyle.h> |
---|
| 35 | #include <qlist.h> |
---|
| 36 | #include <qrect.h> |
---|
| 37 | #include <string.h> |
---|
| 38 | #include <qtreeview.h> |
---|
| 39 | #include <qdirmodel.h> |
---|
[21] | 40 | #include <qevent.h> |
---|
[20] | 41 | |
---|
[21] | 42 | |
---|
[20] | 43 | #include "Tools/Viewer/Parser/include/parser.h" |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | #define NORTH 0 |
---|
| 47 | #define SOUTH 1 |
---|
| 48 | #define EAST 2 |
---|
| 49 | #define WEST 3 |
---|
| 50 | |
---|
[21] | 51 | #define MARGEX 50 |
---|
| 52 | #define MARGEY 70 |
---|
| 53 | |
---|
[20] | 54 | using namespace morpheo::tools::viewer::parser; |
---|
| 55 | using namespace morpheo::tools::viewer::bdd; |
---|
| 56 | using namespace std; |
---|
| 57 | |
---|
| 58 | namespace morpheo{ |
---|
| 59 | namespace tools{ |
---|
| 60 | namespace viewer{ |
---|
| 61 | namespace graphics{ |
---|
| 62 | |
---|
| 63 | class Window : public QMainWindow |
---|
| 64 | { |
---|
| 65 | |
---|
| 66 | Q_OBJECT |
---|
| 67 | |
---|
| 68 | public: |
---|
| 69 | |
---|
| 70 | Window(QString name); |
---|
[21] | 71 | void _setParse(Parse *p); //parse the base |
---|
| 72 | void _init_file(); //search component and port before drawing |
---|
[20] | 73 | private slots: |
---|
| 74 | |
---|
[21] | 75 | void _open(); //open a file |
---|
[20] | 76 | void _open_end(); |
---|
| 77 | void _open_error(); |
---|
| 78 | |
---|
[21] | 79 | void _save(); //save a file |
---|
[20] | 80 | void _saveAs(); |
---|
| 81 | void _saveAsOk(); |
---|
[21] | 82 | |
---|
| 83 | void _close(); //close a file |
---|
| 84 | |
---|
| 85 | void _quit(); //quit a file |
---|
[20] | 86 | void _quit2(); |
---|
[21] | 87 | |
---|
| 88 | void _zoomIn(); //zoom for the architecture view |
---|
[20] | 89 | void _zoomOut(); |
---|
| 90 | void _defautZoom(); |
---|
| 91 | |
---|
[21] | 92 | void _level(); |
---|
| 93 | void _informations(); //show or hide informations window |
---|
| 94 | void _parameters(); //show or hide parameters window |
---|
| 95 | void _about(); //about the programm |
---|
| 96 | void _component_name(); //show or hide the components name |
---|
| 97 | void _signal_name(); //show or hide the signals name |
---|
[20] | 98 | |
---|
[21] | 99 | void _back(); |
---|
[20] | 100 | |
---|
[21] | 101 | protected : |
---|
| 102 | void mousePressEvent (QMouseEvent *); //mouse handler |
---|
| 103 | |
---|
| 104 | private : |
---|
| 105 | void wparameters(); // parameters window builder |
---|
| 106 | void winformations(); //informations window builder |
---|
| 107 | void paintEvent( QPaintEvent * ); //drawing panel |
---|
| 108 | void repaint(); //repaint the panel with current parameters |
---|
| 109 | void drawPort(int x,int y,int pos,string dir); //draw the components ports |
---|
| 110 | void write_name(string name); //write the name of the component clicked name in the informations window |
---|
| 111 | void write_position(int x, int y);//write the position of the position clicked in the informations window |
---|
| 112 | void write_size(int x, int y);//write the size of the component clicked in the informations window |
---|
| 113 | void write_ports(int x);//write the number of the component clicked in the informations window |
---|
| 114 | |
---|
| 115 | QList <Port> port_east; //ports lists |
---|
[20] | 116 | QList <Port> port_west; |
---|
| 117 | QList <Port> port_north; |
---|
| 118 | QList <Port> port_south; |
---|
| 119 | QList <Component> *compo; |
---|
| 120 | |
---|
[21] | 121 | QWidget *wparam;//windows widget (informations, parameters, open, save ...) |
---|
[20] | 122 | QWidget *winfo; |
---|
| 123 | QWidget *ws; |
---|
| 124 | QWidget *wq; |
---|
| 125 | QWidget *wo; |
---|
| 126 | QWidget *wa; |
---|
| 127 | |
---|
[21] | 128 | QWidget *mess_charg; |
---|
| 129 | QWidget *mess; |
---|
| 130 | QBoxLayout *informations; //informations box |
---|
| 131 | QBoxLayout *parameters; //parameters box |
---|
| 132 | |
---|
| 133 | Parse *parse; //the parser |
---|
| 134 | BaseV *base; //the current BaseV |
---|
| 135 | BaseP p; //the current BaseP |
---|
| 136 | Entity *entity; //entity of current base |
---|
| 137 | Coord *c; |
---|
[20] | 138 | |
---|
| 139 | QPainter painter; |
---|
| 140 | |
---|
| 141 | QStatusBar *status; |
---|
| 142 | |
---|
[21] | 143 | QLineEdit *file_name; //retrieve the name user wants to open from the open window |
---|
| 144 | QString current_name; //name of the current file opened |
---|
[20] | 145 | |
---|
[21] | 146 | /*items of the informations window*/ |
---|
| 147 | QLabel *lname; //name of the component clicked |
---|
| 148 | QLineEdit *positionX; //x position |
---|
| 149 | QLineEdit *positionY;//y position |
---|
| 150 | QLineEdit *sizeX;//x size |
---|
| 151 | QLineEdit *sizeY;//y size |
---|
| 152 | QLineEdit *nb_ports; |
---|
| 153 | |
---|
| 154 | int cpt_ports;//nb ports of component clicked |
---|
| 155 | |
---|
| 156 | int mouseX; //mouse position |
---|
| 157 | int mouseY; |
---|
| 158 | |
---|
| 159 | int window_height; //main window size |
---|
[20] | 160 | int window_width; |
---|
[21] | 161 | int margeX;//size of the marge |
---|
[20] | 162 | int margeY; |
---|
[21] | 163 | int portX;//port size, position and size of components, used when drawing the architecture |
---|
[20] | 164 | int portY; |
---|
| 165 | int posX; |
---|
| 166 | int posY; |
---|
| 167 | int tailleX; |
---|
| 168 | int tailleY; |
---|
| 169 | |
---|
[21] | 170 | QString father;//father name |
---|
| 171 | QString current;//name of the current architecture visible |
---|
| 172 | |
---|
| 173 | bool save_as; |
---|
[20] | 174 | bool first_save; |
---|
[21] | 175 | bool info_open; //know if the informations window opened or not |
---|
| 176 | bool param_open; //know if the parameters window opened or not |
---|
| 177 | bool is_save; //know if the file has been saved |
---|
| 178 | bool paint; //(re)paint or not |
---|
| 179 | bool wq_open; //know if Quit/Open ( 2 windows possible)/Save window is open |
---|
[20] | 180 | bool wo_open; |
---|
| 181 | bool ws_open; |
---|
| 182 | bool wa_open; |
---|
[21] | 183 | bool quit_demand;//know if user clicked on "quit" (used for saving file before quit) |
---|
| 184 | bool file_open;//know if a file is still open (used if user wants to open another file) |
---|
| 185 | bool is_parse;//know is the base has been created |
---|
| 186 | bool signalName;//show or hide signals name |
---|
| 187 | bool componentName;//show or hide components name |
---|
| 188 | bool charg_open;//back chargement message box opened or not |
---|
| 189 | bool mess_open;//chargment message box opened or not |
---|
| 190 | |
---|
[20] | 191 | }; |
---|
| 192 | }; |
---|
| 193 | }; |
---|
| 194 | }; |
---|
| 195 | }; |
---|
| 196 | |
---|
| 197 | #endif |
---|