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>

View File

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

View File

@ -0,0 +1,23 @@
#ifndef CODEDIALOG_H
#define CODEDIALOG_H
#include <QMainWindow>
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

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>codeDialog</class>
<widget class="QMainWindow" name="codeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="okButton">
<property name="text">
<string>&amp;Ok</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTextEdit" name="codeTextEdit">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>codeDialog</receiver>
<slot>hide()</slot>
<hints>
<hint type="sourcelabel">
<x>392</x>
<y>423</y>
</hint>
<hint type="destinationlabel">
<x>319</x>
<y>239</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

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

View File

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

View File

@ -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<DiagramItem *> Items;
QList<Arrow *> Arrows;
@ -333,7 +329,7 @@ QDomDocument DiagramScene::toXmlFormat()
int DiagramScene::fromXmlFormat(QDomDocument document)
{
//Read diagrams TODO: in future... add multi projects functionality
QHash<int , DiagramItem *> 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);
}
}
}
}
}
}

View File

@ -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<int , DiagramItem *> getDiagramsID ()
{ return DiagramsID;}
QStringList getLibList(){return libraryList;}
void setLibList(QStringList list)
{libraryList=list;}
@ -136,6 +139,7 @@ private:
QStringList libraryList;
QHash<QString , QDomElement*> domElementsByName;
QHash<QString , int> buttonIdByName;
QHash<int , DiagramItem *> DiagramsID;
MainWindow *myOwnerWindow;
};

View File

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

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-bm3IFDvHlY,guid=a9cadece3d5adbab4e7ecc664cc367c4</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,11 +84,11 @@
<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-EOe3re</value>
<value type="QString">GNOME_KEYRING_PID=1591</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>
<value type="QString">LANGUAGE=</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=juan64bits</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
@ -96,20 +96,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/1609,unix/Maximus:/tmp/.ICE-unix/1609</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=1645</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-EOe3re/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-XFOps8/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-1287874500.2500-279079160</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/sie_cg/diagramscene.pro</value>
<value type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg/diagramscene.pro</value>
<value type="QString">-spec</value>
<value type="QString">linux-g++</value>
<value type="QString">-r</value>
@ -117,7 +117,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/sie_cg</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg</value>
</valuemap>
</data>
<data>
@ -125,7 +125,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-bm3IFDvHlY,guid=a9cadece3d5adbab4e7ecc664cc367c4</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,11 +133,11 @@
<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-EOe3re</value>
<value type="QString">GNOME_KEYRING_PID=1591</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>
<value type="QString">LANGUAGE=</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=juan64bits</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
@ -145,17 +145,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/1609,unix/Maximus:/tmp/.ICE-unix/1609</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=1645</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-EOe3re/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-XFOps8/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-1287874500.2500-279079160</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 +163,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/sie_cg</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/juan64bits/ebd/ECB/nn-usb-fpga/Software/sie_cg</value>
</valuemap>
</data>
<data>

View File

@ -24,5 +24,6 @@
<file>images/yes.png</file>
<file>images/zoom_in.png</file>
<file>images/zoom_out.png</file>
<file>images/cg.png</file>
</qresource>
</RCC>

BIN
Software/sie_cg/images/cg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -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<int , DiagramItem *> DiagramsID = scene->getDiagramsID();
foreach (QGraphicsItem *item, scene->items()) {
if (item->type() == DiagramItem::Type) {
Test+=(tr("\nDiagramID=\t") + QString::number(DiagramsID.
key(qgraphicsitem_cast<DiagramItem *>(item))));
QList<DiagramTextItem *> TextItems =
qgraphicsitem_cast<DiagramItem *>(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);
}

View File

@ -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<QString , QDomElement*> domElementsByName;
QHash<QString , int> 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());
}
};

View File

@ -26,7 +26,7 @@ Arrows depend of items, and items depend of libraries!!!!
</DiagramItem>
<DiagramItem x="2460" y="2350" z="500" type="Right Shift" ID="1" color="#00ffff">
<diagramValues>
<diagramValue value="1" ID="11"/>
<diagramValue value="2" ID="11"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2670" y="2350" z="500" type="PWM Single" ID="2" color="#808000">
@ -39,21 +39,19 @@ Arrows depend of items, and items depend of libraries!!!!
</DiagramItem>
<DiagramItem x="2470" y="2100" z="500" type="Constant" ID="4" color="#00ffff">
<diagramValues>
<diagramValue value="Value" ID="21"/>
<diagramValue value="1" ID="19"/>
<diagramValue value="1" ID="1"/>
</diagramValues>
</DiagramItem>
<DiagramItem x="2220" y="2330" z="-0.1" type="ADC Single" ID="5" color="#808080">
<DiagramItem x="2230" y="2330" z="-0.1" type="ADC Single" ID="5" color="#808080">
<diagramValues>
<diagramValue value="255" ID="9"/>
<diagramValue value="0" ID="4"/>
<diagramValue value="255" ID="7"/>
</diagramValues>
</DiagramItem>
</DiagramItems>
<Arrows>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
</Arrows>
</Diagram>
<Test/>