Software/sie_cg/block_editor/diagramscene.cpp |
43 | 43 | #include <QHash> |
44 | 44 | #include "diagramscene.h" |
45 | 45 | |
46 | | DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent) |
| 46 | DiagramScene::DiagramScene(QMenu *itemMenu, MainWindow *ownerWindow, |
| 47 | QObject *parent) |
47 | 48 | : QGraphicsScene(parent) |
48 | 49 | { |
| 50 | myOwnerWindow = ownerWindow; |
49 | 51 | myItemMenu = itemMenu; |
50 | 52 | myMode = MoveItem; |
51 | 53 | |
... | ... | |
59 | 61 | myPolygonPath=0; |
60 | 62 | myCorners=0; |
61 | 63 | |
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)); |
64 | 66 | addItem(TitleText); |
65 | 67 | |
66 | 68 | } |
... | ... | |
124 | 126 | } |
125 | 127 | } |
126 | 128 | |
| 129 | QString 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 | |
127 | 189 | void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) |
128 | 190 | { |
129 | 191 | 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(); |
131 | 221 | |
| 222 | QString Text; |
132 | 223 | if (mouseEvent->button() != Qt::LeftButton) |
133 | 224 | return; |
134 | 225 | |
| 226 | int addResult=0; |
| 227 | |
135 | 228 | switch (myMode) |
136 | 229 | { |
137 | 230 | case InsertText: |
... | ... | |
146 | 239 | |
147 | 240 | textItem = new DiagramTextItem(0,0,1,myTextType,0,Text, |
148 | 241 | mouseEvent->scenePos()); |
149 | | if(addTextItem(textItem)) |
| 242 | addResult=addTextItem(textItem); |
| 243 | if(addResult!=-1) |
150 | 244 | { |
151 | 245 | textItem->setZValue(1000.0); |
152 | 246 | connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)), |
153 | 247 | this, SLOT(editorLostFocus(DiagramTextItem*))); |
154 | 248 | addItem(textItem); |
| 249 | textItem->setTextID(addResult); |
155 | 250 | } |
156 | 251 | else |
157 | 252 | { |
158 | 253 | delete(textItem); |
159 | | QMessageBox::warning(0,"Full","The block can only have only" |
| 254 | QMessageBox::warning(0,"Full","The block can only have " |
160 | 255 | "255 text items"); |
161 | 256 | } |
162 | 257 | emit textInserted(textItem); |
... | ... | |
237 | 332 | void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) |
238 | 333 | { |
239 | 334 | doSnapToGrid(mouseEvent); |
240 | | if (myMode != EditPolygon && line == 0) |
| 335 | if(myMode != EditPolygon && line == 0) |
241 | 336 | QGraphicsScene::mouseReleaseEvent(mouseEvent); |
242 | 337 | } |
243 | 338 | |
... | ... | |
377 | 472 | } |
378 | 473 | } |
379 | 474 | } |
380 | | |
| 475 | myOwnerWindow->updateProt(); |
381 | 476 | return 1; |
382 | 477 | } |
383 | 478 | |
... | ... | |
418 | 513 | if(iter==textItemsByID.end()) |
419 | 514 | { |
420 | 515 | textItemsByID.insert(i,textItem); |
421 | | return 1; |
| 516 | return i; |
422 | 517 | } |
423 | 518 | } |
424 | | return 0; |
| 519 | return -1; |
425 | 520 | } |
426 | 521 | |
427 | 522 | void DiagramScene::removeTextItem(DiagramTextItem * textItem) |
Software/sie_cg/block_editor/diagramscene.pro.user |
76 | 76 | <valuemap type="QVariantMap"> |
77 | 77 | <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> |
78 | 78 | <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> |
80 | 80 | <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value> |
81 | 81 | <value type="QString">DESKTOP_SESSION=gnome</value> |
82 | 82 | <value type="QString">DISPLAY=:0.0</value> |
... | ... | |
84 | 84 | <value type="QString">GDM_KEYBOARD_LAYOUT=es</value> |
85 | 85 | <value type="QString">GDM_LANG=en_US.utf8</value> |
86 | 86 | <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> |
89 | 88 | <value type="QString">GTK_MODULES=canberra-gtk-module</value> |
90 | 89 | <value type="QString">HOME=/home/juan64bits</value> |
91 | 90 | <value type="QString">LANG=en_US.utf8</value> |
... | ... | |
96 | 95 | <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value> |
97 | 96 | <value type="QString">PWD=/home/juan64bits</value> |
98 | 97 | <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> |
100 | 99 | <value type="QString">SHELL=/bin/bash</value> |
101 | 100 | <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> |
104 | 103 | <value type="QString">USER=juan64bits</value> |
105 | 104 | <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> |
107 | 106 | <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value> |
108 | 107 | <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> |
110 | 109 | </valuelist> |
111 | 110 | <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> |
113 | 112 | <value type="QString">-spec</value> |
114 | 113 | <value type="QString">linux-g++</value> |
115 | 114 | <value type="QString">-r</value> |
... | ... | |
117 | 116 | </valuelist> |
118 | 117 | <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> |
119 | 118 | <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> |
121 | 120 | </valuemap> |
122 | 121 | </data> |
123 | 122 | <data> |
... | ... | |
125 | 124 | <valuemap type="QVariantMap"> |
126 | 125 | <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> |
127 | 126 | <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> |
129 | 128 | <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value> |
130 | 129 | <value type="QString">DESKTOP_SESSION=gnome</value> |
131 | 130 | <value type="QString">DISPLAY=:0.0</value> |
... | ... | |
133 | 132 | <value type="QString">GDM_KEYBOARD_LAYOUT=es</value> |
134 | 133 | <value type="QString">GDM_LANG=en_US.utf8</value> |
135 | 134 | <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> |
138 | 136 | <value type="QString">GTK_MODULES=canberra-gtk-module</value> |
139 | 137 | <value type="QString">HOME=/home/juan64bits</value> |
140 | 138 | <value type="QString">LANG=en_US.utf8</value> |
... | ... | |
145 | 143 | <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value> |
146 | 144 | <value type="QString">PWD=/home/juan64bits</value> |
147 | 145 | <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> |
149 | 147 | <value type="QString">SHELL=/bin/bash</value> |
150 | 148 | <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> |
153 | 151 | <value type="QString">USER=juan64bits</value> |
154 | 152 | <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> |
156 | 154 | <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value> |
157 | 155 | <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> |
159 | 157 | </valuelist> |
160 | 158 | <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value> |
161 | 159 | <valuelist key="abstractProcess.arguments" type="QVariantList"> |
... | ... | |
163 | 161 | </valuelist> |
164 | 162 | <value key="abstractProcess.command" type="QString">/usr/bin/make</value> |
165 | 163 | <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> |
167 | 165 | </valuemap> |
168 | 166 | </data> |
169 | 167 | <data> |
Software/sie_cg/block_editor/mainwindow.cpp |
51 | 51 | createActions(); |
52 | 52 | createToolBox(); |
53 | 53 | createMenus(); |
| 54 | statusBar = new QStatusBar(this); |
54 | 55 | |
55 | | scene = new DiagramScene(itemMenu); |
| 56 | scene = new DiagramScene(itemMenu,this); |
56 | 57 | scene->setSceneRect(QRectF(0, 0, 1000, 1000)); |
57 | 58 | connect(scene, SIGNAL(textInserted(QGraphicsTextItem*)), |
58 | 59 | this, SLOT(textInserted(QGraphicsTextItem*))); |
59 | 60 | |
60 | 61 | createToolbars(); |
61 | 62 | |
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); |
66 | 91 | |
67 | 92 | QWidget *widget = new QWidget; |
68 | 93 | widget->setLayout(layout); |
... | ... | |
74 | 99 | |
75 | 100 | if(QApplication::argc()>1) |
76 | 101 | {newDiagram(QString(QApplication::argv()[1]));} |
| 102 | statusBar->showMessage("Ready..."); |
| 103 | this->setStatusBar(statusBar); |
77 | 104 | } |
78 | 105 | |
79 | 106 | void MainWindow::deleteItem() |
... | ... | |
103 | 130 | scene->removeItem(item); |
104 | 131 | delete(item); |
105 | 132 | } |
| 133 | updateProt(); |
106 | 134 | } |
107 | 135 | } |
108 | 136 | } |
... | ... | |
111 | 139 | { |
112 | 140 | buttonGroup->button(selectedButton)->setChecked(false); |
113 | 141 | scene->setMode(DiagramScene::MoveItem); |
| 142 | updateProt(); |
114 | 143 | } |
115 | 144 | |
| 145 | void MainWindow::updateProt() |
| 146 | { |
| 147 | prototypeLabel->setText(scene->createPrototype()); |
| 148 | } |
116 | 149 | |
117 | 150 | void MainWindow::sceneScaleChanged(const QString &scale) |
118 | 151 | { |
... | ... | |
158 | 191 | QGridLayout *layout = new QGridLayout; |
159 | 192 | //INPUTS |
160 | 193 | int i=0; |
161 | | layout->addWidget(createToolButton(129+i,tr("Bool"), |
| 194 | layout->addWidget(createToolButton(128+i,tr("Bool"), |
162 | 195 | QIcon(":/images/background1.png")),++i,0); |
163 | | layout->addWidget(createToolButton(129+i,tr("Char"), |
| 196 | layout->addWidget(createToolButton(128+i,tr("Char"), |
164 | 197 | QIcon(":/images/background1.png")),++i,0); |
165 | | layout->addWidget(createToolButton(129+i,tr("Integer"), |
| 198 | layout->addWidget(createToolButton(128+i,tr("Integer"), |
166 | 199 | QIcon(":/images/background1.png")),++i,0); |
167 | | layout->addWidget(createToolButton(129+i,tr("Double"), |
| 200 | layout->addWidget(createToolButton(128+i,tr("Double"), |
168 | 201 | QIcon(":/images/background1.png")),++i,0); |
169 | | layout->addWidget(createToolButton(129+i,tr("Float"), |
| 202 | layout->addWidget(createToolButton(128+i,tr("Float"), |
170 | 203 | QIcon(":/images/background1.png")),++i,0); |
171 | | layout->addWidget(createToolButton(129+i,tr("Short"), |
| 204 | layout->addWidget(createToolButton(128+i,tr("Short"), |
172 | 205 | QIcon(":/images/background1.png")),++i,0); |
173 | | layout->addWidget(createToolButton(129+i,tr("Long"), |
| 206 | layout->addWidget(createToolButton(128+i,tr("Long"), |
174 | 207 | QIcon(":/images/background1.png")),++i,0); |
175 | | layout->addWidget(createToolButton(129+i,tr("UChar"), |
| 208 | layout->addWidget(createToolButton(128+i,tr("UChar"), |
176 | 209 | QIcon(":/images/background1.png")),++i,0); |
177 | | layout->addWidget(createToolButton(129+i,tr("UInt"), |
| 210 | layout->addWidget(createToolButton(128+i,tr("UInt"), |
178 | 211 | QIcon(":/images/background1.png")),++i,0); |
179 | | layout->addWidget(createToolButton(129+i,tr("UShort"), |
| 212 | layout->addWidget(createToolButton(128+i,tr("UShort"), |
180 | 213 | QIcon(":/images/background1.png")),++i,0); |
181 | | layout->addWidget(createToolButton(129+i,tr("ULong"), |
| 214 | layout->addWidget(createToolButton(128+i,tr("ULong"), |
182 | 215 | QIcon(":/images/background1.png")),++i,0); |
183 | 216 | |
184 | 217 | |
... | ... | |
343 | 376 | { |
344 | 377 | saveIfNeeded(); |
345 | 378 | scene->cleanScene(); |
| 379 | prototypeLabel->setText("\nvoid BLOCK_NAME () {"); |
346 | 380 | myFilePath=""; |
347 | 381 | |
348 | 382 | if(filePath=="") |
... | ... | |
357 | 391 | file.close(); |
358 | 392 | if(!parsing) |
359 | 393 | { |
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."); |
362 | 396 | return 0; |
363 | 397 | } |
364 | 398 | scene->fromXmlFormat(document); |
Software/sie_cg/diagramscene.cpp |
277 | 277 | QDomElement diagram = document.createElement("Diagram"); |
278 | 278 | document.appendChild(diagram); |
279 | 279 | |
280 | | QDomElement test = document.createElement("Test"); |
281 | | test.text().fromAscii("TEXT HERE"); |
282 | | document.appendChild(test); |
283 | | |
284 | 280 | //Lists of items |
285 | 281 | QList<DiagramItem *> Items; |
286 | 282 | QList<Arrow *> Arrows; |
... | ... | |
333 | 329 | int DiagramScene::fromXmlFormat(QDomDocument document) |
334 | 330 | { |
335 | 331 | //Read diagrams TODO: in future... add multi projects functionality |
336 | | QHash<int , DiagramItem *> DiagramsID; |
| 332 | DiagramsID.clear(); |
337 | 333 | QDomNodeList diagrams = document.elementsByTagName("Diagram"); |
338 | 334 | if(!diagrams.at(0).isElement()) |
339 | 335 | return 0; |
... | ... | |
436 | 432 | DiagramTextItem *startItem= |
437 | 433 | DiagramsID.value(arrow.attribute("start-Owner").toInt()) |
438 | 434 | ->pointerText(arrow.attribute("start-ID").toInt()); |
| 435 | bool startIsIO = |
| 436 | DiagramsID.value(arrow.attribute("start-Owner").toInt()) |
| 437 | ->textIsIO(arrow.attribute("start-ID").toInt()); |
439 | 438 | DiagramTextItem *endItem= |
440 | 439 | DiagramsID.value(arrow.attribute("end-Owner").toInt()) |
441 | 440 | ->pointerText(arrow.attribute("end-ID").toInt()); |
| 441 | bool endIsIO = |
| 442 | DiagramsID.value(arrow.attribute("end-Owner").toInt()) |
| 443 | ->textIsIO(arrow.attribute("end-ID").toInt()); |
442 | 444 | |
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) |
454 | 446 | { |
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() ; |
461 | 473 | !node.isNull() ; |
462 | 474 | node = node.nextSibling()) |
463 | 475 | { |
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") |
466 | 479 | 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 | } |
473 | 495 | } |
474 | 496 | } |
475 | | |
476 | 497 | } |
477 | 498 | } |
478 | 499 | } |
Software/sie_cg/diagramscene.pro.user |
76 | 76 | <valuemap type="QVariantMap"> |
77 | 77 | <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> |
78 | 78 | <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> |
80 | 80 | <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value> |
81 | 81 | <value type="QString">DESKTOP_SESSION=gnome</value> |
82 | 82 | <value type="QString">DISPLAY=:0.0</value> |
... | ... | |
84 | 84 | <value type="QString">GDM_KEYBOARD_LAYOUT=es</value> |
85 | 85 | <value type="QString">GDM_LANG=en_US.utf8</value> |
86 | 86 | <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> |
89 | 88 | <value type="QString">GTK_MODULES=canberra-gtk-module</value> |
90 | 89 | <value type="QString">HOME=/home/juan64bits</value> |
91 | 90 | <value type="QString">LANG=en_US.utf8</value> |
| 91 | <value type="QString">LANGUAGE=</value> |
92 | 92 | <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> |
93 | 93 | <value type="QString">LOGNAME=juan64bits</value> |
94 | 94 | <value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value> |
... | ... | |
96 | 96 | <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value> |
97 | 97 | <value type="QString">PWD=/home/juan64bits</value> |
98 | 98 | <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> |
100 | 100 | <value type="QString">SHELL=/bin/bash</value> |
101 | 101 | <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> |
104 | 104 | <value type="QString">USER=juan64bits</value> |
105 | 105 | <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> |
107 | 107 | <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value> |
108 | 108 | <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> |
110 | 110 | </valuelist> |
111 | 111 | <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> |
113 | 113 | <value type="QString">-spec</value> |
114 | 114 | <value type="QString">linux-g++</value> |
115 | 115 | <value type="QString">-r</value> |
... | ... | |
117 | 117 | </valuelist> |
118 | 118 | <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> |
119 | 119 | <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> |
121 | 121 | </valuemap> |
122 | 122 | </data> |
123 | 123 | <data> |
... | ... | |
125 | 125 | <valuemap type="QVariantMap"> |
126 | 126 | <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> |
127 | 127 | <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> |
129 | 129 | <value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value> |
130 | 130 | <value type="QString">DESKTOP_SESSION=gnome</value> |
131 | 131 | <value type="QString">DISPLAY=:0.0</value> |
... | ... | |
133 | 133 | <value type="QString">GDM_KEYBOARD_LAYOUT=es</value> |
134 | 134 | <value type="QString">GDM_LANG=en_US.utf8</value> |
135 | 135 | <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> |
138 | 137 | <value type="QString">GTK_MODULES=canberra-gtk-module</value> |
139 | 138 | <value type="QString">HOME=/home/juan64bits</value> |
140 | 139 | <value type="QString">LANG=en_US.utf8</value> |
| 140 | <value type="QString">LANGUAGE=</value> |
141 | 141 | <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> |
142 | 142 | <value type="QString">LOGNAME=juan64bits</value> |
143 | 143 | <value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value> |
... | ... | |
145 | 145 | <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value> |
146 | 146 | <value type="QString">PWD=/home/juan64bits</value> |
147 | 147 | <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> |
149 | 149 | <value type="QString">SHELL=/bin/bash</value> |
150 | 150 | <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> |
153 | 153 | <value type="QString">USER=juan64bits</value> |
154 | 154 | <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> |
156 | 156 | <value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value> |
157 | 157 | <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> |
159 | 159 | </valuelist> |
160 | 160 | <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value> |
161 | 161 | <valuelist key="abstractProcess.arguments" type="QVariantList"> |
... | ... | |
163 | 163 | </valuelist> |
164 | 164 | <value key="abstractProcess.command" type="QString">/usr/bin/make</value> |
165 | 165 | <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> |
167 | 167 | </valuemap> |
168 | 168 | </data> |
169 | 169 | <data> |
Software/sie_cg/mainwindow.cpp |
50 | 50 | { |
51 | 51 | buttonGroup=0; |
52 | 52 | toolBox=0; |
53 | | |
| 53 | statusBar = new QStatusBar(this); |
54 | 54 | createActions(); |
55 | 55 | createMenus(); |
56 | 56 | scene = new DiagramScene(itemMenu,this); |
... | ... | |
68 | 68 | setUnifiedTitleAndToolBarOnMac(true); |
69 | 69 | myFilePath = ""; |
70 | 70 | libDialog=0; |
71 | | |
| 71 | cgDialog=0; |
72 | 72 | if(QApplication::argc()>1) |
73 | 73 | {newDiagram(QString(QApplication::argv()[1]));} |
| 74 | statusBar->showMessage("Ready..."); |
| 75 | this->setStatusBar(statusBar); |
74 | 76 | } |
75 | 77 | |
76 | 78 | void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button) |
... | ... | |
147 | 149 | scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId())); |
148 | 150 | } |
149 | 151 | |
| 152 | void 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 | |
150 | 181 | void MainWindow::bringToFront() |
151 | 182 | { |
152 | 183 | sendTo(1); |
... | ... | |
378 | 409 | //toolBox->addItem(backgroundWidget, tr("Backgrounds")); |
379 | 410 | |
380 | 411 | //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); |
383 | 414 | view = new QGraphicsView(scene); |
384 | | newLayout->addWidget(view); |
| 415 | newLayout->addWidget(view,0,1); |
385 | 416 | |
386 | 417 | QWidget *widget = new QWidget; |
387 | 418 | widget->setLayout(newLayout); |
... | ... | |
466 | 497 | |
467 | 498 | |
468 | 499 | libraryAction = new QAction(tr("&Library..."),this); |
| 500 | libraryAction->setStatusTip(tr("Add, Remove or edit libraries")); |
469 | 501 | connect(libraryAction, SIGNAL(triggered()), |
470 | 502 | this, SLOT(libraryForm())); |
471 | 503 | |
472 | 504 | optionsAction = new QAction(tr("&Options"),this); |
473 | 505 | optionsAction->setShortcuts(QKeySequence::Preferences); |
| 506 | optionsAction->setStatusTip(tr("Edit options")); |
474 | 507 | connect(optionsAction, SIGNAL(triggered()), |
475 | 508 | this, SLOT(optionsForm())); |
476 | 509 | |
... | ... | |
518 | 551 | editToolBar->addAction(toFrontAction); |
519 | 552 | editToolBar->addAction(sendBackAction); |
520 | 553 | |
| 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 | |
521 | 568 | fontCombo = new QFontComboBox(); |
522 | 569 | fontSizeCombo = new QComboBox(); |
523 | 570 | connect(fontCombo, SIGNAL(currentFontChanged(QFont)), |
... | ... | |
602 | 649 | pointerToolbar->addWidget(pointerButton); |
603 | 650 | pointerToolbar->addWidget(linePointerButton); |
604 | 651 | pointerToolbar->addWidget(sceneScaleCombo); |
| 652 | |
605 | 653 | } |
606 | 654 | |
607 | 655 | QWidget *MainWindow::createCellWidget(QString text, QDomElement *customItem) |
... | ... | |
712 | 760 | file.close(); |
713 | 761 | if(!parsing) |
714 | 762 | { |
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."); |
717 | 765 | } |
718 | 766 | } |
719 | 767 | else |
... | ... | |
821 | 869 | |
822 | 870 | int MainWindow::libraryForm() |
823 | 871 | { |
| 872 | bool firstTime=0; |
824 | 873 | if(!libDialog) |
825 | 874 | { |
826 | 875 | createLibraryDialog(); |
| 876 | firstTime=1; |
827 | 877 | } |
828 | 878 | libDialog->setModal(1); |
829 | 879 | libUi->listLib->clear(); |
830 | 880 | libUi->listLib->addItems(libraryList); |
831 | 881 | libDialog->setWindowTitle(tr("Library paths...")); |
832 | 882 | QStringList oldLibraryList=libraryList; |
833 | | libDialog->exec(); |
| 883 | if(firstTime) |
| 884 | libDialog->exec(); |
| 885 | else |
| 886 | libDialog->show(); |
834 | 887 | |
835 | 888 | if (libDialog->result() == QDialog::Rejected) |
836 | 889 | libraryList = oldLibraryList; |
... | ... | |
838 | 891 | { |
839 | 892 | scene->setLibList(libraryList); |
840 | 893 | updateLibraries(); |
841 | | } |
| 894 | } |
842 | 895 | |
843 | 896 | return 0; |
844 | 897 | } |
... | ... | |
854 | 907 | connect(libUi->editLib,SIGNAL(clicked()),this,SLOT(editLibPath())); |
855 | 908 | } |
856 | 909 | |
| 910 | int 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 | |
| 924 | void MainWindow::createCgDialog() |
| 925 | { |
| 926 | cgDialog = new QMainWindow(this); |
| 927 | cgUi = new Ui_codeDialog; |
| 928 | cgUi->setupUi(cgDialog); |
| 929 | } |
| 930 | |
857 | 931 | void MainWindow::addLibPath() |
858 | 932 | { |
859 | 933 | QString |
... | ... | |
869 | 943 | " or not exists."); |
870 | 944 | return; |
871 | 945 | } |
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 | { |
876 | 950 | libraryList.append(relativePath); |
877 | 951 | libUi->listLib->addItem(relativePath); |
878 | 952 | } |
Software/sie_cg/mainwindow.h |
54 | 54 | #include "lineitem.h" |
55 | 55 | #include "arrow.h" |
56 | 56 | #include "ui_librarydialog.h" |
| 57 | #include "ui_codedialog.h" |
57 | 58 | |
58 | 59 | class DiagramScene; |
| 60 | class DiagramTextItem; |
| 61 | class DiagramItem; |
59 | 62 | class Ui_libraryDialog; |
| 63 | class callexternappT; |
60 | 64 | |
61 | 65 | QT_BEGIN_NAMESPACE |
62 | 66 | class QAction; |
... | ... | |
86 | 90 | |
87 | 91 | int updateLibraries(); |
88 | 92 | |
| 93 | QStatusBar *statusBar; |
| 94 | |
89 | 95 | private slots: |
90 | 96 | void backgroundButtonGroupClicked(QAbstractButton *button); |
91 | 97 | void buttonGroupClicked(int id); |
| 98 | void cgGroupClicked(int id); |
92 | 99 | void deleteItem(); |
93 | 100 | void pointerGroupClicked(int id); |
94 | 101 | void bringToFront(); |
... | ... | |
121 | 128 | |
122 | 129 | int optionsForm(); |
123 | 130 | |
124 | | |
| 131 | int codeForm(); |
125 | 132 | |
126 | 133 | private: |
127 | 134 | int saveIfNeeded(); |
128 | 135 | void addLibrariesButtons(QGridLayout *layout); |
129 | 136 | QDomDocument parseDocument(QString filePath); |
130 | 137 | void createLibraryDialog(); |
| 138 | void createCgDialog(); |
131 | 139 | void createToolBox(); |
132 | 140 | void createActions(); |
133 | 141 | void createMenus(); |
... | ... | |
167 | 175 | QMenu *aboutMenu; |
168 | 176 | |
169 | 177 | QToolBar *fileToolBar; |
| 178 | QToolBar *cgToolbar; |
170 | 179 | QToolBar *textToolBar; |
171 | 180 | QToolBar *editToolBar; |
172 | 181 | QToolBar *colorToolBar; |
173 | | QToolBar *pointerToolbar; |
| 182 | QToolBar *pointerToolbar; |
174 | 183 | |
175 | 184 | QComboBox *sceneScaleCombo; |
176 | 185 | QComboBox *itemColorCombo; |
... | ... | |
181 | 190 | QToolBox *toolBox; |
182 | 191 | QButtonGroup *buttonGroup; |
183 | 192 | QButtonGroup *pointerTypeGroup; |
| 193 | QButtonGroup *cgGroup; |
184 | 194 | QButtonGroup *backgroundButtonGroup; |
185 | 195 | QToolButton *fontColorToolButton; |
186 | 196 | QToolButton *fillColorToolButton; |
... | ... | |
192 | 202 | QAction *fillAction; |
193 | 203 | QAction *lineAction; |
194 | 204 | QString myFilePath; |
195 | | |
196 | 205 | QDialog *libDialog; |
197 | 206 | Ui_libraryDialog *libUi; |
| 207 | QMainWindow *cgDialog; |
| 208 | Ui_codeDialog *cgUi; |
198 | 209 | QStringList libraryList; |
199 | 210 | QHash<QString , QDomElement*> domElementsByName; |
200 | 211 | QHash<QString , int> buttonIdByName; |
201 | | static QString callexternapp(QString xexecFile, QString xexecParm); |
202 | | |
| 212 | static QString callexternapp(QString xexecFile, QString xexecParm); |
203 | 213 | }; |
204 | 214 | |
205 | 215 | class callexternappT : public QThread |
... | ... | |
212 | 222 | { |
213 | 223 | QProcess lnexternapp; |
214 | 224 | 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()); |
217 | 227 | } |
218 | 228 | }; |
219 | 229 | |