diff --git a/Software/sie_cg/block_editor/adc_single.die b/Software/sie_cg/block_editor/adc_single.die
index 917c43e..1bbd6b0 100644
--- a/Software/sie_cg/block_editor/adc_single.die
+++ b/Software/sie_cg/block_editor/adc_single.die
@@ -13,11 +13,11 @@
-
-
-
+
+
-
-
+
+
+
diff --git a/Software/sie_cg/block_editor/arrow.cpp b/Software/sie_cg/block_editor/arrow.cpp
index edfaef3..0adb705 100644
--- a/Software/sie_cg/block_editor/arrow.cpp
+++ b/Software/sie_cg/block_editor/arrow.cpp
@@ -196,6 +196,8 @@ void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
SECLine->setColor(myColor);
}
}
+ painter->setBrush(Qt::lightGray);
+ painter->drawPolygon(this->path().toFillPolygon());
setSelectedArrows();
}
diff --git a/Software/sie_cg/block_editor/constant.die b/Software/sie_cg/block_editor/constant.die
index 2d365e1..e17c5c9 100644
--- a/Software/sie_cg/block_editor/constant.die
+++ b/Software/sie_cg/block_editor/constant.die
@@ -7,8 +7,8 @@
-
+
-
+
diff --git a/Software/sie_cg/block_editor/diagramscene.cpp b/Software/sie_cg/block_editor/diagramscene.cpp
index 6b7615c..bd86d6b 100644
--- a/Software/sie_cg/block_editor/diagramscene.cpp
+++ b/Software/sie_cg/block_editor/diagramscene.cpp
@@ -43,9 +43,11 @@
#include
#include "diagramscene.h"
-DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent)
+DiagramScene::DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow,
+ QObject *parent)
: QGraphicsScene(parent)
{
+ myOwnerWindow = ownerWindow;
myItemMenu = itemMenu;
myMode = MoveItem;
@@ -59,8 +61,8 @@ DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent)
myPolygonPath=0;
myCorners=0;
- TitleText = new DiagramTextItem(0,0,1,0xFFF,255,"BLOCK NAME HERE (not visible)",
- QPointF(250,250));
+ TitleText = new DiagramTextItem(0,0,1,0xFFF,255,"BLOCK NAME HERE not visible",
+ QPointF(500,370));
addItem(TitleText);
}
@@ -124,14 +126,105 @@ void DiagramScene::doSnapToGrid(QGraphicsSceneMouseEvent *mouseEvent)
}
}
+QString DiagramScene::createPrototype()
+{
+ bool first = 1;
+ QString functionPrototype = "\nvoid " +
+ TitleText->toPlainText().replace(' ','_') + "(";
+
+ foreach (QGraphicsItem *item, this->items()) {
+ if (item->type() == DiagramTextItem::Type) {
+ int styleIO = qgraphicsitem_cast(item)->styleIO();
+ if(styleIO<256)
+ {
+ int ioID = qgraphicsitem_cast(item)->textID();
+ if(!first) functionPrototype += ","; first = 0;
+ switch(styleIO&127)
+ {
+ case 1:
+ functionPrototype += "bool ";
+ break;
+ case 2:
+ functionPrototype += "char ";
+ break;
+ case 3:
+ functionPrototype += "integer ";
+ break;
+ case 4:
+ functionPrototype += "double ";
+ break;
+ case 5:
+ functionPrototype += "float ";
+ break;
+ case 6:
+ functionPrototype += "short ";
+ break;
+ case 7:
+ functionPrototype += "long ";
+ break;
+ case 8:
+ functionPrototype += "unsigned char ";
+ break;
+ case 9:
+ functionPrototype += "unsigned integer ";
+ break;
+ case 10:
+ functionPrototype += "unsigned short ";
+ break;
+ case 11:
+ functionPrototype += "unsigned long ";
+ break;
+ default:;
+ }
+ functionPrototype += (styleIO>>7)? "in":"&out";
+ functionPrototype += "_" + QString::number(ioID);
+ }
+ }
+ }
+
+ functionPrototype += ") {";
+ return functionPrototype;
+}
+
void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
doSnapToGrid(mouseEvent);
- QString Text;
+ foreach (QGraphicsItem *item, this->items(mouseEvent->scenePos())) {
+ if (item->type() == DiagramTextItem::Type) {
+ if(qgraphicsitem_cast(item)->styleIO()<256)
+ {
+ myOwnerWindow->statusBar->showMessage(
+ qgraphicsitem_cast(item)->toPlainText() +
+ tr("\t : Input/Output text label -> {ID = ") +
+ QString::number(qgraphicsitem_cast
+ (item)->textID()) + tr("}"));
+ }
+ else if(qgraphicsitem_cast(item)->styleIO()==256)
+ {
+ myOwnerWindow->statusBar->showMessage(
+ qgraphicsitem_cast(item)->toPlainText() +
+ tr("\t : Text label -> {ID = ") +
+ QString::number(qgraphicsitem_cast
+ (item)->textID()) + tr("}"));
+ }
+ else if(qgraphicsitem_cast(item)->styleIO()==257)
+ {
+ myOwnerWindow->statusBar->showMessage(
+ qgraphicsitem_cast(item)->toPlainText() +
+ tr("\t : Editable text label -> {ID = ") +
+ QString::number(qgraphicsitem_cast
+ (item)->textID()) + tr("}"));
+ }
+ }
+ }
+ myOwnerWindow->updateProt();
+ QString Text;
if (mouseEvent->button() != Qt::LeftButton)
return;
+ int addResult=0;
+
switch (myMode)
{
case InsertText:
@@ -146,17 +239,19 @@ void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
textItem = new DiagramTextItem(0,0,1,myTextType,0,Text,
mouseEvent->scenePos());
- if(addTextItem(textItem))
+ addResult=addTextItem(textItem);
+ if(addResult!=-1)
{
textItem->setZValue(1000.0);
connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)),
this, SLOT(editorLostFocus(DiagramTextItem*)));
addItem(textItem);
+ textItem->setTextID(addResult);
}
else
{
delete(textItem);
- QMessageBox::warning(0,"Full","The block can only have only"
+ QMessageBox::warning(0,"Full","The block can only have "
"255 text items");
}
emit textInserted(textItem);
@@ -237,7 +332,7 @@ void DiagramScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
doSnapToGrid(mouseEvent);
- if (myMode != EditPolygon && line == 0)
+ if(myMode != EditPolygon && line == 0)
QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
@@ -377,7 +472,7 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
}
}
}
-
+ myOwnerWindow->updateProt();
return 1;
}
@@ -418,10 +513,10 @@ int DiagramScene::addTextItem(DiagramTextItem * textItem)
if(iter==textItemsByID.end())
{
textItemsByID.insert(i,textItem);
- return 1;
+ return i;
}
}
- return 0;
+ return -1;
}
void DiagramScene::removeTextItem(DiagramTextItem * textItem)
diff --git a/Software/sie_cg/block_editor/diagramscene.h b/Software/sie_cg/block_editor/diagramscene.h
index b93f814..39137b5 100644
--- a/Software/sie_cg/block_editor/diagramscene.h
+++ b/Software/sie_cg/block_editor/diagramscene.h
@@ -47,6 +47,7 @@
#include
#include "diagramtextitem.h"
#include "arrow.h"
+#include "mainwindow.h"
QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
@@ -56,8 +57,9 @@ class QGraphicsLineItem;
class QFont;
class QGraphicsTextItem;
class QColor;
+class QStatusBar;
QT_END_NAMESPACE
-
+class MainWindow;
class Arrow;
class DiagramTextItem;
@@ -68,7 +70,7 @@ class DiagramScene : public QGraphicsScene
public:
enum Mode { MoveItem , EditPolygon, InsertText };
- DiagramScene(QMenu *itemMenu, QObject *parent = 0);
+ DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow, QObject *parent=0);
QDomDocument toXmlFormat();
int fromXmlFormat(QDomDocument xmlDocument);
@@ -81,6 +83,8 @@ public:
int addTextItem(DiagramTextItem * textItem);
void removeTextItem(DiagramTextItem * textItem);
+ QString createPrototype();
+
public slots:
void setMode(Mode mode){myMode=mode;}
void editorLostFocus(DiagramTextItem *item);
@@ -116,6 +120,7 @@ private:
short int myGrid;
int myCorners;
QHash textItemsByID;
+ MainWindow *myOwnerWindow;
};
#endif
diff --git a/Software/sie_cg/block_editor/diagramscene.pro.user b/Software/sie_cg/block_editor/diagramscene.pro.user
index da71f5d..01524d2 100644
--- a/Software/sie_cg/block_editor/diagramscene.pro.user
+++ b/Software/sie_cg/block_editor/diagramscene.pro.user
@@ -76,7 +76,7 @@
Debug
- DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MI4KrAyPP5,guid=5c5c5e6146195c74b6ad266d4cc07afd
+ DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
DESKTOP_SESSION=gnome
DISPLAY=:0.0
@@ -84,8 +84,7 @@
GDM_KEYBOARD_LAYOUT=es
GDM_LANG=en_US.utf8
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
- GNOME_KEYRING_CONTROL=/tmp/keyring-CFAuJK
- GNOME_KEYRING_PID=1516
+ GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0
GTK_MODULES=canberra-gtk-module
HOME=/home/juan64bits
LANG=en_US.utf8
@@ -96,20 +95,20 @@
PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/juan64bits
QTDIR=/usr/share/qt4
- SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1534,unix/Maximus:/tmp/.ICE-unix/1534
+ SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244
SHELL=/bin/bash
SPEECHD_PORT=7560
- SSH_AGENT_PID=1570
- SSH_AUTH_SOCK=/tmp/keyring-CFAuJK/ssh
+ SSH_AGENT_PID=1408
+ SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh
USER=juan64bits
USERNAME=juan64bits
- XAUTHORITY=/var/run/gdm/auth-for-juan64bits-V4ry7M/database
+ XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/
- XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287682812.550485-1725059380
+ XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519
- /home/juan64bits/QT/diagramscene/block_editor/diagramscene.pro
+ /home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor/diagramscene.pro
-spec
linux-g++
-r
@@ -117,7 +116,7 @@
/usr/bin/qmake-qt4
false
- /home/juan64bits/QT/diagramscene/block_editor
+ /home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor
@@ -125,7 +124,7 @@
Debug
- DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MI4KrAyPP5,guid=5c5c5e6146195c74b6ad266d4cc07afd
+ DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
DESKTOP_SESSION=gnome
DISPLAY=:0.0
@@ -133,8 +132,7 @@
GDM_KEYBOARD_LAYOUT=es
GDM_LANG=en_US.utf8
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
- GNOME_KEYRING_CONTROL=/tmp/keyring-CFAuJK
- GNOME_KEYRING_PID=1516
+ GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0
GTK_MODULES=canberra-gtk-module
HOME=/home/juan64bits
LANG=en_US.utf8
@@ -145,17 +143,17 @@
PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/juan64bits
QTDIR=/usr/share/qt4
- SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1534,unix/Maximus:/tmp/.ICE-unix/1534
+ SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244
SHELL=/bin/bash
SPEECHD_PORT=7560
- SSH_AGENT_PID=1570
- SSH_AUTH_SOCK=/tmp/keyring-CFAuJK/ssh
+ SSH_AGENT_PID=1408
+ SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh
USER=juan64bits
USERNAME=juan64bits
- XAUTHORITY=/var/run/gdm/auth-for-juan64bits-V4ry7M/database
+ XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/
- XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287682812.550485-1725059380
+ XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519
false
@@ -163,7 +161,7 @@
/usr/bin/make
true
- /home/juan64bits/QT/diagramscene/block_editor
+ /home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor
diff --git a/Software/sie_cg/block_editor/diagramtextitem.h b/Software/sie_cg/block_editor/diagramtextitem.h
index bda5886..03aa146 100644
--- a/Software/sie_cg/block_editor/diagramtextitem.h
+++ b/Software/sie_cg/block_editor/diagramtextitem.h
@@ -70,14 +70,14 @@ public:
{ return Type;}
int styleIO()
- { return myStyleIO;}
-
- unsigned char ID()
- { return myID;}
+ { return myStyleIO;}
unsigned char textID() const
{ return myID;}
+ void setTextID(unsigned char ID)
+ { myID=ID;}
+
QPointF offset() const
{ return posOffset;}
diff --git a/Software/sie_cg/block_editor/left_shift.die b/Software/sie_cg/block_editor/left_shift.die
index 8bf5800..1493f2d 100644
--- a/Software/sie_cg/block_editor/left_shift.die
+++ b/Software/sie_cg/block_editor/left_shift.die
@@ -9,10 +9,10 @@
-
-
-
-
+
+
+
+
diff --git a/Software/sie_cg/block_editor/lineitem.h b/Software/sie_cg/block_editor/lineitem.h
index 682cdab..d548ec1 100644
--- a/Software/sie_cg/block_editor/lineitem.h
+++ b/Software/sie_cg/block_editor/lineitem.h
@@ -53,6 +53,7 @@ class QRectF;
class QGraphicsSceneMouseEvent;
class QPainterPath;
QT_END_NAMESPACE
+class Arrow;
class lineItem : public QGraphicsLineItem
{
diff --git a/Software/sie_cg/block_editor/main.cpp b/Software/sie_cg/block_editor/main.cpp
index f407824..52d16cb 100644
--- a/Software/sie_cg/block_editor/main.cpp
+++ b/Software/sie_cg/block_editor/main.cpp
@@ -49,7 +49,7 @@ int main(int argv, char *args[])
QApplication app(argv, args);
MainWindow mainWindow;
- mainWindow.setGeometry(100, 100, 1024, 640);
+ mainWindow.setGeometry(100, 100, 1024, 768);
mainWindow.show();
return app.exec();
}
diff --git a/Software/sie_cg/block_editor/mainwindow.cpp b/Software/sie_cg/block_editor/mainwindow.cpp
index 0a3b24b..0adf950 100644
--- a/Software/sie_cg/block_editor/mainwindow.cpp
+++ b/Software/sie_cg/block_editor/mainwindow.cpp
@@ -51,18 +51,43 @@ MainWindow::MainWindow()
createActions();
createToolBox();
createMenus();
+ statusBar = new QStatusBar(this);
- scene = new DiagramScene(itemMenu);
+ scene = new DiagramScene(itemMenu,this);
scene->setSceneRect(QRectF(0, 0, 1000, 1000));
connect(scene, SIGNAL(textInserted(QGraphicsTextItem*)),
this, SLOT(textInserted(QGraphicsTextItem*)));
createToolbars();
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(toolBox);
- view = new QGraphicsView(scene);
- layout->addWidget(view);
+ /* Create widgets for code editor */
+ headerTextEdit = new QTextEdit;
+ headerTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ headerTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ blockTextEdit = new QTextEdit;
+ blockTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ blockTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ extraTextEdit = new QTextEdit;
+ extraTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ extraTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ prototypeLabel = new QLabel;
+ prototypeLabel->setText("\nvoid BLOCK_NAME () {");
+ headerLabel = new QLabel;
+ headerLabel->setText("Code for Header Section Here");
+ extraLabel = new QLabel;
+ extraLabel->setText("}\n\nCode for Extra Section Here");
+
+ /* Create central widget */
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(toolBox,0,0,7,1);
+ view = new QGraphicsView(scene);
+ layout->addWidget(view,0,1,1,1);
+ layout->addWidget(headerLabel,1,1,1,1);
+ layout->addWidget(headerTextEdit,2,1,1,1);
+ layout->addWidget(prototypeLabel,3,1,1,1);
+ layout->addWidget(blockTextEdit,4,1,1,1);
+ layout->addWidget(extraLabel,5,1,1,1);
+ layout->addWidget(extraTextEdit,6,1,1,1);
QWidget *widget = new QWidget;
widget->setLayout(layout);
@@ -74,6 +99,8 @@ MainWindow::MainWindow()
if(QApplication::argc()>1)
{newDiagram(QString(QApplication::argv()[1]));}
+ statusBar->showMessage("Ready...");
+ this->setStatusBar(statusBar);
}
void MainWindow::deleteItem()
@@ -103,6 +130,7 @@ void MainWindow::deleteItem()
scene->removeItem(item);
delete(item);
}
+ updateProt();
}
}
}
@@ -111,8 +139,13 @@ void MainWindow::textInserted(QGraphicsTextItem*)
{
buttonGroup->button(selectedButton)->setChecked(false);
scene->setMode(DiagramScene::MoveItem);
+ updateProt();
}
+void MainWindow::updateProt()
+{
+ prototypeLabel->setText(scene->createPrototype());
+}
void MainWindow::sceneScaleChanged(const QString &scale)
{
@@ -158,27 +191,27 @@ void MainWindow::createToolBox()
QGridLayout *layout = new QGridLayout;
//INPUTS
int i=0;
- layout->addWidget(createToolButton(129+i,tr("Bool"),
+ layout->addWidget(createToolButton(128+i,tr("Bool"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("Char"),
+ layout->addWidget(createToolButton(128+i,tr("Char"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("Integer"),
+ layout->addWidget(createToolButton(128+i,tr("Integer"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("Double"),
+ layout->addWidget(createToolButton(128+i,tr("Double"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("Float"),
+ layout->addWidget(createToolButton(128+i,tr("Float"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("Short"),
+ layout->addWidget(createToolButton(128+i,tr("Short"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("Long"),
+ layout->addWidget(createToolButton(128+i,tr("Long"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("UChar"),
+ layout->addWidget(createToolButton(128+i,tr("UChar"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("UInt"),
+ layout->addWidget(createToolButton(128+i,tr("UInt"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("UShort"),
+ layout->addWidget(createToolButton(128+i,tr("UShort"),
QIcon(":/images/background1.png")),++i,0);
- layout->addWidget(createToolButton(129+i,tr("ULong"),
+ layout->addWidget(createToolButton(128+i,tr("ULong"),
QIcon(":/images/background1.png")),++i,0);
@@ -343,6 +376,7 @@ bool MainWindow::newDiagram(QString filePath)
{
saveIfNeeded();
scene->cleanScene();
+ prototypeLabel->setText("\nvoid BLOCK_NAME () {");
myFilePath="";
if(filePath=="")
@@ -357,8 +391,8 @@ bool MainWindow::newDiagram(QString filePath)
file.close();
if(!parsing)
{
- QMessageBox::warning(this,"Aborting","Failed to parse file, "
- "wrong format or encoding.");
+ QMessageBox::warning(this,"Parsing warning","Invalid or void "
+ " element found in file.");
return 0;
}
scene->fromXmlFormat(document);
diff --git a/Software/sie_cg/block_editor/mainwindow.h b/Software/sie_cg/block_editor/mainwindow.h
index 3728a0a..08c9967 100644
--- a/Software/sie_cg/block_editor/mainwindow.h
+++ b/Software/sie_cg/block_editor/mainwindow.h
@@ -50,6 +50,7 @@
#include "diagramtextitem.h"
#include "lineitem.h"
#include "arrow.h"
+#include
class DiagramScene;
@@ -80,6 +81,9 @@ public:
{ return QDir::currentPath();}
void saveIfNeeded();
+ void updateProt();
+
+ QStatusBar *statusBar;
private slots:
void deleteItem();
@@ -97,6 +101,7 @@ private:
void createActions();
void createMenus();
void createToolbars();
+
QWidget *createToolButton(int ID, QString type,QIcon icon);
DiagramScene *scene;
@@ -126,6 +131,14 @@ private:
QButtonGroup *buttonGroup;
+ QLabel * headerLabel;
+ QTextEdit * headerTextEdit;
+ QLabel * prototypeLabel;
+ QTextEdit * blockTextEdit;
+ QLabel * extraLabel;
+ QTextEdit * extraTextEdit;
+
+
int selectedButton;
QString myFilePath;
diff --git a/Software/sie_cg/block_editor/pwm_single.die b/Software/sie_cg/block_editor/pwm_single.die
index 73cbda8..d264ba5 100644
--- a/Software/sie_cg/block_editor/pwm_single.die
+++ b/Software/sie_cg/block_editor/pwm_single.die
@@ -23,10 +23,10 @@
-
-
-
-
+
+
+
+
diff --git a/Software/sie_cg/block_editor/right_shift.die b/Software/sie_cg/block_editor/right_shift.die
index 0f2fd90..e7a0a7a 100644
--- a/Software/sie_cg/block_editor/right_shift.die
+++ b/Software/sie_cg/block_editor/right_shift.die
@@ -9,10 +9,10 @@
-
-
-
-
+
+
+
+
diff --git a/Software/sie_cg/block_editor/while.die b/Software/sie_cg/block_editor/while.die
index 81ef45d..ab4ada0 100644
--- a/Software/sie_cg/block_editor/while.die
+++ b/Software/sie_cg/block_editor/while.die
@@ -23,7 +23,7 @@
-
+
diff --git a/Software/sie_cg/codedialog.cpp b/Software/sie_cg/codedialog.cpp
new file mode 100644
index 0000000..4bb690c
--- /dev/null
+++ b/Software/sie_cg/codedialog.cpp
@@ -0,0 +1,26 @@
+#include "codedialog.h"
+#include "ui_codedialog.h"
+
+codeDialog::codeDialog(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::codeDialog)
+{
+ ui->setupUi(this);
+}
+
+codeDialog::~codeDialog()
+{
+ delete ui;
+}
+
+void codeDialog::changeEvent(QEvent *e)
+{
+ QMainWindow::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
diff --git a/Software/sie_cg/codedialog.h b/Software/sie_cg/codedialog.h
new file mode 100644
index 0000000..464d9a9
--- /dev/null
+++ b/Software/sie_cg/codedialog.h
@@ -0,0 +1,23 @@
+#ifndef CODEDIALOG_H
+#define CODEDIALOG_H
+
+#include
+
+namespace Ui {
+ class codeDialog;
+}
+
+class codeDialog : public QMainWindow {
+ Q_OBJECT
+public:
+ codeDialog(QWidget *parent = 0);
+ ~codeDialog();
+
+protected:
+ void changeEvent(QEvent *e);
+
+private:
+ Ui::codeDialog *ui;
+};
+
+#endif // CODEDIALOG_H
diff --git a/Software/sie_cg/codedialog.ui b/Software/sie_cg/codedialog.ui
new file mode 100644
index 0000000..db9309b
--- /dev/null
+++ b/Software/sie_cg/codedialog.ui
@@ -0,0 +1,54 @@
+
+
+ codeDialog
+
+
+
+ 0
+ 0
+ 640
+ 480
+
+
+
+ MainWindow
+
+
+
+ -
+
+
+ &Ok
+
+
+
+ -
+
+
+ Qt::ScrollBarAsNeeded
+
+
+
+
+
+
+
+
+
+ okButton
+ clicked()
+ codeDialog
+ hide()
+
+
+ 392
+ 423
+
+
+ 319
+ 239
+
+
+
+
+
diff --git a/Software/sie_cg/diagramitem.cpp b/Software/sie_cg/diagramitem.cpp
index 3a81d4c..7e96bdb 100644
--- a/Software/sie_cg/diagramitem.cpp
+++ b/Software/sie_cg/diagramitem.cpp
@@ -147,6 +147,17 @@ DiagramTextItem *DiagramItem::pointerText(unsigned char ID)
return 0;
}
+bool DiagramItem::textIsIO(unsigned char ID)
+{
+ foreach(DiagramTextItem *item, textItems)
+ {
+ if(item->textID()==ID)
+ if(item->styleIO()!=0)
+ return 1;
+ }
+ return 0;
+}
+
unsigned char DiagramItem::existArrow(DiagramTextItem *startItem,
DiagramTextItem *endItem)
{
diff --git a/Software/sie_cg/diagramitem.h b/Software/sie_cg/diagramitem.h
index cf98f1d..bf67f49 100644
--- a/Software/sie_cg/diagramitem.h
+++ b/Software/sie_cg/diagramitem.h
@@ -108,7 +108,6 @@ public:
unsigned char existArrow(DiagramTextItem *startItem,
DiagramTextItem *endItem);
-
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{QGraphicsPolygonItem::mousePressEvent(mouseEvent);}
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
@@ -118,6 +117,7 @@ public:
bool setValue(unsigned char ioID, QString value);
DiagramTextItem * pointerText(unsigned char ID);
+ bool textIsIO(unsigned char ID);
void setColor(const QColor &color)
{ myColor=color; setBrush(color); }
diff --git a/Software/sie_cg/diagramscene.cpp b/Software/sie_cg/diagramscene.cpp
index 92805e5..112eead 100644
--- a/Software/sie_cg/diagramscene.cpp
+++ b/Software/sie_cg/diagramscene.cpp
@@ -277,10 +277,6 @@ QDomDocument DiagramScene::toXmlFormat()
QDomElement diagram = document.createElement("Diagram");
document.appendChild(diagram);
- QDomElement test = document.createElement("Test");
- test.text().fromAscii("TEXT HERE");
- document.appendChild(test);
-
//Lists of items
QList Items;
QList Arrows;
@@ -333,7 +329,7 @@ QDomDocument DiagramScene::toXmlFormat()
int DiagramScene::fromXmlFormat(QDomDocument document)
{
//Read diagrams TODO: in future... add multi projects functionality
- QHash DiagramsID;
+ DiagramsID.clear();
QDomNodeList diagrams = document.elementsByTagName("Diagram");
if(!diagrams.at(0).isElement())
return 0;
@@ -436,43 +432,68 @@ int DiagramScene::fromXmlFormat(QDomDocument document)
DiagramTextItem *startItem=
DiagramsID.value(arrow.attribute("start-Owner").toInt())
->pointerText(arrow.attribute("start-ID").toInt());
+ bool startIsIO =
+ DiagramsID.value(arrow.attribute("start-Owner").toInt())
+ ->textIsIO(arrow.attribute("start-ID").toInt());
DiagramTextItem *endItem=
DiagramsID.value(arrow.attribute("end-Owner").toInt())
->pointerText(arrow.attribute("end-ID").toInt());
+ bool endIsIO =
+ DiagramsID.value(arrow.attribute("end-Owner").toInt())
+ ->textIsIO(arrow.attribute("end-ID").toInt());
- Arrow *newArrow = new Arrow(startItem, endItem,0,this);
- newArrow->setColor(QColor(arrow.attribute("color")));
- startItem->ownerItem()->addArrow(newArrow);
- endItem->ownerItem()->addArrow(newArrow);
- newArrow->setZValue(0.0);
- addItem(newArrow);
- newArrow->updatePosition();
-
- for (QDomNode node = arrow.firstChild() ;
- !node.isNull() ;
- node = node.nextSibling())
+ if(!startIsIO||!endIsIO)
{
- //Load diagram text values and set on diagram item
- QDomElement arrowCorners = node.toElement();
- if(arrowCorners.tagName()!="arrowCorners")
- return 0;
- int i=0;
- for (QDomNode node = arrowCorners.firstChild() ;
+ QMessageBox::warning(0,"Arrow can't be loaded.",
+ tr("An arrow can not be loaded because ")+
+ tr("will be connected to a label")+
+ tr(" that isn't an Input/Output type. ")+
+ tr("Probable cause may be that the start")+
+ tr(" or end block has been modified."));
+ }
+ else if(startItem==0 || endItem==0)
+ {
+ QMessageBox::warning(0,"Arrow can't be loaded",
+ tr("An arrow can not be loaded because ")+
+ tr("her IO label ID could not be found. ")+
+ tr("Probable cause may be that the start")+
+ tr(" or end block has been modified."));
+ }
+ else
+ {
+ Arrow *newArrow = new Arrow(startItem, endItem,0,this);
+ newArrow->setColor(QColor(arrow.attribute("color")));
+ startItem->ownerItem()->addArrow(newArrow);
+ endItem->ownerItem()->addArrow(newArrow);
+ newArrow->setZValue(0.0);
+ addItem(newArrow);
+ newArrow->updatePosition();
+
+ for (QDomNode node = arrow.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
{
- QDomElement arrowCorner = node.toElement();
- if(arrowCorner.tagName()!="arrowCorner")
+ //Load diagram text values and set on diagram item
+ QDomElement arrowCorners = node.toElement();
+ if(arrowCorners.tagName()!="arrowCorners")
return 0;
+ int i=0;
+ for (QDomNode node = arrowCorners.firstChild() ;
+ !node.isNull() ;
+ node = node.nextSibling())
+ {
+ QDomElement arrowCorner = node.toElement();
+ if(arrowCorner.tagName()!="arrowCorner")
+ return 0;
- QPointF cornerPos =
- QPointF(arrowCorner.attribute("x").toFloat(),
- arrowCorner.attribute("y").toFloat());
+ QPointF cornerPos =
+ QPointF(arrowCorner.attribute("x").toFloat(),
+ arrowCorner.attribute("y").toFloat());
- newArrow->createCorner(cornerPos,++i);
+ newArrow->createCorner(cornerPos,++i);
+ }
}
}
-
}
}
}
diff --git a/Software/sie_cg/diagramscene.h b/Software/sie_cg/diagramscene.h
index bded4e3..4453c00 100644
--- a/Software/sie_cg/diagramscene.h
+++ b/Software/sie_cg/diagramscene.h
@@ -67,7 +67,7 @@ class DiagramScene : public QGraphicsScene
public:
enum Mode { InsertItem, InsertLine, InsertText, MoveItem };
- DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow = 0,
+ DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow,
QObject *parent = 0);
QFont font() const
@@ -88,6 +88,9 @@ public:
int fromXmlFormat(QDomDocument xmlDocument);
void cleanScene();
+ QHash getDiagramsID ()
+ { return DiagramsID;}
+
QStringList getLibList(){return libraryList;}
void setLibList(QStringList list)
{libraryList=list;}
@@ -136,6 +139,7 @@ private:
QStringList libraryList;
QHash domElementsByName;
QHash buttonIdByName;
+ QHash DiagramsID;
MainWindow *myOwnerWindow;
};
diff --git a/Software/sie_cg/diagramscene.pro b/Software/sie_cg/diagramscene.pro
index 995ecc2..ad392fd 100644
--- a/Software/sie_cg/diagramscene.pro
+++ b/Software/sie_cg/diagramscene.pro
@@ -3,16 +3,19 @@ HEADERS = mainwindow.h \
diagramscene.h \
arrow.h \
diagramtextitem.h \
- lineitem.h
+ lineitem.h \
+ codedialog.h \
+ codedialog.h \
+ codedialog.h
SOURCES = mainwindow.cpp \
diagramitem.cpp \
main.cpp \
arrow.cpp \
diagramtextitem.cpp \
diagramscene.cpp \
- lineitem.cpp
+ lineitem.cpp \
+ codedialog.cpp
RESOURCES = diagramscene.qrc
-
TARGET = diagrameditor
# install
@@ -30,4 +33,5 @@ symbian:include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
QT += xml \
svg \
network
-FORMS += librarydialog.ui
+FORMS += librarydialog.ui \
+ codedialog.ui
diff --git a/Software/sie_cg/diagramscene.pro.user b/Software/sie_cg/diagramscene.pro.user
index ff43fba..854b225 100644
--- a/Software/sie_cg/diagramscene.pro.user
+++ b/Software/sie_cg/diagramscene.pro.user
@@ -76,7 +76,7 @@
Debug
- DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-bm3IFDvHlY,guid=a9cadece3d5adbab4e7ecc664cc367c4
+ DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
DESKTOP_SESSION=gnome
DISPLAY=:0.0
@@ -84,11 +84,11 @@
GDM_KEYBOARD_LAYOUT=es
GDM_LANG=en_US.utf8
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
- GNOME_KEYRING_CONTROL=/tmp/keyring-EOe3re
- GNOME_KEYRING_PID=1591
+ GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0
GTK_MODULES=canberra-gtk-module
HOME=/home/juan64bits
LANG=en_US.utf8
+ LANGUAGE=
LD_LIBRARY_PATH=/usr/lib/qtcreator
LOGNAME=juan64bits
MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path
@@ -96,20 +96,20 @@
PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/juan64bits
QTDIR=/usr/share/qt4
- SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1609,unix/Maximus:/tmp/.ICE-unix/1609
+ SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244
SHELL=/bin/bash
SPEECHD_PORT=7560
- SSH_AGENT_PID=1645
- SSH_AUTH_SOCK=/tmp/keyring-EOe3re/ssh
+ SSH_AGENT_PID=1408
+ SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh
USER=juan64bits
USERNAME=juan64bits
- XAUTHORITY=/var/run/gdm/auth-for-juan64bits-XFOps8/database
+ XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/
- XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287874500.2500-279079160
+ XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519
- /home/juan64bits/QT/sie_cg/diagramscene.pro
+ /home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/diagramscene.pro
-spec
linux-g++
-r
@@ -117,7 +117,7 @@
/usr/bin/qmake-qt4
false
- /home/juan64bits/QT/sie_cg
+ /home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg
@@ -125,7 +125,7 @@
Debug
- DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-bm3IFDvHlY,guid=a9cadece3d5adbab4e7ecc664cc367c4
+ DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
DESKTOP_SESSION=gnome
DISPLAY=:0.0
@@ -133,11 +133,11 @@
GDM_KEYBOARD_LAYOUT=es
GDM_LANG=en_US.utf8
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
- GNOME_KEYRING_CONTROL=/tmp/keyring-EOe3re
- GNOME_KEYRING_PID=1591
+ GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0
GTK_MODULES=canberra-gtk-module
HOME=/home/juan64bits
LANG=en_US.utf8
+ LANGUAGE=
LD_LIBRARY_PATH=/usr/lib/qtcreator
LOGNAME=juan64bits
MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path
@@ -145,17 +145,17 @@
PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/juan64bits
QTDIR=/usr/share/qt4
- SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1609,unix/Maximus:/tmp/.ICE-unix/1609
+ SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244
SHELL=/bin/bash
SPEECHD_PORT=7560
- SSH_AGENT_PID=1645
- SSH_AUTH_SOCK=/tmp/keyring-EOe3re/ssh
+ SSH_AGENT_PID=1408
+ SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh
USER=juan64bits
USERNAME=juan64bits
- XAUTHORITY=/var/run/gdm/auth-for-juan64bits-XFOps8/database
+ XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/
- XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287874500.2500-279079160
+ XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519
false
@@ -163,7 +163,7 @@
/usr/bin/make
true
- /home/juan64bits/QT/sie_cg
+ /home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg
diff --git a/Software/sie_cg/diagramscene.qrc b/Software/sie_cg/diagramscene.qrc
index 53ef19b..6850782 100644
--- a/Software/sie_cg/diagramscene.qrc
+++ b/Software/sie_cg/diagramscene.qrc
@@ -24,5 +24,6 @@
images/yes.png
images/zoom_in.png
images/zoom_out.png
+ images/cg.png
diff --git a/Software/sie_cg/images/cg.png b/Software/sie_cg/images/cg.png
new file mode 100755
index 0000000..6d6186e
Binary files /dev/null and b/Software/sie_cg/images/cg.png differ
diff --git a/Software/sie_cg/mainwindow.cpp b/Software/sie_cg/mainwindow.cpp
index ce15e25..7453b38 100644
--- a/Software/sie_cg/mainwindow.cpp
+++ b/Software/sie_cg/mainwindow.cpp
@@ -50,7 +50,7 @@ MainWindow::MainWindow()
{
buttonGroup=0;
toolBox=0;
-
+ statusBar = new QStatusBar(this);
createActions();
createMenus();
scene = new DiagramScene(itemMenu,this);
@@ -68,9 +68,11 @@ MainWindow::MainWindow()
setUnifiedTitleAndToolBarOnMac(true);
myFilePath = "";
libDialog=0;
-
+ cgDialog=0;
if(QApplication::argc()>1)
{newDiagram(QString(QApplication::argv()[1]));}
+ statusBar->showMessage("Ready...");
+ this->setStatusBar(statusBar);
}
void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
@@ -147,6 +149,35 @@ void MainWindow::pointerGroupClicked(int)
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
}
+void MainWindow::cgGroupClicked(int id)
+{
+ if(id==0)
+ {
+ QString Test;
+ QHash DiagramsID = scene->getDiagramsID();
+ foreach (QGraphicsItem *item, scene->items()) {
+ if (item->type() == DiagramItem::Type) {
+ Test+=(tr("\nDiagramID=\t") + QString::number(DiagramsID.
+ key(qgraphicsitem_cast(item))));
+ QList TextItems =
+ qgraphicsitem_cast(item)->getTextItems();
+ foreach (DiagramTextItem *textItem, TextItems) {
+ Test+=(tr("\n\tTextItemID=\t") + QString::number(
+ textItem->textID()));
+ Test+=(tr("\n\t\tTextItemStyleIO=\t") + QString::number(
+ textItem->styleIO()));
+ Test+=(tr("\n\t\tTextItemValue=\t") +
+ textItem->toPlainText());
+ Test+=(tr("\n\t\tTextItemEditable=\t") +
+ (textItem->isEditable()?"true":"false"));
+ }
+ }
+ }
+ codeForm();
+ cgUi->codeTextEdit->setPlainText(Test);
+ }
+}
+
void MainWindow::bringToFront()
{
sendTo(1);
@@ -378,10 +409,10 @@ void MainWindow::createToolBox()
//toolBox->addItem(backgroundWidget, tr("Backgrounds"));
//Add tool box to window
- QHBoxLayout *newLayout = new QHBoxLayout;
- newLayout->addWidget(toolBox);
+ QGridLayout *newLayout = new QGridLayout;
+ newLayout->addWidget(toolBox,0,0);
view = new QGraphicsView(scene);
- newLayout->addWidget(view);
+ newLayout->addWidget(view,0,1);
QWidget *widget = new QWidget;
widget->setLayout(newLayout);
@@ -466,11 +497,13 @@ void MainWindow::createActions()
libraryAction = new QAction(tr("&Library..."),this);
+ libraryAction->setStatusTip(tr("Add, Remove or edit libraries"));
connect(libraryAction, SIGNAL(triggered()),
this, SLOT(libraryForm()));
optionsAction = new QAction(tr("&Options"),this);
optionsAction->setShortcuts(QKeySequence::Preferences);
+ optionsAction->setStatusTip(tr("Edit options"));
connect(optionsAction, SIGNAL(triggered()),
this, SLOT(optionsForm()));
@@ -518,6 +551,20 @@ void MainWindow::createToolbars()
editToolBar->addAction(toFrontAction);
editToolBar->addAction(sendBackAction);
+ QToolButton *cgButton = new QToolButton;
+ cgButton->setCheckable(false);
+ cgButton->setIcon(QIcon(":/images/cg.png"));
+
+ cgGroup = new QButtonGroup;
+ cgGroup->addButton(cgButton,0);
+
+ connect(cgGroup, SIGNAL(buttonClicked(int)),
+ this, SLOT(cgGroupClicked(int)));
+
+ cgToolbar = addToolBar(tr("Code Generator"));
+ cgToolbar->addWidget(cgButton);
+
+
fontCombo = new QFontComboBox();
fontSizeCombo = new QComboBox();
connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
@@ -602,6 +649,7 @@ void MainWindow::createToolbars()
pointerToolbar->addWidget(pointerButton);
pointerToolbar->addWidget(linePointerButton);
pointerToolbar->addWidget(sceneScaleCombo);
+
}
QWidget *MainWindow::createCellWidget(QString text, QDomElement *customItem)
@@ -712,8 +760,8 @@ QDomDocument MainWindow::parseDocument(QString filePath)
file.close();
if(!parsing)
{
- QMessageBox::warning(this,"Operation failed","Failed to parse file, "
- "wrong format or encoding.");
+ QMessageBox::warning(this,"Parsing warning","Invalid or void "
+ " element found in file.");
}
}
else
@@ -821,16 +869,21 @@ int MainWindow::exportDiagram()
int MainWindow::libraryForm()
{
+ bool firstTime=0;
if(!libDialog)
{
createLibraryDialog();
+ firstTime=1;
}
libDialog->setModal(1);
libUi->listLib->clear();
libUi->listLib->addItems(libraryList);
libDialog->setWindowTitle(tr("Library paths..."));
QStringList oldLibraryList=libraryList;
- libDialog->exec();
+ if(firstTime)
+ libDialog->exec();
+ else
+ libDialog->show();
if (libDialog->result() == QDialog::Rejected)
libraryList = oldLibraryList;
@@ -838,7 +891,7 @@ int MainWindow::libraryForm()
{
scene->setLibList(libraryList);
updateLibraries();
- }
+ }
return 0;
}
@@ -854,6 +907,27 @@ void MainWindow::createLibraryDialog()
connect(libUi->editLib,SIGNAL(clicked()),this,SLOT(editLibPath()));
}
+int MainWindow::codeForm()
+{
+ if(!cgDialog)
+ {
+ createCgDialog();
+ }
+
+ cgDialog->setWindowTitle(tr("Code Generator..."));
+ cgUi->codeTextEdit->setAcceptRichText(true);
+ cgDialog->show();
+
+ return 0;
+}
+
+void MainWindow::createCgDialog()
+{
+ cgDialog = new QMainWindow(this);
+ cgUi = new Ui_codeDialog;
+ cgUi->setupUi(cgDialog);
+}
+
void MainWindow::addLibPath()
{
QString
@@ -869,10 +943,10 @@ void MainWindow::addLibPath()
" or not exists.");
return;
}
- if(libUi->listLib->findItems(filePath,Qt::MatchExactly).count()==0)
- {
- QDir myCurrentDir = this->currentDir();
- QString relativePath=myCurrentDir.relativeFilePath(filePath);
+ QDir myCurrentDir = this->currentDir();
+ QString relativePath= myCurrentDir.relativeFilePath(filePath);
+ if(libUi->listLib->findItems(relativePath,Qt::MatchExactly).count()==0)
+ {
libraryList.append(relativePath);
libUi->listLib->addItem(relativePath);
}
diff --git a/Software/sie_cg/mainwindow.h b/Software/sie_cg/mainwindow.h
index e685896..6502c13 100644
--- a/Software/sie_cg/mainwindow.h
+++ b/Software/sie_cg/mainwindow.h
@@ -54,9 +54,13 @@
#include "lineitem.h"
#include "arrow.h"
#include "ui_librarydialog.h"
+#include "ui_codedialog.h"
class DiagramScene;
+class DiagramTextItem;
+class DiagramItem;
class Ui_libraryDialog;
+class callexternappT;
QT_BEGIN_NAMESPACE
class QAction;
@@ -86,9 +90,12 @@ public:
int updateLibraries();
+ QStatusBar *statusBar;
+
private slots:
void backgroundButtonGroupClicked(QAbstractButton *button);
void buttonGroupClicked(int id);
+ void cgGroupClicked(int id);
void deleteItem();
void pointerGroupClicked(int id);
void bringToFront();
@@ -121,13 +128,14 @@ private slots:
int optionsForm();
-
+ int codeForm();
private:
int saveIfNeeded();
void addLibrariesButtons(QGridLayout *layout);
QDomDocument parseDocument(QString filePath);
void createLibraryDialog();
+ void createCgDialog();
void createToolBox();
void createActions();
void createMenus();
@@ -167,10 +175,11 @@ private:
QMenu *aboutMenu;
QToolBar *fileToolBar;
+ QToolBar *cgToolbar;
QToolBar *textToolBar;
QToolBar *editToolBar;
QToolBar *colorToolBar;
- QToolBar *pointerToolbar;
+ QToolBar *pointerToolbar;
QComboBox *sceneScaleCombo;
QComboBox *itemColorCombo;
@@ -181,6 +190,7 @@ private:
QToolBox *toolBox;
QButtonGroup *buttonGroup;
QButtonGroup *pointerTypeGroup;
+ QButtonGroup *cgGroup;
QButtonGroup *backgroundButtonGroup;
QToolButton *fontColorToolButton;
QToolButton *fillColorToolButton;
@@ -192,14 +202,14 @@ private:
QAction *fillAction;
QAction *lineAction;
QString myFilePath;
-
QDialog *libDialog;
Ui_libraryDialog *libUi;
+ QMainWindow *cgDialog;
+ Ui_codeDialog *cgUi;
QStringList libraryList;
QHash domElementsByName;
QHash buttonIdByName;
- static QString callexternapp(QString xexecFile, QString xexecParm);
-
+ static QString callexternapp(QString xexecFile, QString xexecParm);
};
class callexternappT : public QThread
@@ -212,8 +222,8 @@ public:
{
QProcess lnexternapp;
lnexternapp.start(QString("%1 %2").arg(execFile).arg(execParm));
- //lnexternapp.waitForFinished(-1);
- //retnValu = QString(lnexternapp.readAll());
+ lnexternapp.waitForFinished(-1);
+ retnValu = QString(lnexternapp.readAll());
}
};
diff --git a/Software/sie_cg/test.sie b/Software/sie_cg/test.sie
index c12b3a0..8286e58 100644
--- a/Software/sie_cg/test.sie
+++ b/Software/sie_cg/test.sie
@@ -26,7 +26,7 @@ Arrows depend of items, and items depend of libraries!!!!
-
+
@@ -39,21 +39,19 @@ Arrows depend of items, and items depend of libraries!!!!
-
-
+
-
+
+
-
-
-
-
+
+
+
-