개정판 4493ceff
issue #587: reserved word item has line as onwer
Change-Id: Ib65299822d9302bc0d8c9e110a03261682e8b926
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
426 | 426 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
427 | 427 |
from EngineeringVendorItem import QEngineeringVendorItem |
428 | 428 |
from EngineeringEndBreakItem import QEngineeringEndBreakItem |
429 |
from EngineeringReservedWordTextItem import QEngineeringReservedWordTextItem |
|
429 | 430 |
|
430 | 431 |
try: |
431 | 432 |
symbols = [] |
... | ... | |
481 | 482 |
for valve in valves: |
482 | 483 |
valve.connectAttribute(labels, clear=False) |
483 | 484 |
|
485 |
""" try to find reserved word's owner """ |
|
486 |
texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringReservedWordTextItem] |
|
487 |
for reservedWord in texts: |
|
488 |
reservedWord.findOwner(lines) |
|
489 |
|
|
484 | 490 |
""" update line type """ |
485 | 491 |
if update_line_type == True: |
486 |
lines = [line for line in worker.graphicsView.scene.items() if type(line) is QEngineeringLineItem] |
|
492 |
#lines = [line for line in worker.graphicsView.scene.items() if type(line) is QEngineeringLineItem]
|
|
487 | 493 |
#for line in lines: line.lineType = 'Primary' |
488 | 494 |
for line in lines: line.update_line_type() |
489 | 495 |
|
... | ... | |
524 | 530 |
end_break.owner = line_end |
525 | 531 |
end_breaks.append(end_break) |
526 | 532 |
|
527 |
''' |
|
528 |
for lineNo_from in lineNo_froms + lineNo_tos: |
|
529 |
for connector in lineNo_from.connectors: |
|
530 |
for lineNo_to in lineNo_tos + lineNo_froms: |
|
531 |
if lineNo_from is lineNo_to or lineNo_from.owner is lineNo_to.owner : continue |
|
532 |
if connector.connectedItem is lineNo_to: |
|
533 |
end_break = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
534 |
pt = [connector.center()[0] - float(symbol.getOriginalPoint().split(',')[0]), connector.center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
|
535 |
origin = [0,0] |
|
536 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
|
537 |
tokens = symbol.getOriginalPoint().split(',') |
|
538 |
origin = [pt[0] + float(tokens[0]), pt[1] + float(tokens[1])] |
|
539 |
end_break.buildItem(svgFileName, symbol.getType(), 5.7, pt, [end_break.boundingRect().width(), end_break.boundingRect().height()], origin, [], symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getHasInstrumentLabel()) |
|
540 |
|
|
541 |
end_break.set_property('Connected Item', lineNo_to) |
|
542 |
end_break.setToolTip('owner : ' + str(lineNo_from)) |
|
543 |
end_break.area = 'Drawing' |
|
544 |
end_break.owner = lineNo_from |
|
545 |
end_breaks.append(end_break) |
|
546 |
''' |
|
547 |
|
|
548 | 533 |
if end_breaks: |
549 | 534 |
# check dulplication |
550 | 535 |
dupl = set() |
DTI_PID/DTI_PID/Shapes/EngineeringReservedWordTextItem.py | ||
---|---|---|
15 | 15 |
except ImportError: |
16 | 16 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
17 | 17 |
|
18 |
from AppDocData import AppDocData |
|
18 |
from AppDocData import AppDocData, MessageType
|
|
19 | 19 |
from EngineeringTextItem import QEngineeringTextItem |
20 | 20 |
|
21 | 21 |
class QEngineeringReservedWordTextItem(QEngineeringTextItem): |
... | ... | |
23 | 23 |
|
24 | 24 |
def __init__(self, uid=None, parent=None): |
25 | 25 |
QEngineeringTextItem.__init__(self, uid, parent) |
26 |
self.type = 'Reserved Word' |
|
26 |
self.type = 'Reserved Word' |
|
27 |
|
|
28 |
def findOwner(self, lines): |
|
29 |
import sys |
|
30 |
|
|
31 |
try: |
|
32 |
self.onwer = None |
|
33 |
dist = min(self.sceneBoundingRect().height(), self.sceneBoundingRect().width()) * 2 |
|
34 |
center = self.sceneBoundingRect().center() |
|
35 |
|
|
36 |
maxOverlap = 0 |
|
37 |
minDist = sys.maxsize |
|
38 |
selected = None |
|
39 |
hLines = [] |
|
40 |
vLines = [] |
|
41 |
for line in lines: |
|
42 |
if line.sceneBoundingRect().height() > line.sceneBoundingRect().width(): |
|
43 |
vLines.append(line) |
|
44 |
else: |
|
45 |
hLines.append(line) |
|
46 |
|
|
47 |
if self.sceneBoundingRect().height() > self.sceneBoundingRect().width(): |
|
48 |
lines = vLines |
|
49 |
else: |
|
50 |
lines = hLines |
|
51 |
|
|
52 |
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())) |
|
53 |
#print(axisText) |
|
54 |
for line in lines: |
|
55 |
intercept = line.sceneBoundingRect().center().y() if lines is hLines else line.sceneBoundingRect().center().x() |
|
56 |
length = abs(intercept - center.y()) if lines is hLines else abs(intercept - center.x()) |
|
57 |
if (length < dist): |
|
58 |
overlap = 0 |
|
59 |
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())) |
|
60 |
#print(axisLine) |
|
61 |
for onLine in axisLine: |
|
62 |
for onText in axisText: |
|
63 |
if onLine - onText is 0: |
|
64 |
overlap += 1 |
|
65 |
#print(overlap) |
|
66 |
if overlap == maxOverlap and length < minDist: |
|
67 |
selected = line |
|
68 |
maxOverlap = overlap |
|
69 |
minDist = length |
|
70 |
elif overlap > maxOverlap: |
|
71 |
selected = line |
|
72 |
maxOverlap = overlap |
|
73 |
minDist = length |
|
74 |
|
|
75 |
if selected is not None: |
|
76 |
self.owner = selected |
|
77 |
#print(self.owner) |
|
78 |
|
|
79 |
except Exception as ex: |
|
80 |
from App import App |
|
81 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
82 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
83 |
|
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
451 | 451 |
attributeValue = node.find('ATTRIBUTEVALUE') |
452 | 452 |
name = node.find('NAME').text |
453 | 453 |
textInfo = TextInfo(value, x, y, width, height, angle) |
454 |
|
|
454 | 455 |
if name == 'NOTE': |
455 | 456 |
item = TextItemFactory.instance().createTextItem(textInfo) |
456 | 457 |
if item is not None: |
... | ... | |
487 | 488 |
item.uid = uuid.UUID(node.find('UID').text) |
488 | 489 |
item.setVisible(False) |
489 | 490 |
|
490 |
if node.find('OWNER') is not None: |
|
491 |
item._owner = uuid.UUID(node.find('OWNER').text) |
|
491 |
if node.find('OWNER') is not None and node.find('OWNER').text != 'None':
|
|
492 |
item._owner = uuid.UUID(node.find('OWNER').text, version=4)
|
|
492 | 493 |
|
493 | 494 |
## assign area |
494 | 495 |
if item is not None: |
... | ... | |
529 | 530 |
uidNode.text = str(self.uid) |
530 | 531 |
node.append(uidNode) |
531 | 532 |
|
533 |
# write owner's uid to xml |
|
534 |
ownerNode = Element('OWNER') |
|
535 |
if self.owner is not None: |
|
536 |
ownerNode.text = str(self.owner) |
|
537 |
else: |
|
538 |
ownerNode.text = 'None' |
|
539 |
node.append(ownerNode) |
|
540 |
# up to here |
|
541 |
|
|
532 | 542 |
attributeValueNode = Element('ATTRIBUTEVALUE') |
533 | 543 |
attributeValueNode.text = self.attribute |
534 | 544 |
node.append(attributeValueNode) |
... | ... | |
561 | 571 |
areaNode.text = self.area |
562 | 572 |
node.append(areaNode) |
563 | 573 |
|
564 |
# write owner |
|
565 |
if self.owner is not None: |
|
566 |
ownerNode = Element('OWNER') |
|
567 |
ownerNode.text = str(self.owner) |
|
568 |
node.append(ownerNode) |
|
569 |
# up to here |
|
570 | 574 |
except Exception as ex: |
571 | 575 |
from App import App |
572 | 576 |
from AppDocData import MessageType |
내보내기 Unified diff