annotate python/apps/diagrameditor.py @ 73:191d70a0ed52

Removed arrowhead class
author windel
date Sat, 10 Nov 2012 11:53:55 +0100
parents b01311fb3be7
children f506f6b74697
rev   line source
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
1 #!/usr/bin/python
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
2
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
3 from PyQt4.QtGui import *
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
4 from PyQt4.QtCore import *
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
5 import sys, xml
47
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
6 import xml.dom.minidom as md
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
7
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
8 """
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
9 Author: Windel Bouwman
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
10 Year: 2012
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
11 Description: This script implements a diagram editor.
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
12 run with python 3.x as:
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
13 $ python [thisfile.py]
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
14 """
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
15
73
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
16 def buildPath(pts):
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
17 path = QPainterPath(pts[0])
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
18 for pt in pts[1:]:
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
19 path.lineTo(pt)
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
20 return path
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
21
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
22 class Connection(QGraphicsPathItem):
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
23 """ Implementation of a connection between blocks """
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
24 def __init__(self, fromPort, toPort):
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
25 super(Connection, self).__init__()
73
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
26 self.pos1, self.pos2 = None, None
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
27 self.fromPort, self.toPort = None, None
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
28 self.setFlag(self.ItemIsSelectable, True)
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
29 self.setFlag(self.ItemClipsToShape, True)
73
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
30 pen = QPen(Qt.blue, 2)
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
31 pen.setCapStyle(Qt.RoundCap)
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
32 self.setPen(pen)
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
33 self.arrowhead = QGraphicsPathItem(self)
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
34 self.arrowhead.setPath(buildPath([QPointF(0.0, 0.0), QPointF(-6.0, 10.0), QPointF(6.0, 10.0), QPointF(0.0, 0.0)]))
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
35 self.arrowhead.setPen(pen)
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
36 self.arrowhead.setBrush(QBrush(pen.color()))
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
37 self.vias = []
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
38 self.setFromPort(fromPort)
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
39 self.setToPort(toPort)
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
40 def mouseDoubleClickEvent(self, event):
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
41 pos = event.scenePos()
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
42 pts = [self.pos1] + [v.pos() for v in self.vias] + [self.pos2]
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
43 idx = 0
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
44 tidx = 0
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
45 for p1, p2 in zip(pts[0:-1], pts[1:]):
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
46 l1 = QLineF(p1, p2)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
47 l2 = QLineF(p1, pos)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
48 l3 = QLineF(pos, p2)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
49 d = l2.length() + l3.length() - l1.length()
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
50 if d < 5:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
51 tidx = idx
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
52 idx += 1
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
53 self.addHandle(pos, tidx)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
54
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
55 def addHandle(self, pos, idx=None):
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
56 hi = HandleItem(self)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
57 if idx:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
58 self.vias.insert(idx, hi)
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
59 else:
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
60 self.vias.append(hi)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
61 def callback(p):
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
62 self.updateLineStukken()
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
63 return p
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
64 hi.posChangeCallbacks.append(callback)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
65 hi.setPos(pos)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
66 self.updateLineStukken()
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
67 def myDelete(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
68 scene = self.scene()
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
69 if scene:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
70 self.setFromPort(None)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
71 self.setToPort(None)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
72 scene.removeItem(self)
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
73
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
74 def setFromPort(self, fromPort):
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
75 if self.fromPort:
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
76 self.fromPort.posCallbacks.remove(self.setBeginPos)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
77 self.fromPort.connection = None
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
78 self.fromPort = fromPort
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
79 if self.fromPort:
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
80 self.fromPort.connection = self
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
81 self.setBeginPos(fromPort.scenePos())
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
82 self.fromPort.posCallbacks.append(self.setBeginPos)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
83 def setToPort(self, toPort):
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
84 if self.toPort:
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
85 self.toPort.posCallbacks.remove(self.setEndPos)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
86 self.toPort.connection = None
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
87 self.toPort = toPort
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
88 if self.toPort:
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
89 self.setEndPos(toPort.scenePos())
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
90 self.toPort.connection = self
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
91 self.toPort.posCallbacks.append(self.setEndPos)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
92 def setBeginPos(self, pos1):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
93 self.pos1 = pos1
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
94 self.updateLineStukken()
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
95 def setEndPos(self, endpos):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
96 self.pos2 = endpos
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
97 self.updateLineStukken()
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
98 def itemChange(self, change, value):
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
99 if change == self.ItemSelectedHasChanged:
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
100 for via in self.vias:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
101 via.setVisible(value)
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
102 return super(Connection, self).itemChange(change, value)
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
103 def shape(self):
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
104 return self.myshape
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
105 def updateLineStukken(self):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
106 """
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
107 This algorithm determines the optimal routing of all signals.
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
108 TODO: implement nice automatic line router
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
109 """
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
110 if self.pos1 is None or self.pos2 is None:
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
111 return
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
112 pts = [self.pos1] + [v.pos() for v in self.vias] + [self.pos2]
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
113 self.arrowhead.setPos(self.pos2)
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
114 if pts[-1].x() < pts[-2].x():
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
115 self.arrowhead.setRotation(-90)
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
116 else:
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
117 self.arrowhead.setRotation(90)
73
191d70a0ed52 Removed arrowhead class
windel
parents: 72
diff changeset
118 self.setPath(buildPath(pts))
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
119 """ Create a shape outline using the path stroker """
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
120 s = super(Connection, self).shape()
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
121 pps = QPainterPathStroker()
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
122 pps.setWidth(10)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
123 self.myshape = pps.createStroke(s).simplified()
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
124
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
125 class ParameterDialog(QDialog):
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
126 def __init__(self, block, parent = None):
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
127 super(ParameterDialog, self).__init__(parent)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
128 self.block = block
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
129 self.button = QPushButton('Ok', self)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
130 l = QGridLayout(self)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
131 l.addWidget(QLabel('Name:', self), 0, 0)
51
b3a65e154ab2 Added fancy arrow head
windel
parents: 50
diff changeset
132 self.nameEdit = QLineEdit(self.block.name)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
133 l.addWidget(self.nameEdit, 0, 1)
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
134 l.addWidget(QLabel('Code:', self), 1, 0)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
135 self.codeEdit = QTextEdit(self)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
136 self.codeEdit.setPlainText(self.block.code)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
137 l.addWidget(self.codeEdit, 1, 1)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
138 l.addWidget(self.button, 2, 0, 1, 2)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
139 self.button.clicked.connect(self.OK)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
140 def OK(self):
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
141 self.block.setName(self.nameEdit.text())
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
142 self.block.code = self.codeEdit.toPlainText()
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
143 self.close()
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
144
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
145 class PortItem(QGraphicsPathItem):
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
146 """ Represents a port to a subsystem """
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
147 def __init__(self, name, block, direction):
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
148 super(PortItem, self).__init__(block)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
149 self.connection = None
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
150 path = QPainterPath()
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
151 d = 10.0
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
152 if direction == 'input':
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
153 path.moveTo(-d, -d)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
154 path.lineTo(0.0, 0.0)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
155 path.lineTo(-d, d)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
156 else:
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
157 path.moveTo(0.0, -d)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
158 path.lineTo(d, 0.0)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
159 path.lineTo(0.0, d)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
160 self.setPath(path)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
161 self.direction = direction
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
162 self.block = block
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
163 self.setCursor(QCursor(Qt.CrossCursor))
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
164 pen = QPen(Qt.blue, 2)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
165 pen.setCapStyle(Qt.RoundCap)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
166 self.setPen(pen)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
167 self.name = name
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
168 self.textItem = QGraphicsTextItem(name, self)
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
169 self.setName(name)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
170 self.posCallbacks = []
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
171 self.setFlag(self.ItemSendsScenePositionChanges, True)
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
172 def setName(self, name):
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
173 self.name = name
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
174 self.textItem.setPlainText(name)
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
175 rect = self.textItem.boundingRect()
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
176 lw, lh = rect.width(), rect.height()
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
177 if self.direction == 'input':
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
178 lx = 3
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
179 else:
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
180 lx = -3 - lw
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
181 self.textItem.setPos(lx, -lh / 2)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
182 def itemChange(self, change, value):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
183 if change == self.ItemScenePositionHasChanged:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
184 for cb in self.posCallbacks:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
185 cb(value)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
186 return value
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
187 return super(PortItem, self).itemChange(change, value)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
188 def mousePressEvent(self, event):
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
189 if self.direction == 'output':
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
190 self.scene().startConnection(self)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
191
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
192 class OutputPort(PortItem):
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
193 # TODO: create a subclass OR make a member porttype
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
194 pass
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
195
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
196 # Block part:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
197 class HandleItem(QGraphicsEllipseItem):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
198 """ A handle that can be moved by the mouse """
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
199 def __init__(self, parent=None):
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
200 dx = 13.0
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
201 super(HandleItem, self).__init__(QRectF(-0.5*dx,-0.5*dx,dx,dx), parent)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
202 self.posChangeCallbacks = []
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
203 self.setBrush(QBrush(Qt.white))
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
204 self.setFlag(self.ItemSendsScenePositionChanges, True)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
205 self.setFlag(self.ItemIsMovable, True)
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
206 self.setVisible(False)
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
207 self.setCursor(QCursor(Qt.SizeFDiagCursor))
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
208 def mouseMoveEvent(self, event):
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
209 """ Move function without moving the other selected elements """
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
210 p = self.mapToParent(event.pos())
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
211 self.setPos(p)
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
212 def mySetPos(self, p):
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
213 # TODO: use this instead of itemChange?
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
214 self.setPos(p)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
215 def itemChange(self, change, value):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
216 if change == self.ItemPositionChange:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
217 for cb in self.posChangeCallbacks:
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
218 res = cb(value)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
219 if res:
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
220 value = res
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
221 return value
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
222 # Call superclass method:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
223 return super(HandleItem, self).itemChange(change, value)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
224
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
225 def uniqify(name, names):
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
226 newname = name
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
227 i = 1
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
228 while newname in names:
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
229 newname = name + str(i)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
230 i += 1
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
231 return newname
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
232
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
233 class BlockItem(QGraphicsRectItem):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
234 """
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
235 Represents a block in the diagram
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
236 Has an x and y and width and height
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
237 width and height can only be adjusted with a tip in the lower right corner.
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
238
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
239 - in and output ports
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
240 - parameters
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
241 - description
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
242 """
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
243 def __init__(self, name='Untitled', parent=None):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
244 super(BlockItem, self).__init__(parent)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
245 # Properties of the rectangle:
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
246 self.setPen(QPen(Qt.blue, 2))
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
247 self.setBrush(QBrush(Qt.lightGray))
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
248 self.setFlags(self.ItemIsSelectable | self.ItemIsMovable)
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
249 self.setFlag(self.ItemSendsScenePositionChanges, True)
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
250 self.setCursor(QCursor(Qt.PointingHandCursor))
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
251 self.label = QGraphicsTextItem(name, self)
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
252 self.name = name
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
253 self.code = ''
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
254 # Create corner for resize:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
255 self.sizer = HandleItem(self)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
256 self.sizer.posChangeCallbacks.append(self.changeSize) # Connect the callback
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
257 button = QPushButton('+in')
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
258 button.clicked.connect(self.newInputPort)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
259 self.buttonItemAddInput = QGraphicsProxyWidget(self)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
260 self.buttonItemAddInput.setWidget(button)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
261 self.buttonItemAddInput.setVisible(False)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
262 button = QPushButton('+out')
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
263 button.clicked.connect(self.newOutputPort)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
264 self.buttonItemAddOutput = QGraphicsProxyWidget(self)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
265 self.buttonItemAddOutput.setWidget(button)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
266 self.buttonItemAddOutput.setVisible(False)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
267
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
268 # Inputs and outputs of the block:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
269 self.inputs = []
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
270 self.outputs = []
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
271 # Update size:
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
272 self.sizer.mySetPos(QPointF(60, 40)) # This is a better resize function
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
273 def editParameters(self):
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
274 pd = ParameterDialog(self, self.window())
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
275 pd.exec_()
59
f6ea630c4057 Cleanup
windel
parents: 58
diff changeset
276 def mouseDoubleClickEvent(self, event):
f6ea630c4057 Cleanup
windel
parents: 58
diff changeset
277 self.editParameters()
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
278 def newInputPort(self):
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
279 names = [i.name for i in self.inputs + self.outputs]
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
280 self.addInput(PortItem(uniqify('in', names), self, 'input'))
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
281 def newOutputPort(self):
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
282 names = [i.name for i in self.inputs + self.outputs]
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
283 self.addOutput(PortItem(uniqify('out', names), self, 'output'))
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
284 def setName(self, name):
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
285 self.name = name
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
286 self.label.setPlainText(name)
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
287 def addInput(self, i):
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
288 self.inputs.append(i)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
289 self.updateSize()
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
290 def addOutput(self, o):
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
291 self.outputs.append(o)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
292 self.updateSize()
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
293
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
294 def contextMenuEvent(self, event):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
295 menu = QMenu()
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
296 pa = menu.addAction('Parameters')
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
297 pa.triggered.connect(self.editParameters)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
298 menu.exec_(event.screenPos())
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
299 def itemChange(self, change, value):
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
300 if change == self.ItemSelectedHasChanged:
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
301 for child in [self.sizer, self.buttonItemAddInput, self.buttonItemAddOutput]:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
302 child.setVisible(value)
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
303 return super(BlockItem, self).itemChange(change, value)
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
304 def myDelete(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
305 # TODO: move the below to blockitem:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
306 scene = self.scene()
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
307 if scene:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
308 for p in self.inputs + self.outputs:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
309 if p.connection:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
310 p.connection.myDelete()
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
311 scene.removeItem(self)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
312
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
313 def updateSize(self):
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
314 rect = self.rect()
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
315 h, w = rect.height(), rect.width()
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
316 self.buttonItemAddInput.setPos(0, h + 4)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
317 self.buttonItemAddOutput.setPos(w+10, h+4)
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
318 for inp in self.inputs:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
319 inp.setX(0.0)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
320 for inp in self.outputs:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
321 inp.setX(w)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
322 if len(self.inputs) == 1:
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
323 self.inputs[0].setPos(0.0, h / 2)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
324 elif len(self.inputs) > 1:
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
325 y = 15
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
326 dy = (h - 30) / (len(self.inputs) - 1)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
327 for inp in self.inputs:
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
328 inp.setPos(0.0, y)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
329 y += dy
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
330 if len(self.outputs) == 1:
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
331 self.outputs[0].setPos(w, h / 2)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
332 elif len(self.outputs) > 1:
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
333 y = 15
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
334 dy = (h - 30) / (len(self.outputs) - 1)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
335 for outp in self.outputs:
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
336 outp.setPos(w, y)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
337 y += dy
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
338
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
339 def changeSize(self, p):
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
340 """ Resize block function """
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
341 w, h = p.x(), p.y()
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
342 # Limit the block size:
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
343 h = 20 if h < 20 else h
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
344 w = 40 if w < 40 else w
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
345 self.setRect(0.0, 0.0, w, h)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
346 # center label:
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
347 rect = self.label.boundingRect()
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
348 lw, lh = rect.width(), rect.height()
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
349 lx = (w - lw) / 2
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
350 ly = (h - lh) / 2
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
351 self.label.setPos(lx, ly)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
352 # Update port positions:
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
353 self.updateSize()
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
354 return QPointF(w, h)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
355
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
356 class EditorGraphicsView(QGraphicsView):
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
357 def __init__(self, parent=None):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
358 QGraphicsView.__init__(self, parent)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
359 scene = DiagramScene(self)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
360 self.diagramScene = scene
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
361 self.setScene(scene)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
362 self.setDragMode(QGraphicsView.RubberBandDrag)
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
363 testShortcut = QShortcut(QKeySequence("F12"), self)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
364 testShortcut.activated.connect(self.test)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
365 delShort = QShortcut(QKeySequence.Delete, self)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
366 delShort.activated.connect(scene.deleteItems)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
367 self.loadDiagram = scene.loadDiagram
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
368 def save(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
369 self.diagramScene.saveDiagram('diagram2.usd')
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
370 def load(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
371 filename = QFileDialog.getOpenFileName(self)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
372 self.diagramScene.loadDiagram(filename)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
373 def zoomAll(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
374 """ zoom to fit all items """
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
375 rect = self.diagramScene.itemsBoundingRect()
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
376 self.fitInView(rect, Qt.KeepAspectRatio)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
377 def test(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
378 self.rotate(30)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
379 self.zoomAll()
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
380
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
381 def wheelEvent(self, event):
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
382 pos = event.pos()
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
383 posbefore = self.mapToScene(pos)
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
384 degrees = event.delta() / 8.0
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
385 sx = (100.0 + degrees) / 100.0
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
386 self.scale(sx, sx)
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
387 event.accept()
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
388 def dragEnterEvent(self, event):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
389 if event.mimeData().hasFormat('component/name'):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
390 event.accept()
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
391 def dragMoveEvent(self, event):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
392 if event.mimeData().hasFormat('component/name'):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
393 event.accept()
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
394 def dropEvent(self, event):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
395 if event.mimeData().hasFormat('component/name'):
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
396 name = bytes(event.mimeData().data('component/name')).decode()
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
397 pos = self.mapToScene(event.pos())
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
398 self.scene().addNewBlock(pos, name)
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
399
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
400 class LibraryModel(QStandardItemModel):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
401 def __init__(self, parent=None):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
402 QStandardItemModel.__init__(self, parent)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
403 def mimeTypes(self):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
404 return ['component/name']
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
405 def mimeData(self, idxs):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
406 mimedata = QMimeData()
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
407 for idx in idxs:
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
408 if idx.isValid():
45
8a52263d67c4 Fixed width of library
windel
parents: 44
diff changeset
409 txt = self.data(idx, Qt.DisplayRole) # python 3
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
410 mimedata.setData('component/name', txt)
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
411 return mimedata
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
412
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
413 class DiagramScene(QGraphicsScene):
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
414 """ Save and load and deletion of item"""
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
415 def __init__(self, parent=None):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
416 super(DiagramScene, self).__init__(parent)
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
417 self.startedConnection = None
55
9414bad225a8 Added nice resizing
windel
parents: 54
diff changeset
418
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
419 def saveDiagram(self, filename):
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
420 items = self.items()
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
421 blocks = [item for item in items if type(item) is BlockItem]
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
422 connections = [item for item in items if type(item) is Connection]
47
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
423
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
424 doc = md.Document()
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
425 modelElement = doc.createElement('system')
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
426 doc.appendChild(modelElement)
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
427 for block in blocks:
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
428 blockElement = doc.createElement("block")
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
429 x, y = block.scenePos().x(), block.scenePos().y()
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
430 rect = block.rect()
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
431 w, h = rect.width(), rect.height()
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
432 blockElement.setAttribute("name", block.name)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
433 blockElement.setAttribute("x", str(int(x)))
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
434 blockElement.setAttribute("y", str(int(y)))
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
435 blockElement.setAttribute("width", str(int(w)))
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
436 blockElement.setAttribute("height", str(int(h)))
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
437 codeNode = doc.createCDATASection(block.code)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
438 codeElement = doc.createElement('code')
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
439 codeElement.appendChild(codeNode)
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
440 blockElement.appendChild(codeElement)
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
441 for inp in block.inputs:
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
442 portElement = doc.createElement("input")
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
443 portElement.setAttribute("name", inp.name)
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
444 blockElement.appendChild(portElement)
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
445 for outp in block.outputs:
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
446 portElement = doc.createElement("output")
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
447 portElement.setAttribute("name", outp.name)
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
448 blockElement.appendChild(portElement)
47
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
449 modelElement.appendChild(blockElement)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
450 for connection in connections:
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
451 connectionElement = doc.createElement("connection")
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
452 fromPort = connection.fromPort.name
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
453 toPort = connection.toPort.name
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
454 fromBlock = connection.fromPort.block.name
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
455 toBlock = connection.toPort.block.name
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
456 connectionElement.setAttribute("fromBlock", fromBlock)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
457 connectionElement.setAttribute("fromPort", fromPort)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
458 connectionElement.setAttribute("toBlock", toBlock)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
459 connectionElement.setAttribute("toPort", toPort)
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
460 for via in connection.vias:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
461 viaElement = doc.createElement('via')
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
462 viaElement.setAttribute('x', str(int(via.x())))
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
463 viaElement.setAttribute('y', str(int(via.y())))
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
464 connectionElement.appendChild(viaElement)
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
465 modelElement.appendChild(connectionElement)
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
466 with open(filename, 'w') as f:
47
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
467 f.write(doc.toprettyxml())
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
468
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
469 def loadDiagram(self, filename):
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
470 try:
47
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
471 doc = md.parse(filename)
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
472 except IOError as e:
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
473 print('{0} not found'.format(filename))
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
474 return
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
475 except xml.parsers.expat.ExpatError as e:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
476 print('{0}'.format(e))
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
477 return
47
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
478 sysElements = doc.getElementsByTagName('system')
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
479 blockElements = doc.getElementsByTagName('block')
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
480 for sysElement in sysElements:
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
481 blockElements = sysElement.getElementsByTagName('block')
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
482 for blockElement in blockElements:
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
483 x = float(blockElement.getAttribute('x'))
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
484 y = float(blockElement.getAttribute('y'))
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
485 w = float(blockElement.getAttribute('width'))
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
486 h = float(blockElement.getAttribute('height'))
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
487 name = blockElement.getAttribute('name')
c4ec95a588ea Fixed save to xml
windel
parents: 46
diff changeset
488 block = BlockItem(name)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
489 self.addItem(block)
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
490 block.setPos(x, y)
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
491 block.sizer.setPos(w, h)
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
492 codeElements = blockElement.getElementsByTagName('code')
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
493 if codeElements:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
494 cn = codeElements[0].childNodes
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
495 cdatas = [cd for cd in cn if type(cd) is md.CDATASection]
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
496 if len(cdatas) > 0:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
497 block.code = cdatas[0].data
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
498 # Load ports:
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
499 portElements = blockElement.getElementsByTagName('input')
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
500 for portElement in portElements:
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
501 name = portElement.getAttribute('name')
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
502 inp = PortItem(name, block, 'input')
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
503 block.addInput(inp)
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
504 portElements = blockElement.getElementsByTagName('output')
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
505 for portElement in portElements:
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
506 name = portElement.getAttribute('name')
53
6dd7d6a1737c Added in and output port icons
windel
parents: 52
diff changeset
507 outp = PortItem(name, block, 'output')
49
2b07ab2c0dc4 Added line saving
windel
parents: 48
diff changeset
508 block.addOutput(outp)
48
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
509 connectionElements = sysElement.getElementsByTagName('connection')
a309982ab4d5 Added cool rotate function
windel
parents: 47
diff changeset
510 for connectionElement in connectionElements:
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
511 fromBlock = connectionElement.getAttribute('fromBlock')
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
512 fromPort = connectionElement.getAttribute('fromPort')
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
513 toBlock = connectionElement.getAttribute('toBlock')
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
514 toPort = connectionElement.getAttribute('toPort')
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
515 viaElements = connectionElement.getElementsByTagName('via')
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
516 fromPort = self.findPort(fromBlock, fromPort)
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
517 toPort = self.findPort(toBlock, toPort)
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
518 connection = Connection(fromPort, toPort)
60
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
519 for viaElement in viaElements:
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
520 x = int(viaElement.getAttribute('x'))
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
521 y = int(viaElement.getAttribute('y'))
b976546f5a60 Fixed code saving in XML
windel
parents: 59
diff changeset
522 connection.addHandle(QPointF(x, y))
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
523 self.addItem(connection)
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
524 def findPort(self, blockname, portname):
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
525 items = self.items()
50
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
526 blocks = [item for item in items if type(item) is BlockItem]
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
527 for block in [b for b in blocks if b.name == blockname]:
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
528 for port in block.inputs + block.outputs:
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
529 if port.name == portname:
38ff8e178fe4 Fixed saving of connections
windel
parents: 49
diff changeset
530 return port
58
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
531 def addNewBlock(self, pos, name):
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
532 blocknames = [item.name for item in self.items() if type(item) is BlockItem]
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
533 b1 = BlockItem(uniqify(name, blocknames))
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
534 b1.setPos(pos)
65acf6874a8d Removed auto routing
windel
parents: 57
diff changeset
535 self.addItem(b1)
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
536 def mouseMoveEvent(self, event):
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
537 if self.startedConnection:
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
538 pos = event.scenePos()
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
539 self.startedConnection.setEndPos(pos)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
540 super(DiagramScene, self).mouseMoveEvent(event)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
541 def mouseReleaseEvent(self, event):
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
542 if self.startedConnection:
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
543 items = self.items(event.scenePos())
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
544 for item in items:
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
545 if type(item) is PortItem:
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
546 self.startedConnection.setToPort(item)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
547 self.startedConnection = None
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
548 return
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
549 self.startedConnection.myDelete()
56
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
550 self.startedConnection = None
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
551 super(DiagramScene, self).mouseReleaseEvent(event)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
552 def startConnection(self, port):
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
553 self.startedConnection = Connection(port, None)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
554 pos = port.scenePos()
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
555 self.startedConnection.setEndPos(pos)
7a82f0d52e85 Cleanup of line selection
windel
parents: 55
diff changeset
556 self.addItem(self.startedConnection)
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
557 def deleteItems(self):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
558 # Try to delete all currently selected items:
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
559 for item in list(self.selectedItems()):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
560 item.myDelete()
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
561
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
562 class LibraryWidget(QListView):
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
563 def __init__(self):
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
564 super(LibraryWidget, self).__init__(None)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
565 self.libraryModel = LibraryModel(self)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
566 self.libraryModel.setColumnCount(1)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
567 # Create an icon with an icon:
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
568 pixmap = QPixmap(60, 60)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
569 pixmap.fill()
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
570 painter = QPainter(pixmap)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
571 painter.fillRect(10, 10, 40, 40, Qt.blue)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
572 painter.setBrush(Qt.yellow)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
573 painter.drawEllipse(20, 20, 20, 20)
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
574 painter.end()
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
575
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
576 # Fill library:
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
577 self.libItems = []
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
578 self.libItems.append( QStandardItem(QIcon(pixmap), 'Block') )
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
579 self.libItems.append( QStandardItem(QIcon(pixmap), 'Uber Unit') )
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
580 self.libItems.append( QStandardItem(QIcon(pixmap), 'Device') )
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
581 for i in self.libItems:
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
582 self.libraryModel.appendRow(i)
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
583 self.setModel(self.libraryModel)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
584 self.setViewMode(self.IconMode)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
585 self.setDragDropMode(self.DragOnly)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
586
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
587 class Main(QMainWindow):
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
588 def __init__(self):
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
589 super(Main, self).__init__(None)
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
590 self.editor = EditorGraphicsView()
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
591 self.setCentralWidget(self.editor)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
592 self.setWindowTitle("Diagram editor")
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
593 toolbar = self.addToolBar('Tools')
72
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
594 def act(name, shortcut, callback):
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
595 a = QAction(name, self)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
596 a.setShortcuts(shortcut)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
597 a.triggered.connect(callback)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
598 toolbar.addAction(a)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
599 act('Save', QKeySequence.Save, self.editor.save)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
600 act('Load', QKeySequence.Open, self.editor.load)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
601 act('Full screen', QKeySequence("F11"), self.toggleFullScreen)
b01311fb3be7 Refinements to clean up
windel
parents: 63
diff changeset
602 act('Fit in view', QKeySequence("F8"), self.editor.zoomAll)
54
d8163d2c3779 Rework of delete function.
windel
parents: 53
diff changeset
603
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
604 self.library = LibraryWidget()
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
605 libraryDock = QDockWidget('Library', self)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
606 libraryDock.setWidget(self.library)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
607 self.addDockWidget(Qt.LeftDockWidgetArea, libraryDock)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
608
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
609 self.editor.loadDiagram('diagram2.usd')
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
610
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
611 def toggleFullScreen(self):
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
612 self.setWindowState(self.windowState() ^ Qt.WindowFullScreen)
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
613 self.editor.zoomAll()
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
614
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
615 if __name__ == '__main__':
45
8a52263d67c4 Fixed width of library
windel
parents: 44
diff changeset
616 if sys.version_info.major != 3:
8a52263d67c4 Fixed width of library
windel
parents: 44
diff changeset
617 print('Please use python 3.x')
8a52263d67c4 Fixed width of library
windel
parents: 44
diff changeset
618 sys.exit(1)
8a52263d67c4 Fixed width of library
windel
parents: 44
diff changeset
619
46
7964065400b7 Added xml save function
windel
parents: 45
diff changeset
620 app = QApplication(sys.argv)
61
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
621 main = Main()
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
622 main.show()
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
623 main.resize(700, 500)
6fa41208a3a8 Rework into windowed system
windel
parents: 60
diff changeset
624 main.editor.zoomAll()
44
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
625 app.exec_()
cbf199e007c2 Added some demo applications
windel
parents:
diff changeset
626