1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2025-04-21 12:27:27 +03:00

Adding bases to the code generator. Code text edit, fixing input/output ID control, etc.

This commit is contained in:
Juan64Bits
2010-11-20 16:19:34 -05:00
parent 9d578912b7
commit 2efe106cf3
29 changed files with 531 additions and 157 deletions

View File

@@ -13,11 +13,11 @@
<Point x="-60" y="40"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="3" text="ADC Single Channel" posOffset-x="0"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="4" text="0" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="5" text="CH:" posOffset-x="-20"/>
<TextItem myStyleIO="7" posOffset-y="-20" editableItem="0" ID="7" text=" Long" posOffset-x="110"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="9" text="255" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="0" ID="6" text="SP:" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-20" editableItem="1" ID="7" text="255" posOffset-x="20"/>
<TextItem myStyleIO="8" posOffset-y="-20" editableItem="0" ID="8" text="UChar" posOffset-x="110"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="5" text="CH:" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="4" text="0" posOffset-x="20"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="3" text="ADC Single Channel" posOffset-x="0"/>
</TextItems>
</CustomItem>

View File

@@ -196,6 +196,8 @@ void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
SECLine->setColor(myColor);
}
}
painter->setBrush(Qt::lightGray);
painter->drawPolygon(this->path().toFillPolygon());
setSelectedArrows();
}

View File

@@ -7,8 +7,8 @@
<Point x="30" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="21" text="Value" posOffset-x="-30"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="1" text="1" posOffset-x="10"/>
<TextItem myStyleIO="3" posOffset-y="-20" editableItem="0" ID="15" text="OUT Integer" posOffset-x="30"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="1" ID="19" text="1" posOffset-x="10"/>
<TextItem myStyleIO="0" posOffset-y="-0" editableItem="0" ID="0" text="Value" posOffset-x="-30"/>
</TextItems>
</CustomItem>

View File

