X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/4cf57e6db08da791233d75237f62e74bc88dd427..77e28a24d444098399304f0175b1aba43c83017f:/MainWindow.cpp?ds=sidebyside diff --git a/MainWindow.cpp b/MainWindow.cpp index 79bc6f9..683ba3d 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "NewProjectDialog.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { @@ -223,6 +224,12 @@ void MainWindow::enableAnalysisActions(bool enbMenu, quint16 mask, quint8 op) { else { graphAnalysis->setEnabled(false); } + if (analysisMenuEnb & ANALYSIS_GENERATE) { + generateVHDL->setEnabled(true); + } + else { + generateVHDL->setEnabled(false); + } } void MainWindow::createMenus(){ @@ -241,6 +248,7 @@ void MainWindow::createMenus(){ projectMenu->addAction(openLibrary); analysisMenu->addAction(graphAnalysis); + analysisMenu->addAction(generateVHDL); toolsMenu->addAction(vhdlToXmlAct); @@ -284,23 +292,28 @@ void MainWindow::createActions() { vhdlToXmlAct->setStatusTip(tr("Create a new XML generator")); connect(vhdlToXmlAct, SIGNAL(triggered()), this, SLOT(slotVHDLToXml())); - graphAnalysis = new QAction(tr("&graph validation"), this); + graphAnalysis = new QAction(tr("&graph analysis"), this); graphAnalysis->setIcon(QPixmap::fromImage(QImage("icons/new.ico"))); graphAnalysis->setStatusTip(tr("validate the graph")); connect(graphAnalysis, SIGNAL(triggered()), this, SLOT(slotGraphAnalysis())); + generateVHDL = new QAction(tr("generate &VHDL"), this); + generateVHDL->setIcon(QPixmap::fromImage(QImage("icons/new.ico"))); + generateVHDL->setStatusTip(tr("generate the VHDL code for the whole design")); + connect(generateVHDL, SIGNAL(triggered()), this, SLOT(slotGenerateVHDL())); + } -void MainWindow::save(QString absoluteFilename) { - params->save(absoluteFilename); +void MainWindow::save(QString projectFile) { + params->save(projectFile); } void MainWindow::slotLoadProject(){ - absoluteFilename = QFileDialog::getOpenFileName(0, "select a project file", "save/",tr("sauvegardes (*.xml)")); + params->projectFile = QFileDialog::getOpenFileName(0, "select a project file", "save/",tr("sauvegardes (*.xml)")); - if(! absoluteFilename.isEmpty()){ - GroupWidget* topGroup = dispatcher->loadProject(absoluteFilename); + if(! params->projectFile.isEmpty()){ + GroupWidget* topGroup = dispatcher->loadProject(params->projectFile); if (topGroup != NULL) { addTopGroup(topGroup); library->updateComboScene(); @@ -322,13 +335,18 @@ void MainWindow::slotLoadProject(){ void MainWindow::slotNewProject(){ - enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ); - enableAnalysisActions(true, ANALYSIS_ANALYZE, OP_RAZ); - GroupWidget* topGroup = dispatcher->createTopScene(); - addTopGroup(topGroup); - library->updateComboScene(); - library->show(); - params->isCurrentProject = true; + NewProjectDialog* dialog = new NewProjectDialog(params); + int ret = dialog->exec(); + + if (ret == 1) { + enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ); + enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ); + GroupWidget* topGroup = dispatcher->createTopScene(); + addTopGroup(topGroup); + library->updateComboScene(); + library->show(); + params->isCurrentProject = true; + } } bool MainWindow::slotCloseProject(){ @@ -368,7 +386,7 @@ bool MainWindow::slotCloseProject(){ params->isCurrentProject = false; params->unsaveModif = false; - absoluteFilename = QString(); + params->projectFile = QString(); initialize(); } @@ -382,8 +400,8 @@ void MainWindow::slotVHDLToXml() { } void MainWindow::slotSaveProject(){ - if(absoluteFilename != QString()){ - save(absoluteFilename); + if(params->projectFile != QString()){ + save(params->projectFile); } else { slotSaveAsProject(); } @@ -395,9 +413,9 @@ void MainWindow::slotSaveAsProject(){ dial.setDefaultSuffix(".xml"); dial.setAcceptMode(QFileDialog::AcceptSave); if(dial.exec() == QFileDialog::AcceptSave){ - absoluteFilename = dial.selectedFiles().at(0); - if(absoluteFilename != QString()) - save(absoluteFilename); + params->projectFile = dial.selectedFiles().at(0); + if(params->projectFile != QString()) + save(params->projectFile); } } } @@ -428,6 +446,15 @@ void MainWindow::slotGraphAnalysis() { } } +void MainWindow::slotGenerateVHDL() { + try { + params->getGraph()->generateVHDL(params->projectPath); + } + catch(Exception e) { + cerr << qPrintable(e.getMessage()) << endl; + } +} + void MainWindow::addTopGroup(GroupWidget *_topGroup) { topGroup = _topGroup; stackedWidget->addWidget(topGroup);