개정판 2819dd5f
issue #1052: 기기을 이동했을때 Streamline의 형상 보정
Change-Id: I2056b14fc99f893d9bff4929f6764c0f5633c7fd
HYTOS/HYTOS/Shapes/EngineeringArrowItem.py | ||
---|---|---|
29 | 29 |
""" initialize arrow """ |
30 | 30 |
|
31 | 31 |
QGraphicsPolygonItem.__init__(self, polygon, parent) |
32 |
#QEngineeringAbstractItem.__init__(self) |
|
33 | 32 |
|
34 | 33 |
self.setFlag(QGraphicsItem.ItemIsSelectable, False) |
35 | 34 |
self.setFlag(QGraphicsItem.ItemIsFocusable, False) |
HYTOS/HYTOS/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
340 | 340 |
|
341 | 341 |
self.connect(None) |
342 | 342 |
|
343 |
## unhighlight underitem
|
|
343 |
# unhighlight underitem |
|
344 | 344 |
if hasattr(self, '_underItem') and self._underItem is not None: |
345 | 345 |
self._underItem.highlight(False) |
346 |
## up to here
|
|
346 |
# up to here |
|
347 | 347 |
|
348 | 348 |
for symbol in [self.parentItem() for self in items if type(self.parentItem()) is SymbolSvgItem]: |
349 | 349 |
symbol.transfer.on_pos_changed.connect(self.parent.on_symbol_pos_changed) |
HYTOS/HYTOS/Shapes/EngineeringReservedWordTextItem.py | ||
---|---|---|
4 | 4 |
import os.path |
5 | 5 |
import sys |
6 | 6 |
import copy |
7 |
|
|
7 | 8 |
try: |
8 | 9 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
9 | 10 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
10 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
|
11 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, \ |
|
12 |
QGraphicsTextItem |
|
11 | 13 |
except ImportError: |
12 | 14 |
try: |
13 | 15 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
... | ... | |
18 | 20 |
from AppDocData import AppDocData, MessageType |
19 | 21 |
from EngineeringTextItem import QEngineeringTextItem |
20 | 22 |
|
23 |
|
|
21 | 24 |
class QEngineeringReservedWordTextItem(QEngineeringTextItem): |
22 | 25 |
""" This is engineering reserved words text item class """ |
23 | 26 |
|
... | ... | |
49 | 52 |
lines = vLines |
50 | 53 |
else: |
51 | 54 |
lines = hLines |
52 |
|
|
53 |
axisText = range(round(self.sceneBoundingRect().x()), round(self.sceneBoundingRect().x() + self.sceneBoundingRect().width())) if lines is hLines else range(round(self.sceneBoundingRect().y()), round(self.sceneBoundingRect().y() + self.sceneBoundingRect().height())) |
|
54 |
#print(axisText) |
|
55 |
|
|
56 |
axisText = range(round(self.sceneBoundingRect().x()), round( |
|
57 |
self.sceneBoundingRect().x() + self.sceneBoundingRect().width())) if lines is hLines else range( |
|
58 |
round(self.sceneBoundingRect().y()), |
|
59 |
round(self.sceneBoundingRect().y() + self.sceneBoundingRect().height())) |
|
60 |
# print(axisText) |
|
55 | 61 |
for line in lines: |
56 | 62 |
intercept = line.sceneBoundingRect().center().y() if lines is hLines else line.sceneBoundingRect().center().x() |
57 | 63 |
length = abs(intercept - center.y()) if lines is hLines else abs(intercept - center.x()) |
58 | 64 |
if (length < dist): |
59 | 65 |
overlap = 0 |
60 |
axisLine = range(round(line.sceneBoundingRect().x()), round(line.sceneBoundingRect().x() + line.sceneBoundingRect().width())) if lines is hLines else range(round(line.sceneBoundingRect().y()), round(line.sceneBoundingRect().y() + line.sceneBoundingRect().height())) |
|
61 |
#print(axisLine) |
|
66 |
axisLine = range(round(line.sceneBoundingRect().x()), round( |
|
67 |
line.sceneBoundingRect().x() + line.sceneBoundingRect().width())) if lines is hLines else range( |
|
68 |
round(line.sceneBoundingRect().y()), |
|
69 |
round(line.sceneBoundingRect().y() + line.sceneBoundingRect().height())) |
|
70 |
# print(axisLine) |
|
62 | 71 |
for onLine in axisLine: |
63 | 72 |
for onText in axisText: |
64 | 73 |
if onLine - onText is 0: |
65 | 74 |
overlap += 1 |
66 |
#print(overlap) |
|
75 |
# print(overlap)
|
|
67 | 76 |
if overlap == maxOverlap and length < minDist: |
68 | 77 |
selected = line |
69 | 78 |
maxOverlap = overlap |
... | ... | |
76 | 85 |
if selected is not None: |
77 | 86 |
self.owner = selected |
78 | 87 |
return |
79 |
#print(self.owner) |
|
88 |
# print(self.owner)
|
|
80 | 89 |
## up to here |
81 | 90 |
|
82 | 91 |
# fine line owner orthogonal |
... | ... | |
90 | 99 |
if line.connectors[1].connectedItem is not None: continue |
91 | 100 |
|
92 | 101 |
dl = min(self.sceneBoundingRect().height(), self.sceneBoundingRect().width()) / 10 |
93 |
dx = dl if (line.connectors[0].sceneConnectPoint[0] - line.connectors[1].sceneConnectPoint[0]) > 0 else -dl |
|
94 |
dy = -dl if (line.connectors[0].sceneConnectPoint[1] - line.connectors[1].sceneConnectPoint[1]) > 0 else dl |
|
95 |
|
|
102 |
dx = dl if (line.connectors[0].sceneConnectPoint[0] - line.connectors[1].sceneConnectPoint[ |
|
103 |
0]) > 0 else -dl |
|
104 |
dy = -dl if (line.connectors[0].sceneConnectPoint[1] - line.connectors[1].sceneConnectPoint[ |
|
105 |
1]) > 0 else dl |
|
106 |
|
|
96 | 107 |
startPoint = line.endPoint() |
97 | 108 |
for index in range(30): |
98 | 109 |
point = (startPoint[0] + index * dx, startPoint[1] + index * dy) |
... | ... | |
109 | 120 |
from App import App |
110 | 121 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
111 | 122 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
112 |
|
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py | ||
---|---|---|
22 | 22 |
class QEngineeringStreamlineItem(QGraphicsPathItem, QEngineeringAbstractItem): |
23 | 23 |
""" This is EngineeringStreamlineItem Class """ |
24 | 24 |
|
25 |
ARROW_SIZE = 10 |
|
26 |
ZVALUE = 100 |
|
25 |
ARROW_SIZE = 5 |
|
26 |
ZVALUE = 50 |
|
27 |
MIN_LENGTH = 10 |
|
27 | 28 |
onRemoved = pyqtSignal(QGraphicsItem) |
28 | 29 |
|
29 | 30 |
''' |
... | ... | |
119 | 120 |
from SymbolSvgItem import SymbolSvgItem |
120 | 121 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
121 | 122 |
|
123 |
if not self._vertices: |
|
124 |
return |
|
125 |
|
|
122 | 126 |
targets = [] |
123 | 127 |
index = 0 |
124 |
for vertex in [self._vertices[0],self._vertices[-1]]:
|
|
128 |
for vertex in [self._vertices[0], self._vertices[-1]]:
|
|
125 | 129 |
if pointsUids: |
126 | 130 |
connector = QEngineeringConnectorItem(pointsUids[index], parent=self, index=index+1) |
127 | 131 |
else: |
... | ... | |
142 | 146 |
if len(connected) > index: |
143 | 147 |
connected_item_uid = connected[index] |
144 | 148 |
if connected_item_uid: |
145 |
connector.connect(connected_item_uid) |
|
146 | 149 |
target = QEngineeringConnectorItem.find_connector(connected_item_uid) |
150 |
connector.connect(target) |
|
147 | 151 |
if target: |
148 | 152 |
target.connect(connector) |
149 | 153 |
targets.append(target) |
... | ... | |
190 | 194 |
else: |
191 | 195 |
self._arrow.setPolygon(polygon) |
192 | 196 |
|
197 |
self._arrow.setPen(Qt.blue) |
|
193 | 198 |
self._arrow.setBrush(Qt.blue) |
194 | 199 |
self._arrow.update() |
195 | 200 |
|
... | ... | |
232 | 237 |
return |
233 | 238 |
|
234 | 239 |
try: |
240 |
# re-positioning vertex of stream line |
|
241 |
self._vertices = [] |
|
242 |
|
|
243 |
self._vertices.append(self.connectors[0].center()) |
|
244 |
dx = self.connectors[-1].center()[0] - self._vertices[0][0] |
|
245 |
dy = self.connectors[-1].center()[1] - self._vertices[0][1] |
|
246 |
if (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \ |
|
247 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'): |
|
248 |
if dx >= 0 and dy > 0: |
|
249 |
self._vertices.append((self._vertices[0][0], self._vertices[0][1] + dy)) |
|
250 |
elif dx < 0 <= dy: |
|
251 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
252 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
253 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
254 |
elif dx < 0 and dy < 0: |
|
255 |
self._vertices.append( |
|
256 |
(self._vertices[0][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
257 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
258 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
259 |
elif dx > 0 > dy: |
|
260 |
self._vertices.append( |
|
261 |
(self._vertices[0][0], self._vertices[0][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
262 |
self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1])) |
|
263 |
self._vertices.append((self._vertices[-1][0], self.connectors[-1].center()[1])) |
|
264 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \ |
|
265 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'): |
|
266 |
if dx >= 0 and dy < 0: |
|
267 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
268 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
269 |
self._vertices.append((self._vertices[-1][0], |
|
270 |
self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
271 |
elif dx < 0 and dy < 0: |
|
272 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
273 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
274 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
275 |
elif dx < 0 and dy >= 0: |
|
276 |
self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy)) |
|
277 |
elif dx >= 0 and dy >= 0: |
|
278 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
279 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
280 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
281 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \ |
|
282 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'): |
|
283 |
if dx >= 0 and dy < 0: |
|
284 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
285 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
286 |
self._vertices.append((self._vertices[-1][0], |
|
287 |
self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH*2)) |
|
288 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
289 |
elif dx < 0 and dy < 0: |
|
290 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
291 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
292 |
self._vertices.append((self._vertices[-1][0], |
|
293 |
self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH * 2)) |
|
294 |
self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1])) |
|
295 |
elif dx < 0 and dy >= 0: |
|
296 |
self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy*0.5)) |
|
297 |
self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1])) |
|
298 |
elif dx >= 0 and dy >= 0: |
|
299 |
self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy * 0.5)) |
|
300 |
self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1])) |
|
301 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \ |
|
302 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'): |
|
303 |
if dx >= 0 and dy < 0: |
|
304 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
305 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
306 |
elif dx < 0 and dy < 0: |
|
307 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
308 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
309 |
elif dx < 0 and dy >= 0: |
|
310 |
self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
311 |
self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1])) |
|
312 |
elif dx >= 0 and dy >= 0: |
|
313 |
self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
314 |
self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1])) |
|
315 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \ |
|
316 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'): |
|
317 |
if dx >= 0 and dy < 0: |
|
318 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
319 |
elif dx >= 0 and dy >= 0: |
|
320 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
321 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
322 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
323 |
elif dx < 0 and dy >= 0: |
|
324 |
self._vertices.append( |
|
325 |
(self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
326 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH , self._vertices[-1][1])) |
|
327 |
self._vertices.append( |
|
328 |
(self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
329 |
else: |
|
330 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
331 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
332 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
333 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \ |
|
334 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'): |
|
335 |
if dx >= 0 and dy < 0: |
|
336 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
337 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
338 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy * 0.5)) |
|
339 |
elif dx < 0 and dy < 0: |
|
340 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
341 |
elif dx < 0 and dy >= 0: |
|
342 |
self._vertices.append( |
|
343 |
(self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
344 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
345 |
self._vertices.append( |
|
346 |
(self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
347 |
else: |
|
348 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
349 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
350 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
351 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \ |
|
352 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'): |
|
353 |
if dy < 0: |
|
354 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy * 0.5)) |
|
355 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
356 |
else: |
|
357 |
self._vertices.append( |
|
358 |
(self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
359 |
self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1])) |
|
360 |
self._vertices.append((self._vertices[-1][0], |
|
361 |
self.connectors[-1].center()[1] + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
362 |
self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1])) |
|
363 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \ |
|
364 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'): |
|
365 |
if dx >= 0 and dy < 0: |
|
366 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
367 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
368 |
elif dx < 0 and dy < 0: |
|
369 |
self._vertices.append( |
|
370 |
(self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
371 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
372 |
elif dx < 0 and dy >= 0: |
|
373 |
self._vertices.append( |
|
374 |
(self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
375 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
376 |
else: |
|
377 |
self._vertices.append( |
|
378 |
(self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
379 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
380 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \ |
|
381 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'): |
|
382 |
if dx >= 0: |
|
383 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
384 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
385 |
else: |
|
386 |
self._vertices.append( |
|
387 |
(self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
388 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
389 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH*2, |
|
390 |
self._vertices[-1][1])) |
|
391 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
392 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \ |
|
393 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'): |
|
394 |
if dx >= 0 and dy < 0: |
|
395 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
396 |
elif dx < 0 and dy < 0: |
|
397 |
self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
398 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
399 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
400 |
elif dx < 0 and dy >= 0: |
|
401 |
self._vertices.append( |
|
402 |
(self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
403 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
404 |
self._vertices.append( |
|
405 |
(self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
406 |
else: |
|
407 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
408 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
409 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
410 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \ |
|
411 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'): |
|
412 |
if dx >= 0 and dy < 0: |
|
413 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
414 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
415 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
416 |
elif dx < 0 and dy < 0: |
|
417 |
self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
418 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
419 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
420 |
elif dx < 0 and dy >= 0: |
|
421 |
self._vertices.append( |
|
422 |
(self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
423 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
424 |
self._vertices.append( |
|
425 |
(self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
426 |
else: |
|
427 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
428 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \ |
|
429 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'): |
|
430 |
if dx >= 0 and dy < 0: |
|
431 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
432 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
433 |
elif dx < 0 and dy < 0: |
|
434 |
self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
435 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
436 |
elif dx < 0 and dy >= 0: |
|
437 |
self._vertices.append( |
|
438 |
(self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
439 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
440 |
else: |
|
441 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
442 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
443 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \ |
|
444 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'): |
|
445 |
if dx >= 0 and dy < 0: |
|
446 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
447 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
448 |
elif dx < 0 and dy < 0: |
|
449 |
self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
450 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
451 |
elif dx < 0 and dy >= 0: |
|
452 |
self._vertices.append( |
|
453 |
(self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
454 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
455 |
else: |
|
456 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
457 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
458 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \ |
|
459 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'): |
|
460 |
if dx >= 0 and dy < 0: |
|
461 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
462 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
463 |
elif dx < 0 and dy < 0: |
|
464 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
465 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
466 |
elif dx < 0 and dy >= 0: |
|
467 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
468 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
469 |
else: |
|
470 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
471 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
472 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH*2, self._vertices[-1][1])) |
|
473 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
474 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \ |
|
475 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'): |
|
476 |
if dx >= 0 and dy < 0: |
|
477 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
478 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
479 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
480 |
elif dx < 0 and dy < 0: |
|
481 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
482 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH)) |
|
483 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
484 |
elif dx < 0 and dy >= 0: |
|
485 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
486 |
else: |
|
487 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
488 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
489 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
490 |
elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \ |
|
491 |
(self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'): |
|
492 |
if dx >= 0 and dy < 0: |
|
493 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
494 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5)) |
|
495 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
496 |
elif dx < 0 and dy < 0: |
|
497 |
self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1])) |
|
498 |
elif dx < 0 and dy >= 0: |
|
499 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
500 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
501 |
self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1])) |
|
502 |
else: |
|
503 |
self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
504 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH)) |
|
505 |
self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1])) |
|
506 |
else: |
|
507 |
self._vertices.append((self._vertices[0][0] + dx * 0.5, self._vertices[0][1])) |
|
508 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
509 |
|
|
510 |
self._vertices.append(self.connectors[-1].center()) |
|
511 |
# up to here |
|
512 |
|
|
235 | 513 |
path = QPainterPath() |
236 | 514 |
path.moveTo(self._vertices[0][0], self._vertices[0][1]) |
237 | 515 |
|
... | ... | |
349 | 627 |
|
350 | 628 |
def highlight(self, flag): |
351 | 629 |
self.hover = flag |
352 |
self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else self.setZValue(
|
|
353 |
QEngineeringStreamlineItem.ZVALUE) |
|
630 |
self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else \
|
|
631 |
self.setZValue(QEngineeringStreamlineItem.ZVALUE)
|
|
354 | 632 |
self.update() |
355 | 633 |
|
356 | 634 |
def paint(self, painter, option, widget): |
... | ... | |
406 | 684 |
def on_connector_pos_changed(self, connector): |
407 | 685 |
""" rebuild stream line """ |
408 | 686 |
|
409 |
self._vertices = [] |
|
410 |
|
|
411 |
self._vertices.append(self.connectors[0].center()) |
|
412 |
dx = self.connectors[-1].center()[0] - self._vertices[0][0] |
|
413 |
dy = self.connectors[-1].center()[1] - self._vertices[0][1] |
|
414 |
self._vertices.append((self._vertices[0][0] + dx*0.5, self._vertices[0][1])) |
|
415 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
|
416 |
self._vertices.append(self.connectors[-1].center()) |
|
417 | 687 |
self.build_path() |
418 | 688 |
self.update_arrow() |
419 | 689 |
self.update() |
... | ... | |
487 | 757 |
|
488 | 758 |
@staticmethod |
489 | 759 |
def fromDatabase(componentInfos): |
490 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
|
491 | 760 |
from AppDocData import AppDocData |
492 | 761 |
|
493 | 762 |
item = None |
... | ... | |
512 | 781 |
connectorItems = [componentInfos[0][15], componentInfos[-1][15]] |
513 | 782 |
|
514 | 783 |
item.setVisible(False) |
515 |
item.build_path() |
|
516 | 784 |
item.build_connectors(connectorItems, pointsUids) |
785 |
item.build_path() |
|
517 | 786 |
|
518 | 787 |
item.update() |
519 | 788 |
|
... | ... | |
521 | 790 |
from App import App |
522 | 791 |
from AppDocData import MessageType |
523 | 792 |
|
524 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
793 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
525 | 794 |
sys.exc_info()[-1].tb_lineno) |
526 | 795 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
527 | 796 |
|
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
23 | 23 |
""" This is symbolsvgitem class """ |
24 | 24 |
|
25 | 25 |
clicked = pyqtSignal(QGraphicsSvgItem) |
26 |
ZVALUE = 50
|
|
26 |
ZVALUE = 100
|
|
27 | 27 |
HOVER_COLOR = 'url(#hover)' |
28 | 28 |
|
29 | 29 |
''' |
... | ... | |
55 | 55 |
self.size = None |
56 | 56 |
self._owner = None |
57 | 57 |
self.parentSymbol = '' |
58 |
self.childSymbol = ''
|
|
58 |
self.childSymbol = '' |
|
59 | 59 |
self.hasInstrumentLabel = 0 |
60 | 60 |
self.flip = flip |
61 | 61 |
# attributeType uid |
62 | 62 |
self.attribute = '' |
63 |
self._properties = {SymbolProp(None, 'Supplied By', 'String'):None} |
|
63 |
self._properties = {SymbolProp(None, 'Supplied By', 'String'): None}
|
|
64 | 64 |
|
65 | 65 |
self.setAcceptDrops(True) |
66 | 66 |
self.setAcceptHoverEvents(True) |
67 | 67 |
self.setAcceptedMouseButtons(Qt.LeftButton) |
68 | 68 |
self.setAcceptTouchEvents(True) |
69 |
|
|
69 |
|
|
70 | 70 |
self.currentCursor = 0 |
71 | 71 |
self.transfer = Transfer() |
72 | 72 |
|
... | ... | |
83 | 83 |
except Exception as ex: |
84 | 84 |
from App import App |
85 | 85 |
from AppDocData import MessageType |
86 |
|
|
86 |
|
|
87 | 87 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
88 | 88 |
sys.exc_info()[-1].tb_lineno) |
89 | 89 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
... | ... | |
136 | 136 |
""" getter of properties """ |
137 | 137 |
import uuid |
138 | 138 |
|
139 |
for prop,value in self._properties.items(): |
|
139 |
for prop, value in self._properties.items():
|
|
140 | 140 |
try: |
141 | 141 |
if prop.is_selectable and type(value) is uuid.UUID and self.scene(): |
142 | 142 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)] |
143 | 143 |
if matches: self._properties[prop] = matches[0] |
144 |
|
|
144 |
|
|
145 | 145 |
if prop.Expression: |
146 |
item = self._properties[prop] # assign item
|
|
146 |
item = self._properties[prop] # assign item |
|
147 | 147 |
self._properties[prop] = eval(prop.Expression) |
148 | 148 |
except Exception as ex: |
149 |
from App import App
|
|
149 |
from App import App |
|
150 | 150 |
|
151 | 151 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
152 | 152 |
sys.exc_info()[-1].tb_lineno) |
153 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
153 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
154 | 154 |
|
155 | 155 |
return self._properties |
156 | 156 |
|
... | ... | |
162 | 162 |
def set_property(self, property, value): |
163 | 163 |
""" set property with given value """ |
164 | 164 |
if issubclass(type(value), QEngineeringAbstractItem): self.add_assoc_item(value, 0) |
165 |
matches = [prop for prop,_ in self._properties.items() if prop.Attribute == property] |
|
165 |
matches = [prop for prop, _ in self._properties.items() if prop.Attribute == property]
|
|
166 | 166 |
if matches: self._properties[matches[0]] = value |
167 | 167 |
|
168 | 168 |
def prop(self, name): |
169 | 169 |
""" return the value of given property with name """ |
170 |
matches = [(prop,value) for prop,value in self.properties.items() if prop.Attribute == name]
|
|
170 |
matches = [(prop, value) for prop, value in self.properties.items() if prop.Attribute == name]
|
|
171 | 171 |
if matches: return matches[0][1] |
172 | 172 |
|
173 | 173 |
return None |
... | ... | |
182 | 182 |
return matches[0].text() |
183 | 183 |
else: |
184 | 184 |
return None |
185 |
|
|
185 |
|
|
186 | 186 |
def includes(self, pt, margin=0): |
187 | 187 |
""" return True if symbol contains given point else return False """ |
188 | 188 |
rect = self.sceneBoundingRect() |
... | ... | |
200 | 200 |
maxX = minX + rect.width() + margin |
201 | 201 |
maxY = minY + rect.height() + margin |
202 | 202 |
|
203 |
#print([minX, minY, maxX, maxY]) |
|
203 |
# print([minX, minY, maxX, maxY])
|
|
204 | 204 |
|
205 | 205 |
return True if (pt[0] >= minX and pt[0] <= maxX and pt[1] >= minY and pt[1] <= maxY) else False |
206 | 206 |
|
... | ... | |
211 | 211 |
|
212 | 212 |
res = [] |
213 | 213 |
appDocData = AppDocData.instance() |
214 |
|
|
214 |
|
|
215 | 215 |
rect = self.sceneBoundingRect() |
216 | 216 |
|
217 | 217 |
cols = ['UID', 'Symbols_UID', 'X', 'Y', 'Rotation', 'Scale'] |
218 |
values = ['?','?', '?', '?', '?', '?'] |
|
218 |
values = ['?', '?', '?', '?', '?', '?']
|
|
219 | 219 |
param = [str(self.uid), str(self.dbUid), rect.left(), rect.top(), str(self.angle), self.transform().m11()] |
220 | 220 |
sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
221 | 221 |
res.append((sql, tuple(param))) |
222 |
|
|
222 |
|
|
223 | 223 |
# save connectors to database |
224 | 224 |
index = 1 |
225 | 225 |
for connector in self.connectors: |
... | ... | |
247 | 247 |
|
248 | 248 |
self.name = name |
249 | 249 |
self.index = self.counters[name] |
250 |
self.type = _type
|
|
251 |
self.angle = angle
|
|
250 |
self.type = _type |
|
251 |
self.angle = angle |
|
252 | 252 |
self._scale = scale |
253 |
self.loc = loc
|
|
253 |
self.loc = loc |
|
254 | 254 |
|
255 | 255 |
docData = AppDocData.instance() |
256 | 256 |
if dbUid is None: |
257 | 257 |
symbolInfo = docData.getSymbolByQuery('name', name) |
258 | 258 |
else: |
259 | 259 |
symbolInfo = docData.getSymbolByQuery('UID', dbUid) |
260 |
|
|
260 |
|
|
261 | 261 |
self.dbUid = symbolInfo.uid |
262 | 262 |
self.category = symbolInfo.sCategory |
263 | 263 |
originalPoint = symbolInfo.getOriginalPoint().split(',') |
264 | 264 |
self.symbolOrigin = [float(originalPoint[0]), float(originalPoint[1])] |
265 |
|
|
265 |
|
|
266 | 266 |
# setting connectors |
267 | 267 |
connectionPoints = symbolInfo.getConnectionPoint().split('/') |
268 | 268 |
for index in range(len(connectionPoints)): |
... | ... | |
270 | 270 |
break |
271 | 271 |
tokens = connectionPoints[index].split(',') |
272 | 272 |
|
273 |
direction = 'AUTO'
|
|
273 |
direction = 'AUTO' |
|
274 | 274 |
symbol_idx = '0' |
275 | 275 |
|
276 | 276 |
if len(tokens) == 2: |
... | ... | |
287 | 287 |
symbol_idx = tokens[3] |
288 | 288 |
|
289 | 289 |
if pointsUids: |
290 |
self.setConnector(pointsUids[index], index+1)
|
|
290 |
self.setConnector(pointsUids[index], index + 1)
|
|
291 | 291 |
else: |
292 |
self.setConnector(None, index+1)
|
|
293 |
|
|
292 |
self.setConnector(None, index + 1)
|
|
293 |
|
|
294 | 294 |
self.connectors[index].direction = direction |
295 | 295 |
self.connectors[index].symbol_idx = symbol_idx |
296 | 296 |
self.connectors[index].setPos((x, y)) |
297 | 297 |
self.connectors[index].connectPoint = (x, y) |
298 |
|
|
298 |
|
|
299 | 299 |
tooltip = '<b>{}</b><br>{}={}'.format(str(self.uid), self.type, self.name) |
300 | 300 |
self.setToolTip(tooltip) |
301 | 301 |
except Exception as ex: |
302 |
from App import App
|
|
302 |
from App import App |
|
303 | 303 |
|
304 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
304 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
305 | 305 |
sys.exc_info()[-1].tb_lineno) |
306 | 306 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
307 | 307 |
|
... | ... | |
313 | 313 |
|
314 | 314 |
def rect(self): |
315 | 315 |
return self.sceneBoundingRect() |
316 |
|
|
316 |
|
|
317 | 317 |
''' |
318 | 318 |
@brief return true if line is able to connect symbol |
319 | 319 |
@author humkyung |
... | ... | |
321 | 321 |
''' |
322 | 322 |
|
323 | 323 |
def is_connectable(self, item, toler=10): |
324 |
#from EngineeringLineItem import QEngineeringLineItem |
|
324 |
# from EngineeringLineItem import QEngineeringLineItem
|
|
325 | 325 |
|
326 | 326 |
''' |
327 | 327 |
if False:#type(item) is QEngineeringLineItem: |
... | ... | |
341 | 341 |
for iConnector in item.connectors: |
342 | 342 |
dx = connector.sceneConnectPoint[0] - iConnector.sceneConnectPoint[0] |
343 | 343 |
dy = connector.sceneConnectPoint[1] - iConnector.sceneConnectPoint[1] |
344 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True
|
|
344 |
if (math.sqrt(dx * dx + dy * dy) < toler): return True
|
|
345 | 345 |
|
346 | 346 |
return False |
347 |
|
|
347 |
|
|
348 | 348 |
''' |
349 | 349 |
@author humkyung |
350 | 350 |
@date 2018.07.03 |
... | ... | |
364 | 364 |
rhs_matches = [at for at in range(len(self.connectors)) if self.connectors[at].connectedItem == rhs] |
365 | 365 |
if lhs_matches and rhs_matches: |
366 | 366 |
return (lhs_matches[0] in [0, 1] and rhs_matches[0] in [0, 1]) or ( |
367 |
lhs_matches[0] in [2, 3] and rhs_matches[0] in [2, 3])
|
|
367 |
lhs_matches[0] in [2, 3] and rhs_matches[0] in [2, 3]) |
|
368 | 368 |
|
369 | 369 |
return False |
370 | 370 |
|
... | ... | |
392 | 392 |
self.connectors[i].connect(obj) |
393 | 393 |
if obj.connectors[0].connectedItem is None: |
394 | 394 |
obj.connectors[0].connect(self) |
395 |
|
|
395 |
|
|
396 | 396 |
res.append(obj) |
397 | 397 |
if (Point(endPt[0], endPt[1]).distance(Point(self.connectors[i].sceneConnectPoint[0], |
398 | 398 |
self.connectors[i].sceneConnectPoint[1])) < toler): |
... | ... | |
400 | 400 |
self.connectors[i].connect(obj) |
401 | 401 |
if obj.connectors[1].connectedItem is None: |
402 | 402 |
obj.connectors[1].connect(self) |
403 |
|
|
403 |
|
|
404 | 404 |
res.append(obj) |
405 | 405 |
elif issubclass(type(obj), SymbolSvgItem): |
406 | 406 |
for i in range(len(self.connectors)): |
... | ... | |
415 | 415 |
|
416 | 416 |
res.append(obj) |
417 | 417 |
except Exception as ex: |
418 |
from App import App
|
|
418 |
from App import App |
|
419 | 419 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
420 | 420 |
sys.exc_info()[-1].tb_lineno) |
421 | 421 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
... | ... | |
445 | 445 |
for connector in self.connectors: |
446 | 446 |
dx = connector.sceneConnectPoint[0] - pt[0] |
447 | 447 |
dy = connector.sceneConnectPoint[1] - pt[1] |
448 |
if math.sqrt(dx*dx + dy*dy) < toler: return connPt
|
|
449 |
|
|
448 |
if math.sqrt(dx * dx + dy * dy) < toler: return connPt
|
|
449 |
|
|
450 | 450 |
return None |
451 | 451 |
|
452 | 452 |
''' |
... | ... | |
457 | 457 |
|
458 | 458 |
def center(self): |
459 | 459 |
return self.sceneBoundingRect().center() |
460 |
|
|
460 |
|
|
461 | 461 |
''' |
462 | 462 |
@brief highlight connector and attribute |
463 | 463 |
@authro humkyung |
... | ... | |
502 | 502 |
""" highlight/unhighlight the symbol """ |
503 | 503 |
|
504 | 504 |
try: |
505 |
self.hover = flag
|
|
505 |
self.hover = flag |
|
506 | 506 |
self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else self.setZValue(SymbolSvgItem.ZVALUE) |
507 | 507 |
self.update() |
508 |
|
|
509 |
#for assoc in self.associations(): |
|
510 |
# assoc.highlight(flag) |
|
511 |
except Exception as ex: |
|
512 |
from App import App |
|
513 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
508 |
except Exception as ex: |
|
509 |
from App import App |
|
510 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
514 | 511 |
sys.exc_info()[-1].tb_lineno) |
515 | 512 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
516 | 513 |
|
... | ... | |
568 | 565 |
if change == QGraphicsItem.ItemPositionHasChanged: |
569 | 566 |
self.transfer.on_pos_changed.emit(self) |
570 | 567 |
return value |
571 |
|
|
568 |
|
|
572 | 569 |
return super().itemChange(change, value) |
573 | 570 |
|
574 | 571 |
def removeSelfAttr(self, attributeName): |
... | ... | |
577 | 574 |
if attr.Attribute == attributeName: |
578 | 575 |
target = attr |
579 | 576 |
break |
580 |
|
|
577 |
|
|
581 | 578 |
if target: |
582 | 579 |
del self.attrs[attr] |
583 | 580 |
|
... | ... | |
613 | 610 |
self.deleteSvgItemFromScene() |
614 | 611 |
elif event.key() == Qt.Key_QuoteLeft: |
615 | 612 |
self.mouseDoubleClickEvent(event) |
616 |
|
|
613 |
|
|
617 | 614 |
''' |
618 | 615 |
@brief connect attribute |
619 | 616 |
@author humkyung |
... | ... | |
624 | 621 |
def connectAttribute(self, attributes, clear=True): |
625 | 622 |
import math |
626 | 623 |
from EngineeringTextItem import QEngineeringTextItem |
627 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
|
|
624 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
|
628 | 625 |
|
629 | 626 |
try: |
630 | 627 |
if clear: |
... | ... | |
632 | 629 |
|
633 | 630 |
configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio') |
634 | 631 |
ratio = float(configs[0].value) if 1 == len(configs) else 1.5 |
635 |
|
|
632 |
|
|
636 | 633 |
dist = max(self.sceneBoundingRect().height(), self.sceneBoundingRect().width()) * ratio |
637 | 634 |
center = self.sceneBoundingRect().center() |
638 | 635 |
|
... | ... | |
640 | 637 |
selected = None |
641 | 638 |
for attr in attributes: |
642 | 639 |
# size text and operation code text will find onwer themselves in findowner method |
643 |
if False:# type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem: |
|
640 |
if False: # type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem:
|
|
644 | 641 |
dx = attr.center().x() - center.x() |
645 | 642 |
dy = attr.center().y() - center.y() |
646 |
length = math.sqrt(dx*dx + dy*dy)
|
|
643 |
length = math.sqrt(dx * dx + dy * dy)
|
|
647 | 644 |
if (length < dist) and (minDist is None or length < minDist): |
648 | 645 |
minDist = length |
649 | 646 |
selected = attr |
... | ... | |
651 | 648 |
if not attr.is_connected: |
652 | 649 |
dx = attr.center().x() - center.x() |
653 | 650 |
dy = attr.center().y() - center.y() |
654 |
if math.sqrt(dx*dx + dy*dy) < dist:
|
|
651 |
if math.sqrt(dx * dx + dy * dy) < dist:
|
|
655 | 652 |
if self.add_assoc_item(attr): |
656 | 653 |
attr.owner = self |
657 | 654 |
|
... | ... | |
660 | 657 |
selected.owner = self |
661 | 658 |
|
662 | 659 |
except Exception as ex: |
663 |
from App import App
|
|
660 |
from App import App |
|
664 | 661 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
665 | 662 |
sys.exc_info()[-1].tb_lineno) |
666 | 663 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
... | ... | |
674 | 671 |
def mouseDoubleClickEvent(self, event): |
675 | 672 |
func_map = [ |
676 | 673 |
(('Equipment - [ Pressure Drop ]', 'Air Fin Cooler', 'AF_Cooler'), self.show_AirFinCooler), |
677 |
(('Equipment - [ Pressure Drop ]', 'Filter', ('Filter_H','Filter_V')), self.show_Filter), |
|
674 |
(('Equipment - [ Pressure Drop ]', 'Filter', ('Filter_H', 'Filter_V')), self.show_Filter),
|
|
678 | 675 |
(('Equipment - [ Pressure Drop ]', 'Heat Exchanger', ('HEX_DP', 'HEX_H', 'HEX_K', 'HEX_V')), |
679 | 676 |
self.show_ShlTubHeatExchanger), |
680 | 677 |
(('Equipment - [ Pressure Drop ]', 'Heat Exchanger', ('HEX_P')), self.show_PlateHeatExchanger), |
681 | 678 |
(('Equipment - [ Pressure Drop ]', 'Miscellaneous', ('M_Coil')), self.show_Coil), |
682 | 679 |
(('Equipment - [ Pressure Drop ]', 'Miscellaneous', ('M_DP_E')), self.show_DP_Equipment), |
683 | 680 |
(('Equipment - [ Pressure Drop ]', 'Miscellaneous', ('M_React')), self.show_Reactor), |
684 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('T_Strainer_H','T_Strainer_V')), self.show_Strainer_T), |
|
685 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('Y_Strainer_H','Y_Strainer_V')), self.show_Strainer_Y), |
|
681 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('T_Strainer_H', 'T_Strainer_V')), self.show_Strainer_T),
|
|
682 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('Y_Strainer_H', 'Y_Strainer_V')), self.show_Strainer_Y),
|
|
686 | 683 |
(('Equipment - [ Pressurized ]', 'Battery Limit', None), self.show_BatteryLimit), |
687 | 684 |
(('Equipment - [ Pressurized ]', 'Column', ('CwT')), self.show_Tray), |
688 | 685 |
(('Equipment - [ Pressurized ]', 'Column', ('CwP_Single')), self.show_SinglePacked), |
... | ... | |
693 | 690 |
(('Equipment - [ Pressurized ]', 'Tank', ('Ball_Tank')), self.show_Ball), |
694 | 691 |
(('Equipment - [ Pressurized ]', 'Tank', ('CRT')), self.show_ConeRoof), |
695 | 692 |
(('Equipment - [ Pressurized ]', 'Tank', ('DRT')), self.show_DomeRoof), |
696 |
(('Equipment - [ Rotating ]', 'Compressor', ('L_Comp','R_Comp')), self.show_Compressor), |
|
697 |
(('Equipment - [ Rotating ]', 'Pump', ('L_Pump','R_Pump','V_Pump')), self.show_Pump),
|
|
698 |
(('Instrument', 'Valve', ('CV_H','CV_V')), self.show_ValveControl), |
|
699 |
(('Instrument', 'Valve', ('MV_H','MV_V')), self.show_ValveManual), |
|
693 |
(('Equipment - [ Rotating ]', 'Compressor', ('L_Comp', 'R_Comp')), self.show_Compressor),
|
|
694 |
(('Equipment - [ Rotating ]', 'Pump', ('L_Pump', 'R_Pump', 'V_Pump')), self.show_Pump),
|
|
695 |
(('Instrument', 'Valve', ('CV_H', 'CV_V')), self.show_ValveControl),
|
|
696 |
(('Instrument', 'Valve', ('MV_H', 'MV_V')), self.show_ValveManual),
|
|
700 | 697 |
(('Instrument', 'Line Splitter', ('Line_Splitter')), self.show_LineSplitter), |
701 | 698 |
(('Instrument', 'Flowmeter', ( |
702 |
'Ori_Flowmeter_H', 'Oth_Flowmeter_H', 'Ven_Flowmeter_H', 'Ori_Flowmeter_V', 'Oth_Flowmeter_V', |
|
703 |
'Ven_Flowmeter_V')), self.show_Flowmeter), |
|
704 |
(('Instrument', 'Reducer', ('Re_Ex_Dw','Re_Ex_L','Re_Ex_R','Re_Ex_Up')), self.show_Reducer)
|
|
705 |
]
|
|
699 |
'Ori_Flowmeter_H', 'Oth_Flowmeter_H', 'Ven_Flowmeter_H', 'Ori_Flowmeter_V', 'Oth_Flowmeter_V',
|
|
700 |
'Ven_Flowmeter_V')), self.show_Flowmeter),
|
|
701 |
(('Instrument', 'Reducer', ('Re_Ex_Dw', 'Re_Ex_L', 'Re_Ex_R', 'Re_Ex_Up')), self.show_Reducer)
|
|
702 |
] |
|
706 | 703 |
|
707 | 704 |
connectedItems = [connector for connector in self.connectors if connector.connectedItem is not None] |
708 |
if len(connectedItems) < 1:
|
|
705 |
if len(connectedItems) < 1: |
|
709 | 706 |
msg = QMessageBox() |
710 | 707 |
msg.setIcon(QMessageBox.Information) |
711 | 708 |
msg.setText(self.tr('Connect Line before Data input')) |
712 | 709 |
msg.setWindowTitle(self.tr("Notice")) |
713 | 710 |
msg.setStandardButtons(QMessageBox.Ok) |
714 |
msg.exec_()
|
|
711 |
msg.exec_() |
|
715 | 712 |
return |
716 | 713 |
|
717 | 714 |
matches = [func for func in func_map if func[0][0] == self.category and func[0][1] == self.type and ( |
718 |
func[0][2] is None or self.name in func[0][2])]
|
|
715 |
func[0][2] is None or self.name in func[0][2])] |
|
719 | 716 |
if matches: matches[0][1]() |
720 | 717 |
|
721 | 718 |
def show_AirFinCooler(self): |
... | ... | |
726 | 723 |
|
727 | 724 |
def show_Filter(self): |
728 | 725 |
from Filter import QFilter |
729 |
|
|
726 |
|
|
730 | 727 |
dialog = QFilter() |
731 | 728 |
dialog.showDialog(self) |
732 | 729 |
|
733 | 730 |
def show_Coil(self): |
734 | 731 |
from Coil import QCoil |
735 |
|
|
732 |
|
|
736 | 733 |
dialog = QCoil() |
737 | 734 |
dialog.showDialog(self) |
738 | 735 |
|
739 | 736 |
def show_DP_Equipment(self): |
740 | 737 |
from DP_Equipment import QDP_Equipment |
741 |
|
|
738 |
|
|
742 | 739 |
dialog = QDP_Equipment() |
743 | 740 |
dialog.showDialog(self) |
744 | 741 |
|
745 | 742 |
def show_Reactor(self): |
746 | 743 |
from Reactor import QReactor |
747 |
|
|
744 |
|
|
748 | 745 |
dialog = QReactor() |
749 | 746 |
dialog.showDialog(self) |
750 | 747 |
|
751 | 748 |
def show_Strainer_T(self): |
752 | 749 |
from Strainer_T import QStrainer_T |
753 |
|
|
750 |
|
|
754 | 751 |
dialog = QStrainer_T() |
755 | 752 |
dialog.showDialog(self) |
756 | 753 |
|
757 | 754 |
def show_Strainer_Y(self): |
758 | 755 |
from Strainer_Y import QStrainer_Y |
759 |
|
|
756 |
|
|
760 | 757 |
dialog = QStrainer_Y() |
761 | 758 |
dialog.showDialog(self) |
762 | 759 |
|
763 | 760 |
def show_BatteryLimit(self): |
764 | 761 |
from BatteryLimit import QBatteryLimit |
765 |
|
|
762 |
|
|
766 | 763 |
dialog = QBatteryLimit() |
767 | 764 |
dialog.showDialog(self) |
768 |
|
|
765 |
|
|
769 | 766 |
def show_Tray(self): |
770 | 767 |
from Tray import QTray |
771 |
|
|
768 |
|
|
772 | 769 |
dialog = QTray() |
773 | 770 |
dialog.showDialog(self) |
774 | 771 |
|
775 | 772 |
def show_SinglePacked(self): |
776 | 773 |
from SinglePacked import QSinglePacked |
777 |
|
|
774 |
|
|
778 | 775 |
dialog = QSinglePacked() |
779 | 776 |
dialog.showDialog(self) |
780 | 777 |
|
781 | 778 |
def show_DualPacked(self): |
782 | 779 |
from DualPacked import QDualPacked |
783 |
|
|
780 |
|
|
784 | 781 |
dialog = QDualPacked() |
785 | 782 |
dialog.showDialog(self) |
786 | 783 |
|
787 | 784 |
def show_Drum_Horizontal(self): |
788 | 785 |
from Drum_Horizontal import QDrum_Horizontal |
789 |
|
|
786 |
|
|
790 | 787 |
dialog = QDrum_Horizontal() |
791 | 788 |
dialog.showDialog(self) |
792 | 789 |
|
793 | 790 |
def show_Drum_Vertical(self): |
794 | 791 |
from Drum_Vertical import QDrum_Vertical |
795 |
|
|
792 |
|
|
796 | 793 |
dialog = QDrum_Vertical() |
797 | 794 |
dialog.showDialog(self) |
798 | 795 |
|
799 | 796 |
def show_PlateHeatExchanger(self): |
800 | 797 |
from PlateHeatExchanger import QPlateHeatExchanger |
801 |
|
|
798 |
|
|
802 | 799 |
dialog = QPlateHeatExchanger() |
803 | 800 |
dialog.showDialog(self) |
804 | 801 |
|
805 | 802 |
def show_Equipment(self): |
806 | 803 |
from Equipment import QEquipment |
807 |
|
|
804 |
|
|
808 | 805 |
dialog = QEquipment() |
809 | 806 |
dialog.showDialog(self) |
810 | 807 |
|
811 | 808 |
def show_Ball(self): |
812 | 809 |
from Ball import QBall |
813 |
|
|
810 |
|
|
814 | 811 |
dialog = QBall() |
815 | 812 |
dialog.showDialog(self) |
816 | 813 |
|
817 | 814 |
def show_ShlTubHeatExchanger(self): |
818 | 815 |
from ShlTubHeatExchanger import QShlTubHeatExchanger |
819 |
|
|
816 |
|
|
820 | 817 |
dialog = QShlTubHeatExchanger() |
821 | 818 |
dialog.showDialog(self) |
822 | 819 |
|
823 | 820 |
def show_ConeRoof(self): |
824 | 821 |
from ConeRoof import QConeRoof |
825 |
|
|
822 |
|
|
826 | 823 |
dialog = QConeRoof() |
827 | 824 |
dialog.showDialog(self) |
828 |
|
|
825 |
|
|
829 | 826 |
def show_DomeRoof(self): |
830 | 827 |
from DomeRoof import QDomeRoof |
831 |
|
|
828 |
|
|
832 | 829 |
dialog = QDomeRoof() |
833 | 830 |
dialog.showDialog(self) |
834 | 831 |
|
835 | 832 |
def show_Compressor(self): |
836 | 833 |
from Compressor import QCompressor |
837 |
|
|
834 |
|
|
838 | 835 |
dialog = QCompressor() |
839 | 836 |
dialog.showDialog(self) |
840 | 837 |
|
841 | 838 |
def show_Pump(self): |
842 | 839 |
from Pump import QPump |
843 |
|
|
840 |
|
|
844 | 841 |
dialog = QPump() |
845 | 842 |
dialog.showDialog(self) |
846 | 843 |
|
847 | 844 |
def show_ValveControl(self): |
848 | 845 |
from Valve_Control import QValve_Control |
849 |
|
|
846 |
|
|
850 | 847 |
dialog = QValve_Control() |
851 | 848 |
dialog.showDialog(self) |
852 | 849 |
|
853 | 850 |
def show_ValveManual(self): |
854 | 851 |
from Valve_Manual import QValve_Manual |
855 |
|
|
852 |
|
|
856 | 853 |
dialog = QValve_Manual() |
857 | 854 |
dialog.showDialog(self) |
858 | 855 |
|
859 | 856 |
def show_LineSplitter(self): |
860 | 857 |
from LineSplitter import QLineSplitter |
861 |
|
|
858 |
|
|
862 | 859 |
dialog = QLineSplitter() |
863 | 860 |
dialog.showDialog(self) |
864 | 861 |
|
865 | 862 |
def show_Flowmeter(self): |
866 | 863 |
from Flowmeter import QFlowmeter |
867 |
|
|
864 |
|
|
868 | 865 |
dialog = QFlowmeter() |
869 | 866 |
dialog.showDialog(self) |
870 | 867 |
|
871 | 868 |
def show_Reducer(self): |
872 | 869 |
from Reducer import QReducer |
873 |
|
|
870 |
|
|
874 | 871 |
dialog = QReducer() |
875 | 872 |
dialog.showDialog(self) |
876 | 873 |
|
877 |
@staticmethod
|
|
874 |
@staticmethod |
|
878 | 875 |
def fromDatabase(componentInfos): |
879 | 876 |
""" create a componenet from database """ |
880 | 877 |
item = None |
881 | 878 |
|
882 | 879 |
try: |
883 |
uid = componentInfos[0][0] # uid@Components
|
|
884 |
dbUid = componentInfos[0][2] # Symbol_UID@Components
|
|
885 |
category = componentInfos[0][3] # Category@SymbolType
|
|
886 |
_type = componentInfos[0][4] # Type@SymbolType
|
|
887 |
name = componentInfos[0][5] # Name@Symbols
|
|
888 |
originalPoint = componentInfos[0][6] # OriginalPoint@Symbols
|
|
889 |
x = componentInfos[0][7] # X@Components
|
|
890 |
y = componentInfos[0][8] # Y@Components
|
|
891 |
angle = componentInfos[0][9] # Rotation@Components
|
|
892 |
scale = componentInfos[0][10] # Scale@Components
|
|
880 |
uid = componentInfos[0][0] # uid@Components |
|
881 |
dbUid = componentInfos[0][2] # Symbol_UID@Components |
|
882 |
category = componentInfos[0][3] # Category@SymbolType |
|
883 |
_type = componentInfos[0][4] # Type@SymbolType |
|
884 |
name = componentInfos[0][5] # Name@Symbols |
|
885 |
originalPoint = componentInfos[0][6] # OriginalPoint@Symbols |
|
886 |
x = componentInfos[0][7] # X@Components |
|
887 |
y = componentInfos[0][8] # Y@Components |
|
888 |
angle = componentInfos[0][9] # Rotation@Components
|
|
889 |
scale = componentInfos[0][10] # Scale@Components
|
|
893 | 890 |
|
894 | 891 |
pt = [] |
895 | 892 |
pt.append(float(x)) |
... | ... | |
901 | 898 |
|
902 | 899 |
pointsUids = [] |
903 | 900 |
for componentInfo in componentInfos: |
904 |
pointsUid = componentInfo[11] # uid@Points
|
|
901 |
pointsUid = componentInfo[11] # uid@Points |
|
905 | 902 |
pointsUids.append(pointsUid) |
906 | 903 |
|
907 | 904 |
app_doc_data = AppDocData.instance() |
... | ... | |
912 | 909 |
item.setVisible(False) |
913 | 910 |
item.buildItem(name, _type, float(angle), float(scale), pt, origin, connPts, dbUid, pointsUids) |
914 | 911 |
except Exception as ex: |
915 |
from App import App
|
|
916 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
912 |
from App import App |
|
913 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
917 | 914 |
sys.exc_info()[-1].tb_lineno) |
918 | 915 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
919 | 916 |
|
... | ... | |
929 | 926 |
''' |
930 | 927 |
|
931 | 928 |
@staticmethod |
932 |
def createItem(type, path, uid=None, owner=None, flip=0):
|
|
933 |
from EngineeringNozzleItem import QEngineeringNozzleItem
|
|
934 |
from EngineeringErrorItem import QEngineeringErrorItem
|
|
929 |
def createItem(type, path, uid=None, owner=None, flip=0): |
|
930 |
from EngineeringNozzleItem import QEngineeringNozzleItem |
|
931 |
from EngineeringErrorItem import QEngineeringErrorItem |
|
935 | 932 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
936 | 933 |
from AppDocData import AppDocData |
937 | 934 |
import uuid |
... | ... | |
1001 | 998 |
if node.hasChildNodes(): |
1002 | 999 |
att_val = self.recursive_get_attribute(node.firstChild(), attName) |
1003 | 1000 |
if att_val is not None: return att_val |
1004 |
|
|
1001 |
|
|
1005 | 1002 |
node = node.nextSibling() |
1006 | 1003 |
|
1007 | 1004 |
return None |
... | ... | |
1041 | 1038 |
|
1042 | 1039 |
if node.hasChildNodes(): |
1043 | 1040 |
recursiveChangeAttributes(node.firstChild(), attName, attValue) |
1044 |
|
|
1041 |
|
|
1045 | 1042 |
node = node.nextSibling() |
1046 | 1043 |
|
1047 | 1044 |
''' |
... | ... | |
1150 | 1147 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1151 | 1148 |
|
1152 | 1149 |
self.transfer.onRemoved.emit(self) |
1153 |
|
|
1150 |
|
|
1154 | 1151 |
''' |
1155 | 1152 |
@brief Return real item position |
1156 | 1153 |
@author Jeongwoo |
... | ... | |
1184 | 1181 |
|
1185 | 1182 |
def rotateSymbol(self, angle=None): |
1186 | 1183 |
if angle is None: |
1187 |
#degree 0 |
|
1184 |
# degree 0
|
|
1188 | 1185 |
if 0 == self.angle: |
1189 | 1186 |
self.angle = 1.57 |
1190 |
#degree 90 |
|
1187 |
# degree 90
|
|
1191 | 1188 |
elif (1.57 == self.angle): |
1192 | 1189 |
self.angle = 3.14 |
1193 |
#degree 180 |
|
1190 |
# degree 180
|
|
1194 | 1191 |
elif 3.14 == self.angle: |
1195 | 1192 |
self.angle = 4.71 |
1196 |
#degree 270 |
|
1197 |
elif 4.71 == self.angle :
|
|
1193 |
# degree 270
|
|
1194 |
elif 4.71 == self.angle: |
|
1198 | 1195 |
self.angle = 0 |
1199 | 1196 |
else: |
1200 | 1197 |
self.angle = 0 |
1201 |
|
|
1198 |
|
|
1202 | 1199 |
self.size[0], self.size[1] = self.size[1], self.size[0] |
1203 | 1200 |
else: |
1204 | 1201 |
self.angle = angle |
1205 |
|
|
1206 |
#scene = self.scene() |
|
1207 |
#self.scene().removeItem(self) |
|
1208 |
#self.addSvgItemToScene(scene) |
|
1202 |
|
|
1203 |
# scene = self.scene()
|
|
1204 |
# self.scene().removeItem(self)
|
|
1205 |
# self.addSvgItemToScene(scene)
|
|
1209 | 1206 |
currentPoint = self.getCurrentPoint() |
1210 | 1207 |
self.reSettingSymbol(currentPoint, self.angle) |
1211 | 1208 |
|
... | ... | |
1217 | 1214 |
|
1218 | 1215 |
def reSettingSymbol(self, standardPoint, angle): |
1219 | 1216 |
transform = QTransform() |
1220 |
|
|
1217 |
|
|
1221 | 1218 |
transform.translate(self.loc[0] + self.symbolOrigin[0], self.loc[1] + self.symbolOrigin[1]) |
1222 | 1219 |
transform.rotateRadians(-angle) |
1223 | 1220 |
transform.translate(-standardPoint[0], -standardPoint[1]) |
... | ... | |
1264 | 1261 |
|
1265 | 1262 |
def changeStandardPoint(self): |
1266 | 1263 |
connPtsCount = len(self.connectors) |
1267 |
|
|
1264 |
|
|
1268 | 1265 |
if self.currentPointModeIndex < connPtsCount: |
1269 | 1266 |
self.currentPointModeIndex += 1 |
1270 | 1267 |
else: |
... | ... | |
1272 | 1269 |
|
1273 | 1270 |
currentPoint = self.getCurrentPoint() |
1274 | 1271 |
self.reSettingSymbol(currentPoint, self.angle) |
1275 |
|
|
1272 |
|
|
1276 | 1273 |
''' |
1277 | 1274 |
@brief get standard point |
1278 | 1275 |
@author kyouho |
... | ... | |
1286 | 1283 |
for connector in self.connectors: |
1287 | 1284 |
pointList.append(connector.connectPoint) |
1288 | 1285 |
|
1289 |
#if type(self) is QEngineeringSpecBreakItem: |
|
1286 |
# if type(self) is QEngineeringSpecBreakItem:
|
|
1290 | 1287 |
# self.currentPointModeIndex = 1 |
1291 | 1288 |
|
1292 | 1289 |
return pointList[self.currentPointModeIndex] |
... | ... | |
1306 | 1303 |
transform.translate(-currentPoint[0], -currentPoint[1]) |
1307 | 1304 |
# 시작점을 구하기 위해서 |
1308 | 1305 |
goPoint = transform.map(QPoint(self.symbolOrigin[0], self.symbolOrigin[1])) |
1309 |
|
|
1306 |
|
|
1310 | 1307 |
self.loc = [self.loc[0] + self.origin[0] - goPoint.x(), self.loc[1] + self.origin[1] - goPoint.y()] |
1311 | 1308 |
|
1312 | 1309 |
def resize(self, change): |
... | ... | |
1315 | 1312 |
rect = self.sceneBoundingRect() |
1316 | 1313 |
loc = QPointF(rect.x(), rect.y()) |
1317 | 1314 |
self.resetTransform() |
1318 |
#self.setScale(1) |
|
1315 |
# self.setScale(1)
|
|
1319 | 1316 |
rect = self.sceneBoundingRect() |
1320 |
scale = [(change.width() - loc.x())/rect.width(), (change.height() - loc.y())/rect.height()]
|
|
1321 |
#scale the item |
|
1317 |
scale = [(change.width() - loc.x()) / rect.width(), (change.height() - loc.y()) / rect.height()]
|
|
1318 |
# scale the item
|
|
1322 | 1319 |
if scale[0] > 0 and scale[1] > 0: |
1323 | 1320 |
self.setPos(loc) |
1324 |
#self.setScale(scale[0] if scale[0] < scale[1] else scale[1]) |
|
1321 |
# self.setScale(scale[0] if scale[0] < scale[1] else scale[1])
|
|
1325 | 1322 |
trans = QTransform() |
1326 |
trans.scale(scale[0] if scale[0] < scale[1] else scale[1],scale[0] if scale[0] < scale[1] else scale[1]) |
|
1323 |
trans.scale(scale[0] if scale[0] < scale[1] else scale[1], scale[0] if scale[0] < scale[1] else scale[1])
|
|
1327 | 1324 |
self.setTransform(trans) |
1328 | 1325 |
self.prepareGeometryChange() |
1329 | 1326 |
self.update() |
1330 | 1327 |
|
1331 | 1328 |
self.transfer.on_size_changed.emit(self) |
1332 | 1329 |
|
1333 |
def moveto(self, to, timeLine = 5000, rotation = 0):
|
|
1330 |
def moveto(self, to, timeLine=5000, rotation=0):
|
|
1334 | 1331 |
"""Move the item from one position to one other.""" |
1335 | 1332 |
|
1336 | 1333 |
anim = QPropertyAnimation(self, b'pos') |
1337 | 1334 |
rect = self.sceneBoundingRect() |
1338 | 1335 |
anim.setStartValue(QPointF(0, 0)) |
1339 |
anim.setEndValue(QPointF(100,10)) |
|
1336 |
anim.setEndValue(QPointF(100, 10))
|
|
1340 | 1337 |
anim.setDuration(10000) |
1341 | 1338 |
anim.start() |
1342 | 1339 |
|
... | ... | |
1350 | 1347 |
|
1351 | 1348 |
if node.hasChildNodes(): |
1352 | 1349 |
recursiveChangeAttributes(node.firstChild(), attName, attValue) |
1353 |
|
|
1350 |
|
|
1354 | 1351 |
node = node.nextSibling() |
1355 | 1352 |
|
1356 | 1353 |
|
... | ... | |
1366 | 1363 |
on_size_changed = pyqtSignal(QGraphicsItem) |
1367 | 1364 |
onRemoved = pyqtSignal(QGraphicsItem) |
1368 | 1365 |
|
1369 |
def __init__(self, parent = None):
|
|
1366 |
def __init__(self, parent=None):
|
|
1370 | 1367 |
QObject.__init__(self, parent) |
1371 | 1368 |
|
1372 | 1369 |
|
내보내기 Unified diff