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
RevLine 
[171]1//! \file    MainWindow.cpp
2//! \brief   Implementation of the main Visual_YAO code.
[341]3//! \version 2010
4//! \author  MAYAKI Abdouramane
[171]5/*
6  Nom du Fichier: MainWindow.cpp
7  Nom de classe: MainWindow
[271]8  Role: Outre son role de fichier d'implémentation des méthodes, ce fichier gÚre toutes les fenêtres graphiques.
[356]9  Nombre de methodes: 50
10  Nombre d'attributs: 81
[171]11  */
12
[315]13#include "include/MainWindow.hpp"
[171]14#include<iostream>
15
[254]16using namespace std;
[393]17//using namespace antlr;
[291]18using namespace yao;
[335]19
[171]20//! \class MainWindow(QWidget *parent) : QMainWindow(parent)
21//! \brief Implementation of the Main window for visual_YAO.
22
[335]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 */
[320]30/**************************************** Implementation of the constructor MainWindow() *************************************************************/
[171]31/*
32  Implementation du constructeur de la classe MainWindow
33
34*/
35
[470]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)     
[366]37{
[437]38
[341]39        setWindowTitle(" Visual YAO ");         //Gives a title to the mainwindow.
[362]40        pt_espace = new QWorkspace;                             //Crée un espace de travail. Ici, ça serait notre zone centrale
41                pt_espace = &espace;
[171]42        fv  = new FilesViewer();                        //Création d'un espace montrant l'arborescence des fichiers sur le disque dûr.
43       
[216]44        fenetreProjet                 = new QDockWidget("Aperçu des projets: ", this); // Réservation de l'espace pour la fenêtre projet
[171]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.
[216]47        QDockWidget *dock2            = new QDockWidget("", this);
[171]48        addDockWidget(Qt::LeftDockWidgetArea, fenetreProjet); //Positionnement de la fenêtre projet à gauche dans la QMainWindow.
[216]49        addDockWidget(Qt::LeftDockWidgetArea, dock2);
[171]50       
[362]51        setCentralWidget(pt_espace);    //Ici, se précise la zone centrale de la QMainWindow.
[357]52       
[171]53        // Appel des differentes méthodes crées.
[270]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
[171]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);
[295]62
[171]63        tabWidget = new QTabWidget(dock3);//(this);
[216]64        dock3->setWidget(tabWidget); 
[295]65        page1 = new QWidget();
66        tabWidget->addTab(page1, "          Compilation               ");
67        page2 = new QWidget();
68        tabWidget->addTab(page2, "                 Exécution          ");
[476]69       
70        //Editor *edit = new Editor;
71        //pt_espace->addWindow(editor);
72        //editor->show();
[171]73
[300]74        connect(this, SIGNAL(WindowTitleChanged()), this, SLOT(setTitle()));
[295]75        this->showMaximized(); // Maximise toujours la fenetre principale.
[363]76               
77       
[171]78}
[389]79
[419]80/*************************************** Implementation of the contructor MainWindow(Table <Constant> aConstant) *********************************/
[391]81MainWindow::MainWindow(Table <Constant> aConstantTable): theConstantTablePt(aConstantTable)
82{
83        theConstantTablePt = aConstantTable;
84        //theConstantTable;                     
85}
86
87/******************************************* Implementation of the method setTitle() *****************************************************************/
[300]88void MainWindow::setTitle() {
[171]89
[397]90        QWidget::setWindowTitle(tr("%1[*]  %2").arg("Projet:").arg(QString(getProjectName().c_str())));
[300]91
92}
93
[335]94/************************************ Implementation of the method createMenus() *******************************************************************/
[270]95void MainWindow::createMenus() {
[171]96
[366]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();
[393]104                menuFichier->addAction(actionSaveProject);
[397]105                menuFichier->addAction(actionSaveAsProject);
[366]106                menuFichier->addSeparator();
107                menuFichier->addAction(actionSortieProjet);
108        menuEdition = menuBar()->addMenu("&Edition");
[436]109                //menuEdition->addAction(actionFichierDescription);
110                //menuEdition->addAction(actionFichierHat);
[366]111                //nouveau->addAction(actionModule);
112                menuEdition->addAction(actionFichierInstruction);
113                menuEdition->addAction(actionGrapheModulaire);
[436]114                //menuEdition->addAction(actionInfosProjet);
[171]115
[366]116        menuAffichage = menuBar()->addMenu("&Affichage");
117                menuAffichage->addAction(actionCacherBarreOutils);
[171]118
[366]119                menuAffichage->addAction(actionCacherFenetreApercu);
120                menuAffichage->addAction(actionCacherFenetreProjet);
121                menuAffichage->addAction(actionCacherFenetreDialog);
122        menuExecution = menuBar()->addMenu("&Exécution");
123                menuExecution->addAction(actionGenerationD);
[437]124                menuExecution->addAction(actionGenerationI);
[366]125                menuExecution->addAction(actionCompilation);
126                menuExecution->addAction(actionExecution);
[449]127               
[366]128        menuConfig    = menuBar()->addMenu("&Configuration");
129                menuConfig->addAction(actionEditeur);
130        menuAide = menuBar()->addMenu(tr("&Aide"));
131                menuAide->addAction(actionDocYao);
132                menuAide->addAction(actionRapport);
[171]133
134}
135
[320]136/******************************** Implementation of the method Implémentation de la methode createActions() ****************************************/
[270]137void MainWindow::createActions()  {
[171]138
[437]139       
140        QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
[366]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"));
[171]146
[366]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
[386]156                connect(actionOuvrirProjet, SIGNAL(triggered()), this, SLOT(openProject()));
[366]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());
[393]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");
[419]174                connect(actionSaveProject, SIGNAL(triggered()), this, SLOT(save()));
[397]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()));
[366]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
[171]190     // Les actions du menu Edition
[436]191        //actionFichierDescription = new QAction(tr("Fichier de description (.d)"), this);
[171]192
[436]193                //connect(actionFichierDescription, SIGNAL(triggered()), this, SLOT(generateDFile()));
[171]194
[436]195        //actionFichierHat = new QAction(tr("Fichier  (.h)"), this);
196                //actionModule = new QAction(tr("Modul"), this);
[437]197        actionFichierInstruction = new QAction(tr("Fichier d'instruction (.i)"), this);
[436]198                connect(actionFichierInstruction, SIGNAL(triggered()), this, SLOT(instructionFileManager()));
[366]199        actionGrapheModulaire = new QAction(tr("Graphe modulaire"), this);
[436]200        //actionInfosProjet = new QAction(tr("Edition infos projet"), this);
[171]201
202     // Les actions du menu Affichage
[366]203        actionCacherBarreOutils = new QAction(tr("Cacher la barre d'outils"), this);
204                actionCacherBarreOutils->setCheckable(true);
[171]205
[366]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
[171]216     // Les actions du menu Execution
[437]217        actionGenerationD = new QAction(this);
[366]218                actionGenerationD->setEnabled(false);
[437]219                actionGenerationD->setText("Générer le fichier .d");
[171]220
[470]221                connect(actionGenerationD, SIGNAL(triggered()), this, SLOT(callGenerateDFile()));
[419]222                //connect(actionGenerationD, SIGNAL(triggered()), this, SLOT(information()));
[171]223
[437]224        actionGenerationI = new QAction(this);
[449]225                actionGenerationI->setEnabled(false);
[437]226                actionGenerationI->setText("Générer le fichier .i"); 
227                connect(actionGenerationI, SIGNAL(triggered()), this, SLOT(generateIFile()));
228
[366]229        actionCompilation = new QAction(tr("Compilation"), this);
230                actionCompilation->setEnabled(false);
[437]231        actionExecution = new QAction(this);
[366]232                actionExecution->setEnabled(false);
[437]233                actionExecution->setText("Exécution");
[366]234
[171]235     // Les actions du menu Configuration
[366]236        actionEditeur = new QAction(tr("Editeur par defaut"), this);
[171]237
238     // Les actions du menu Aide
[366]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);
[171]242
243     // Les actions de la barre d'outils
244
[366]245        toolBarActions(espace);
[171]246
247}
[459]248
[460]249/********************************* Implementation of the enableIAction() method ***************************************************************************/
[449]250void MainWindow::enableIAction() {
[171]251
[449]252        actionGenerationI->setEnabled(true);
253
254}
[459]255
[460]256/********************************* Implementation of the createToolBar() method ****************************************/
[270]257void MainWindow::createToolBar() {
[171]258
[366]259        yaoToolBar = addToolBar(tr("&YaoToolbar"));
[171]260
[366]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);
[171]274
275}
276
[460]277/******************************** Implementation of the cacherBarreOutils() method ***************************************/
[171]278void MainWindow::cacherBarreOutils() {
279
[295]280        yaoToolBar->hide();
281        barreEtat->showMessage(tr("La barre des outils est cachée!"), 2000);
282
[171]283}
[391]284
[460]285/********************************** Implementation of the toolBarActions() method ****************************************/
[366]286void MainWindow::toolBarActions(QWorkspace &espace) 
287{
[171]288
[366]289        m_constantButton    = new QPushButton(tr("Defval"), this);
[400]290                //m_constantButton->setToolTip("Bouton désactivé. Vous devez d'abord creer un nouveau projet ou en ouvrir un.");
[366]291                connect(m_constantButton, SIGNAL(clicked()), this, SLOT(createDefvalWindow()));
292                connect(m_constantButton, SIGNAL(clicked()), this, SLOT(changeColorConstantButton()));
[317]293       
[366]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()));
[289]297 
[366]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()));
[171]301
[366]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()));
[171]326
[366]327        desactivateToolBarButtons(); // Désactive tous les boutons de la barre d'outils
[171]328}
[391]329
[460]330/*********************************************** Implementation of the createDefvalWindow() method *************************************************/
[366]331void MainWindow::createDefvalWindow() 
332{
[317]333
[349]334        if (m_constantWindow == NULL) { //to test if the object is already created.
[317]335
[366]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.
[317]339        }
340
[349]341        connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(hatUpdate()));
342        connect(m_constantWindow, SIGNAL(rowIsDeleted(QString )), this, SLOT(hatUpdate(QString )));
[459]343        connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(trajUpdate()));
[429]344        //connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(contextUpdate()));
[397]345        connect(m_constantWindow, SIGNAL(rowIsAdded()), this, SLOT(mainWindowIsModified()));
[349]346        connect(m_constantWindow, SIGNAL(windowIsClosed(int )), this, SLOT(initializeWindow(int )));// The signal is in the ConstantWindow.hpp file.
[476]347        //connect(m_constantWindow, SIGNAL(clicked(bool )), , SLOT(hatUpdate()));
[317]348
349}
[391]350
[460]351/******************************************** Implementation of the createHatNameWindow() method ***************************************************/
[317]352void MainWindow::createHatNameWindow() {
353
[349]354        if (m_hatnameWindow == NULL) { //to test if the object is already created.
[317]355
[366]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.
[317]359        }
360
[349]361        connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
[317]362}
[391]363
[320]364/********************************************* Implementation of the method createContextWindow() *************************************************/
365void MainWindow::createContextWindow() {
[317]366
[349]367        if (m_contextWindow == NULL) { //to test if the object is already created.
[317]368
[466]369                m_contextWindow = new ContextWindow(&theContext, &theConstantTable, &theContextData); //mwc.getContext();
[366]370                espace.addWindow(m_contextWindow)->move(5, 0);
371                m_contextWindow->show();
[428]372                contextTest = true;
[320]373        }
374
[349]375        connect(m_contextWindow, SIGNAL(contextWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
[320]376}
[391]377
[320]378/********************************************* Implementation of the method createTrajectoryWindow() ************************************************/
379void MainWindow::createTrajectoryWindow() {
380
[349]381        if (m_trajectoryWindow == NULL) { //to test if the object is already created.
[320]382
[366]383                m_trajectoryWindow = new TrajectoryWindow(&theTrajectoryTable, &theConstantTable); //mwc.getTraj();
384                espace.addWindow(m_trajectoryWindow)->move(30, 10);
385                m_trajectoryWindow->show(); 
[320]386
387        }
388
[349]389        connect(m_trajectoryWindow, SIGNAL(trajectoryWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
[358]390        connect(m_trajectoryWindow, SIGNAL(trajRowIsAdded(bool)), m_spaceButton, SLOT(setEnabled(bool)));
391        connect(m_trajectoryWindow, SIGNAL(trajRowIsAdded(bool)), m_operaButton, SLOT(setEnabled(bool)));
[320]392}
[391]393
[320]394/********************************************* Implementation of the method createSpaceWindow() ************************************************/
395void MainWindow::createSpaceWindow() {
396
[349]397        if (m_spaceWindow == NULL) { //to test if the object is already created.
[320]398       
[366]399                m_spaceWindow = new SpaceWindow(&theSpaceTable, &theTrajectoryTable, &theConstantTable); //mwc.getSpace();
400                espace.addWindow(m_spaceWindow)->move(30, 20);
401                m_spaceWindow->show(); 
[320]402        }
403
[349]404        connect(m_spaceWindow, SIGNAL(spaceWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
[381]405        connect(m_spaceWindow, SIGNAL(spaceRowIsAdded(bool)), m_modulButton, SLOT(setEnabled(bool)));
[320]406}
[349]407
408/********************************************* Implementation of the method createOperaWindow() ************************************************/
409void MainWindow::createOperaWindow() {
410
411        if (m_operaWindow == NULL) { //to test if the object is already created.
[377]412                m_operaWindow =  new OperaWindow(&theOperaTable, &theTrajectoryTable, &theConstantTable); //mwc.getOpera();
[362]413                espace.addWindow(m_operaWindow)->move(5, 8);
[349]414                m_operaWindow->show(); 
415        }
416
[350]417        connect(m_operaWindow, SIGNAL(operaWindowIsClosed(int )), this, SLOT(initializeWindow(int )));
[381]418        //connect(m_operaWindow, SIGNAL(operaRowIsAdded(bool)), m_modulButton, SLOT(setEnabled(bool)));
[349]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.
[370]425                m_netwardWindow = new NetwardWindow(&theNeuronTable, &theConstantTable); //mwc.getNetward();
[362]426                espace.addWindow(m_netwardWindow)->move(5, 15);
[349]427                m_netwardWindow->show();
428        }
[350]429        connect(m_netwardWindow, SIGNAL(netwardWindowIsClosed(int )), this, SLOT(initializeWindow(int )));
[349]430        //connect(m_netwardButton, SIGNAL(clicked()), this, SLOT(changeColorNetwardButton()));
431}
[391]432
[341]433/********************************************* Implementation of the method createModulWindow() ************************************************/
434void MainWindow::createModulWindow() {
435
[349]436        if (m_modulWindow == NULL) { //to test if the object is already created.
[371]437                m_modulWindow = new ModulWindow(&theModulTable, &theSpaceTable, &theOperaTable, &theConstantTable, &the_mwc, &m_newProjectName, &m_projectPath); //mwc.getModul();
[362]438                espace.addWindow(m_modulWindow)->move(30, 15);
[351]439                m_modulWindow->show(); 
[341]440        }
441
[349]442        connect(m_modulWindow, SIGNAL(modulWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
[459]443        connect(m_modulWindow, SIGNAL(modulRowIsAdded(bool)), m_ctinButton, SLOT(setEnabled(bool)));
[341]444}
[351]445
446/********************************************* Implementation of the method createCtinWindow() ************************************************/
447void MainWindow::createCtinWindow() {
448
449        if (m_ctinWindow == NULL) { //to test if the object is already created.
[381]450                m_ctinWindow = new ConnectionWindow(&theConnectionTable, &theModulTable, &theConstantTable); //mwc.getCtin();
[362]451                espace.addWindow(m_ctinWindow)->move(0, 0);
[351]452                m_ctinWindow->show();
453        }
454
455        connect(m_ctinWindow, SIGNAL(ctinWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
[459]456        connect(m_ctinWindow, SIGNAL(ctinRowIsAdded(bool)), m_orderButton, SLOT(setEnabled(bool)));
[351]457}
[391]458
[351]459/********************************************* Implementation of the method createOrderWindow() ************************************************/
460void MainWindow::createOrderWindow() {
461
462        if (m_orderWindow == NULL) { //to test if the object is already created.
[471]463                m_orderWindow = new OrderWindow(&theTrajectoryTable, &theSpaceTable, &theOperaTable, &theModulTable, &theOrderTable); //mwc.getOrder();
[362]464                espace.addWindow(m_orderWindow)->move(2, 0);
[351]465                m_orderWindow->show();
466        }
467
468        connect(m_orderWindow, SIGNAL(orderWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
469
470}
[391]471
[351]472/********************************************* Implementation of the method createInsertFCTWindow() ************************************************/
473void MainWindow::createInsertFCTWindow() {
474
475        if (m_insertFCTWindow == NULL) { //to test if the object is already created.
[365]476                m_insertFCTWindow = new InsertFCTWindow(&theFunctionTable); //mwc.getInsertFCT();
[362]477                espace.addWindow(m_insertFCTWindow)->move(30, 20);
[351]478                m_insertFCTWindow->show();
479        }
480
481        connect(m_insertFCTWindow, SIGNAL(insertFCTWindowIsClosed(int)), this, SLOT(initializeWindow(int)));
482
483}
[391]484
[320]485/********************************************* Implementation of the method directivesManage() *****************************************************/
[268]486void MainWindow::directivesManager() {
487
[304]488        theHeaderList.push_back(getProjectName() + ".h") ; 
[289]489       
[268]490}
[317]491
[320]492/*********************************** Implementation of the method activateToolBarButtons() *********************************************************/
[270]493void MainWindow::activateToolBarButtons() {
[171]494
[366]495        m_constantButton->setEnabled(true);
496        m_hatNameButton->setEnabled(true);
497        m_contextButton->setEnabled(true);
498        m_trajButton->setEnabled(true);
[431]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);
[366]501        m_netwardButton->setEnabled(true);
[431]502         theModulTable.empty() == true ? m_modulButton->setEnabled(false): m_modulButton->setEnabled(true);
503       
[459]504        m_ctinButton->setEnabled(false);
505         theModulTable.empty() == true ? m_ctinButton->setEnabled(false): m_ctinButton->setEnabled(true);
[366]506        m_orderButton->setEnabled(true);
[460]507         //theModulTable.empty() == true ? m_orderButton->setEnabled(false): m_orderButton->setEnabled(true);
[366]508        m_insertFCTButton->setEnabled(true);
[391]509}
[171]510
[320]511/********************************** Implementation of the method desactivateToolBarButtons() *******************************************************/
[270]512void MainWindow::desactivateToolBarButtons() {
[171]513
[263]514        m_constantButton->setEnabled(false);
[171]515        m_hatNameButton->setEnabled(false);
[263]516        m_contextButton->setEnabled(false);
[171]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
[320]527/**************************************** Implementation of the method nouveauProjet (SLOT) *******************************************************/
[254]528void MainWindow::createNewProjectWindow()       { // Affiche la fenetre nouveau projet lorsqu'elle est appelée.
[366]529
[453]530        //clearAllStructures();
[429]531        espace.closeAllWindows(); 
[454]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.
[371]534        m_projectPath = m_newProjectWindow->getProjectPath();
[453]535        if (!m_newProjectName.empty()) {
[455]536                clearAllStructures();// To eraze Yao structure before creating the new project.
[453]537                theHeaderList.push_back(m_newProjectWindow->getProjectName() + ".h");
[454]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.
[470]541                actionSaveAsProject->setEnabled(true); // Option désactivée par défaut.
[453]542        }
[455]543        fv->updateTheView(); //Permet de mettre à jour automatiquement la liste des fichiers visibles dans filesviewer.
[364]544        //connect(m_newProjectWindow, SIGNAL(newProjectIsCreated()), this, SLOT(activateToolBarButtons()));
[453]545        //      connect(m_newProjectWindow, SIGNAL(projectDone()), this, SLOT(clearAllStructures()));
[216]546}
[278]547
[429]548/*************************************** Implementation of the method clearAllStrutures() *********************************************************/
549void MainWindow::clearAllStructures() {
550
551
[454]552        theConstantTable.clear();//Erase data from Table <Constant>
[429]553        theHeaderList.clear();
554        theTrajectoryTable.clear();
555        theSpaceTable.clear();
556        theOperaTable.clear();
557        theNeuronTable.clear();
558        theModulTable.clear();
559        theConnectionTable.clear();
560        theFunctionTable.clear();       
[454]561       
[460]562        //To restaure all buttons original color
[454]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       
[429]581}
[397]582/**************************************** Implementation of the method mainWindowIsModified() (SLOT) ************************************************/
583void MainWindow::mainWindowIsModified() {
584
585        setWindowModified(true);
586        actionSaveProject->setEnabled(true);
587        actionSaveAsProject->setEnabled(true);
588
589}
[419]590/**************************************** Implementation of the method save() (SLOT) *******************************************************/
591void MainWindow::save() {
592       
593        generateDFile();
594        setWindowModified(false);
[397]595
[419]596}
[470]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}
[397]605/**************************************** Implementation of the method saveAs() (SLOT) *******************************************************/
606void MainWindow::saveAs() {
607       
608       
609        m_newProjectWindow = new  NewProjectWindow ;
[419]610        //m_newProjectWindow->setWindowTitle("testhj");
[397]611        m_newProjectName = m_newProjectWindow->getProjectName();
612        m_projectPath = m_newProjectWindow->getProjectPath();
613        theHeaderList.push_back(m_newProjectWindow->getProjectName() + ".h");
[455]614        fv->updateTheView(); //To refresh the view from FileViewer class.
[397]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();
[419]624        generateDFile(m_projectPath + "/");
[397]625        //cout << cheminFichier.toStdString() << endl;
[470]626       
627        actionGenerationD->setEnabled(true);
[397]628
629}
[386]630/**************************************** Implementation of the method nouveauProjet (SLOT) *******************************************************/
631void MainWindow::openProject()  { // Affiche la fenetre nouveau projet lorsqu'elle est appelée.
632
[428]633
[391]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.
[419]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"
[397]642        QString test("");
[391]643        builder.setProcessChannelMode(QProcess::MergedChannels);
[419]644        builder.start("Yao9Generator " + cheminFichier);//Will execute the linux command
[393]645        if (!builder.waitForFinished())
646                qDebug() << "Make failed:" << builder.errorString();
647        else {
[419]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.
[470]650                FilePath aString, theShape, name, parent, aType, boot, offset, step, size, netname, indegree, outdegree, modname, arg;
[399]651                vector <int> theShapeVector;
[397]652
[419]653                while ( getline(iss, aString, '\n' ) ) // Here we notified that the words in the string are separated by "\n"
[391]654                        {
[467]655                                //For DEFVAL
[419]656                                if (aString.getExtension() == ".def1")//
[391]657                                {                       
[397]658                                        //cout << aString.getTitle() << endl;
659                                        name = aString;
[391]660                                }
[397]661                                if (aString.getExtension() == ".def2" && name.getExtension() == ".def1")
[391]662                                {
[397]663                                        Constant aConstant(name.getTitle(), aString.getTitle());       
[391]664                                        theConstantTable.push_back(aConstant);
665                                }
[467]666                                //For HATNAME
[397]667                                if (aString.getExtension() == ".h")
[391]668                                {
[397]669                                //      cout << aString << endl;
670                                        theHeaderList.push_back(aString);       
671                                }
[467]672                                //For TRAJ
[397]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)   
[399]699                                        //if (m_trajectoryWindow->isTrajectoryTableEmpty())
[397]700
701                                }               //theConstantTable.push_back(aString.getTitle());
[467]702                                //For SPACE
[399]703                                if (aString.getExtension() == ".sp1")//{
[397]704                                        name = aString.getTitle();
[399]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                                       
[467]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                                }
[470]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") {
[460]746                                        parent = aString.getTitle(); 
[470]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();
[460]754                                        //cout << parent << endl;
755                                        Space espace(name, theTrajectoryTable.find(parent), theShapeVector);
756                                        theSpaceTable.push_back(espace);
757                                        theShapeVector.clear();
758                                       
759                                }*/
[470]760
[467]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                                }
[399]773                        }
[391]774                       
[399]775                                //m_spaceButton->setEnabled(true);
[397]776               
[391]777        }
[397]778        if (!cheminFichier.isEmpty() && !test.isEmpty()) {
779                        activateToolBarButtons();
780                        //actionSaveProject->setEnabled(true);
781                        actionSaveAsProject->setEnabled(true);
782                }
[470]783       
784       
785       
[399]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
[391]789       
[386]790}
[391]791
[320]792/**************************************** Implementation of the method hatUpdate() ****************************************************************/
[300]793void MainWindow::hatUpdate() {
[317]794       
[355]795        if (m_hatnameWindow != NULL) //Teste si l'objet n'est pas déjà crée. S'il n'est pas
[300]796                { 
[367]797                        delete m_hatnameWindow;
[349]798                        m_hatnameWindow = new HatNameWindow(&theHeaderList, &theConstantTable); //Crée un autre objet.
[362]799                        espace.addWindow(m_hatnameWindow)->move(350, 0);
[349]800                        m_hatnameWindow->show();
[362]801                        espace.setActiveWindow(m_constantWindow);
[367]802                        //m_hatnameWindow->update();
803
804                        connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
[300]805                }
[367]806
[355]807        else
808                return;
[300]809}
[301]810
[320]811/******************************************* Implementation of the method hatUpdate(QString choix) **************************************************/
[301]812void MainWindow::hatUpdate(QString choix) {
813
[349]814        if (m_hatnameWindow != NULL) //Teste si l'objet n'est pas déjà crée.
[301]815                { 
[429]816                        m_hatnameWindow->deleteARow(choix.toStdString()); 
[459]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       
[429]826                        //delete m_hatnameWindow;
[459]827                        //cout << "Voici la chaine supprimée: " + choix.toStdString() << endl;
[429]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);
[367]832
[429]833                        //connect(m_hatnameWindow, SIGNAL(hatWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
[301]834                }
[355]835        else
836                return;
[301]837}
[391]838
[367]839/******************************************* Implementation of the method contextUpdate(QString choix) ************************************************/
[429]840/*void MainWindow::contextUpdate() {
[367]841
842        if (m_contextWindow != NULL) //Teste si l'objet n'est pas déjà crée.
843                {
844                        delete m_contextWindow ;
[428]845                        m_contextWindow = new ContextWindow(&theContext, &theConstantTable); //mwc.getContext();
[367]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;
[429]856}*/
[391]857
[429]858/******************************************* Implementation of the method trajUpdate() **************************************************/
[459]859void MainWindow::trajUpdate() {
[429]860
861        if (m_trajectoryWindow != NULL) //Teste si l'objet n'est pas déjà crée.
862                { 
[459]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();
[429]867                        espace.setActiveWindow(m_constantWindow);
868
[459]869                        connect(m_trajectoryWindow, SIGNAL(trajectoryWindowIsClosed(int)), this, SLOT(initializeWindow(int)));// The signal is in the HatNameWindow.hpp file.
[429]870                }
871        else
872                return;
[459]873}
[320]874/***************************************** Implementation of the method montrerActionGenererD() ****************************************************/
[171]875void MainWindow::montrerActionGenererD() {
[366]876
877        actionGenerationD->setEnabled(true);
[171]878}
879
[320]880/*********************************** Implementation of the method montrerActionCompilation() *******************************************************/
881void MainWindow::montrerActionCompilation() {
[171]882
[366]883        actionCompilation->setEnabled(true);
[217]884}
[391]885 
[320]886/************************************************* Implementation of the method setProjectName(string chaine) **************************************/
[260]887void MainWindow::setProjectName(string chaine) {
[254]888 
[366]889        m_newProjectName = chaine; //To initialize or to give a name for the project.
[263]890
[254]891}
[320]892/***************************************************** Implementation of the method getProjectName() **********************************************/
[260]893 string MainWindow::getProjectName() {
[254]894       
895        return m_newProjectName;
896} 
897
[320]898/************************************* Implementation of the method setProjectPath(string aPath) ******************************************/
[261]899void MainWindow::setProjectPath(string aPath) {
[254]900 
[366]901        m_projectPath = aPath ; //We store here the project path. Ex: ~/interface/projects
902}
[254]903 
[320]904/********************************************* Implementation of the method getProjectPath() ********************************************************/
[254]905string MainWindow::getProjectPath() {
906 
[366]907        return m_projectPath; 
908}
[254]909
[397]910/********************************************* Implementation of the method setActiveProject(const bool aBool) ***********************************/
[344]911void MainWindow::setActiveProject(const bool aBool) {
[254]912
[344]913        m_activeProject = aBool;
914}
[366]915
[397]916/********************************************* Implementation of the method isActiveProject() ***********************************/
[344]917 bool MainWindow::isActiveProject() {
918
919        return m_activeProject; 
920}
[366]921
[470]922/**************************************** Implementation of the method generateDFile(string destination) (SLOT) *****************************/
[397]923void MainWindow::generateDFile(string destination) {
924       
925        date = new QDateEdit;
926                 date->setDate(QDate::currentDate());
[356]927
[397]928       
[366]929        try
930                {
931                        filename = getProjectName();
[397]932                        filepath = destination + filename + "/" + filename + ".d"; //"projects/test/test.d";
[366]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);
[397]937                        description << "#-------------------------------------------------------------------------------------------------" << endl;
[445]938                        description << "#---Fichier " + filename + ".d généré par visual Yao le " << date->date().toString().toStdString()  << endl;
[397]939                        description << "#-------------------------------------------------------------------------------------------------" << endl;
940
[388]941                        if (!theConstantTable.empty()) {
[397]942                        description << "#DEFVAL name value -------------------------------------------------------------------------------" << endl;
[366]943                                for (Table<Constant>::iterator it = theConstantTable.begin(); it != theConstantTable.end(); it++)
[369]944                                        description << "defval " << it->getName() << " " << it->getText() << endl;
[366]945                                        description << endl;
[388]946                        }
947                        if (!theHeaderList.empty()) {
[397]948                        description << "#HATNAME fileList --------------------------------------------------------------------------------" << endl;
[366]949                                for(vector <string>::iterator it = theHeaderList.begin(); it != theHeaderList.end(); it++)
950                                        description << "hat_name \"" << it->c_str() << "\"" << endl;
951                                        description << endl;
[388]952                        }
[466]953                        if (!theContextData.empty()) {
[428]954                        description << "#OPTION (optionAttribute)+ ---------------------------------------------------------------------" << endl;
[466]955                        description << /*m_contextWindow->getContextParameters()*/ theContextData << endl; //"option " << it->toStdString() << endl;
[428]956                //      cout << m_contextWindow->getContextParameters() << endl; //"option " << it->toStdString() << endl;
957                                        description << endl;
[466]958                        }
[388]959                        if (!theTrajectoryTable.empty()) {
[419]960                        description << "#TRAJ name type uptime offtime dtime steptime ------------------------------------------" << endl;
[366]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;
[388]964                        }
965                        if(!theSpaceTable.empty()){
[397]966                        description << "#SPACE name type dim1 [[dim2]---[dim3]] traj ---------------------------------------------------" << endl; 
[366]967                                for (Table<Space>::iterator it = theSpaceTable.begin(); it != theSpaceTable.end(); it++)
[419]968                                        description << "space " << it->getProperty(0) << " M " << it->getProperty(1) << " " << it->getProperty(2) << endl;
[366]969                                        description << endl;
[388]970                        }
971                        if(!theOperaTable.empty()) {
[397]972                        description << "#OPERATOR name type shape parent --------------------------------------------------------------" << endl; 
[377]973                                for (Table <Operator>::iterator it = theOperaTable.begin(); it != theOperaTable.end(); it++)
[369]974                                        description << "opera " << it->getProperty(0) << " " << it->getProperty(1) << " " << it->getProperty(2) << endl;
[428]975                                        description << endl;
[388]976                        }
977                        if (!theNeuronTable.empty()) {
[397]978                        description << "#NETWARD name indegree outdegree --------------------------------------------------------------" << endl;
[370]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;
[388]982                        }
983                        if (!theModulTable.empty()){
[397]984                        description << "#MODUL name parent ( modulAttribute )* --------------------------------------------------------" << endl;
[400]985                                for (Table<Modul>::iterator it = theModulTable.begin(); it != theModulTable.end(); it++) {
986                                        string parentType = it->isSpaceOrOperator()? "space " : "operator ";
[470]987                                        string aString =  "modul " + it->getName() + " " + parentType + it->getSpaceOrOperator(); 
988                                        if (!it->getInput())
989                                                aString.append(" input " + it->getInput());
[474]990                                        description << aString << " " << "output "<< it->getOutput() << " " << "target " << it->getTarget()<< endl;
[400]991                                }
[378]992                                        description << endl;
[388]993                        }
[444]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++)
[466]997                                        description << "ctin " << it->getInModule() << " " << it->getIn() << " from " << it->getOutModule() << " " << it->getOut() /*<< it->getI() */<< endl; 
[444]998
[428]999                                        description << endl;
[444]1000                        }
[388]1001                        if (!theFunctionTable.empty()) {
[397]1002                        description << "#USER FUNCTIONS  ( ARG )? name ----------------------------------------------------------------" << endl;
[369]1003                                for (Table<Function>::iterator it = theFunctionTable.begin(); it != theFunctionTable.end(); it++) {
[371]1004                                        string aString = it->isParameterized()? "arg" : "   ";
[369]1005                                        description << "insert_fct " << aString << " " << it->getName() << endl;
1006                                        }
[397]1007                                        //description << endl;
[388]1008                        }
[397]1009
1010                        /*    for (QStringList::iterator it = m_insertFCTWindow->getDataFCT().begin(); it != m_insertFCTWindow->getDataFCT().end(); it++)
[366]1011                        description << "insert_fct " << it->toStdString() << endl;
1012                        description << endl;
[356]1013*/
1014
[366]1015                        description.close();
1016                }
[363]1017
[366]1018                catch (...) 
1019                        {
1020
1021                                QMessageBox::critical(this, "Erreur", "Erreur dans la generation du fichier .d");
1022                        }
[356]1023}
1024
[437]1025/**************************************** Implementation of the method generateIFile() (SLOT) ****************************************************/
1026void MainWindow::generateIFile(string destination) {
1027       
1028        date = new QDateEdit;
1029                 date->setDate(QDate::currentDate());
1030
[445]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);
[437]1036
[445]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;
[449]1042                       
[452]1043                        if (!iw->getInstruction().isEmpty()) {
[449]1044                       
[452]1045                        for (vector <string>::iterator it = theInstructionData.begin(); it != theInstructionData.end(); it++)
[445]1046
[452]1047                                instruction << it->c_str() << endl;
[449]1048                       
1049                                instruction << endl;
1050                               
1051                                //emit activeTheIAction();
[452]1052                        }
[445]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
[437]1066}
[459]1067
[436]1068/********************************************* Implementation of the method instructionFileManager() *********************************************/
1069void MainWindow::instructionFileManager() {
1070
1071       
[452]1072        iw = new InstructionWindow(&theInstructionData, &theFunctionTable) ;
[436]1073        espace.addWindow(iw)->move(0, 0); 
1074        iw->show();     
1075
[449]1076        connect(iw, SIGNAL(activeTheIAction()), this, SLOT(enableIAction()));
[436]1077}
[459]1078
[356]1079/********************************************* Implementation of the method initializeWindow(int anInt) *********************************************/
1080void MainWindow::initializeWindow(int anInt) {
[254]1081
[356]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       
[263]1130}
[171]1131
[320]1132/*********************************** Implementation of the method changeButtonColor() (SLOT) ********************************************************/
[263]1133void MainWindow::changeButtonColor(QPushButton *aButton) {
1134
[366]1135        aButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1136
1137}
1138
[320]1139/*********************************** Implementation of the method changeColorConstantButton() (SLOT) ***********************************************/
[263]1140void MainWindow::changeColorConstantButton() {
1141
[366]1142        changeButtonColor(m_constantButton);
[263]1143
1144}
1145
[320]1146/*********************************** Implementation of the method changeColorHatButton() (SLOT) ***************************************************/
[263]1147void MainWindow::changeColorHatButton() {
1148
[317]1149        m_hatNameButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1150}
1151
[320]1152/*********************************** Implementation of the method changeColorContextButton() (SLOT) ************************************************/
[263]1153 void MainWindow::changeColorContextButton() {
1154
[366]1155        m_contextButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1156 }
1157
[320]1158/************************************ Implementation of the method changeColorTrajButton() (SLOT) ***************************************************/
[263]1159void MainWindow::changeColorTrajButton() {
[320]1160
[366]1161        m_trajButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1162}
1163
[320]1164/************************************* Implementation of the method changeColorSpaceButton() (SLOT) *************************************************/
[263]1165void MainWindow::changeColorSpaceButton() {
1166
[366]1167        m_spaceButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1168
1169}
[320]1170/********************************** Implementation of the method changeColorOperaButton() (SLOT) *****************************************************/
[263]1171void MainWindow::changeColorOperaButton() {
[171]1172 
[366]1173        m_operaButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1174 
1175 }
[171]1176
[320]1177/*********************************** Implementation of the method changeColorModulButton() (SLOT) *************************************************/
[263]1178void MainWindow::changeColorModulButton() {
[171]1179
[366]1180        m_modulButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[171]1181}
[255]1182
[320]1183/************************************ Implementation of the method changeColorCtinButton() (SLOT) **************************************************/
[263]1184void MainWindow::changeColorCtinButton() {
[255]1185
[366]1186        m_ctinButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1187
[255]1188}
1189
[320]1190/********************************* Implementation of the method changeColorNetwardButton() (SLOT) **************************************************/
[263]1191void MainWindow::changeColorNetwardButton() {
[255]1192
[366]1193        m_netwardButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[171]1194
[263]1195}
[320]1196/************************************* Implementation of the method changeColorInsertFCTButton() ***************************************************/
[263]1197void MainWindow::changeColorInsertFCTButton() {
[255]1198
[366]1199        m_insertFCTButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[171]1200
[263]1201}
[171]1202
[348]1203/************************************ Implementation of the method changeColorOrderButton() whitch is a SLOT **********************************************/
1204void MainWindow::changeColorOrderButton() {
[171]1205
[366]1206        m_orderButton->setStyleSheet("background-color: rgb(180, 180, 180)");
[263]1207
1208}
1209
[320]1210/*********************************** Implementation of the virtual method closeEvent() ************************************************************/
[263]1211/*void MainWindow::closeEvent(QCloseEvent *event) {
1212       
1213      if (maybeSave()) {
1214            //writeSettings();
1215            event->accept();
1216      }
1217        else
1218            event->ignore();
1219     
1220}*/
[470]1221/********************************** **/
[263]1222
[320]1223/*********************************** Implementation of the destructor method (~MainWindow()) *******************************************************/
[263]1224/*MainWindow::~MainWindow() {
1225
[171]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;
[393]1240                    delete actionSaveProject;
[397]1241                    delete actionSaveAsProject;
[171]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;
[263]1254                    delete m_contextButton;
[171]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;
[216]1265}*/
[320]1266/************************************* Enf of the destructor method. ******************************************************************************/
1267/*************************************          End of file.         ******************************************************************************/
1268/**************************************************************************************************************************************************/
Note: See TracBrowser for help on using the repository browser.