Date:2010-11-20 22:19:34 (9 years 19 days ago)
Author:Juan64Bits
Commit:2efe106cf30654a74ec979a00de820e2aca3021e
Message:Adding bases to the code generator. Code text edit, fixing input/output ID control, etc.

Files: Software/sie_cg/block_editor/adc_single.die (1 diff)
Software/sie_cg/block_editor/arrow.cpp (1 diff)
Software/sie_cg/block_editor/constant.die (1 diff)
Software/sie_cg/block_editor/diagramscene.cpp (7 diffs)
Software/sie_cg/block_editor/diagramscene.h (5 diffs)
Software/sie_cg/block_editor/diagramscene.pro.user (8 diffs)
Software/sie_cg/block_editor/diagramtextitem.h (1 diff)
Software/sie_cg/block_editor/left_shift.die (1 diff)
Software/sie_cg/block_editor/lineitem.h (1 diff)
Software/sie_cg/block_editor/main.cpp (1 diff)
Software/sie_cg/block_editor/mainwindow.cpp (7 diffs)
Software/sie_cg/block_editor/mainwindow.h (4 diffs)
Software/sie_cg/block_editor/pwm_single.die (1 diff)
Software/sie_cg/block_editor/right_shift.die (1 diff)
Software/sie_cg/block_editor/while.die (1 diff)
Software/sie_cg/codedialog.cpp (1 diff)
Software/sie_cg/codedialog.h (1 diff)
Software/sie_cg/codedialog.ui (1 diff)
Software/sie_cg/diagramitem.cpp (1 diff)
Software/sie_cg/diagramitem.h (2 diffs)
Software/sie_cg/diagramscene.cpp (3 diffs)
Software/sie_cg/diagramscene.h (3 diffs)
Software/sie_cg/diagramscene.pro (2 diffs)
Software/sie_cg/diagramscene.pro.user (8 diffs)
Software/sie_cg/diagramscene.qrc (1 diff)
Software/sie_cg/images/cg.png (0 diffs)
Software/sie_cg/mainwindow.cpp (12 diffs)
Software/sie_cg/mainwindow.h (7 diffs)
Software/sie_cg/test.sie (2 diffs)

Change Details

