source: trunk/yao/src/interface/src/MainWindow.cpp @ 477

Last change on this file since 477 was 477, checked in by yerima, 14 years ago

An text editor is implemented in the visual Yao interface. The user must lunch the editor with a specific file.

File size: 54.6 KB
Line 
1//! \file    MainWindow.cpp
2//! \brief   Implementation of the main Visual_YAO code.
3//! \version 2010
4//! \author  MAYAKI Abdouramane
5/*
6  Nom du Fichier: MainWindow.cpp
7  Nom de classe: MainWindow
8  Role: Outre son role de fichier d'implémentation des méthodes, ce fichier gÚre toutes les fenêtres graphiques.
9  Nombre de methodes: 50
10  Nombre d'attributs: 81
11  */
12
13#include "include/MainWindow.hpp"
14#include<iostream>
15
16using namespace std;
17//using namespace antlr;
18using namespace yao;
19
20//! \class MainWindow(QWidget *parent) : QMainWindow(parent)
21//! \brief Implementation of the Main window for visual_YAO.
22
23/*!
24 * \fn MainWindow(MainWindowController *mwc, QWidget *parent)
25 * \brief Constructor of the class MainWindow().
26 *
27 * \param MainWindowController *mwc, QWidget *parent.
28 * \return void.
29 */
30/**************************************** Implementation of the constructor MainWindow() *************************************************************/
31/*
32  Implementation du constructeur de la classe MainWindow
33
34*/
35
36MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_constantWindow(NULL), m_hatnameWindow(NULL), m_contextWindow(NULL), m_trajectoryWindow(NULL), m_spaceWindow(NULL), m_operaWindow(NULL), m_netwardWindow(NULL), m_modulWindow(NULL), m_ctinWindow(NULL), m_orderWindow(NULL), m_insertFCTWindow(NULL), m_newProjectWindow(NULL), m_newProjectName(""), theConstantTablePt(theConstantTable), contextTest(false), iw(NULL), confirmationFlag(false)     
37{
38
39        setWindowTitle(" Visual YAO ");         //Gives a title to the mainwindow.
40        pt_espace = new QWorkspace;                             //Crée un espace de travail. Ici, ça serait notre zone centrale
41                pt_espace = &espace;
42        fv  = new FilesViewer();                        //Création d'un espace montrant l'arborescence des fichiers sur le disque dûr.
43       
44        fenetreProjet                 = new QDockWidget("Aperçu des projets: ", this); // Réservation de l'espace pour la fenêtre projet
45                fenetreProjet->setFeatures(QDockWidget::NoDockWidgetFeatures);  //La fenêtre projet ne pourra être ni deplacée ni fermée.
46                fenetreProjet->setWidget(fv);                   // L'arborescence des fichiers est incluse dans la fenêtre projet.
47        QDockWidget *dock2            = new QDockWidget("", this);
48        addDockWidget(Qt::LeftDockWidgetArea, fenetreProjet); //Positionnement de la fenêtre projet à gauche dans la QMainWindow.
49        addDockWidget(Qt::LeftDockWidgetArea, dock2);
50       
51        setCentralWidget(pt_espace);    //Ici, se précise la zone centrale de la QMainWindow.
52       
53        // Appel des differentes méthodes crées.
54        createActions();                //Appel de la methode createActions(), voir le code ci-aprÚs.
55        createMenus();                          // Appel de la méthode creerMenu(), voir le code ci-aprÚs.
56        createToolBar();             //Cree la barre d'outils
57        barreEtat = statusBar();        //Affiche la barre d'état.
58       
59        QDockWidget *dock3            = new QDockWidget("Résultats", this);/////////////////////////////////
60                dock3->setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea); 
61        addDockWidget(Qt::BottomDockWidgetArea, dock3);
62
63        tabWidget = new QTabWidget(dock3);//(this);
64        dock3->setWidget(tabWidget); 
65        page1 = new QWidget();
66        tabWidget->addTab(page1, "          Compilation               ");
67        page2 = new QWidget();
68        tabWidget->addTab(page2, "                 Exécution          ");
69       
70                connect(this, SIGNAL(WindowTitleChanged()), this, SLOT(setTitle()));
71        this->showMaximized(); // Maximise toujours la fenetre principale.
72               
73       
74}
75
76/*************************************** Implementation of the contructor MainWindow(Table <Constant> aConstant) *********************************/
77MainWindow::MainWindow(Table <Constant> aConstantTable): theConstantTablePt(aConstantTable)
78{
79        theConstantTablePt = aConstantTable;
80        //theConstantTable;                     
81}
82
83/******************************************* Implementation of the method setTitle() *****************************************************************/
84void MainWindow::setTitle() {
85
86        QWidget::setWindowTitle(tr("%1[*]  %2").arg("Projet:").arg(QString(getProjectName().c_str())));
87
88}
89
90/************************************ Implementation of the method createMenus() *******************************************************************/
91void MainWindow::createMenus() {
92
93        menuFichier = menuBar()->addMenu(tr("&Fichier"));
94                menuFichier->addAction(actionNouveauProjet);
95                menuFichier->addAction(actionOuvrirProjet);
96                menuFichier->addAction(actionOuvrirProjetsRecents);
97                menuFichier->addSeparator(); // Met une ligne horizontale entre les menus
98                //menuFichier->addAction(actionImporterProjet);
99                menuFichier->addSeparator();
100                menuFichier->addAction(actionSaveProject);
101                menuFichier->addAction(actionSaveAsProject);
102                menuFichier->addSeparator();
103                menuFichier->addAction(actionSortieProjet);
104        menuEdition = menuBar()->addMenu("&Edition");
105                //menuEdition->addAction(actionFichierDescription);
106                //menuEdition->addAction(actionFichierHat);
107                //nouveau->addAction(actionModule);
108                menuEdition->addAction(actionFichierInstruction);
109                menuEdition->addAction(actionGrapheModulaire);
110                //menuEdition->addAction(actionInfosProjet);
111
112        menuAffichage = menuBar()->addMenu("&Affichage");
113                menuAffichage->addAction(actionCacherBarreOutils);
114
115                menuAffichage->addAction(actionCacherFenetreApercu);
116                menuAffichage->addAction(actionCacherFenetreProjet);
117                menuAffichage->addAction(actionCacherFenetreDialog);
118        menuExecution = menuBar()->addMenu("&Exécution");
119                menuExecution->addAction(actionGenerationD);
120                menuExecution->addAction(actionGenerationI);
121                menuExecution->addAction(actionCompilation);
122                menuExecution->addAction(actionExecution);
123               
124        menuConfig    = menuBar()->addMenu("&Configuration");
125                menuConfig->addAction(actionEditeur);
126        menuAide = menuBar()->addMenu(tr("&Aide"));
127                menuAide->addAction(actionDocYao);
128                menuAide->addAction(actionRapport);
129
130}
131
132/******************************** Implementation of the method Implémentation de la methode createActions() ****************************************/
133void MainWindow::createActions()  {
134
135       
136        QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
137        // Les actions du menu fichier
138        actionNouveauProjet = new QAction(tr("&Nouveau projet"), this);
139                actionNouveauProjet->setIcon(QIcon("Images/icons/newfile.png"));
140                actionNouveauProjet->setStatusTip("Créer un nouveau projet");
141                actionNouveauProjet->setShortcut(tr("Ctrl+N"));
142
143                //connect(actionNouveauProjet, SIGNAL(triggered()), this, SLOT(activateToolBarButtons()));
144                connect(actionNouveauProjet, SIGNAL(triggered()), this, SLOT(createNewProjectWindow()));
145                connect(actionNouveauProjet, SIGNAL(triggered()), this, SLOT(montrerActionGenererD()));
146
147        actionOuvrirProjet = new QAction(tr("&Ouvrir un projet"), this);
148                actionOuvrirProjet->setIcon(QIcon("Images/icons/openfile.png"));
149                actionOuvrirProjet->setShortcut(tr("Ctrl+O"));
150                actionOuvrirProjet->setStatusTip("Ouvrir un projet existant");
151
152                connect(actionOuvrirProjet, SIGNAL(triggered()), this, SLOT(openProject()));
153                //connect(actionOuvrirProjet, SIGNAL(triggered()), this, SLOT(montrerActionCompilation()));
154
155        actionOuvrirProjetsRecents = new QAction(tr("Ouvrir projets recents"), this);
156                //compilAction->setIcon(QIcon(""));
157                actionOuvrirProjetsRecents->setShortcut(tr("Ctrl+P"));
158                actionOuvrirProjetsRecents->setStatusTip("Projets recemment ouverts");
159                //connect(compilAction, SIGNAL(triggered()), this, SLOT());
160        //actionImporterProjet = new QAction(tr("&Importer"), this);
161                //runAction->setIcon(QIcon(""));
162                //  actionImporterProjet->setShortcut(tr("Ctrl+E"));
163                //  actionImporterProjet->setStatusTip("Importer un projet");
164
165                //connect(runAction, SIGNAL(triggered()), this, SLOT());
166        actionSaveProject = new QAction(tr("Enregi&strer"), this);
167                actionSaveProject->setIcon(QIcon("Images/icons/save.png"));
168                actionSaveProject->setEnabled(false); // Option désactivée par défaut.
169                actionSaveProject->setStatusTip("Pour sauvegarder le projet en cours");
170                connect(actionSaveProject, SIGNAL(triggered()), this, SLOT(save()));
171
172        actionSaveAsProject = new QAction(tr("Enregistrer sous"), this);
173                actionSaveAsProject->setIcon(QIcon("Images/icons/saveas.png"));
174                actionSaveAsProject->setEnabled(false); // Option désactivée par défaut.
175                actionSaveAsProject->setStatusTip("En le projet sous un autre nom");
176                connect(actionSaveAsProject, SIGNAL(triggered()), this, SLOT(saveAs()));
177        actionImprimerProjet = new QAction(tr("Imprimer"), this);
178                actionImprimerProjet->setStatusTip("Options d'impression");
179        actionSortieProjet = new QAction(tr("&Sortir"), this);
180                actionSortieProjet->setIcon(QIcon("Images/icons/exit.png"));
181                actionSortieProjet->setShortcut(tr("Ctrl+Q"));
182                actionSortieProjet->setStatusTip("Fermer le programme");
183
184                connect(actionSortieProjet, SIGNAL(triggered()), this, SLOT(close()));
185
186     // Les actions du menu Edition
187        //actionFichierDescription = new QAction(tr("Fichier de description (.d)"), this);
188
189                //connect(actionFichierDescription, SIGNAL(triggered()), this, SLOT(generateDFile()));
190
191        //actionFichierHat = new QAction(tr("Fichier  (.h)"), this);
192                //actionModule = new QAction(tr("Modul"), this);
193        actionFichierInstruction = new QAction(tr("Fichier d'instruction (.i)"), this);
194                connect(actionFichierInstruction, SIGNAL(triggered()), this, SLOT(instructionFileManager()));
195        actionGrapheModulaire = new QAction(tr("Graphe modulaire"), this);
196        //actionInfosProjet = new QAction(tr("Edition infos projet"), this);
197
198     // Les actions du menu Affichage
199        actionCacherBarreOutils = new QAction(tr("Cacher la barre d'outils"), this);
200                actionCacherBarreOutils->setCheckable(true);
201
202              // connect(actionCacherBarreOutils, SIGNAL(triggered()), this, SLOT(cacherBarreOutils()));
203        actionCacherFenetreApercu = new QAction(tr("Cacher la fenetre apercu"), this);
204                actionCacherFenetreApercu->setCheckable(true);
205        actionCacherFenetreProjet = new QAction(tr("Cacher la fenetre Projet"), this);
206                actionCacherFenetreProjet->setCheckable(true);
207        actionCacherFenetreDialog = new QAction(tr("Cacher la fenetre dialog"), this);
208                actionCacherFenetreDialog->setCheckable(true);
209        //actionPleinEcran = new QAction(tr("Plein ecran"), this);
210                //actionPleinEcran->setCheckable(true);
211
212     // Les actions du menu Execution
213        actionGenerationD = new QAction(this);
214                actionGenerationD->setEnabled(false);
215                actionGenerationD->setText("Générer le fichier .d");
216
217                connect(actionGenerationD, SIGNAL(triggered()), this, SLOT(callGenerateDFile()));
218                //connect(actionGenerationD, SIGNAL(triggered()), this, SLOT(information()));
219
220        actionGenerationI = new QAction(this);
221                actionGenerationI->setEnabled(false);
222                actionGenerationI->setText("Générer le fichier .i"); 
223                connect(actionGenerationI, SIGNAL(triggered()), this, SLOT(generateIFile()));
224
225        actionCompilation = new QAction(tr("Compilation"), this);
226                actionCompilation->setEnabled(false);
227        actionExecution = new QAction(this);
228                actionExecution->setEnabled(false);
229                actionExecution->setText("Exécution");
230
231     // Les actions du menu Configuration
232        actionEditeur = new QAction(tr("Editeur par defaut"), this);
233                connect(actionEditeur, SIGNAL(triggered()), this, SLOT(createEditor()));
234
235     // Les actions du menu Aide
236        actionDocYao = new QAction(tr("Doc Yao"), this);
237        actionRapport = new QAction(tr("Rapport"), this);
238        //aproposYao = new QAction(tr("A propos de Yao"), this);
239
240     // Les actions de la barre d'outils
241
242        toolBarActions(espace);
243
244}
245
246/******************************** Implementation of the createEditor() SLOT *********************************************************************/
247void MainWindow::createEditor() {
248
249        Editor *edit = new Editor(this);
250        edit->open();
251        pt_espace->addWindow(edit); 
252        edit->show();
253
254
255}
256/********************************* Implementation of the enableIAction() method ***************************************************************************/
257void MainWindow::enableIAction() {
258
259        actionGenerationI->setEnabled(true);
260
261}
262
263/********************************* Implementation of the createToolBar() method ****************************************/
264void MainWindow::createToolBar() {
265
266        yaoToolBar = addToolBar(tr("&YaoToolbar"));
267
268                yaoToolBar->addWidget(m_constantButton);
269                yaoToolBar->addWidget(m_hatNameButton);
270                yaoToolBar->addWidget(m_contextButton);
271                yaoToolBar->addWidget(m_trajButton);
272                yaoToolBar->addWidget(m_spaceButton);
273                yaoToolBar->addWidget(m_operaButton);
274                yaoToolBar->addWidget(m_netwardButton);
275                yaoToolBar->addWidget(m_modulButton);
276                yaoToolBar->addWidget(m_ctinButton);
277                yaoToolBar->addWidget(m_orderButton);
278                yaoToolBar->addWidget(m_insertFCTButton);
279                yaoToolBar->addSeparator();
280                yaoToolBar->addAction(actionSortieProjet);
281
282}
283
284/******************************** Implementation of the cacherBarreOutils() method ***************************************/
285void MainWindow::cacherBarreOutils() {
286
287        yaoToolBar->hide();
288        barreEtat->showMessage(tr("La barre des outils est cachée!"), 2000);
289
290}
291
292/********************************** Implementation of the toolBarActions() method ****************************************/
293void MainWindow::toolBarActions(QWorkspace &espace) 
294{
295
296        m_constantButton    = new QPushButton(tr("Defval"), this);
297                //m_constantButton->setToolTip("Bouton désactivé. Vous devez d'abord creer un nouveau projet ou en ouvrir un.");
298                connect(m_constantButton, SIGNAL(clicked()), this, SLOT(createDefvalWindow()));
299                connect(m_constantButton, SIGNAL(clicked()), this, SLOT(changeColorConstantButton()));
300       
301        m_hatNameButton   = new QPushButton(tr("Hatname"), this);
302                connect(m_hatNameButton, SIGNAL(clicked()), this, SLOT(createHatNameWindow()));
303                connect(m_hatNameButton, SIGNAL(clicked()), this, SLOT(changeColorHatButton()));
304 
305        m_contextButton    = new QPushButton(tr("Option"), this);
306                connect(m_contextButton, SIGNAL(clicked()), this, SLOT(createContextWindow()));
307                connect(m_contextButton, SIGNAL(clicked()), this, SLOT(changeColorContextButton()));
308
309        m_trajButton      = new QPushButton(tr("Trajectory"), this);
310                connect(m_trajButton, SIGNAL(clicked()), this, SLOT(createTrajectoryWindow()));
311                connect(m_trajButton, SIGNAL(clicked()), this, SLOT(changeColorTrajButton()));
312        m_spaceButton     = new QPushButton(tr("Space"), this);
313                connect(m_spaceButton, SIGNAL(clicked()), this, SLOT(createSpaceWindow()));
314                connect(m_spaceButton, SIGNAL(clicked()), this, SLOT(changeColorSpaceButton()));
315        m_operaButton     = new QPushButton(tr("Operator"), this);
316                connect(m_operaButton, SIGNAL(clicked()), this, SLOT(createOperaWindow()));
317                connect(m_operaButton, SIGNAL(clicked()), this, SLOT(changeColorOperaButton()));
318        m_netwardButton   = new QPushButton(tr("Netward"), this);
319                connect(m_netwardButton, SIGNAL(clicked()), this, SLOT(createNetwardWindow()));
320                connect(m_netwardButton, SIGNAL(clicked()), this, SLOT(changeColorNetwardButton()));
321        m_modulButton     = new QPushButton(tr("Modul"), this);
322                connect(m_modulButton, SIGNAL(clicked()), this, SLOT(createModulWindow()));
323                connect(m_modulButton, SIGNAL(clicked()), this, SLOT(changeColorModulButton()));
324        m_ctinButton      = new QPushButton(tr("Connection"), this);
325                connect(m_ctinButton, SIGNAL(clicked()), this, SLOT(createCtinWindow()));
326                connect(m_ctinButton, SIGNAL(clicked()), this, SLOT(changeColorCtinButton()));
327        m_orderButton     = new QPushButton(tr("Order"), this);
328                connect(m_orderButton, SIGNAL(clicked()), this, SLOT(createOrderWindow()));
329                connect(m_orderButton, SIGNAL(clicked()), this, SLOT(changeColorOrderButton()));
330        m_insertFCTButton = new QPushButton(tr("Insert_fct"), this);
331                connect(m_insertFCTButton, SIGNAL(clicked()), this, SLOT(createInsertFCTWindow()));
332                connect(m_insertFCTButton, SIGNAL(clicked()), this, SLOT(changeColorInsertFCTButton()));
333
334        desactivateToolBarButtons(); // Désactive tous les boutons de la barre d'outils
335}
336
337/*********************************************** Implementation of the createDefvalWindow() method *************************************************/
338void MainWindow::createDefvalWindow() 
339{
340
341        if (m_constantWindow == NULL) { //to test if the object is already created.
342
343                m_constantWindow = new ConstantWindow(&theConstantTable, &theHeaderList, &the_mwc); //Then create the object and initialize it.
344                espace.addWindow(m_constantWindow)->move(0, 0); //Put the object in the workspace (here, espace is the QWorkspace's object.)
345                m_constantWindow->show();// shows the object.
346        }
347
348        connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(hatUpdate()));
349        connect(m_constantWindow, SIGNAL(rowIsDeleted(QString )), this, SLOT(hatUpdate(QString )));
350        connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(trajUpdate()));
351        //connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(contextUpdate()));
352        connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(mainWindowIsModified()));
353        connect(m_constantWindow, SIGNAL(windowIsClosed(int )), this, SLOT(initializeWindow(int )));// The signal is in the ConstantWindow.hpp file.
354        //connect(m_constantWindow, SIGNAL(clicked(bool )), , SLOT(hatUpdate()));
355
356}
357
358/******************************************** Implementation of the createHatNameWindow() method ***************************************************/
359void MainWindow::createHatNameWindow() {
360
361        if (m_hatnameWindow == NULL) { //to test if the object is already created.
362
363                m_hatnameWindow = new HatNameWindow(&theHeaderList, &theConstantTable); //Then create the object and initialize it.
364                espace.addWindow(m_hatnameWindow)->move(350, 0); //Put the object in the workspace (here, espace is the QWorkspace's object.)
365                m_hatnameWindow->show();// shows the object.
366        }
367
368        connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
369}
370
371/********************************************* Implementation of the method createContextWindow() *************************************************/
372void MainWindow::createContextWindow() {
373
374        if (m_contextWindow == NULL) { //to test if the object is already created.
375
376                m_contextWindow = new ContextWindow(&theContext, &theConstantTable, &theContextData); //mwc.getContext();
377                espace.addWindow(m_contextWindow)->move(5, 0);
378                m_contextWindow->show();
379                contextTest = true;
380        }
381
382        connect(m_contextWindow, SIGNAL(contextWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
383}
384
385/********************************************* Implementation of the method createTrajectoryWindow() ************************************************/
386void MainWindow::createTrajectoryWindow() {
387
388        if (m_trajectoryWindow == NULL) { //to test if the object is already created.
389
390                m_trajectoryWindow = new TrajectoryWindow(&theTrajectoryTable, &theConstantTable); //mwc.getTraj();
391                espace.addWindow(m_trajectoryWindow)->move(30, 10);
392                m_trajectoryWindow->show(); 
393
394        }
395
396        connect(m_trajectoryWindow, SIGNAL(trajectoryWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
397        connect(m_trajectoryWindow, SIGNAL(trajRowIsAdded(bool)), m_spaceButton, SLOT(setEnabled(bool)));
398        connect(m_trajectoryWindow, SIGNAL(trajRowIsAdded(bool)), m_operaButton, SLOT(setEnabled(bool)));
399}
400
401/********************************************* Implementation of the method createSpaceWindow() ************************************************/
402void MainWindow::createSpaceWindow() {
403
404        if (m_spaceWindow == NULL) { //to test if the object is already created.
405       
406                m_spaceWindow = new SpaceWindow(&theSpaceTable, &theTrajectoryTable, &theConstantTable); //mwc.getSpace();
407                espace.addWindow(m_spaceWindow)->move(30, 20);
408                m_spaceWindow->show(); 
409        }
410
411        connect(m_spaceWindow, SIGNAL(spaceWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
412        connect(m_spaceWindow, SIGNAL(spaceRowIsAdded(bool)), m_modulButton, SLOT(setEnabled(bool)));
413}
414
415/********************************************* Implementation of the method createOperaWindow() ************************************************/
416void MainWindow::createOperaWindow() {
417
418        if (m_operaWindow == NULL) { //to test if the object is already created.
419                m_operaWindow =  new OperaWindow(&theOperaTable, &theTrajectoryTable, &theConstantTable); //mwc.getOpera();
420                espace.addWindow(m_operaWindow)->move(5, 8);
421                m_operaWindow->show(); 
422        }
423
424        connect(m_operaWindow, SIGNAL(operaWindowIsClosed(int )), this, SLOT(initializeWindow(int )));
425        //connect(m_operaWindow, SIGNAL(operaRowIsAdded(bool)), m_modulButton, SLOT(setEnabled(bool)));
426}
427
428/********************************************* Implementation of the method createNetwardWindow() ************************************************/
429void MainWindow::createNetwardWindow() {
430
431        if (m_netwardWindow == NULL) { //to test if the object is already created.
432                m_netwardWindow = new NetwardWindow(&theNeuronTable, &theConstantTable); //mwc.getNetward();
433                espace.addWindow(m_netwardWindow)->move(5, 15);
434                m_netwardWindow->show();
435        }
436        connect(m_netwardWindow, SIGNAL(netwardWindowIsClosed(int )), this, SLOT(initializeWindow(int )));
437        //connect(m_netwardButton, SIGNAL(clicked()), this, SLOT(changeColorNetwardButton()));
438}
439
440/********************************************* Implementation of the method createModulWindow() ************************************************/
441void MainWindow::createModulWindow() {
442
443        if (m_modulWindow == NULL) { //to test if the object is already created.
444                m_modulWindow = new ModulWindow(&theModulTable, &theSpaceTable, &theOperaTable, &theConstantTable, &the_mwc, &m_newProjectName, &m_projectPath); //mwc.getModul();
445                espace.addWindow(m_modulWindow)->move(30, 15);
446                m_modulWindow->show(); 
447        }
448
449        connect(m_modulWindow, SIGNAL(modulWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
450        connect(m_modulWindow, SIGNAL(modulRowIsAdded(bool)), m_ctinButton, SLOT(setEnabled(bool)));
451}
452
453/********************************************* Implementation of the method createCtinWindow() ************************************************/
454void MainWindow::createCtinWindow() {
455
456        if (m_ctinWindow == NULL) { //to test if the object is already created.
457                m_ctinWindow = new ConnectionWindow(&theConnectionTable, &theModulTable, &theConstantTable); //mwc.getCtin();
458                espace.addWindow(m_ctinWindow)->move(0, 0);
459                m_ctinWindow->show();
460        }
461
462        connect(m_ctinWindow, SIGNAL(ctinWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
463        connect(m_ctinWindow, SIGNAL(ctinRowIsAdded(bool)), m_orderButton, SLOT(setEnabled(bool)));
464}
465
466/********************************************* Implementation of the method createOrderWindow() ************************************************/
467void MainWindow::createOrderWindow() {
468
469        if (m_orderWindow == NULL) { //to test if the object is already created.
470                m_orderWindow = new OrderWindow(&theTrajectoryTable, &theSpaceTable, &theOperaTable, &theModulTable, &theOrderTable); //mwc.getOrder();
471                espace.addWindow(m_orderWindow)->move(2, 0);
472                m_orderWindow->show();
473        }
474
475        connect(m_orderWindow, SIGNAL(orderWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
476
477}
478
479/********************************************* Implementation of the method createInsertFCTWindow() ************************************************/
480void MainWindow::createInsertFCTWindow() {
481
482        if (m_insertFCTWindow == NULL) { //to test if the object is already created.
483                m_insertFCTWindow = new InsertFCTWindow(&theFunctionTable); //mwc.getInsertFCT();
484                espace.addWindow(m_insertFCTWindow)->move(30, 20);
485                m_insertFCTWindow->show();
486        }
487
488        connect(m_insertFCTWindow, SIGNAL(insertFCTWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
489
490}
491
492/********************************************* Implementation of the method directivesManage() *****************************************************/
493void MainWindow::directivesManager() {
494
495        theHeaderList.push_back(getProjectName() + ".h") ; 
496       
497}
498
499/*********************************** Implementation of the method activateToolBarButtons() *********************************************************/
500void MainWindow::activateToolBarButtons() {
501
502        m_constantButton->setEnabled(true);
503        m_hatNameButton->setEnabled(true);
504        m_contextButton->setEnabled(true);
505        m_trajButton->setEnabled(true);
506         theSpaceTable.empty() == true ? m_spaceButton->setEnabled(false): m_spaceButton->setEnabled(true);//The button will be enabled/disabled depending on the structure's status (empty or not).
507         theOperaTable.empty() == true ? m_operaButton->setEnabled(false): m_operaButton->setEnabled(true);
508        m_netwardButton->setEnabled(true);
509         theModulTable.empty() == true ? m_modulButton->setEnabled(false): m_modulButton->setEnabled(true);
510       
511        m_ctinButton->setEnabled(false);
512         theModulTable.empty() == true ? m_ctinButton->setEnabled(false): m_ctinButton->setEnabled(true);
513        m_orderButton->setEnabled(true);
514         //theModulTable.empty() == true ? m_orderButton->setEnabled(false): m_orderButton->setEnabled(true);
515        m_insertFCTButton->setEnabled(true);
516}
517
518/********************************** Implementation of the method desactivateToolBarButtons() *******************************************************/
519void MainWindow::desactivateToolBarButtons() {
520
521        m_constantButton->setEnabled(false);
522        m_hatNameButton->setEnabled(false);
523        m_contextButton->setEnabled(false);
524        m_trajButton->setEnabled(false);
525        m_spaceButton->setEnabled(false);
526        m_operaButton->setEnabled(false);
527        m_netwardButton->setEnabled(false);
528        m_modulButton->setEnabled(false);
529        m_ctinButton->setEnabled(false);
530        m_orderButton->setEnabled(false);
531        m_insertFCTButton->setEnabled(false);
532}
533
534/**************************************** Implementation of the method nouveauProjet (SLOT) *******************************************************/
535void MainWindow::createNewProjectWindow()       { // Affiche la fenetre nouveau projet lorsqu'elle est appelée.
536
537        //clearAllStructures();
538        espace.closeAllWindows(); 
539        m_newProjectWindow = new NewProjectWindow(espace);//The new project window will be appeared in the workspace.
540        m_newProjectName = m_newProjectWindow->getProjectName();//Gets the current project's name.
541        m_projectPath = m_newProjectWindow->getProjectPath();
542        if (!m_newProjectName.empty()) {
543                clearAllStructures();// To eraze Yao structure before creating the new project.
544                theHeaderList.push_back(m_newProjectWindow->getProjectName() + ".h");
545                emit WindowTitleChanged(); //Emits the signal to change the window's title.
546                emit newProjectIsCreated();//Emits the signal that the project is created.
547                activateToolBarButtons(); // To active the toolbar buttons.
548                actionSaveAsProject->setEnabled(true); // Option désactivée par défaut.
549        }
550        fv->updateTheView(); //Permet de mettre à jour automatiquement la liste des fichiers visibles dans filesviewer.
551        //connect(m_newProjectWindow, SIGNAL(newProjectIsCreated()), this, SLOT(activateToolBarButtons()));
552        //      connect(m_newProjectWindow, SIGNAL(projectDone()), this, SLOT(clearAllStructures()));
553}
554
555/*************************************** Implementation of the method clearAllStrutures() *********************************************************/
556void MainWindow::clearAllStructures() {
557
558
559        theConstantTable.clear();//Erase data from Table <Constant>
560        theHeaderList.clear();
561        theTrajectoryTable.clear();
562        theSpaceTable.clear();
563        theOperaTable.clear();
564        theNeuronTable.clear();
565        theModulTable.clear();
566        theConnectionTable.clear();
567        theFunctionTable.clear();       
568       
569        //To restaure all buttons original color
570        for (int i=1; i<=11; i++) {
571
572                switch (i) {
573                        case 1: m_constantButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
574                        case 2: m_hatNameButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
575                        case 3: m_contextButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
576                        case 4: m_trajButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
577                        case 5: m_spaceButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
578                        case 6: m_operaButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
579                        case 7: m_netwardButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
580                        case 8: m_modulButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
581                        case 9: m_ctinButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
582                        case 10:m_orderButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
583                        case 11:m_insertFCTButton->setStyleSheet("background-color: rgb(255, 255, 255)"); 
584                }
585        }
586
587       
588}
589/**************************************** Implementation of the method mainWindowIsModified() (SLOT) ************************************************/
590void MainWindow::mainWindowIsModified() {
591
592        setWindowModified(true);
593        actionSaveProject->setEnabled(true);
594        actionSaveAsProject->setEnabled(true);
595
596}
597/**************************************** Implementation of the method save() (SLOT) *******************************************************/
598void MainWindow::save() {
599       
600        generateDFile();
601        setWindowModified(false);
602
603}
604
605/**************************************** Implementation of the method callgenerateDFile() (SLOT) *******************************************************/
606void MainWindow::callGenerateDFile() {
607       
608        generateDFile();
609        QMessageBox::about(this, "Avis", "Le fichier <B>"+ QString(getProjectName().c_str()) + ".d</B> a été généré avec succÚs.");
610
611}
612/**************************************** Implementation of the method saveAs() (SLOT) *******************************************************/
613void MainWindow::saveAs() {
614       
615       
616        m_newProjectWindow = new  NewProjectWindow ;
617        //m_newProjectWindow->setWindowTitle("testhj");
618        m_newProjectName = m_newProjectWindow->getProjectName();
619        m_projectPath = m_newProjectWindow->getProjectPath();
620        theHeaderList.push_back(m_newProjectWindow->getProjectName() + ".h");
621        fv->updateTheView(); //To refresh the view from FileViewer class.
622        //connect(m_newProjectWindow, SIGNAL(newProjectIsCreated()), this, SLOT(activateToolBarButtons()));
623        activateToolBarButtons();
624        emit WindowTitleChanged();
625        emit newProjectIsCreated();
626
627        //QFileDialog *dialog = new QFileDialog(this); //Crée une boite de dialogue
628        //dialog->setFileMode(QFileDialog::Directory);
629        //QString cheminFichier = dialog->getExistingDirectory(this, tr("Enregistrement d'un projet."), ".");
630        //m_newProjectName = cheminFichier.toStdString();
631        generateDFile(m_projectPath + "/");
632        //cout << cheminFichier.toStdString() << endl;
633       
634        actionGenerationD->setEnabled(true);
635
636}
637/**************************************** Implementation of the method nouveauProjet (SLOT) *******************************************************/
638void MainWindow::openProject()  { // Affiche la fenetre nouveau projet lorsqu'elle est appelée.
639
640
641        QFileDialog *dialogue = new QFileDialog(this); //Crée une boite de dialogue
642
643        QString cheminFichier = dialogue->getOpenFileName(this, tr("Ouverture d'un project existant."), QDir::homePath(), tr("*.d *.i *.txt")); //Retourne le chemin du fichier.
644        FilePath localName(cheminFichier.toStdString());
645        setProjectName(localName.getTitle());
646        setProjectPath(localName.getLocation());
647        setTitle();
648        QProcess builder;//To lanch an external command. Example: "ls -l"
649        QString test("");
650        builder.setProcessChannelMode(QProcess::MergedChannels);
651        builder.start("Yao9Generator " + cheminFichier);//Will execute the linux command
652        if (!builder.waitForFinished())
653                qDebug() << "Make failed:" << builder.errorString();
654        else {
655                test = builder.readAll();//the results are saved in a string format.
656                istringstream iss(test.toStdString()); //To have each word that compose the string.
657                FilePath aString, theShape, name, parent, aType, boot, offset, step, size, netname, indegree, outdegree, modname, arg;
658                vector <int> theShapeVector;
659
660                while ( getline(iss, aString, '\n' ) ) // Here we notified that the words in the string are separated by "\n"
661                        {
662                                //For DEFVAL
663                                if (aString.getExtension() == ".def1")//
664                                {                       
665                                        //cout << aString.getTitle() << endl;
666                                        name = aString;
667                                }
668                                if (aString.getExtension() == ".def2" && name.getExtension() == ".def1")
669                                {
670                                        Constant aConstant(name.getTitle(), aString.getTitle());       
671                                        theConstantTable.push_back(aConstant);
672                                }
673                                //For HATNAME
674                                if (aString.getExtension() == ".h")
675                                {
676                                //      cout << aString << endl;
677                                        theHeaderList.push_back(aString);       
678                                }
679                                //For TRAJ
680                                if (aString.getExtension() == ".traj1"){
681                                        name = aString.getTitle();
682                                //      cout << name << endl;
683                                }
684                                if (aString.getExtension() == ".traj2"){
685                                        aType = aString.getTitle();
686                                //      cout << aType << endl;
687                                }
688                                if (aString.getExtension() == ".traj3") {
689                                        boot = aString.getTitle();
690                                //      cout << boot << endl;
691                                }
692                                if (aString.getExtension() == ".traj4"){
693                                        offset = aString.getTitle();   
694                                //      cout << offset << endl;
695                                }
696                                if (aString.getExtension() == ".traj5"){
697                                        step = aString.getTitle();
698                                //      cout << step << endl;
699                                }
700                                if (aString.getExtension() == ".traj6")
701                                {
702                                        size = aString.getTitle();
703                                //      cout << size << endl;
704                                        Trajectory localTrajectory(name, m_trajectoryWindow->toInt(boot), m_trajectoryWindow->toDouble(size), m_trajectoryWindow->toDouble(step), m_trajectoryWindow->toInt(offset), 'M');//Trajectory object.
705                                        theTrajectoryTable.push_back(localTrajectory); //Trajectory vector (contents many objects)   
706                                        //if (m_trajectoryWindow->isTrajectoryTableEmpty())
707
708                                }               //theConstantTable.push_back(aString.getTitle());
709                                //For SPACE
710                                if (aString.getExtension() == ".sp1")//{
711                                        name = aString.getTitle();
712                                        //cout << name << endl;
713                                //}
714                                if (aString.getExtension() == ".sp2"){
715                                        aType = aString.getTitle();     
716                                        istringstream aShape1(aType); 
717                                        while ( getline(aShape1, theShape, ' ' )){
718                                                theShapeVector.push_back(m_spaceWindow->toInt(theShape));
719                                                //cout << aType << endl;
720                                        }
721                                }
722                                if (aString.getExtension() == ".sp3") {
723                                        parent = aString.getTitle(); 
724                                        //cout << parent << endl;
725                                        Space espace(name, theTrajectoryTable.find(parent), theShapeVector);
726                                        theSpaceTable.push_back(espace);
727                                        theShapeVector.clear();
728                                       
729                                }
730                                //For NETWARD   
731                                if (aString.getExtension() == ".nw1") {
732                                        netname = aString.getTitle(); 
733                                }
734
735                                if (aString.getExtension() == ".nw2") {
736                                        indegree = aString.getTitle(); 
737                                }
738
739                                if (aString.getExtension() == ".nw3") {
740                                        outdegree = aString.getTitle(); 
741                                        theNeuronTable.push_back(Neuron(netname, m_netwardWindow->toInt(indegree), m_netwardWindow->toInt(outdegree)));
742                                }
743                                //For MODUL
744                                if (aString.getExtension() == ".mod1") {
745                                        modname = aString.getTitle(); 
746                                       
747                                }
748                                if (aString.getExtension() == ".mod2") {
749                                        aType = aString.getTitle(); 
750                                       
751                                }
752                                if (aString.getExtension() == ".mod3") {
753                                        parent = aString.getTitle(); 
754                                       
755                                        Modul mod1(modname, theSpaceTable.find(parent), true);
756                                        theModulTable.push_back(mod1); 
757                                }
758                                //For CONNECTION
759                                /*if (aString.getExtension() == ".mod1") {
760                                        parent = aString.getTitle();
761                                        //cout << parent << endl;
762                                        Space espace(name, theTrajectoryTable.find(parent), theShapeVector);
763                                        theSpaceTable.push_back(espace);
764                                        theShapeVector.clear();
765                                       
766                                }*/
767
768                                //For INSERTFCT
769                                if (aString.getExtension() == ".fct1") {
770                                        arg = aString.getTitle(); 
771                                        //cout << parent << endl;
772                                }
773                                if (aString.getExtension() == ".fct2") {
774                                        bool aBool;
775                                        parent = aString.getTitle();
776                                        aBool = arg.empty() ? false : true ; 
777                                        theFunctionTable.push_back(Function(parent, aBool));
778                                        //cout << parent << endl;
779                                }
780                        }
781                       
782                                //m_spaceButton->setEnabled(true);
783               
784        }
785        if (!cheminFichier.isEmpty() && !test.isEmpty()) {
786                        activateToolBarButtons();
787                        //actionSaveProject->setEnabled(true);
788                        actionSaveAsProject->setEnabled(true);
789                }
790       
791       
792       
793        //connect(m_trajectoryWindow, SIGNAL(trajRowIsAdded(bool)), m_spaceButton, SLOT(setEnabled(bool)));
794        //connect(m_trajectoryWindow, SIGNAL(trajRowIsAdded(bool)), m_operaButton, SLOT(setEnabled(bool)));
795
796       
797}
798
799/**************************************** Implementation of the method hatUpdate() ****************************************************************/
800void MainWindow::hatUpdate() {
801       
802        if (m_hatnameWindow != NULL) //Teste si l'objet n'est pas déjà crée. S'il n'est pas
803                { 
804                        delete m_hatnameWindow;
805                        m_hatnameWindow = new HatNameWindow(&theHeaderList, &theConstantTable); //Crée un autre objet.
806                        espace.addWindow(m_hatnameWindow)->move(350, 0);
807                        m_hatnameWindow->show();
808                        espace.setActiveWindow(m_constantWindow);
809                        //m_hatnameWindow->update();
810
811                        connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
812                }
813
814        else
815                return;
816}
817
818/******************************************* Implementation of the method hatUpdate(QString choix) **************************************************/
819void MainWindow::hatUpdate(QString choix) {
820
821        if (m_hatnameWindow != NULL) //Teste si l'objet n'est pas déjà crée.
822                { 
823                        m_hatnameWindow->deleteARow(choix.toStdString()); 
824                        delete m_hatnameWindow;
825                        m_hatnameWindow = new HatNameWindow(&theHeaderList, &theConstantTable); //Crée un autre objet.
826                        espace.addWindow(m_hatnameWindow)->move(350, 0);
827                        m_hatnameWindow->show();
828                        espace.setActiveWindow(m_constantWindow);
829                        //m_hatnameWindow->update();
830
831                        connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
832       
833                        //delete m_hatnameWindow;
834                        //cout << "Voici la chaine supprimée: " + choix.toStdString() << endl;
835                        //m_hatnameWindow = new HatNameWindow(&theHeaderList, &theConstantTable); //Crée un autre objet.
836                        //espace.addWindow(m_hatnameWindow)->move(350, 0);
837                        //m_hatnameWindow->show();
838                        //espace.setActiveWindow(m_constantWindow);
839
840                        //connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
841                }
842        else
843                return;
844}
845
846/******************************************* Implementation of the method contextUpdate(QString choix) ************************************************/
847/*void MainWindow::contextUpdate() {
848
849        if (m_contextWindow != NULL) //Teste si l'objet n'est pas déjà crée.
850                {
851                        delete m_contextWindow ;
852                        m_contextWindow = new ContextWindow(&theContext, &theConstantTable); //mwc.getContext();
853                        espace.addWindow(m_contextWindow)->move(350, 0);
854                        m_contextWindow->show();
855                        espace.setActiveWindow(m_constantWindow);
856                        //m_contextWindow->update();
857
858                        connect(m_contextWindow, SIGNAL(contextWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
859
860                }
861        else
862                return;
863}*/
864
865/******************************************* Implementation of the method trajUpdate() **************************************************/
866void MainWindow::trajUpdate() {
867
868        if (m_trajectoryWindow != NULL) //Teste si l'objet n'est pas déjà crée.
869                { 
870                        delete m_trajectoryWindow ;
871                        m_trajectoryWindow = new TrajectoryWindow(&theTrajectoryTable, &theConstantTable); //mwc.getTraj();
872                        espace.addWindow(m_trajectoryWindow)->move(30, 10);
873                        m_trajectoryWindow->show();
874                        espace.setActiveWindow(m_constantWindow);
875
876                        connect(m_trajectoryWindow, SIGNAL(trajectoryWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
877                }
878        else
879                return;
880}
881/***************************************** Implementation of the method montrerActionGenererD() ****************************************************/
882void MainWindow::montrerActionGenererD() {
883
884        actionGenerationD->setEnabled(true);
885}
886
887/*********************************** Implementation of the method montrerActionCompilation() *******************************************************/
888void MainWindow::montrerActionCompilation() {
889
890        actionCompilation->setEnabled(true);
891}
892 
893/************************************************* Implementation of the method setProjectName(string chaine) **************************************/
894void MainWindow::setProjectName(string chaine) {
895 
896        m_newProjectName = chaine; //To initialize or to give a name for the project.
897
898}
899/***************************************************** Implementation of the method getProjectName() **********************************************/
900 string MainWindow::getProjectName() {
901       
902        return m_newProjectName;
903} 
904
905/************************************* Implementation of the method setProjectPath(string aPath) ******************************************/
906void MainWindow::setProjectPath(string aPath) {
907 
908        m_projectPath = aPath ; //We store here the project path. Ex: ~/interface/projects
909}
910 
911/********************************************* Implementation of the method getProjectPath() ********************************************************/
912string MainWindow::getProjectPath() {
913 
914        return m_projectPath; 
915}
916
917/********************************************* Implementation of the method setActiveProject(const bool aBool) ***********************************/
918void MainWindow::setActiveProject(const bool aBool) {
919
920        m_activeProject = aBool;
921}
922
923/********************************************* Implementation of the method isActiveProject() ***********************************/
924 bool MainWindow::isActiveProject() {
925
926        return m_activeProject; 
927}
928
929/**************************************** Implementation of the method generateDFile(string destination) (SLOT) *****************************/
930void MainWindow::generateDFile(string destination) {
931       
932        date = new QDateEdit;
933                 date->setDate(QDate::currentDate());
934
935       
936        try
937                {
938                        filename = getProjectName();
939                        filepath = destination + filename + "/" + filename + ".d"; //"projects/test/test.d";
940                        ofstream description(filepath.c_str(), ios::out | ios::binary | ios::trunc);
941
942                        if(!description.is_open())
943                                throw ofstream::failure("couldn't create " + filename);
944                        description << "#-------------------------------------------------------------------------------------------------" << endl;
945                        description << "#---Fichier " + filename + ".d généré par visual Yao le " << date->date().toString().toStdString()  << endl;
946                        description << "#-------------------------------------------------------------------------------------------------" << endl;
947
948                        if (!theConstantTable.empty()) {
949                        description << "#DEFVAL name value -------------------------------------------------------------------------------" << endl;
950                                for (Table<Constant>::iterator it = theConstantTable.begin(); it != theConstantTable.end(); it++)
951                                        description << "defval " << it->getName() << " " << it->getText() << endl;
952                                        description << endl;
953                        }
954                        if (!theHeaderList.empty()) {
955                        description << "#HATNAME fileList --------------------------------------------------------------------------------" << endl;
956                                for(vector <string>::iterator it = theHeaderList.begin(); it != theHeaderList.end(); it++)
957                                        description << "hat_name \"" << it->c_str() << "\"" << endl;
958                                        description << endl;
959                        }
960                        if (!theContextData.empty()) {
961                        description << "#OPTION (optionAttribute)+ ---------------------------------------------------------------------" << endl;
962                        description << /*m_contextWindow->getContextParameters()*/ theContextData << endl; //"option " << it->toStdString() << endl;
963                //      cout << m_contextWindow->getContextParameters() << endl; //"option " << it->toStdString() << endl;
964                                        description << endl;
965                        }
966                        if (!theTrajectoryTable.empty()) {
967                        description << "#TRAJ name type uptime offtime dtime steptime ------------------------------------------" << endl;
968                                for (Table<Trajectory>::iterator it = theTrajectoryTable.begin(); it != theTrajectoryTable.end(); it++)
969                                        description << "traj " << it->getName() << " " << it->getType() << " " << it->getBoot() << " "  << it->getOffset() << " " << it->getStep() << " " << it->getSize()<< " " << endl;
970                                        description << endl;
971                        }
972                        if(!theSpaceTable.empty()){
973                        description << "#SPACE name type dim1 [[dim2]---[dim3]] traj ---------------------------------------------------" << endl; 
974                                for (Table<Space>::iterator it = theSpaceTable.begin(); it != theSpaceTable.end(); it++)
975                                        description << "space " << it->getProperty(0) << " M " << it->getProperty(1) << " " << it->getProperty(2) << endl;
976                                        description << endl;
977                        }
978                        if(!theOperaTable.empty()) {
979                        description << "#OPERATOR name type shape parent --------------------------------------------------------------" << endl; 
980                                for (Table <Operator>::iterator it = theOperaTable.begin(); it != theOperaTable.end(); it++)
981                                        description << "opera " << it->getProperty(0) << " " << it->getProperty(1) << " " << it->getProperty(2) << endl;
982                                        description << endl;
983                        }
984                        if (!theNeuronTable.empty()) {
985                        description << "#NETWARD name indegree outdegree --------------------------------------------------------------" << endl;
986                                for (Table<Neuron>::iterator it = theNeuronTable.begin(); it != theNeuronTable.end(); it++)
987                                        description << "netward " << it->getName() << " " << it->getInDegree() << " " << it->getOutDegree() << endl;
988                                        description << endl;
989                        }
990                        if (!theModulTable.empty()){
991                        description << "#MODUL name parent ( modulAttribute )* --------------------------------------------------------" << endl;
992                                for (Table<Modul>::iterator it = theModulTable.begin(); it != theModulTable.end(); it++) {
993                                        string parentType = it->isSpaceOrOperator()? "space " : "operator ";
994                                        string aString =  "modul " + it->getName() + " " + parentType + it->getSpaceOrOperator(); 
995                                        if (!it->getInput())
996                                                aString.append(" input " + it->getInput());
997                                        description << aString << " " << "output "<< it->getOutput() << " " << "target " << it->getTarget()<< endl;
998                                }
999                                        description << endl;
1000                        }
1001                        if (!theConnectionTable.empty()){
1002                        description << "#CONNECTIONS name range[0] FROM! name range[1] range_i ( range_jkt )? -------------------------" << endl;
1003                                 for (Table<Connection>::iterator it = theConnectionTable.begin(); it != theConnectionTable.end(); it++)
1004                                        description << "ctin " << it->getInModule() << " " << it->getIn() << " from " << it->getOutModule() << " " << it->getOut() /*<< it->getI() */<< endl; 
1005
1006                                        description << endl;
1007                        }
1008                        if (!theFunctionTable.empty()) {
1009                        description << "#USER FUNCTIONS  ( ARG )? name ----------------------------------------------------------------" << endl;
1010                                for (Table<Function>::iterator it = theFunctionTable.begin(); it != theFunctionTable.end(); it++) {
1011                                        string aString = it->isParameterized()? "arg" : "   ";
1012                                        description << "insert_fct " << aString << " " << it->getName() << endl;
1013                                        }
1014                                        //description << endl;
1015                        }
1016
1017                        /*    for (QStringList::iterator it = m_insertFCTWindow->getDataFCT().begin(); it != m_insertFCTWindow->getDataFCT().end(); it++)
1018                        description << "insert_fct " << it->toStdString() << endl;
1019                        description << endl;
1020*/
1021
1022                        description.close();
1023                }
1024
1025                catch (...) 
1026                        {
1027
1028                                QMessageBox::critical(this, "Erreur", "Erreur dans la generation du fichier .d");
1029                        }
1030}
1031
1032/**************************************** Implementation of the method generateIFile() (SLOT) ****************************************************/
1033void MainWindow::generateIFile(string destination) {
1034       
1035        date = new QDateEdit;
1036                 date->setDate(QDate::currentDate());
1037
1038try
1039                {
1040                        filename = getProjectName();
1041                        filepath = destination + filename + "/" + filename + ".i"; //"projects/test/test.d";
1042                        ofstream instruction(filepath.c_str(), ios::out | ios::binary | ios::trunc);
1043
1044                        if(!instruction.is_open())
1045                                throw ofstream::failure("couldn't create " + filename);
1046                        instruction << "#-------------------------------------------------------------------------------------------------" << endl;
1047                        instruction << "#---Fichier " + filename + ".i généré par visual Yao le " << date->date().toString().toStdString()  << endl;
1048                        instruction << "#-------------------------------------------------------------------------------------------------" << endl;
1049                       
1050                        if (!iw->getInstruction().isEmpty()) {
1051                       
1052                        for (vector <string>::iterator it = theInstructionData.begin(); it != theInstructionData.end(); it++)
1053
1054                                instruction << it->c_str() << endl;
1055                       
1056                                instruction << endl;
1057                               
1058                                //emit activeTheIAction();
1059                        }
1060                        instruction.close();
1061
1062                        QMessageBox::about(this, "Avis", "Le fichier " +QString(getProjectName().c_str())+".i a été généré avec succÚs.");
1063                       
1064                }
1065
1066                catch (...) 
1067                        {
1068
1069                                QMessageBox::critical(this, "Erreur", "Erreur dans la generation du fichier .i");
1070                        }
1071
1072
1073}
1074
1075/********************************************* Implementation of the method instructionFileManager() *********************************************/
1076void MainWindow::instructionFileManager() {
1077
1078       
1079        iw = new InstructionWindow(&theInstructionData, &theFunctionTable) ;
1080        espace.addWindow(iw)->move(0, 0); 
1081        iw->show();     
1082
1083        connect(iw, SIGNAL(activeTheIAction()), this, SLOT(enableIAction()));
1084}
1085
1086/********************************************* Implementation of the method initializeWindow(int anInt) *********************************************/
1087void MainWindow::initializeWindow(int anInt) {
1088
1089        switch (anInt) {
1090       
1091                case 1: { 
1092                                m_constantWindow = NULL; 
1093                                break;
1094                        }
1095                case 2: { 
1096                                m_hatnameWindow = NULL; 
1097                                break;
1098                        }
1099                case 3: { 
1100                                m_contextWindow  = NULL; 
1101                                break;
1102                        }
1103                case 4: { 
1104                                m_trajectoryWindow = NULL; 
1105                                break;
1106                        }
1107                case 5: { 
1108                                m_spaceWindow = NULL; 
1109                                break;
1110                        }
1111                case 6: { 
1112                                m_operaWindow = NULL; 
1113                        }       break;
1114                case 7: {               
1115                                m_netwardWindow = NULL; 
1116                                break;
1117                        }
1118                case 8: { 
1119                                m_modulWindow = NULL; 
1120                                break;
1121                        }
1122                case 9: { 
1123                                m_ctinWindow = NULL; 
1124                                break;
1125                        }
1126                case 10: { 
1127                                m_orderWindow = NULL; 
1128                                break;
1129                        }
1130                case 11: { 
1131                                m_insertFCTWindow = NULL; 
1132                                break;
1133                        }
1134                default:  m_constantWindow = NULL;  m_hatnameWindow = NULL;  m_contextWindow  = NULL; m_trajectoryWindow = NULL;  m_spaceWindow = NULL;m_spaceWindow = NULL; m_operaWindow = NULL;  m_netwardWindow = NULL;   m_modulWindow = NULL;   m_ctinWindow = NULL;  m_orderWindow = NULL; m_insertFCTWindow = NULL; 
1135        }
1136       
1137}
1138
1139/*********************************** Implementation of the method changeButtonColor() (SLOT) ********************************************************/
1140void MainWindow::changeButtonColor(QPushButton *aButton) {
1141
1142        aButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1143
1144}
1145
1146/*********************************** Implementation of the method changeColorConstantButton() (SLOT) ***********************************************/
1147void MainWindow::changeColorConstantButton() {
1148
1149        changeButtonColor(m_constantButton);
1150
1151}
1152
1153/*********************************** Implementation of the method changeColorHatButton() (SLOT) ***************************************************/
1154void MainWindow::changeColorHatButton() {
1155
1156        m_hatNameButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1157}
1158
1159/*********************************** Implementation of the method changeColorContextButton() (SLOT) ************************************************/
1160 void MainWindow::changeColorContextButton() {
1161
1162        m_contextButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1163 }
1164
1165/************************************ Implementation of the method changeColorTrajButton() (SLOT) ***************************************************/
1166void MainWindow::changeColorTrajButton() {
1167
1168        m_trajButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1169}
1170
1171/************************************* Implementation of the method changeColorSpaceButton() (SLOT) *************************************************/
1172void MainWindow::changeColorSpaceButton() {
1173
1174        m_spaceButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1175
1176}
1177/********************************** Implementation of the method changeColorOperaButton() (SLOT) *****************************************************/
1178void MainWindow::changeColorOperaButton() {
1179 
1180        m_operaButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1181 
1182 }
1183
1184/*********************************** Implementation of the method changeColorModulButton() (SLOT) *************************************************/
1185void MainWindow::changeColorModulButton() {
1186
1187        m_modulButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1188}
1189
1190/************************************ Implementation of the method changeColorCtinButton() (SLOT) **************************************************/
1191void MainWindow::changeColorCtinButton() {
1192
1193        m_ctinButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1194
1195}
1196
1197/********************************* Implementation of the method changeColorNetwardButton() (SLOT) **************************************************/
1198void MainWindow::changeColorNetwardButton() {
1199
1200        m_netwardButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1201
1202}
1203/************************************* Implementation of the method changeColorInsertFCTButton() ***************************************************/
1204void MainWindow::changeColorInsertFCTButton() {
1205
1206        m_insertFCTButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1207
1208}
1209
1210/************************************ Implementation of the method changeColorOrderButton() whitch is a SLOT **********************************************/
1211void MainWindow::changeColorOrderButton() {
1212
1213        m_orderButton->setStyleSheet("background-color: rgb(180, 180, 180)");
1214
1215}
1216
1217/*********************************** Implementation of the virtual method closeEvent() ************************************************************/
1218/*void MainWindow::closeEvent(QCloseEvent *event) {
1219       
1220      if (maybeSave()) {
1221            //writeSettings();
1222            event->accept();
1223      }
1224        else
1225            event->ignore();
1226     
1227}*/
1228/********************************** **/
1229
1230/*********************************** Implementation of the destructor method (~MainWindow()) *******************************************************/
1231/*MainWindow::~MainWindow() {
1232
1233                    delete menuFichier;
1234                    delete menuEdition;
1235                    delete menuAffichage;
1236                    delete menuExecution;
1237                    delete menuConfig;
1238                    delete menuAide;
1239                    delete actionFichierDescription;
1240                    delete actionFichierHat;
1241                    delete actionFichierInstruction;
1242                    delete actionGrapheModulaire;
1243                    delete actionInfosProjet;
1244                    delete actionNouveauProjet;
1245                    delete actionOuvrirProjet;
1246                    delete actionOuvrirProjetsRecents;
1247                    delete actionSaveProject;
1248                    delete actionSaveAsProject;
1249                    delete actionImprimerProjet;
1250                    delete actionSortieProjet;
1251                    delete actionCacherBarreOutils;
1252                    delete actionCacherFenetreApercu;
1253                    delete actionCacherFenetreProjet;
1254                    delete actionCacherFenetreDialog;
1255                    delete actionGenerationD;
1256                    delete actionCompilation;
1257                    delete actionExecution;
1258                    delete actionEditeur;
1259                    delete actionDocYao;
1260                    delete actionRapport;
1261                    delete m_contextButton;
1262                    delete m_trajButton;
1263                    delete m_spaceButton;
1264                    delete m_operaButton;
1265                    delete m_netwardButton;
1266                    delete m_modulButton;
1267                    delete m_ctinButton;
1268                    delete m_orderButton;
1269                    delete m_insertFCTButton;
1270                    delete yaoToolBar;
1271                    delete tableWidget;
1272}*/
1273/************************************* Enf of the destructor method. ******************************************************************************/
1274/*************************************          End of file.         ******************************************************************************/
1275/**************************************************************************************************************************************************/
Note: See TracBrowser for help on using the repository browser.