[20] | 1 | #include "window.h" |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | using namespace std; |
---|
| 5 | using namespace morpheo::tools::viewer::parser; |
---|
| 6 | using namespace morpheo::tools::viewer::bdd; |
---|
| 7 | using namespace morpheo::tools::viewer::graphics; |
---|
| 8 | |
---|
| 9 | Window::Window(QString name) |
---|
| 10 | { |
---|
| 11 | paint = false; |
---|
| 12 | is_parse = false; |
---|
| 13 | window_height = 620; |
---|
| 14 | window_width = 600; |
---|
| 15 | margeX = 50; |
---|
| 16 | margeY = 70; |
---|
| 17 | |
---|
| 18 | /*menu bar*/ |
---|
| 19 | QMenuBar *menu_bar = new QMenuBar(this); |
---|
| 20 | |
---|
| 21 | /*items of the menu bar*/ |
---|
| 22 | QMenu *file = new QMenu(); |
---|
| 23 | QMenu *tools = new QMenu(); |
---|
| 24 | QMenu *help = new QMenu(); |
---|
| 25 | |
---|
| 26 | /*connect signals of "file" menu with items of the menu bar*/ |
---|
| 27 | QAction *openAct; |
---|
| 28 | openAct = new QAction(tr("&open"),this); |
---|
| 29 | connect(openAct,SIGNAL(triggered()),this,SLOT(_open())); |
---|
| 30 | |
---|
| 31 | QAction *closeAct; |
---|
| 32 | closeAct = new QAction(tr("&close"),this); |
---|
| 33 | connect(closeAct,SIGNAL(triggered()),this,SLOT(_close())); |
---|
| 34 | |
---|
| 35 | QAction *saveAct; |
---|
| 36 | saveAct = new QAction(tr("&save"),this); |
---|
| 37 | connect(saveAct,SIGNAL(triggered()),this,SLOT(_save())); |
---|
| 38 | |
---|
| 39 | QAction *saveAsAct; |
---|
| 40 | saveAsAct = new QAction(tr("&save_as"),this); |
---|
| 41 | connect(saveAsAct,SIGNAL(triggered()),this,SLOT(_saveAs())); |
---|
| 42 | |
---|
| 43 | QAction *quitAct; |
---|
| 44 | quitAct = new QAction(tr("&quit"),this); |
---|
| 45 | connect(quitAct,SIGNAL(triggered()),this,SLOT(_quit())); |
---|
| 46 | |
---|
| 47 | /*add the menu "file" to the menu bar*/ |
---|
| 48 | file = menu_bar->addMenu(tr("&File")); |
---|
| 49 | file->addAction(openAct); |
---|
| 50 | file->addAction(saveAct); |
---|
| 51 | file->addAction(saveAsAct); |
---|
| 52 | file->addAction(closeAct); |
---|
| 53 | file->addAction(quitAct); |
---|
| 54 | |
---|
| 55 | /*connect signals of the menu "tools" with items of the menu bar*/ |
---|
| 56 | QAction *zoomInAct; |
---|
| 57 | zoomInAct = new QAction(tr("&zoom in"),this); |
---|
| 58 | connect(zoomInAct,SIGNAL(triggered()),this,SLOT(_zoomIn())); |
---|
| 59 | |
---|
| 60 | QAction *zoomOutAct; |
---|
| 61 | zoomOutAct = new QAction(tr("&zoom out"),this); |
---|
| 62 | connect(zoomOutAct,SIGNAL(triggered()),this,SLOT(_zoomOut())); |
---|
| 63 | |
---|
| 64 | QAction *defautZoomAct; |
---|
| 65 | defautZoomAct = new QAction(tr("&defaut zoom"),this); |
---|
| 66 | connect(defautZoomAct,SIGNAL(triggered()),this,SLOT(_defautZoom())); |
---|
| 67 | |
---|
| 68 | QAction *levelAct; |
---|
| 69 | levelAct = new QAction(tr("&level"),this); |
---|
| 70 | connect(levelAct,SIGNAL(triggered()),this,SLOT(_level())); |
---|
| 71 | |
---|
| 72 | QAction *infoAct; |
---|
| 73 | infoAct = new QAction(tr("&informations"),this); |
---|
| 74 | connect(infoAct,SIGNAL(triggered()),this,SLOT(_informations())); |
---|
| 75 | |
---|
| 76 | QAction *paramAct; |
---|
| 77 | paramAct = new QAction(tr("¶meters"),this); |
---|
| 78 | connect(paramAct,SIGNAL(triggered()),this,SLOT(_parameters())); |
---|
| 79 | |
---|
| 80 | /*add the menu "tools" to the menu bar*/ |
---|
| 81 | tools = menu_bar->addMenu(tr("&Tools")); |
---|
| 82 | tools->addAction(zoomInAct); |
---|
| 83 | tools->addAction(zoomOutAct); |
---|
| 84 | tools->addAction(defautZoomAct); |
---|
| 85 | tools->addAction(levelAct); |
---|
| 86 | tools->addAction(infoAct); |
---|
| 87 | tools->addAction(paramAct); |
---|
| 88 | |
---|
| 89 | /*connect the menu "about" with items of the menu bar*/ |
---|
| 90 | QAction *aboutAct; |
---|
| 91 | aboutAct = new QAction(tr("&about"),this); |
---|
| 92 | connect(aboutAct,SIGNAL(triggered()),this,SLOT(_about())); |
---|
| 93 | |
---|
| 94 | /*add the emenu "about" yo yhe menu bar*/ |
---|
| 95 | help = menu_bar->addMenu(tr("&About")); |
---|
| 96 | help->addAction(aboutAct); |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | /*add the menu bar to the main window*/ |
---|
| 100 | this->setMenuWidget(menu_bar); |
---|
| 101 | |
---|
| 102 | /*add a status bar to the main menu*/ |
---|
| 103 | status = new QStatusBar(); |
---|
| 104 | this->setStatusBar(status); |
---|
| 105 | |
---|
| 106 | /*defaut size*/ |
---|
| 107 | this->setFixedSize(window_width,window_height); |
---|
| 108 | |
---|
| 109 | /*defaut position*/ |
---|
| 110 | this->move(0,0); |
---|
| 111 | |
---|
| 112 | /*main window title*/ |
---|
| 113 | this->setWindowTitle("Viewer"); |
---|
| 114 | |
---|
| 115 | /*parameters window creation*/ |
---|
| 116 | this->wparameters(); |
---|
| 117 | param_open = true; |
---|
| 118 | |
---|
| 119 | /*informations window creation*/ |
---|
| 120 | this->winformations(); |
---|
| 121 | info_open = true; |
---|
| 122 | |
---|
| 123 | /*if quit_demand = true, then the user clicked on "quit"*/ |
---|
| 124 | quit_demand = false; |
---|
| 125 | |
---|
| 126 | /*little windows (open, save...), closed at init*/ |
---|
| 127 | wo_open = false; |
---|
| 128 | wq_open = false; |
---|
| 129 | ws_open = false; |
---|
| 130 | wa_open = false; |
---|
| 131 | |
---|
| 132 | /*file unsaved at init*/ |
---|
| 133 | save_as = false; |
---|
| 134 | first_save = false; //first_save = true for a new file |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | current_name = name; |
---|
| 138 | if(current_name != NULL){ |
---|
| 139 | is_save = true; |
---|
| 140 | } |
---|
| 141 | else { |
---|
| 142 | file_open = false; |
---|
| 143 | paint = false; |
---|
| 144 | is_save = false; |
---|
| 145 | } |
---|
| 146 | } |
---|