]> AND Private Git Repository - blast.git/blobdiff - MainWindow.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
correct bug with clkrstgen
[blast.git] / MainWindow.cpp
index e7724255ddb2be2854b9a063a2e3df2dd385b736..79bc6f9708943e5930308f71694528839bdec15c 100644 (file)
@@ -4,10 +4,9 @@
 #include "BlockLibraryWidget.h"
 #include "GroupWidget.h"
 #include "GroupScene.h"
 #include "BlockLibraryWidget.h"
 #include "GroupWidget.h"
 #include "GroupScene.h"
-#include "BlockWidget.h"
-#include "AbstractBoxItem.h"
+#include "VHDLConverter.h"
 #include "Graph.h"
 #include "Graph.h"
-#include "GroupItem.h"
+#include "FunctionalBlock.h"
 #include <QDomDocument>
 #include <QDomElement>
 #include <QDomText>
 #include <QDomDocument>
 #include <QDomElement>
 #include <QDomText>
@@ -54,6 +53,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
 
   cout << "all references and implementations are loaded" << endl;
 
 
   cout << "all references and implementations are loaded" << endl;
 
+  params->createDelayBlock();
+
   // create the menu, action, ...
   dispatcher = new Dispatcher(params,this);
   params->setDispatcher(dispatcher);
   // create the menu, action, ...
   dispatcher = new Dispatcher(params,this);
   params->setDispatcher(dispatcher);
@@ -86,9 +87,11 @@ MainWindow::~MainWindow() {}
 void MainWindow::initialize() {
 
   projectMenuEnb = 0;
 void MainWindow::initialize() {
 
   projectMenuEnb = 0;
+  analysisMenuEnb = 0;
 
   stackedWidget->setCurrentIndex(0);
   enableProjectActions(true,PROJECT_NEW | PROJECT_OPEN, OP_RAZ);
 
   stackedWidget->setCurrentIndex(0);
   enableProjectActions(true,PROJECT_NEW | PROJECT_OPEN, OP_RAZ);
+  enableAnalysisActions(false);
 
   stackedWidget->setCurrentIndex(0);
 
 
   stackedWidget->setCurrentIndex(0);
 
@@ -195,11 +198,39 @@ void MainWindow::enableProjectActions(bool enbMenu, quint16 mask, quint8 op) {
   }
 }
 
   }
 }
 