@@ -43,9 +43,11 @@
#include <QHash>
#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<DiagramTextItem*>(item)->styleIO();
if(styleIO<256)
{
int ioID = qgraphicsitem_cast<DiagramTextItem*>(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<DiagramTextItem *>(item)->styleIO()<256)
{
myOwnerWindow->statusBar->showMessage(
qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
tr("\t : Input/Output text label -> {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}"));
}
else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==256)
{
myOwnerWindow->statusBar->showMessage(
qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
tr("\t : Text label -> {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(item)->textID()) + tr("}"));
}
else if(qgraphicsitem_cast<DiagramTextItem *>(item)->styleIO()==257)
{
myOwnerWindow->statusBar->showMessage(
qgraphicsitem_cast<DiagramTextItem *>(item)->toPlainText() +
tr("\t : Editable text label -> {ID = ") +
QString::number(qgraphicsitem_cast<DiagramTextItem *>
(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)

View File

@@ -47,6 +47,7 @@
#include <QtXml>
#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<int,DiagramTextItem*> textItemsByID;
MainWindow *myOwnerWindow;
};
#endif

View File

@@ -76,7 +76,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MI4KrAyPP5,guid=5c5c5e6146195c74b6ad266d4cc07afd</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
@@ -84,8 +84,7 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-CFAuJK</value>
<value type="QString">GNOME_KEYRING_PID=1516</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/juan64bits</value>
<value type="QString">LANG=en_US.utf8</value>
@@ -96,20 +95,20 @@
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/juan64bits</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1534,unix/Maximus:/tmp/.ICE-unix/1534</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1570</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-CFAuJK/ssh</value>
<value type="QString">SSH_AGENT_PID=1408</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
<value type="QString">USER=juan64bits</value>
<value type="QString">USERNAME=juan64bits</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-V4ry7M/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287682812.550485-1725059380</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">/home/juan64bits/QT/diagramscene/block_editor/diagramscene.pro</value>
<value type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor/diagramscene.pro</value>
<value type="QString">-spec</value>
<value type="QString">linux-g++</value>
<value type="QString">-r</value>
@@ -117,7 +116,7 @@
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
<value key="abstractProcess.enabled" type="bool">false</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/QT/diagramscene/block_editor</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor</value>
</valuemap>
</data>
<data>
@@ -125,7 +124,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MI4KrAyPP5,guid=5c5c5e6146195c74b6ad266d4cc07afd</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-i0TevybO0n,guid=8b93acbaab2ecdba6bb7d4064ce7e29f</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
@@ -133,8 +132,7 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=es</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-CFAuJK</value>
<value type="QString">GNOME_KEYRING_PID=1516</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7RmeU0</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/juan64bits</value>
<value type="QString">LANG=en_US.utf8</value>
@@ -145,17 +143,17 @@
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/juan64bits</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1534,unix/Maximus:/tmp/.ICE-unix/1534</value>
<value type="QString">SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/1244,unix/Maximus:/tmp/.ICE-unix/1244</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1570</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-CFAuJK/ssh</value>
<value type="QString">SSH_AGENT_PID=1408</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7RmeU0/ssh</value>
<value type="QString">USER=juan64bits</value>
<value type="QString">USERNAME=juan64bits</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-V4ry7M/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-juan64bits-W3dU0B/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1287682812.550485-1725059380</value>
<value type="QString">XDG_SESSION_COOKIE=b9a7fbc4d869fc15bd6cdd474bcc9a28-1290265246.859440-43205519</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">
@@ -163,7 +161,7 @@
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
<value key="abstractProcess.enabled" type="bool">true</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/QT/diagramscene/block_editor</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/block_editor</value>
</valuemap>
</data>
<data>

View File

@@ -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;}

View File

@@ -9,10 +9,10 @@
<Point x="-70" y="-30"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="9" posOffset-y="-0" editableItem="0" ID="13" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="138" posOffset-y="-0" editableItem="0" ID="12" text="IN" posOffset-x="-70"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text="&lt;&lt;" posOffset-x="-20"/>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="0" text="IN" posOffset-x="-70"/>
<TextItem myStyleIO="3" posOffset-y="-0" editableItem="0" ID="1" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="5" text="Bitwise Shift" posOffset-x="-10"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text="&lt;&lt;" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
</TextItems>
</CustomItem>

View File

@@ -53,6 +53,7 @@ class QRectF;
class QGraphicsSceneMouseEvent;
class QPainterPath;
QT_END_NAMESPACE
class Arrow;
class lineItem : public QGraphicsLineItem
{

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -50,6 +50,7 @@
#include "diagramtextitem.h"
#include "lineitem.h"
#include "arrow.h"
#include <QtGui>
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;

View File

@@ -23,10 +23,10 @@
<Point x="-90" y="20"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="137" posOffset-y="-0" editableItem="0" ID="14" text="UChar" posOffset-x="-90"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="15" text="|-Duty-|" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="1" ID="16" text="0" posOffset-x="0"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="11" text="Out:" posOffset-x="-20"/>
<TextItem myStyleIO="136" posOffset-y="-0" editableItem="0" ID="4" text="UChar" posOffset-x="-90"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="18" text="PWM" posOffset-x="-50"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="0" ID="11" text="Out:" posOffset-x="-20"/>
<TextItem myStyleIO="0" posOffset-y="40" editableItem="1" ID="16" text="0" posOffset-x="0"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="15" text="|-Duty-|" posOffset-x="-20"/>
</TextItems>
</CustomItem>

View File

@@ -9,10 +9,10 @@
<Point x="-70" y="-30"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="9" posOffset-y="-0" editableItem="0" ID="13" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="138" posOffset-y="-0" editableItem="0" ID="12" text="IN" posOffset-x="-70"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text=">>" posOffset-x="-20"/>
<TextItem myStyleIO="2" posOffset-y="-0" editableItem="0" ID="3" text="OUT" posOffset-x="60"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="5" text="Bitwise Shift" posOffset-x="-10"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="0" ID="10" text=">>" posOffset-x="-20"/>
<TextItem myStyleIO="131" posOffset-y="-0" editableItem="0" ID="2" text="IN" posOffset-x="-70"/>
<TextItem myStyleIO="0" posOffset-y="-10" editableItem="1" ID="11" text="1" posOffset-x="10"/>
</TextItems>
</CustomItem>

View File

@@ -23,7 +23,7 @@
<Point x="-50" y="-10"/>
</Polygon>
<TextItems>
<TextItem myStyleIO="130" posOffset-y="-10" editableItem="0" ID="14" text="IN Bool" posOffset-x="-50"/>
<TextItem myStyleIO="129" posOffset-y="-10" editableItem="0" ID="6" text="IN Bool" posOffset-x="-50"/>
<TextItem myStyleIO="0" posOffset-y="20" editableItem="0" ID="23" text="System While" posOffset-x="0"/>
</TextItems>
</CustomItem>