Changeset 371 for trunk/yao


Ignore:
Timestamp:
07/01/10 01:37:02 (14 years ago)
Author:
yerima
Message:

Generating file from modul window. Visual Yao.

Location:
trunk/yao/src/interface/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yao/src/interface/src/MainWindow.cpp

    r370 r371  
    393393 
    394394        if (m_modulWindow == NULL) { //to test if the object is already created. 
    395                 m_modulWindow = new ModulWindow(&theModulTable, &theSpaceTable, &theOperaTable, &theConstantTable, &the_mwc); //mwc.getModul(); 
     395                m_modulWindow = new ModulWindow(&theModulTable, &theSpaceTable, &theOperaTable, &theConstantTable, &the_mwc, &m_newProjectName, &m_projectPath); //mwc.getModul(); 
    396396                espace.addWindow(m_modulWindow)->move(30, 15); 
    397397                m_modulWindow->show();  
     
    487487        m_newProjectWindow = new NewProjectWindow(espace); 
    488488        m_newProjectName = m_newProjectWindow->getProjectName(); 
     489        m_projectPath = m_newProjectWindow->getProjectPath(); 
    489490        theHeaderList.push_back(m_newProjectWindow->getProjectName() + ".h"); 
    490491        fv->appelActualiser(); //Permet de mettre à jour automatiquement la liste des fichiers visibles dans filesviewer. 
     
    650651                                for (Table<Function>::iterator it = theFunctionTable.begin(); it != theFunctionTable.end(); it++) { 
    651652                                                 
    652                                         string aString = it->isParameterized()? "arg" : " "; 
     653                                        string aString = it->isParameterized()? "arg" : "   "; 
    653654                                        description << "insert_fct " << aString << " " << it->getName() << endl; 
    654655                                        } 
  • trunk/yao/src/interface/src/ModulWindow.cpp

    r370 r371  
    2020//! \brief Implementation of the Modul window for visual_YAO. 
    2121//ModulWindow::ModulWindow(QWidget *parent):QWidget(parent) { 
    22 ModulWindow::ModulWindow(Table <Modul> *aModulTable, Table <Space> *aSpaceTable, Table <Operator> *anOperatorTable, Table <Constant> *aConstantTable, MainWindowController *mwc, QWidget *parent) : QWidget(parent), m_localModulTable(NULL) { 
     22ModulWindow::ModulWindow(Table <Modul> *aModulTable, Table <Space> *aSpaceTable, Table <Operator> *anOperatorTable, Table <Constant> *aConstantTable, MainWindowController *mwc, string *aProjectName, string *aProjectPath, QWidget *parent) : QWidget(parent), m_localModulTable(NULL) { 
    2323 
    2424 
     
    2828        m_localSpaceTable       = aSpaceTable; 
    2929        m_localOperaTable       = anOperatorTable; 
     30        m_localProjectName      = aProjectName; 
     31        m_localProjectPath      = aProjectPath; 
    3032 
    3133        QRegExp regExp("[A-Za-z_][A-Za-z1-9_]{0,}");  
     
    4042        m_modulInter2Combo->setDisabled(true); 
    4143        m_modulInter3Combo->setDisabled(true); 
     44         
     45        //cout << "voici le chemin du projet courant: " << endl << *m_localProjectPath + "/" + *m_localProjectName << endl; 
    4246         
    4347        if (isModulTableEmpty())  
     
    157161                modulParent = m_modulSpaceCombo->currentText().toStdString() ; 
    158162        else 
    159                 modulParent = m_modulOperaCombo->currentText().toStdString() ; 
     163                if (m_modulOperaRadioButton->isChecked()) 
     164                        modulParent = m_modulOperaCombo->currentText().toStdString() ; 
    160165 
    161166        if (!(modulName.empty() || modulParent.empty() )) { 
     
    167172                 
    168173                (m_modulSpaceRadioButton->isChecked())? m_localModulTable->push_back(Modul(modulName, m_localSpaceTable->find(modulParent), true)): m_localModulTable->push_back(Modul(modulName, m_localOperaTable->find(modulParent), false)); 
    169  
     174                 
     175                generateModulFile(modulName);            
    170176        } 
    171177//      m_modulModel->setItem(row, 4, new QStandardItem(m_comboModulLopera->currentText()));   
     
    188194        }        
    189195} 
     196 
     197/***********************************************************************************************************/ 
     198void ModulWindow::generateModulFile(string aFilename)  
     199{ 
     200        date = new QDateEdit; 
     201                date->setDate(QDate::currentDate()); 
     202        //string theFile ; 
     203        string path = *m_localProjectPath + "/" + *m_localProjectName + "/" + aFilename + ".h"; 
     204        ofstream theFile(path.c_str(), ios::out | ios::binary | ios::trunc); 
     205                if(!theFile.is_open()) 
     206                        throw ofstream::failure("couldn't create " + path); 
     207        theFile << endl; 
     208        theFile << "              Date: " << date->date().toString().toStdString().c_str() << "                  " << endl;  
     209        theFile << "//===========================================================================" << endl; 
     210        theFile << "forward ()                                                                   " << endl; 
     211        theFile << "{                                                                            " << endl; 
     212        theFile << endl; 
     213        theFile << endl; 
     214        theFile << endl; 
     215        theFile << endl; 
     216        theFile << endl; 
     217        theFile << endl; 
     218        theFile << endl; 
     219        theFile << endl; 
     220        theFile << endl; 
     221        theFile << endl; 
     222        theFile << "}                                                                            " << endl; 
     223        theFile << endl; 
     224        theFile << "//===========================================================================" << endl; 
     225        theFile << "// methodes classe C: backward                                               " << endl; 
     226        theFile << "//===========================================================================" << endl; 
     227        theFile << "backward ()                                                                  " << endl; 
     228        theFile << "{                                                                            " << endl; 
     229        theFile << endl; 
     230        theFile << endl; 
     231        theFile << endl; 
     232        theFile << endl; 
     233        theFile << endl; 
     234        theFile << endl; 
     235        theFile << endl; 
     236        theFile << endl; 
     237        theFile << endl; 
     238        theFile << endl; 
     239        theFile << "}                                                                            " << endl; 
     240        theFile << "//===========================================================================" << endl; 
     241        theFile << "//************************** FIN DU MODULE C  *******************************" << endl; 
     242 
     243        theFile.close(); 
     244} 
     245 
    190246/**************************************** Implémentation de la méthode addLoperaRow() **************************************************************/ 
    191247void ModulWindow::addLoperaRow() { 
  • trunk/yao/src/interface/src/include/ModulWindow.hpp

    r362 r371  
    44#include "MainWindowController.hpp" 
    55#include <QString> 
     6#include <QDateEdit>  
    67#include <QFileDialog> 
    78#include <QStringListModel> 
     
    2021 
    2122        public : 
    22                 ModulWindow(yao::Table <yao::Modul> *aModulTable, yao::Table <yao::Space> *aSpaceIdentifier, yao::Table <yao::Operator> *anOperatorTable, yao::Table <yao::Constant> *aConstantTable, MainWindowController *mwc, QWidget *parent=0); 
     23                ModulWindow(yao::Table <yao::Modul> *aModulTable, yao::Table <yao::Space> *aSpaceIdentifier, yao::Table <yao::Operator> *anOperatorTable, yao::Table <yao::Constant> *aConstantTable, MainWindowController *mwc, std::string *aProjectName, std::string *aProjectPath, QWidget *parent=0); 
    2324 
    2425                void eraseDataFromLineEdit(); 
    25                  bool isModulTableEmpty();  
     26                bool isModulTableEmpty();  
     27                void generateModulFile(string aFilename);  
     28 
    2629        private slots: 
    2730 
     
    4447                QModelIndex index; 
    4548                QModelIndex m_loperaIndex; 
     49                std::string *m_localProjectPath; 
     50                std::string *m_localProjectName; 
    4651                yao::Table <yao::Modul> *m_localModulTable; 
    4752                std::vector<std::string> anVector; 
     
    5055                yao::Table <yao::Operator> *m_localOperaTable; 
    5156                MainWindowController *localMwc; 
     57                QDateEdit *date; 
    5258 
    5359}; 
Note: See TracChangeset for help on using the changeset viewer.