+void MainWindow::enableAnalysisActions(bool enbMenu, quint16 mask, quint8 op) {
+  if (enbMenu) {
+    analysisMenu->setEnabled(true);
+  }
+  else {
+    analysisMenu->setEnabled(false);
+  }
+
+  if (op == OP_ADD) {
+    analysisMenuEnb = analysisMenuEnb | mask;
+  }
+  else if (op == OP_REM) {
+    analysisMenuEnb = (analysisMenuEnb | mask) ^ mask;
+  }
+  else if (op == OP_RAZ) {
+    analysisMenuEnb = mask;
+  }
+
+
+  if (analysisMenuEnb & ANALYSIS_ANALYZE) {
+    graphAnalysis->setEnabled(true);
+  }
+  else {
+    graphAnalysis->setEnabled(false);
+  }
+}
+
 void MainWindow::createMenus(){
 
   allMenuBar = menuBar();
 
   projectMenu = allMenuBar->addMenu(tr("&Project"));
 void MainWindow::createMenus(){
 
   allMenuBar = menuBar();
 
   projectMenu = allMenuBar->addMenu(tr("&Project"));
+  analysisMenu = allMenuBar->addMenu(tr("&Analysis"));
   toolsMenu = allMenuBar->addMenu(tr("&Tools"));
 
   projectMenu->addAction(newProject);
   toolsMenu = allMenuBar->addMenu(tr("&Tools"));
 
   projectMenu->addAction(newProject);
@@ -209,8 +240,10 @@ void MainWindow::createMenus(){
   projectMenu->addAction(closeProject);
   projectMenu->addAction(openLibrary);
 
   projectMenu->addAction(closeProject);
   projectMenu->addAction(openLibrary);
 
-  toolsMenu->addAction(newBlockWidgetAct);
-  toolsMenu->addAction(graphValidation);
+  analysisMenu->addAction(graphAnalysis);
+
+  toolsMenu->addAction(vhdlToXmlAct);
+
 
 }
 
 
 }
 
@@ -246,15 +279,15 @@ void MainWindow::createActions() {
   openLibrary->setStatusTip(tr("Open block library window"));
   connect(openLibrary, SIGNAL(triggered()), this, SLOT(slotOpenBlockLibrary()));
 
   openLibrary->setStatusTip(tr("Open block library window"));
   connect(openLibrary, SIGNAL(triggered()), this, SLOT(slotOpenBlockLibrary()));
 
-  newBlockWidgetAct = new QAction(tr("&XML generator"), this);
-  newBlockWidgetAct->setIcon(QPixmap::fromImage(QImage("icons/new.ico")));
-  newBlockWidgetAct->setStatusTip(tr("Create a new XML generator"));
-  connect(newBlockWidgetAct, SIGNAL(triggered()), this, SLOT(slotNewBlockWidget()));
+  vhdlToXmlAct = new QAction(tr("&XML generator"), this);
+  vhdlToXmlAct->setIcon(QPixmap::fromImage(QImage("icons/new.ico")));
+  vhdlToXmlAct->setStatusTip(tr("Create a new XML generator"));
+  connect(vhdlToXmlAct, SIGNAL(triggered()), this, SLOT(slotVHDLToXml()));
 
 
-  graphValidation = new QAction(tr("&graph validation"), this);
-  graphValidation->setIcon(QPixmap::fromImage(QImage("icons/new.ico")));
-  graphValidation->setStatusTip(tr("validate the graph"));
-  connect(graphValidation, SIGNAL(triggered()), this, SLOT(slotGraphValidation()));
+  graphAnalysis = new QAction(tr("&graph validation"), this);
+  graphAnalysis->setIcon(QPixmap::fromImage(QImage("icons/new.ico")));
+  graphAnalysis->setStatusTip(tr("validate the graph"));
+  connect(graphAnalysis, SIGNAL(triggered()), this, SLOT(slotGraphAnalysis()));
 
 }
 
 
 }
 
@@ -273,6 +306,7 @@ void MainWindow::slotLoadProject(){
       library->updateComboScene();
       params->isCurrentProject = true;
       enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
       library->updateComboScene();
       params->isCurrentProject = true;
       enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
+      enableAnalysisActions(true, ANALYSIS_ANALYZE, OP_RAZ);
     }
     else {
       QMessageBox msgBox;
     }
     else {
       QMessageBox msgBox;
@@ -289,6 +323,7 @@ void MainWindow::slotLoadProject(){
 void MainWindow::slotNewProject(){
 
   enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
 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();
   GroupWidget* topGroup = dispatcher->createTopScene();
   addTopGroup(topGroup);
   library->updateComboScene();
@@ -342,8 +377,8 @@ bool MainWindow::slotCloseProject(){
 }
 
 
 }
 
 
-void MainWindow::slotNewBlockWidget() {
-  new BlockWidget();
+void MainWindow::slotVHDLToXml() {
+  new VHDLConverter();
 }
 
 void MainWindow::slotSaveProject(){
 }
 
 void MainWindow::slotSaveProject(){
@@ -372,12 +407,24 @@ void MainWindow::slotOpenBlockLibrary() {
 }
 
 
 }
 
 
-void MainWindow::slotGraphValidation() {
-  try {
-    params->getGraph()->computeOutputPatterns(5); 
+void MainWindow::slotGraphAnalysis() {
+  bool compat = true;
+  try {    
+    params->getGraph()->computeOutputPatterns(1);
   }
   catch(Exception e) {
   }
   catch(Exception e) {
-    cerr << qPrintable(e.getMessage()) << endl;    
+    cerr << qPrintable(e.getMessage()) << endl;
+    compat = false;
+    if (e.getType() == IP_AP_NOTCOMPAT) {
+      FunctionalBlock* toBlock = (FunctionalBlock*)(e.getSource());
+      QString msg = tr("");
+      msg.append(toBlock->getName());
+      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);
+      }
+    }
   }
 }
 
   }
 }