#include <QDomElement>
#include <QDomText>
#include <sstream>
+#include "NewProjectDialog.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
try {
params->loadBlastConfiguration("blastconfig.xml");
+ // first load external sources
+ params->loadSources();
+
if (!QFileInfo::exists(params->refLib)) {
params->loadReferencesFromXml();
int ret = QMessageBox::question(this,tr("Building references library"),tr("The reference block library does not exists.\n References have been read directly from the xml descriptions of blocks.\n It can be saved into a library in order to start application faster. "), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);
else {
graphAnalysis->setEnabled(false);
}
+ if (analysisMenuEnb & ANALYSIS_GENERATE) {
+ generateVHDL->setEnabled(true);
+ }
+ else {
+ generateVHDL->setEnabled(false);
+ }
}
void MainWindow::createMenus(){
projectMenu->addAction(openLibrary);
analysisMenu->addAction(graphAnalysis);
+ analysisMenu->addAction(generateVHDL);
toolsMenu->addAction(vhdlToXmlAct);
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(){
+void MainWindow::slotLoadProject(QString fileName){
- absoluteFilename = QFileDialog::getOpenFileName(0, "select a project file", "save/",tr("sauvegardes (*.xml)"));
+ if (fileName == "") {
+ params->projectFile = QFileDialog::getOpenFileName(0, "select a project file", "save/",tr("sauvegardes (*.xml)"));
+ }
+ else {
+ params->projectFile = fileName;
+ }
- 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();
+ library->updateBoxConn();
params->isCurrentProject = true;
enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
- enableAnalysisActions(true, ANALYSIS_ANALYZE, OP_RAZ);
+ enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ);
}
else {
QMessageBox msgBox;
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(Dispatcher::Design, params->mainClock);
+ addTopGroup(topGroup);
+ library->updateComboScene();
+ library->updateBoxConn();
+ library->show();
+ params->isCurrentProject = true;
+ }
}
bool MainWindow::slotCloseProject(){
params->isCurrentProject = false;
params->unsaveModif = false;
- absoluteFilename = QString();
+ params->projectFile = QString();
initialize();
}
}
void MainWindow::slotSaveProject(){
- if(absoluteFilename != QString()){
- save(absoluteFilename);
+ if(params->projectFile != QString()){
+ save(params->projectFile);
} else {
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);
}
}
}
msg += " is not compatible with its input pattern.\nDo you want to launch automatic modification process to ensure the compatibility ?";
int ret = QMessageBox::question(this,tr("Building references library"),msg, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);
if (ret == QMessageBox::Ok) {
- dispatcher->findGraphModifications(toBlock);
+ dispatcher->findGraphModifications(Dispatcher::Design, toBlock);
}
}
}
}
+void MainWindow::slotGenerateVHDL() {
+
+ try {
+ dispatcher->generateVHDL(Dispatcher::Design);
+ }
+ catch(Exception e) {
+ cerr << qPrintable(e.getMessage()) << endl;
+ }
+}
+
void MainWindow::addTopGroup(GroupWidget *_topGroup) {
topGroup = _topGroup;
stackedWidget->addWidget(topGroup);
void MainWindow::mousePressEvent(QMouseEvent *e) {
if (dispatcher->getCurrentGroup() != NULL) {
- dispatcher->setCurrentGroupWidget(dispatcher->getCurrentGroup());
+ dispatcher->setCurrentGroupWidget(Dispatcher::Design, dispatcher->getCurrentGroup());
}
QMainWindow::mousePressEvent(e);
}