Software/sie_cg/block_editor/adc_single.die
1313        <Point x="-60" y="40"/>
1414    </Polygon>
1515    <TextItems>
16        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="3" text="ADC Single Channel" posOffset-x="0"/>
17        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="4" text="0" posOffset-x="20"/>
18        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="5" text="CH:" posOffset-x="-20"/>
16        <TextItem myStyleIO="7" posOffset-y="-20" editableItem="0" ID="7" text=" Long" posOffset-x="110"/>
17        <TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="9" text="255" posOffset-x="20"/>
1918        <TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="6" text="SP:" posOffset-x="-20"/>
20        <TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="7" text="255" posOffset-x="20"/>
21        <TextItem myStyleIO="8" posOffset-y="-20" editableItem="0" ID="8" text="UChar" posOffset-x="110"/>
19        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="5" text="CH:" posOffset-x="-20"/>
20        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="4" text="0" posOffset-x="20"/>
21        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="3" text="ADC Single Channel" posOffset-x="0"/>
2222    </TextItems>
2323</CustomItem>
Software/sie_cg/block_editor/arrow.cpp
196196                SECLine->setColor(myColor);
197197        }
198198    }
199    painter->setBrush(Qt::lightGray);
200    painter->drawPolygon(this->path().toFillPolygon());
199201    setSelectedArrows();
200202}
201203
Software/sie_cg/block_editor/constant.die
77        <Point x="30" y="-10"/>
88    </Polygon>
99    <TextItems>
10        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="21" text="Value" posOffset-x="-30"/>
10        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="1" text="1" posOffset-x="10"/>
1111        <TextItem myStyleIO="3" posOffset-y="-20" editableItem="0" ID="15" text="OUT Integer" posOffset-x="30"/>
12        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="19" text="1" posOffset-x="10"/>
12        <TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="0" text="Value" posOffset-x="-30"/>
1313    </TextItems>
1414</CustomItem>
Software/sie_cg/block_editor/diagramscene.cpp
4343#include <QHash>
4444#include "diagramscene.h"
4545
46DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent)
46DiagramScene::DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow,
47                           QObject *parent)
4748    : QGraphicsScene(parent)
4849{
50    myOwnerWindow = ownerWindow;
4951    myItemMenu = itemMenu;
5052    myMode = MoveItem;
5153
...... 
5961    myPolygonPath=0;
6062    myCorners=0;
6163
62    TitleText = new DiagramTextItem(0,0,1,0xFFF,255,"BLOCK NAME HERE (not visible)",
63                                    QPointF(250,250));
64    TitleText = new DiagramTextItem(0,0,1,0xFFF,255,"BLOCK NAME HERE not visible",
65                                    QPointF(500,370));
6466    addItem(TitleText);
6567
6668}
...... 
124126    }
125127}
126128
129QString DiagramScene::createPrototype()
130{
131    bool first = 1;
132    QString functionPrototype = "\nvoid " +
133                                TitleText->toPlainText().replace(' ','_') + "(";
134
135    foreach (QGraphicsItem *item, this->items()) {
136        if (item->type() == DiagramTextItem::Type) {
137            int styleIO = qgraphicsitem_cast<DiagramTextItem*>(item)->styleIO();
138            if(styleIO<256)
139            {
140              int ioID = qgraphicsitem_cast<DiagramTextItem*>(item)->textID();
141              if(!first) functionPrototype += ","; first = 0;
142              switch(styleIO&127)
143              {
144                  case 1:
145                      functionPrototype += "bool ";
146                      break;
147                  case 2:
148                      functionPrototype += "char ";
149                      break;
150                  case 3:
151                      functionPrototype += "integer ";
152                      break;
153                  case 4:
154                      functionPrototype += "double ";
155                      break;
156                  case 5:
157                      functionPrototype += "float ";
158                      break;
159                  case 6:
160                      functionPrototype += "short ";
161                      break;
162                  case 7:
163                      functionPrototype += "long ";
164                      break;
165                  case 8:
166                      functionPrototype += "unsigned char ";
167                      break;
168                  case 9:
169                      functionPrototype += "unsigned integer ";
170                      break;
171                  case 10:
172                      functionPrototype += "unsigned short ";
173                      break;
174                  case 11:
175                      functionPrototype += "unsigned long ";
176                      break;
177                  default:;
178              }
179              functionPrototype += (styleIO>>7)? "in":"&out";
180              functionPrototype += "_" + QString::number(ioID);
181            }
182        }
183    }
184
185    functionPrototype += ") {";
186    return functionPrototype;
187}
188
127189void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
128190{
129191    doSnapToGrid(mouseEvent);
130    QString Text;
192    foreach (QGraphicsItem *item, this->items(mouseEvent->scenePos())) {
193        if (item->type() == DiagramTextItem::Type) {
194            if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()<256)
195            {
196                myOwnerWindow->statusBar->showMessage(
197                  qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
198                  tr("\t : Input/Output text label -> {ID = ") +
199                  QString::number(qgraphicsitem_cast<DiagramTextItem *>
200                                  (item)->textID()) + tr("}"));
201            }
202            else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==256)
203            {
204                myOwnerWindow->statusBar->showMessage(
205                  qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
206                  tr("\t : Text label -> {ID = ") +
207                  QString::number(qgraphicsitem_cast<DiagramTextItem *>
208                                  (item)->textID()) + tr("}"));
209            }
210            else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==257)
211            {
212                myOwnerWindow->statusBar->showMessage(
213                  qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
214                  tr("\t : Editable text label -> {ID = ") +
215                  QString::number(qgraphicsitem_cast<DiagramTextItem *>
216                                  (item)->textID()) + tr("}"));
217            }
218        }
219    }
220    myOwnerWindow->updateProt();
131221
222    QString Text;
132223    if (mouseEvent->button() != Qt::LeftButton)
133224        return;
134225
226    int addResult=0;
227
135228    switch (myMode)
136229    {
137230        case InsertText:
...... 
146239
147240            textItem = new DiagramTextItem(0,0,1,myTextType,0,Text,
148241                                           mouseEvent->scenePos());
149            if(addTextItem(textItem))
242            addResult=addTextItem(textItem);
243            if(addResult!=-1)
150244            {
151245                textItem->setZValue(1000.0);
152246                connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)),
153247                        this, SLOT(editorLostFocus(DiagramTextItem*)));
154248                addItem(textItem);
249                textItem->setTextID(addResult);
155250            }
156251            else
157252            {
158253                delete(textItem);
159                QMessageBox::warning(0,"Full","The block can only have only"
254                QMessageBox::warning(0,"Full","The block can only have "
160255                                     "255 text items");
161256            }
162257            emit textInserted(textItem);
...... 
237332void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
238333{
239334    doSnapToGrid(mouseEvent);
240   if (myMode != EditPolygon && line == 0)
335   if(myMode != EditPolygon && line == 0)
241336        QGraphicsScene::mouseReleaseEvent(mouseEvent);
242337}
243338
...... 
377472            }
378473        }
379474    }
380
475    myOwnerWindow->updateProt();
381476    return 1;
382477}
383478
...... 
418513        if(iter==textItemsByID.end())
419514        {
420515            textItemsByID.insert(i,textItem);
421            return 1;
516            return i;
422517        }
423518    }
424    return 0;
519    return -1;
425520}
426521
427522void DiagramScene::removeTextItem(DiagramTextItem * textItem)
Software/sie_cg/block_editor/diagramscene.h
4747#include <QtXml>
4848#include "diagramtextitem.h"
4949#include "arrow.h"
50#include "mainwindow.h"
5051
5152QT_BEGIN_NAMESPACE
5253class QGraphicsSceneMouseEvent;
...... 
5657class QFont;
5758class QGraphicsTextItem;
5859class QColor;
60class QStatusBar;
5961QT_END_NAMESPACE
60
62class MainWindow;
6163class Arrow;
6264class DiagramTextItem;
6365
...... 
6870public:
6971    enum Mode { MoveItem , EditPolygon, InsertText };
7072
71    DiagramScene(QMenu *itemMenu, QObject *parent = 0);
73    DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow, QObject *parent=0);
7274
7375    QDomDocument toXmlFormat();
7476    int fromXmlFormat(QDomDocument xmlDocument);
...... 
8183    int addTextItem(DiagramTextItem * textItem);
8284    void removeTextItem(DiagramTextItem * textItem);
8385
86    QString createPrototype();
87
8488public slots:
8589    void setMode(Mode mode){myMode=mode;}
8690    void editorLostFocus(DiagramTextItem *item);
...... 
116120    short int myGrid;
117121    int myCorners;
118122    QHash<int,DiagramTextItem*> textItemsByID;
123    MainWindow *myOwnerWindow;
119124};
120125
121126#endif
Software/sie_cg/block_editor/diagramscene.pro.user
7676  <valuemap type="QVariantMap">
7777   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
7878   <valuelist key="abstractProcess.Environment" type="QVariantList">
79    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MI4KrAyPP5,guid=5c5c5e6146195c74b6ad266d4cc07afd</value>
79    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
8080    <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
8181    <value type="QString">DESKTOP_SESSION=gnome</value>
8282    <value type="QString">DISPLAY=:0.0</value>
...... 
8484    <value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
8585    <value type="QString">GDM_LANG=en_US.utf8</value>
8686    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
87    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-CFAuJK</value>
88    <value type="QString">GNOME_KEYRING_PID=1516</value>
87    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
8988    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
9089    <value type="QString">HOME=/home/juan64bits</value>
9190    <value type="QString">LANG=en_US.utf8</value>
...... 
9695    <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
9796    <value type="QString">PWD=/home/juan64bits</value>
9897    <value type="QString">QTDIR=/usr/share/qt4</value>
99    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1534,unix/Maximus:/tmp/.ICE-unix/1534</value>
98    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
10099    <value type="QString">SHELL=/bin/bash</value>
101100    <value type="QString">SPEECHD_PORT=7560</value>
102    <value type="QString">SSH_AGENT_PID=1570</value>
103    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-CFAuJK/ssh</value>
101    <value type="QString">SSH_AGENT_PID=1408</value>
102    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
104103    <value type="QString">USER=juan64bits</value>
105104    <value type="QString">USERNAME=juan64bits</value>
106    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-V4ry7M/database</value>
105    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
107106    <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
108107    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
109    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287682812.550485-1725059380</value>
108    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
110109   </valuelist>
111110   <valuelist key="abstractProcess.arguments" type="QVariantList">
112    <value type="QString">/home/juan64bits/QT/diagramscene/block_editor/diagramscene.pro</value>
111    <value type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor/diagramscene.pro</value>
113112    <value type="QString">-spec</value>
114113    <value type="QString">linux-g++</value>
115114    <value type="QString">-r</value>
...... 
117116   </valuelist>
118117   <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
119118   <value key="abstractProcess.enabled" type="bool">false</value>
120   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/QT/diagramscene/block_editor</value>
119   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor</value>
121120  </valuemap>
122121 </data>
123122 <data>
...... 
125124  <valuemap type="QVariantMap">
126125   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
127126   <valuelist key="abstractProcess.Environment" type="QVariantList">
128    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MI4KrAyPP5,guid=5c5c5e6146195c74b6ad266d4cc07afd</value>
127    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
129128    <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
130129    <value type="QString">DESKTOP_SESSION=gnome</value>
131130    <value type="QString">DISPLAY=:0.0</value>
...... 
133132    <value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
134133    <value type="QString">GDM_LANG=en_US.utf8</value>
135134    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
136    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-CFAuJK</value>
137    <value type="QString">GNOME_KEYRING_PID=1516</value>
135    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
138136    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
139137    <value type="QString">HOME=/home/juan64bits</value>
140138    <value type="QString">LANG=en_US.utf8</value>
...... 
145143    <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
146144    <value type="QString">PWD=/home/juan64bits</value>
147145    <value type="QString">QTDIR=/usr/share/qt4</value>
148    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1534,unix/Maximus:/tmp/.ICE-unix/1534</value>
146    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
149147    <value type="QString">SHELL=/bin/bash</value>
150148    <value type="QString">SPEECHD_PORT=7560</value>
151    <value type="QString">SSH_AGENT_PID=1570</value>
152    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-CFAuJK/ssh</value>
149    <value type="QString">SSH_AGENT_PID=1408</value>
150    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
153151    <value type="QString">USER=juan64bits</value>
154152    <value type="QString">USERNAME=juan64bits</value>
155    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-V4ry7M/database</value>
153    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
156154    <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
157155    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
158    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287682812.550485-1725059380</value>
156    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
159157   </valuelist>
160158   <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
161159   <valuelist key="abstractProcess.arguments" type="QVariantList">
...... 
163161   </valuelist>
164162   <value key="abstractProcess.command" type="QString">/usr/bin/make</value>
165163   <value key="abstractProcess.enabled" type="bool">true</value>
166   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/QT/diagramscene/block_editor</value>
164   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor</value>
167165  </valuemap>
168166 </data>
169167 <data>
Software/sie_cg/block_editor/diagramtextitem.h
7070        { return Type;}
7171
7272    int styleIO()
73        { return myStyleIO;}
74
75    unsigned char ID()
76        { return myID;}
73        { return myStyleIO;}
7774
7875    unsigned char textID() const
7976        { return myID;}
8077
78    void setTextID(unsigned char ID)
79        { myID=ID;}
80
8181    QPointF offset() const
8282        { return posOffset;}
8383
Software/sie_cg/block_editor/left_shift.die
99        <Point x="-70" y="-30"/>
1010    </Polygon>
1111    <TextItems>
12        <TextItem myStyleIO="9" posOffset-y="-0" editableItem="0" ID="13" text="OUT" posOffset-x="60"/>
13        <TextItem myStyleIO="138" posOffset-y="-0" editableItem="0" ID="12" text="IN" posOffset-x="-70"/>
14        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
15        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text="&lt;&lt;" posOffset-x="-20"/>
12        <TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="0" text="IN" posOffset-x="-70"/>
13        <TextItem myStyleIO="3" posOffset-y="-0" editableItem="0" ID="1" text="OUT" posOffset-x="60"/>
1614        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="5" text="Bitwise Shift" posOffset-x="-10"/>
15        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text="&lt;&lt;" posOffset-x="-20"/>
16        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
1717    </TextItems>
1818</CustomItem>
Software/sie_cg/block_editor/lineitem.h
5353class QGraphicsSceneMouseEvent;
5454class QPainterPath;
5555QT_END_NAMESPACE
56class Arrow;
5657
5758class lineItem : public QGraphicsLineItem
5859{
Software/sie_cg/block_editor/main.cpp
4949
5050    QApplication app(argv, args);
5151    MainWindow mainWindow;
52    mainWindow.setGeometry(100, 100, 1024, 640);
52    mainWindow.setGeometry(100, 100, 1024, 768);
5353    mainWindow.show();
5454    return app.exec();
5555}
Software/sie_cg/block_editor/mainwindow.cpp
5151    createActions();
5252    createToolBox();
5353    createMenus();
54    statusBar = new QStatusBar(this);
5455
55    scene = new DiagramScene(itemMenu);
56    scene = new DiagramScene(itemMenu,this);
5657    scene->setSceneRect(QRectF(0, 0, 1000, 1000));
5758    connect(scene, SIGNAL(textInserted(QGraphicsTextItem*)),
5859        this, SLOT(textInserted(QGraphicsTextItem*)));
5960
6061    createToolbars();
6162
62    QHBoxLayout *layout = new QHBoxLayout;
63    layout->addWidget(toolBox);
64    view = new QGraphicsView(scene);
65    layout->addWidget(view);
63    /* Create widgets for code editor */
64    headerTextEdit = new QTextEdit;
65    headerTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
66    headerTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
67    blockTextEdit = new QTextEdit;
68    blockTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
69    blockTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
70    extraTextEdit = new QTextEdit;
71    extraTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
72    extraTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
73    prototypeLabel = new QLabel;
74    prototypeLabel->setText("\nvoid BLOCK_NAME () {");
75    headerLabel = new QLabel;
76    headerLabel->setText("Code for Header Section Here");
77    extraLabel = new QLabel;
78    extraLabel->setText("}\n\nCode for Extra Section Here");
79
80    /* Create central widget */
81    QGridLayout *layout = new QGridLayout;
82    layout->addWidget(toolBox,0,0,7,1);
83    view = new QGraphicsView(scene);
84    layout->addWidget(view,0,1,1,1);
85    layout->addWidget(headerLabel,1,1,1,1);
86    layout->addWidget(headerTextEdit,2,1,1,1);
87    layout->addWidget(prototypeLabel,3,1,1,1);
88    layout->addWidget(blockTextEdit,4,1,1,1);
89    layout->addWidget(extraLabel,5,1,1,1);
90    layout->addWidget(extraTextEdit,6,1,1,1);
6691
6792    QWidget *widget = new QWidget;
6893    widget->setLayout(layout);
...... 
7499
75100    if(QApplication::argc()>1)
76101        {newDiagram(QString(QApplication::argv()[1]));}
102    statusBar->showMessage("Ready...");
103    this->setStatusBar(statusBar);
77104}
78105
79106void MainWindow::deleteItem()
...... 
103130               scene->removeItem(item);
104131               delete(item);
105132           }
133           updateProt();
106134       }
107135    }
108136}
...... 
111139{
112140    buttonGroup->button(selectedButton)->setChecked(false);
113141    scene->setMode(DiagramScene::MoveItem);
142    updateProt();
114143}
115144
145void MainWindow::updateProt()
146{
147    prototypeLabel->setText(scene->createPrototype());
148}
116149
117150void MainWindow::sceneScaleChanged(const QString &scale)
118151{
...... 
158191    QGridLayout *layout = new QGridLayout;
159192    //INPUTS
160193    int i=0;
161    layout->addWidget(createToolButton(129+i,tr("Bool"),
194    layout->addWidget(createToolButton(128+i,tr("Bool"),
162195                      QIcon(":/images/background1.png")),++i,0);
163    layout->addWidget(createToolButton(129+i,tr("Char"),
196    layout->addWidget(createToolButton(128+i,tr("Char"),
164197                      QIcon(":/images/background1.png")),++i,0);
165    layout->addWidget(createToolButton(129+i,tr("Integer"),
198    layout->addWidget(createToolButton(128+i,tr("Integer"),
166199                      QIcon(":/images/background1.png")),++i,0);
167    layout->addWidget(createToolButton(129+i,tr("Double"),
200    layout->addWidget(createToolButton(128+i,tr("Double"),
168201                      QIcon(":/images/background1.png")),++i,0);
169    layout->addWidget(createToolButton(129+i,tr("Float"),
202    layout->addWidget(createToolButton(128+i,tr("Float"),
170203                      QIcon(":/images/background1.png")),++i,0);
171    layout->addWidget(createToolButton(129+i,tr("Short"),
204    layout->addWidget(createToolButton(128+i,tr("Short"),
172205                      QIcon(":/images/background1.png")),++i,0);
173    layout->addWidget(createToolButton(129+i,tr("Long"),
206    layout->addWidget(createToolButton(128+i,tr("Long"),
174207                      QIcon(":/images/background1.png")),++i,0);
175    layout->addWidget(createToolButton(129+i,tr("UChar"),
208    layout->addWidget(createToolButton(128+i,tr("UChar"),
176209                      QIcon(":/images/background1.png")),++i,0);
177    layout->addWidget(createToolButton(129+i,tr("UInt"),
210    layout->addWidget(createToolButton(128+i,tr("UInt"),
178211                      QIcon(":/images/background1.png")),++i,0);
179    layout->addWidget(createToolButton(129+i,tr("UShort"),
212    layout->addWidget(createToolButton(128+i,tr("UShort"),
180213                      QIcon(":/images/background1.png")),++i,0);
181    layout->addWidget(createToolButton(129+i,tr("ULong"),
214    layout->addWidget(createToolButton(128+i,tr("ULong"),
182215                      QIcon(":/images/background1.png")),++i,0);
183216
184217
...... 
343376{
344377    saveIfNeeded();
345378    scene->cleanScene();
379    prototypeLabel->setText("\nvoid BLOCK_NAME () {");
346380    myFilePath="";
347381
348382    if(filePath=="")
...... 
357391        file.close();
358392        if(!parsing)
359393        {
360            QMessageBox::warning(this,"Aborting","Failed to parse file, "
361                                 "wrong format or encoding.");
394            QMessageBox::warning(this,"Parsing warning","Invalid or void "
395                                 " element found in file.");
362396            return 0;
363397        }
364398        scene->fromXmlFormat(document);
Software/sie_cg/block_editor/mainwindow.h
5050#include "diagramtextitem.h"
5151#include "lineitem.h"
5252#include "arrow.h"
53#include <QtGui>
5354
5455class DiagramScene;
5556
...... 
8081   { return QDir::currentPath();}
8182
8283   void saveIfNeeded();
84   void updateProt();
85
86   QStatusBar *statusBar;
8387
8488private slots:
8589    void deleteItem();
...... 
97101    void createActions();
98102    void createMenus();
99103    void createToolbars();
104
100105    QWidget *createToolButton(int ID, QString type,QIcon icon);
101106
102107    DiagramScene *scene;
...... 
126131
127132    QButtonGroup *buttonGroup;
128133
134    QLabel * headerLabel;
135    QTextEdit * headerTextEdit;
136    QLabel * prototypeLabel;
137    QTextEdit * blockTextEdit;
138    QLabel * extraLabel;
139    QTextEdit * extraTextEdit;
140
141
129142    int selectedButton;
130143
131144    QString myFilePath;
Software/sie_cg/block_editor/pwm_single.die
2323        <Point x="-90" y="20"/>
2424    </Polygon>
2525    <TextItems>
26        <TextItem myStyleIO="137" posOffset-y="-0" editableItem="0" ID="14" text="UChar" posOffset-x="-90"/>
27        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="15" text="|-Duty-|" posOffset-x="-20"/>
28        <TextItem myStyleIO="0" posOffset-y="40" editableItem="1" ID="16" text="0" posOffset-x="0"/>
29        <TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="11" text="Out:" posOffset-x="-20"/>
26        <TextItem myStyleIO="136" posOffset-y="-0" editableItem="0" ID="4" text="UChar" posOffset-x="-90"/>
3027        <TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="18" text="PWM" posOffset-x="-50"/>
28        <TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="11" text="Out:" posOffset-x="-20"/>
29        <TextItem myStyleIO="0" posOffset-y="40" editableItem="1" ID="16" text="0" posOffset-x="0"/>
30        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="15" text="|-Duty-|" posOffset-x="-20"/>
3131    </TextItems>
3232</CustomItem>
Software/sie_cg/block_editor/right_shift.die
99        <Point x="-70" y="-30"/>
1010    </Polygon>
1111    <TextItems>
12        <TextItem myStyleIO="9" posOffset-y="-0" editableItem="0" ID="13" text="OUT" posOffset-x="60"/>
13        <TextItem myStyleIO="138" posOffset-y="-0" editableItem="0" ID="12" text="IN" posOffset-x="-70"/>
14        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
15        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text=">>" posOffset-x="-20"/>
12        <TextItem myStyleIO="2" posOffset-y="-0" editableItem="0" ID="3" text="OUT" posOffset-x="60"/>
1613        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="5" text="Bitwise Shift" posOffset-x="-10"/>
14        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text=">>" posOffset-x="-20"/>
15        <TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="2" text="IN" posOffset-x="-70"/>
16        <TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
1717    </TextItems>
1818</CustomItem>
Software/sie_cg/block_editor/while.die
2323        <Point x="-50" y="-10"/>
2424    </Polygon>
2525    <TextItems>
26        <TextItem myStyleIO="130" posOffset-y="-10" editableItem="0" ID="14" text="IN Bool" posOffset-x="-50"/>
26        <TextItem myStyleIO="129" posOffset-y="-10" editableItem="0" ID="6" text="IN Bool" posOffset-x="-50"/>
2727        <TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="23" text="System While" posOffset-x="0"/>
2828    </TextItems>
2929</CustomItem>
Software/sie_cg/codedialog.cpp
1#include "codedialog.h"
2#include "ui_codedialog.h"
3
4codeDialog::codeDialog(QWidget *parent) :
5    QMainWindow(parent),
6    ui(new Ui::codeDialog)
7{
8    ui->setupUi(this);
9}
10
11codeDialog::~codeDialog()
12{
13    delete ui;
14}
15
16void codeDialog::changeEvent(QEvent *e)
17{
18    QMainWindow::changeEvent(e);
19    switch (e->type()) {
20    case QEvent::LanguageChange:
21        ui->retranslateUi(this);
22        break;
23    default:
24        break;
25    }
26}
Software/sie_cg/codedialog.h
1#ifndef CODEDIALOG_H
2#define CODEDIALOG_H
3
4#include <QMainWindow>
5
6namespace Ui {
7    class codeDialog;
8}
9
10class codeDialog : public QMainWindow {
11    Q_OBJECT
12public:
13    codeDialog(QWidget *parent = 0);
14    ~codeDialog();
15
16protected:
17    void changeEvent(QEvent *e);
18
19private:
20    Ui::codeDialog *ui;
21};
22
23#endif // CODEDIALOG_H
Software/sie_cg/codedialog.ui
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>codeDialog</class>
4 <widget class="QMainWindow" name="codeDialog">
5  <property name="geometry">
6   <rect>
7    <x>0</x>
8    <y>0</y>
9    <width>640</width>
10    <height>480</height>
11   </rect>
12  </property>
13  <property name="windowTitle">
14   <string>MainWindow</string>
15  </property>
16  <widget class="QWidget" name="centralwidget">
17   <layout class="QGridLayout" name="gridLayout">
18    <item row="1" column="0">
19     <widget class="QPushButton" name="okButton">
20      <property name="text">
21       <string>&amp;Ok</string>
22      </property>
23     </widget>
24    </item>
25    <item row="0" column="0">
26     <widget class="QTextEdit" name="codeTextEdit">
27      <property name="horizontalScrollBarPolicy">
28       <enum>Qt::ScrollBarAsNeeded</enum>
29      </property>
30     </widget>
31    </item>
32   </layout>
33  </widget>
34 </widget>
35 <resources/>
36 <connections>
37  <connection>
38   <sender>okButton</sender>
39   <signal>clicked()</signal>
40   <receiver>codeDialog</receiver>
41   <slot>hide()</slot>
42   <hints>
43    <hint type="sourcelabel">
44     <x>392</x>
45     <y>423</y>
46    </hint>
47    <hint type="destinationlabel">
48     <x>319</x>
49     <y>239</y>
50    </hint>
51   </hints>
52  </connection>
53 </connections>
54</ui>
Software/sie_cg/diagramitem.cpp
147147    return 0;
148148}
149149
150bool DiagramItem::textIsIO(unsigned char ID)
151{
152    foreach(DiagramTextItem *item, textItems)
153    {
154            if(item->textID()==ID)
155                if(item->styleIO()!=0)
156                    return 1;
157    }
158    return 0;
159}
160
150161unsigned char DiagramItem::existArrow(DiagramTextItem *startItem,
151162                                     DiagramTextItem *endItem)
152163{
Software/sie_cg/diagramitem.h
108108    unsigned char existArrow(DiagramTextItem *startItem,
109109                             DiagramTextItem *endItem);
110110
111
112111    void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
113112        {QGraphicsPolygonItem::mousePressEvent(mouseEvent);}
114113    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
...... 
118117
119118    bool setValue(unsigned char ioID, QString value);
120119    DiagramTextItem * pointerText(unsigned char ID);
120    bool textIsIO(unsigned char ID);
121121
122122    void setColor(const QColor &color)
123123        { myColor=color; setBrush(color); }
Software/sie_cg/diagramscene.cpp
277277    QDomElement diagram = document.createElement("Diagram");
278278    document.appendChild(diagram);
279279
280    QDomElement test = document.createElement("Test");
281    test.text().fromAscii("TEXT HERE");
282    document.appendChild(test);
283
284280    //Lists of items
285281    QList<DiagramItem *> Items;
286282    QList<Arrow *> Arrows;
...... 
333329int DiagramScene::fromXmlFormat(QDomDocument document)
334330{
335331    //Read diagrams TODO: in future... add multi projects functionality
336    QHash<int , DiagramItem *> DiagramsID;
332    DiagramsID.clear();
337333    QDomNodeList diagrams = document.elementsByTagName("Diagram");
338334    if(!diagrams.at(0).isElement())
339335        return 0;
...... 
436432                DiagramTextItem *startItem=
437433                        DiagramsID.value(arrow.attribute("start-Owner").toInt())
438434                        ->pointerText(arrow.attribute("start-ID").toInt());
435                bool startIsIO =
436                        DiagramsID.value(arrow.attribute("start-Owner").toInt())
437                        ->textIsIO(arrow.attribute("start-ID").toInt());
439438                DiagramTextItem *endItem=
440439                        DiagramsID.value(arrow.attribute("end-Owner").toInt())
441440                        ->pointerText(arrow.attribute("end-ID").toInt());
441                bool endIsIO =
442                        DiagramsID.value(arrow.attribute("end-Owner").toInt())
443                        ->textIsIO(arrow.attribute("end-ID").toInt());
442444
443                Arrow *newArrow = new Arrow(startItem, endItem,0,this);
444                newArrow->setColor(QColor(arrow.attribute("color")));
445                startItem->ownerItem()->addArrow(newArrow);
446                endItem->ownerItem()->addArrow(newArrow);
447                newArrow->setZValue(0.0);
448                addItem(newArrow);
449                newArrow->updatePosition();
450
451                for (QDomNode node = arrow.firstChild() ;
452                     !node.isNull() ;
453                     node = node.nextSibling())
445                if(!startIsIO||!endIsIO)
454446                {
455                    //Load diagram text values and set on diagram item
456                    QDomElement arrowCorners = node.toElement();
457                    if(arrowCorners.tagName()!="arrowCorners")
458                        return 0;
459                    int i=0;
460                    for (QDomNode node = arrowCorners.firstChild() ;
447                    QMessageBox::warning(0,"Arrow can't be loaded.",
448                                     tr("An arrow can not be loaded because ")+
449                                     tr("will be connected to a label")+
450                                     tr(" that isn't an Input/Output type. ")+
451                                     tr("Probable cause may be that the start")+
452                                     tr(" or end block has been modified."));
453                }
454                else if(startItem==0 || endItem==0)
455                {
456                    QMessageBox::warning(0,"Arrow can't be loaded",
457                                     tr("An arrow can not be loaded because ")+
458                                     tr("her IO label ID could not be found. ")+
459                                     tr("Probable cause may be that the start")+
460                                     tr(" or end block has been modified."));
461                }
462                else
463                {
464                    Arrow *newArrow = new Arrow(startItem, endItem,0,this);
465                    newArrow->setColor(QColor(arrow.attribute("color")));
466                    startItem->ownerItem()->addArrow(newArrow);
467                    endItem->ownerItem()->addArrow(newArrow);
468                    newArrow->setZValue(0.0);
469                    addItem(newArrow);
470                    newArrow->updatePosition();
471
472                    for (QDomNode node = arrow.firstChild() ;
461473                         !node.isNull() ;
462474                         node = node.nextSibling())
463475                    {
464                        QDomElement arrowCorner = node.toElement();
465                        if(arrowCorner.tagName()!="arrowCorner")
476                        //Load diagram text values and set on diagram item
477                        QDomElement arrowCorners = node.toElement();
478                        if(arrowCorners.tagName()!="arrowCorners")
466479                            return 0;
467
468                        QPointF cornerPos =
469                                QPointF(arrowCorner.attribute("x").toFloat(),
470                                        arrowCorner.attribute("y").toFloat());
471
472                        newArrow->createCorner(cornerPos,++i);
480                        int i=0;
481                        for (QDomNode node = arrowCorners.firstChild() ;
482                             !node.isNull() ;
483                             node = node.nextSibling())
484                        {
485                            QDomElement arrowCorner = node.toElement();
486                            if(arrowCorner.tagName()!="arrowCorner")
487                                return 0;
488
489                            QPointF cornerPos =
490                                    QPointF(arrowCorner.attribute("x").toFloat(),
491                                            arrowCorner.attribute("y").toFloat());
492
493                            newArrow->createCorner(cornerPos,++i);
494                        }
473495                    }
474496                }
475
476497            }
477498        }
478499    }
Software/sie_cg/diagramscene.h
6767public:
6868    enum Mode { InsertItem, InsertLine, InsertText, MoveItem };
6969
70    DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow = 0,
70    DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow,
7171                 QObject *parent = 0);
7272
7373    QFont font() const
...... 
8888    int fromXmlFormat(QDomDocument xmlDocument);
8989    void cleanScene();
9090
91    QHash<int , DiagramItem *> getDiagramsID ()
92        { return DiagramsID;}
93
9194    QStringList getLibList(){return libraryList;}
9295    void setLibList(QStringList list)
9396        {libraryList=list;}
...... 
136139    QStringList libraryList;
137140    QHash<QString , QDomElement*> domElementsByName;
138141    QHash<QString , int> buttonIdByName;
142    QHash<int , DiagramItem *> DiagramsID;
139143    MainWindow *myOwnerWindow;
140144};
141145
Software/sie_cg/diagramscene.pro
33    diagramscene.h \
44    arrow.h \
55    diagramtextitem.h \
6    lineitem.h
6    lineitem.h \
7    codedialog.h \
8    codedialog.h \
9    codedialog.h
710SOURCES = mainwindow.cpp \
811    diagramitem.cpp \
912    main.cpp \
1013    arrow.cpp \
1114    diagramtextitem.cpp \
1215    diagramscene.cpp \
13    lineitem.cpp
16    lineitem.cpp \
17    codedialog.cpp
1418RESOURCES = diagramscene.qrc
15
1619TARGET = diagrameditor
1720
1821# install
...... 
3033QT += xml \
3134    svg \
3235    network
33FORMS += librarydialog.ui
36FORMS += librarydialog.ui \
37    codedialog.ui
Software/sie_cg/diagramscene.pro.user
7676  <valuemap type="QVariantMap">
7777   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
7878   <valuelist key="abstractProcess.Environment" type="QVariantList">
79    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-bm3IFDvHlY,guid=a9cadece3d5adbab4e7ecc664cc367c4</value>
79    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
8080    <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
8181    <value type="QString">DESKTOP_SESSION=gnome</value>
8282    <value type="QString">DISPLAY=:0.0</value>
...... 
8484    <value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
8585    <value type="QString">GDM_LANG=en_US.utf8</value>
8686    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
87    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-EOe3re</value>
88    <value type="QString">GNOME_KEYRING_PID=1591</value>
87    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
8988    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
9089    <value type="QString">HOME=/home/juan64bits</value>
9190    <value type="QString">LANG=en_US.utf8</value>
91    <value type="QString">LANGUAGE=</value>
9292    <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
9393    <value type="QString">LOGNAME=juan64bits</value>
9494    <value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
...... 
9696    <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
9797    <value type="QString">PWD=/home/juan64bits</value>
9898    <value type="QString">QTDIR=/usr/share/qt4</value>
99    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1609,unix/Maximus:/tmp/.ICE-unix/1609</value>
99    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
100100    <value type="QString">SHELL=/bin/bash</value>
101101    <value type="QString">SPEECHD_PORT=7560</value>
102    <value type="QString">SSH_AGENT_PID=1645</value>
103    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-EOe3re/ssh</value>
102    <value type="QString">SSH_AGENT_PID=1408</value>
103    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
104104    <value type="QString">USER=juan64bits</value>
105105    <value type="QString">USERNAME=juan64bits</value>
106    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-XFOps8/database</value>
106    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
107107    <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
108108    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
109    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287874500.2500-279079160</value>
109    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
110110   </valuelist>
111111   <valuelist key="abstractProcess.arguments" type="QVariantList">
112    <value type="QString">/home/juan64bits/QT/sie_cg/diagramscene.pro</value>
112    <value type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/diagramscene.pro</value>
113113    <value type="QString">-spec</value>
114114    <value type="QString">linux-g++</value>
115115    <value type="QString">-r</value>
...... 
117117   </valuelist>
118118   <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
119119   <value key="abstractProcess.enabled" type="bool">false</value>
120   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/QT/sie_cg</value>
120   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg</value>
121121  </valuemap>
122122 </data>
123123 <data>
...... 
125125  <valuemap type="QVariantMap">
126126   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
127127   <valuelist key="abstractProcess.Environment" type="QVariantList">
128    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-bm3IFDvHlY,guid=a9cadece3d5adbab4e7ecc664cc367c4</value>
128    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
129129    <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
130130    <value type="QString">DESKTOP_SESSION=gnome</value>
131131    <value type="QString">DISPLAY=:0.0</value>
...... 
133133    <value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
134134    <value type="QString">GDM_LANG=en_US.utf8</value>
135135    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
136    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-EOe3re</value>
137    <value type="QString">GNOME_KEYRING_PID=1591</value>
136    <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
138137    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
139138    <value type="QString">HOME=/home/juan64bits</value>
140139    <value type="QString">LANG=en_US.utf8</value>
140    <value type="QString">LANGUAGE=</value>
141141    <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
142142    <value type="QString">LOGNAME=juan64bits</value>
143143    <value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
...... 
145145    <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
146146    <value type="QString">PWD=/home/juan64bits</value>
147147    <value type="QString">QTDIR=/usr/share/qt4</value>
148    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1609,unix/Maximus:/tmp/.ICE-unix/1609</value>
148    <value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
149149    <value type="QString">SHELL=/bin/bash</value>
150150    <value type="QString">SPEECHD_PORT=7560</value>
151    <value type="QString">SSH_AGENT_PID=1645</value>
152    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-EOe3re/ssh</value>
151    <value type="QString">SSH_AGENT_PID=1408</value>
152    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
153153    <value type="QString">USER=juan64bits</value>
154154    <value type="QString">USERNAME=juan64bits</value>
155    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-XFOps8/database</value>
155    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
156156    <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
157157    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
158    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287874500.2500-279079160</value>
158    <value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
159159   </valuelist>
160160   <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
161161   <valuelist key="abstractProcess.arguments" type="QVariantList">
...... 
163163   </valuelist>
164164   <value key="abstractProcess.command" type="QString">/usr/bin/make</value>
165165   <value key="abstractProcess.enabled" type="bool">true</value>
166   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/QT/sie_cg</value>
166   <value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg</value>
167167  </valuemap>
168168 </data>
169169 <data>
Software/sie_cg/diagramscene.qrc
2424        <file>images/yes.png</file>
2525        <file>images/zoom_in.png</file>
2626        <file>images/zoom_out.png</file>
27        <file>images/cg.png</file>
2728    </qresource>
2829</RCC>
Software/sie_cg/images/cg.png
Software/sie_cg/mainwindow.cpp
5050{
5151    buttonGroup=0;
5252    toolBox=0;
53
53    statusBar = new QStatusBar(this);
5454    createActions();
5555    createMenus();
5656    scene = new DiagramScene(itemMenu,this);
...... 
6868    setUnifiedTitleAndToolBarOnMac(true);
6969    myFilePath = "";
7070    libDialog=0;
71
71    cgDialog=0;
7272    if(QApplication::argc()>1)
7373        {newDiagram(QString(QApplication::argv()[1]));}
74    statusBar->showMessage("Ready...");
75    this->setStatusBar(statusBar);
7476}
7577
7678void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
...... 
147149    scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
148150}
149151
152void MainWindow::cgGroupClicked(int id)
153{
154    if(id==0)
155    {
156        QString Test;
157        QHash<int , DiagramItem *> DiagramsID = scene->getDiagramsID();
158        foreach (QGraphicsItem *item, scene->items()) {
159            if (item->type() == DiagramItem::Type) {
160                Test+=(tr("\nDiagramID=\t") + QString::number(DiagramsID.
161                    key(qgraphicsitem_cast<DiagramItem *>(item))));
162                QList<DiagramTextItem *> TextItems =
163                    qgraphicsitem_cast<DiagramItem *>(item)->getTextItems();
164                foreach (DiagramTextItem *textItem, TextItems) {
165                    Test+=(tr("\n\tTextItemID=\t") + QString::number(
166                            textItem->textID()));
167                    Test+=(tr("\n\t\tTextItemStyleIO=\t") + QString::number(
168                            textItem->styleIO()));
169                    Test+=(tr("\n\t\tTextItemValue=\t") +
170                            textItem->toPlainText());
171                    Test+=(tr("\n\t\tTextItemEditable=\t") +
172                           (textItem->isEditable()?"true":"false"));
173                }
174            }
175        }
176        codeForm();
177        cgUi->codeTextEdit->setPlainText(Test);
178    }
179}
180
150181void MainWindow::bringToFront()
151182{
152183    sendTo(1);
...... 
378409    //toolBox->addItem(backgroundWidget, tr("Backgrounds"));
379410
380411    //Add tool box to window
381    QHBoxLayout *newLayout = new QHBoxLayout;
382    newLayout->addWidget(toolBox);
412    QGridLayout *newLayout = new QGridLayout;
413    newLayout->addWidget(toolBox,0,0);
383414    view = new QGraphicsView(scene);
384    newLayout->addWidget(view);
415    newLayout->addWidget(view,0,1);
385416
386417    QWidget *widget = new QWidget;
387418    widget->setLayout(newLayout);
...... 
466497
467498
468499    libraryAction = new QAction(tr("&Library..."),this);
500    libraryAction->setStatusTip(tr("Add, Remove or edit libraries"));
469501    connect(libraryAction, SIGNAL(triggered()),
470502            this, SLOT(libraryForm()));
471503
472504    optionsAction = new QAction(tr("&Options"),this);
473505    optionsAction->setShortcuts(QKeySequence::Preferences);
506    optionsAction->setStatusTip(tr("Edit options"));
474507    connect(optionsAction, SIGNAL(triggered()),
475508            this, SLOT(optionsForm()));
476509
...... 
518551    editToolBar->addAction(toFrontAction);
519552    editToolBar->addAction(sendBackAction);
520553
554    QToolButton *cgButton = new QToolButton;
555    cgButton->setCheckable(false);
556    cgButton->setIcon(QIcon(":/images/cg.png"));
557
558    cgGroup = new QButtonGroup;
559    cgGroup->addButton(cgButton,0);
560
561    connect(cgGroup, SIGNAL(buttonClicked(int)),
562            this, SLOT(cgGroupClicked(int)));
563
564    cgToolbar = addToolBar(tr("Code Generator"));
565    cgToolbar->addWidget(cgButton);
566
567
521568    fontCombo = new QFontComboBox();
522569    fontSizeCombo = new QComboBox();
523570    connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
...... 
602649    pointerToolbar->addWidget(pointerButton);
603650    pointerToolbar->addWidget(linePointerButton);
604651    pointerToolbar->addWidget(sceneScaleCombo);
652
605653}
606654
607655QWidget *MainWindow::createCellWidget(QString text, QDomElement *customItem)
...... 
712760        file.close();
713761        if(!parsing)
714762        {
715            QMessageBox::warning(this,"Operation failed","Failed to parse file, "
716                                 "wrong format or encoding.");
763            QMessageBox::warning(this,"Parsing warning","Invalid or void "
764                                 " element found in file.");
717765        }
718766    }
719767    else
...... 
821869
822870int MainWindow::libraryForm()
823871{
872    bool firstTime=0;
824873    if(!libDialog)
825874    {
826875        createLibraryDialog();
876        firstTime=1;
827877    }
828878    libDialog->setModal(1);
829879    libUi->listLib->clear();
830880    libUi->listLib->addItems(libraryList);
831881    libDialog->setWindowTitle(tr("Library paths..."));
832882    QStringList oldLibraryList=libraryList;
833    libDialog->exec();
883    if(firstTime)
884        libDialog->exec();
885    else
886        libDialog->show();
834887
835888    if (libDialog->result() == QDialog::Rejected)
836889        libraryList = oldLibraryList;
...... 
838891    {
839892        scene->setLibList(libraryList);
840893        updateLibraries();
841    }
894    }
842895
843896    return 0;
844897}
...... 
854907    connect(libUi->editLib,SIGNAL(clicked()),this,SLOT(editLibPath()));
855908}
856909
910int MainWindow::codeForm()
911{
912    if(!cgDialog)
913    {
914        createCgDialog();
915    }
916
917    cgDialog->setWindowTitle(tr("Code Generator..."));
918    cgUi->codeTextEdit->setAcceptRichText(true);
919        cgDialog->show();
920
921    return 0;
922}
923
924void MainWindow::createCgDialog()
925{
926    cgDialog = new QMainWindow(this);
927    cgUi = new Ui_codeDialog;
928    cgUi->setupUi(cgDialog);
929}
930
857931void MainWindow::addLibPath()
858932{
859933    QString
...... 
869943                                           " or not exists.");
870944        return;
871945    }
872    if(libUi->listLib->findItems(filePath,Qt::MatchExactly).count()==0)
873    {
874        QDir myCurrentDir = this->currentDir();
875        QString relativePath=myCurrentDir.relativeFilePath(filePath);
946    QDir myCurrentDir = this->currentDir();
947    QString relativePath= myCurrentDir.relativeFilePath(filePath);
948    if(libUi->listLib->findItems(relativePath,Qt::MatchExactly).count()==0)
949    {
876950        libraryList.append(relativePath);
877951        libUi->listLib->addItem(relativePath);
878952    }
Software/sie_cg/mainwindow.h
5454#include "lineitem.h"
5555#include "arrow.h"
5656#include "ui_librarydialog.h"
57#include "ui_codedialog.h"
5758
5859class DiagramScene;
60class DiagramTextItem;
61class DiagramItem;
5962class Ui_libraryDialog;
63class callexternappT;
6064
6165QT_BEGIN_NAMESPACE
6266class QAction;
...... 
8690
8791   int updateLibraries();
8892
93   QStatusBar *statusBar;
94
8995private slots:
9096    void backgroundButtonGroupClicked(QAbstractButton *button);
9197    void buttonGroupClicked(int id);
98    void cgGroupClicked(int id);
9299    void deleteItem();
93100    void pointerGroupClicked(int id);
94101    void bringToFront();
...... 
121128
122129    int optionsForm();
123130
124
131    int codeForm();
125132
126133private:
127134    int saveIfNeeded();
128135    void addLibrariesButtons(QGridLayout *layout);
129136    QDomDocument parseDocument(QString filePath);
130137    void createLibraryDialog();
138    void createCgDialog();
131139    void createToolBox();
132140    void createActions();
133141    void createMenus();
...... 
167175    QMenu *aboutMenu;
168176
169177    QToolBar *fileToolBar;
178    QToolBar *cgToolbar;
170179    QToolBar *textToolBar;
171180    QToolBar *editToolBar;
172181    QToolBar *colorToolBar;
173    QToolBar *pointerToolbar;
182    QToolBar *pointerToolbar;
174183
175184    QComboBox *sceneScaleCombo;
176185    QComboBox *itemColorCombo;
...... 
181190    QToolBox *toolBox;
182191    QButtonGroup *buttonGroup;
183192    QButtonGroup *pointerTypeGroup;
193    QButtonGroup *cgGroup;
184194    QButtonGroup *backgroundButtonGroup;
185195    QToolButton *fontColorToolButton;
186196    QToolButton *fillColorToolButton;
...... 
192202    QAction *fillAction;
193203    QAction *lineAction;
194204    QString myFilePath;
195
196205    QDialog *libDialog;
197206    Ui_libraryDialog *libUi;
207    QMainWindow *cgDialog;
208    Ui_codeDialog *cgUi;
198209    QStringList libraryList;
199210    QHash<QString , QDomElement*> domElementsByName;
200211    QHash<QString , int> buttonIdByName;
201    static QString callexternapp(QString xexecFile, QString xexecParm);
202
212    static QString callexternapp(QString xexecFile, QString xexecParm);
203213};
204214
205215class callexternappT : public QThread
...... 
212222    {
213223        QProcess lnexternapp;
214224        lnexternapp.start(QString("%1 %2").arg(execFile).arg(execParm));
215        //lnexternapp.waitForFinished(-1);
216        //retnValu = QString(lnexternapp.readAll());
225        lnexternapp.waitForFinished(-1);
226        retnValu = QString(lnexternapp.readAll());
217227    }
218228};
219229
Software/sie_cg/test.sie
2626        </DiagramItem>
2727        <DiagramItem x="2460" y="2350" z="500" type="Right Shift" ID="1" color="#00ffff">
2828            <diagramValues>
29                <diagramValue value="1" ID="11"/>
29                <diagramValue value="2" ID="11"/>
3030            </diagramValues>
3131        </DiagramItem>
3232        <DiagramItem x="2670" y="2350" z="500" type="PWM Single" ID="2" color="#808000">
...... 
3939        </DiagramItem>
4040        <DiagramItem x="2470" y="2100" z="500" type="Constant" ID="4" color="#00ffff">
4141            <diagramValues>
42                <diagramValue value="Value" ID="21"/>
43                <diagramValue value="1" ID="19"/>
42                <diagramValue value="1" ID="1"/>
4443            </diagramValues>
4544        </DiagramItem>
46        <DiagramItem x="2220" y="2330" z="-0.1" type="ADC Single" ID="5" color="#808080">
45        <DiagramItem x="2230" y="2330" z="-0.1" type="ADC Single" ID="5" color="#808080">
4746            <diagramValues>
47                <diagramValue value="255" ID="9"/>
4848                <diagramValue value="0" ID="4"/>
49                <diagramValue value="255" ID="7"/>
5049            </diagramValues>
5150        </DiagramItem>
5251    </DiagramItems>
5352    <Arrows>
54        <Arrow end-ID="12" end-Owner="1" start-x="110" start-y="20" start-Owner="5" ID="0" start-ID="8" end-x="-70" end-y="0" color="#000000"/>
55        <Arrow end-ID="14" end-Owner="2" start-x="60" start-y="0" start-Owner="1" ID="1" start-ID="13" end-x="-90" end-y="0" color="#000000"/>
56        <Arrow end-ID="14" end-Owner="3" start-x="30" start-y="20" start-Owner="4" ID="2" start-ID="15" end-x="-50" end-y="10" color="#000000"/>
53        <Arrow end-ID="2" end-Owner="1" start-x="110" start-y="20" start-Owner="5" ID="0" start-ID="7" end-x="-70" end-y="0" color="#000000"/>
54        <Arrow end-ID="4" end-Owner="2" start-x="60" start-y="0" start-Owner="1" ID="1" start-ID="3" end-x="-90" end-y="0" color="#000000"/>
55        <Arrow end-ID="6" end-Owner="3" start-x="30" start-y="20" start-Owner="4" ID="2" start-ID="15" end-x="-50" end-y="10" color="#000000"/>
5756    </Arrows>
5857</Diagram>
59<Test/>

Archive Download the corresponding diff file

Branches:
master



interactive