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

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

In some class, the class predefined method is implemented. This will reduce the compilation time.

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