#include <QMessageBox>\r
#include "AbstractInterface.h"\r
#include "BlockParameter.h"\r
+#include "Parameters.h"\r
\r
AbstractBlock::AbstractBlock() {\r
name = "";\r
}\r
\r
AbstractBlock::AbstractBlock(const QString& _name) {\r
- name = normalizeName(_name);\r
+ name = Parameters::normalizeName(_name);\r
parent = NULL;\r
}\r
\r
}\r
\r
void AbstractBlock::setName(const QString& str) {\r
- name = normalizeName(str);\r
+ name = Parameters::normalizeName(str);\r
}\r
\r
void AbstractBlock::setParent(AbstractBlock* _parent) {\r
return lst;\r
}\r
\r
-QString AbstractBlock::normalizeName(const QString &name) {\r
- QString s = name;\r
- s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_");\r
- s.replace(QRegularExpression("[_]+"),"_");\r
- return s;\r
-}\r
+\r
\r
\r
bool isWBConfigurable();\r
\r
// others\r
- static QString normalizeName(const QString& name);\r
\r
virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull \r
\r
#include "AbstractInterface.h"
#include "BlockParameterPort.h"
#include "AbstractBlock.h"
+#include "Parameters.h"
AbstractInterface::AbstractInterface(AbstractBlock* _owner) {
AbstractInterface::AbstractInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess) {
owner = _owner;
- name = AbstractBlock::normalizeName(_name);
+ name = Parameters::normalizeName(_name);
width = _width;
direction = _direction;
purpose = _purpose;
AbstractInterface::AbstractInterface(AbstractInterface* other) {
owner = NULL;
- name = AbstractBlock::normalizeName(other->name);
+ name = Parameters::normalizeName(other->name);
type = other->type;
width = other->width;
direction = other->direction;
}
void AbstractInterface::setName(const QString& _name) {
- name = AbstractBlock::normalizeName(_name);
+ name = Parameters::normalizeName(_name);
}
AbstractInterface::~AbstractInterface() {
--- /dev/null
+/*-==============================================================-
+
+file : CustomDialog.cpp
+
+creation date : 08/02/2012
+
+author : S. Domas (sdomas@iut-bm.univ-fcomte.fr)
+
+description :
+
+supp. infos : saved in UTF-8 [éè]
+
+-==============================================================-*/
+#include "CustomDialog.h"
+
+CustomDialog::CustomDialog(const QString &dialogTitle, const QString &boxTitle, QWidget *_parent) : QDialog(_parent) {
+
+ setWindowTitle(dialogTitle);
+ box = new QGroupBox(boxTitle);
+
+ okButton = new QPushButton(tr("OK"));
+ cancelButton = new QPushButton(tr("Cancel"));
+
+ layBottom = new QHBoxLayout;
+ layBottom->addStretch();
+ layBottom->addWidget(okButton);
+ layBottom->addWidget(cancelButton);
+
+ connect(okButton,SIGNAL(clicked()),this, SLOT(checkBeforeAccept()));
+ connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
+}
+
+void CustomDialog::checkBeforeAccept() {
+ accept();
+}
+
+bool CustomDialog::confirmAccept() {
+
+ int ret = QMessageBox::question(NULL,tr("Confirmation"),tr("Are you sure ?"),QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Ok);
+ if (ret == QMessageBox::Ok) return true;
+ return false;
+}
+
+void CustomDialog::setContent(QVBoxLayout *boxLayout) {
+ box->setLayout(boxLayout);
+
+ QVBoxLayout *layAll = new QVBoxLayout;
+
+ layAll->addWidget(box);
+ layAll->addLayout(layBottom);
+
+ setLayout(layAll);
+}
--- /dev/null
+/*-==============================================================-
+
+file : CustomDialog.hpp
+
+creation date : 08/02/2012
+
+author : S. Domas (sdomas@iut-bm.univ-fcomte.fr)
+
+description :
+
+supp. infos : saved in UTF-8 [éè]
+
+-==============================================================-*/
+#ifndef __CUSTOMDIALOG_H__
+#define __CUSTOMDIALOG_H__
+
+#include <iostream>
+#include <fstream>
+
+#include <QtCore>
+#include <QtGui>
+#include <QtWidgets>
+
+using namespace std;
+using namespace Qt;
+
+class CustomDialog : public QDialog {
+
+ Q_OBJECT
+
+public:
+
+ CustomDialog(const QString &dialogTitle, const QString &boxTitle, QWidget *_parent = NULL);
+
+protected:
+
+ QGroupBox *box;
+ QPushButton *okButton;
+ QPushButton *cancelButton;
+
+ void setContent(QVBoxLayout *boxLayout);
+
+private:
+ QHBoxLayout *layBottom;
+
+protected slots:
+ virtual void checkBeforeAccept();
+ virtual bool confirmAccept();
+
+};
+#endif //__CUSTOMDIALOG_H__
throw(e);
}
}
+
+void Graph::generateVHDL(const QString &path) throw(Exception) {
+ try {
+ topGroup->generateVHDL(path);
+ }
+ catch(Exception e) {
+ throw(e);
+ }
+}
void resetPatternComputed();
void computeOutputPatterns(int nbExec) throw(Exception);
-
+ void generateVHDL(const QString& path) throw(Exception);
+
private:
GroupBlock* topGroup;
QList<GroupBlock *> groups; //! usefull to avoid recursive methods to find a particular group.
#include "GroupInterface.h"
#include "string.h"
#include <sstream>
+#include "Parameters.h"
int GroupBlock::counter = 1;
QString coreFile = "";
coreFile = path;
- coreFile.append(normalizeName(name));
+ coreFile.append(Parameters::normalizeName(name));
coreFile.append(".vhd");
QFile vhdlCore(coreFile);
#include <QDomElement>
#include <QDomText>
#include <sstream>
+#include "NewProjectDialog.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
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(){
- 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();
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(){
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);
}
}
}
}
}
+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);
#define PROJECT_LIB (quint16)32
#define ANALYSIS_ANALYZE (quint16)1
+#define ANALYSIS_GENERATE (quint16)2
#define OP_ADD (quint8)0
#define OP_REM (quint8)1
// actions for graph analysis
QAction *graphAnalysis;
+ QAction *generateVHDL;
// actions for tools
QAction *vhdlToXmlAct;
void slotOpenBlockLibrary();
void slotGraphAnalysis();
+ void slotGenerateVHDL();
void slotVHDLToXml();
--- /dev/null
+#include "NewProjectDialog.h"
+
+NewProjectDialog::NewProjectDialog(Parameters *_params, QWidget *parent) : CustomDialog(tr("Create a new project"),tr("Location"), parent) {
+
+ params = _params;
+
+ QHBoxLayout *layNameProj = new QHBoxLayout;
+ QLabel *nameProjLab = new QLabel(tr("Name :"));
+ nameProjEdit = new QLineEdit();
+ nameProjEdit->setMaxLength(100);
+ nameProjEdit->setText("");
+
+ layNameProj->addWidget(nameProjLab);
+ layNameProj->addWidget(nameProjEdit);
+
+ QHBoxLayout *layDirProj = new QHBoxLayout;
+ QLabel *dirProjLab = new QLabel(tr("Path :"));
+ dirProjEdit = new QLineEdit("");
+ dirProjEdit->setMaxLength(500);
+ dirProjButton = new QPushButton(QIcon(":/images/filefind.png"),"");
+ dirProjButton->setFixedWidth(30);
+ pathOk = false;
+
+ layDirProj->addWidget(dirProjLab);
+ layDirProj->addWidget(dirProjEdit);
+ layDirProj->addWidget(dirProjButton);
+
+
+ QVBoxLayout *layAll = new QVBoxLayout;
+ layAll->addLayout(layNameProj);
+ layAll->addLayout(layDirProj);
+
+ setContent(layAll);
+
+ connect(dirProjButton,SIGNAL(clicked()),this,SLOT(chooseProjectPath()));
+ connect(nameProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectName(QString)));
+ connect(dirProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectPath(QString)));
+
+}
+
+void NewProjectDialog::checkBeforeAccept() {
+
+ if ((!nameProjEdit->text().isEmpty()) && (pathOk)) {
+ //cout << "all ok" << endl;
+ params->projectPath = dirProjEdit->text();
+ params->projectFile = params->projectPath + "/" + params->projectName + ".xml";
+
+ accept();
+ }
+ else {
+ int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path");
+
+ }
+}
+
+void NewProjectDialog::chooseProjectPath() {
+
+ QString where;
+ where = QDir::currentPath();
+ QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),where);
+ dirProjEdit->setText(dir);
+}
+
+void NewProjectDialog::checkProjectPath(QString name) {
+ QDir dir(name);
+ if (dir.exists()) {
+ pathOk = true;
+ }
+ else {
+ pathOk = false;
+ }
+}
+
+void NewProjectDialog::checkProjectName(QString name) {
+ params->projectName = Parameters::normalizeName(name);
+ if (name != params->projectName) {
+ nameProjEdit->setText(params->projectName);
+ }
+}
--- /dev/null
+#ifndef __NEWPROJECTDIALOG_H__
+#define __NEWPROJECTDIALOG_H__
+
+#include <iostream>
+#include <fstream>
+
+#include <QtCore>
+#include <QtGui>
+
+#include "CustomDialog.h"
+#include "Parameters.h"
+
+using namespace std;
+using namespace Qt;
+
+class NewProjectDialog : public CustomDialog {
+
+ Q_OBJECT
+
+public:
+
+ NewProjectDialog(Parameters *_params, QWidget *parent = NULL);
+
+private:
+
+ Parameters *params;
+
+ QLineEdit *nameProjEdit;
+ QLineEdit *dirProjEdit;
+ QPushButton *dirProjButton;
+ bool pathOk;
+
+private slots:
+ void checkBeforeAccept();
+ void chooseProjectPath();
+ void checkProjectPath(QString name);
+ void checkProjectName(QString name);
+
+
+};
+
+#endif //__NEWPROJECTDIALOG_H__
\r
unsaveModif = false;\r
isRstClkShown = false;\r
-\r
- projectPath = QDir::currentPath();\r
\r
validityExtension = "_enb";\r
+\r
+ projectPath = "";\r
+ projectName = "";\r
+ projectFile = "";\r
}\r
\r
Parameters::~Parameters() {\r
}\r
return NULL;\r
}\r
+\r
+QString Parameters::normalizeName(const QString &name) {\r
+ QString s = name;\r
+ s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_");\r
+ s.replace(QRegularExpression("[_]+"),"_");\r
+ return s;\r
+}\r
inline void setCursorState(CursorState state) { cursorState = state; }\r
inline void setDispatcher(Dispatcher* _dispatcher) { dispatcher = _dispatcher;}\r
\r
+ // testers\r
+\r
+ // others\r
+ static QString normalizeName(const QString& name);\r
+\r
/***************************************************\r
attributes that are general to the application\r
***************************************************/ \r
bool unsaveModif;\r
bool isRstClkShown;\r
QMap<FunctionalBlock*, BoxItem*> blockToItem; // allow to retrieve a box item from a functionnal block\r
+ QString projectPath;\r
+ QString projectName;\r
+ QString projectFile; // equals to projectPath/projectName.xml\r
\r
Graph* createGraph();\r
void destroyGraph();\r
void save(QString confFile);\r
\r
\r
- QString projectPath;\r
+\r
\r
private:\r
Graph* graph; // the graph model of blocks\r
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-01-24T18:18:10. -->
+<!-- Written by QtCreator 4.2.0, 2018-02-12T16:51:17. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
- <value type="QByteArray">{3701e197-5b6c-48ea-9e98-a6cf6de18672}</value>
+ <value type="QByteArray">{94112477-caab-4897-8f75-5f412f2c883a}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
- <value type="QByteArray" key="CurrentPreferences">qt2</value>
+ <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
- <value type="int" key="EditorConfiguration.IndentSize">2</value>
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
- <value type="int" key="EditorConfiguration.TabSize">4</value>
- <value type="bool" key="EditorConfiguration.UseGlobal">false</value>
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
- <value type="bool" key="EditorConfiguration.cleanWhitespace">false</value>
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{ed04208c-8774-456b-99b9-4a02094ca7a4}</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{c934e180-ebc6-41ed-be82-502cc94f41f6}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
- <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
+ <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
- <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+CustomDialog.h
+CustomDialog.cpp
+NewProjectDialog.h
+NewProjectDialog.cpp
Exception.h
Exception.cpp
AbstractInputModifier.h
$(BUILDPATH)/moc_ParametersWindow.o \
$(BUILDPATH)/InterfacePropertiesWindow.o \
$(BUILDPATH)/moc_InterfacePropertiesWindow.o \
+ $(BUILDPATH)/CustomDialog.o \
+ $(BUILDPATH)/moc_CustomDialog.o \
+ $(BUILDPATH)/NewProjectDialog.o \
+ $(BUILDPATH)/moc_NewProjectDialog.o \
$(BUILDPATH)/blast.o