[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> |
---|
[30] | 41 | #include <qfiledialog.h> |
---|
[32] | 42 | #include <qscrollarea.h> |
---|
| 43 | #include <qcombobox.h> |
---|
| 44 | #include <qspinbox.h> |
---|
[20] | 45 | |
---|
| 46 | #include "Tools/Viewer/Parser/include/parser.h" |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | #define NORTH 0 |
---|
| 50 | #define SOUTH 1 |
---|
| 51 | #define EAST 2 |
---|
| 52 | #define WEST 3 |
---|
| 53 | |
---|
[21] | 54 | #define MARGEX 50 |
---|
| 55 | #define MARGEY 70 |
---|
| 56 | |
---|
[20] | 57 | using namespace morpheo::tools::viewer::parser; |
---|
| 58 | using namespace morpheo::tools::viewer::bdd; |
---|
| 59 | using namespace std; |
---|
| 60 | |
---|
| 61 | namespace morpheo{ |
---|
| 62 | namespace tools{ |
---|
| 63 | namespace viewer{ |
---|
| 64 | namespace graphics{ |
---|
| 65 | |
---|
| 66 | class Window : public QMainWindow |
---|
| 67 | { |
---|
| 68 | |
---|
| 69 | Q_OBJECT |
---|
| 70 | |
---|
| 71 | public: |
---|
| 72 | |
---|
| 73 | Window(QString name); |
---|
[21] | 74 | void _setParse(Parse *p); //parse the base |
---|
| 75 | void _init_file(); //search component and port before drawing |
---|
[32] | 76 | |
---|
[20] | 77 | private slots: |
---|
| 78 | |
---|
[21] | 79 | void _open(); //open a file |
---|
[32] | 80 | void _open_error(); |
---|
[20] | 81 | |
---|
[21] | 82 | void _save(); //save a file |
---|
[20] | 83 | void _saveAs(); |
---|
| 84 | void _saveAsOk(); |
---|
[21] | 85 | |
---|
| 86 | void _close(); //close a file |
---|
| 87 | |
---|
| 88 | void _quit(); //quit a file |
---|
[20] | 89 | void _quit2(); |
---|
[21] | 90 | |
---|
| 91 | void _zoomIn(); //zoom for the architecture view |
---|
[20] | 92 | void _zoomOut(); |
---|
| 93 | void _defautZoom(); |
---|
| 94 | |
---|
[32] | 95 | void _level(); |
---|
[21] | 96 | void _informations(); //show or hide informations window |
---|
| 97 | void _parameters(); //show or hide parameters window |
---|
| 98 | void _about(); //about the programm |
---|
| 99 | void _component_name(); //show or hide the components name |
---|
| 100 | void _signal_name(); //show or hide the signals name |
---|
[20] | 101 | |
---|
[26] | 102 | void _back();//return to the previous view |
---|
[32] | 103 | void _cancel_selection();//cancel the selection of a component |
---|
| 104 | void _apply();//apply the parameters changes |
---|
| 105 | void currentIndexChanged(QString s); |
---|
| 106 | void valueChanged(int i); |
---|
[20] | 107 | |
---|
[21] | 108 | protected : |
---|
[32] | 109 | void mousePressEvent (QMouseEvent *); //mouse handler when mouse pressed |
---|
| 110 | void mouseMoveEvent (QMouseEvent *); //mouse handler in other case |
---|
[21] | 111 | private : |
---|
| 112 | void wparameters(); // parameters window builder |
---|
| 113 | void winformations(); //informations window builder |
---|
| 114 | void paintEvent( QPaintEvent * ); //drawing panel |
---|
| 115 | void repaint(); //repaint the panel with current parameters |
---|
| 116 | void drawPort(int x,int y,int pos,string dir); //draw the components ports |
---|
[32] | 117 | void write_name(string type,string name); //write the name of the component clicked name in the informations window |
---|
[26] | 118 | void write_comment(string comment); |
---|
[30] | 119 | void write_type(string t); |
---|
[32] | 120 | void erase_line(QLabel *l1, QLabel *l2);//erase a line in the informations window |
---|
| 121 | void erase_comment();//erase and hide the comment line in the informations window |
---|
| 122 | void display_param();//display the parameters |
---|
[21] | 123 | |
---|
| 124 | QList <Port> port_east; //ports lists |
---|
[20] | 125 | QList <Port> port_west; |
---|
| 126 | QList <Port> port_north; |
---|
| 127 | QList <Port> port_south; |
---|
[32] | 128 | QList <Component> *compo;//component list |
---|
| 129 | QList <Param> param;//parameters list |
---|
| 130 | QList <Group> *group;//groups list |
---|
[20] | 131 | |
---|
[32] | 132 | QWidget *wscroll; |
---|
| 133 | QMainWindow *wparam;//windows widget (informations, parameters, quit, open) |
---|
[20] | 134 | QWidget *winfo; |
---|
| 135 | QWidget *wq; |
---|
| 136 | QWidget *wa; |
---|
| 137 | |
---|
[21] | 138 | QWidget *mess_charg; |
---|
| 139 | QWidget *mess; |
---|
| 140 | QBoxLayout *informations; //informations box |
---|
| 141 | QBoxLayout *parameters; //parameters box |
---|
[32] | 142 | QBoxLayout *pbox; |
---|
[21] | 143 | |
---|
| 144 | Parse *parse; //the parser |
---|
| 145 | BaseV *base; //the current BaseV |
---|
| 146 | BaseP p; //the current BaseP |
---|
| 147 | Entity *entity; //entity of current base |
---|
| 148 | Coord *c; |
---|
[20] | 149 | |
---|
| 150 | QPainter painter; |
---|
| 151 | |
---|
[32] | 152 | QStatusBar *status;//status bar |
---|
[20] | 153 | |
---|
[21] | 154 | QLineEdit *file_name; //retrieve the name user wants to open from the open window |
---|
| 155 | QString current_name; //name of the current file opened |
---|
[20] | 156 | |
---|
[26] | 157 | /*items of the informations window*/ |
---|
| 158 | QLabel *lname;//name of the component clicked |
---|
[30] | 159 | QLabel *ln; |
---|
[26] | 160 | QLineEdit *comment;//comment associated with the component clicked |
---|
[30] | 161 | QLabel *lt; |
---|
| 162 | QLabel *ltype;//type of the component |
---|
| 163 | |
---|
[26] | 164 | int level; //level of architecture |
---|
[21] | 165 | int mouseX; //mouse position |
---|
| 166 | int mouseY; |
---|
| 167 | |
---|
| 168 | int window_height; //main window size |
---|
[20] | 169 | int window_width; |
---|
[21] | 170 | int portX;//port size, position and size of components, used when drawing the architecture |
---|
[20] | 171 | int portY; |
---|
[32] | 172 | int posX;//used to retrieve the position and the size of a component |
---|
[20] | 173 | int posY; |
---|
| 174 | int tailleX; |
---|
| 175 | int tailleY; |
---|
| 176 | |
---|
[32] | 177 | int cpt_level;//level in the architecture |
---|
| 178 | QString tab[20];//save the father when user change the level |
---|
[26] | 179 | |
---|
[21] | 180 | QString father;//father name |
---|
| 181 | QString current;//name of the current architecture visible |
---|
| 182 | |
---|
[32] | 183 | QScrollArea *sc; |
---|
| 184 | |
---|
[21] | 185 | bool save_as; |
---|
| 186 | bool info_open; //know if the informations window opened or not |
---|
| 187 | bool param_open; //know if the parameters window opened or not |
---|
| 188 | bool is_save; //know if the file has been saved |
---|
| 189 | bool paint; //(re)paint or not |
---|
| 190 | bool wq_open; //know if Quit/Open ( 2 windows possible)/Save window is open |
---|
[20] | 191 | bool wa_open; |
---|
[21] | 192 | bool quit_demand;//know if user clicked on "quit" (used for saving file before quit) |
---|
| 193 | bool file_open;//know if a file is still open (used if user wants to open another file) |
---|
| 194 | bool signalName;//show or hide signals name |
---|
| 195 | bool componentName;//show or hide components name |
---|
| 196 | bool charg_open;//back chargement message box opened or not |
---|
| 197 | bool mess_open;//chargment message box opened or not |
---|
[26] | 198 | bool component_clicked;//if user clicked on a component to modify its parameters |
---|
[32] | 199 | bool apply_display;//if the apply button is displayed |
---|
| 200 | bool scroll_hide; |
---|
| 201 | bool parameter_modify; |
---|
[20] | 202 | }; |
---|
| 203 | }; |
---|
| 204 | }; |
---|
| 205 | }; |
---|
| 206 | }; |
---|
| 207 | |
---|
| 208 | #endif |
---|