개정판 15e26d1c
Implementing issue #489: Trim Line 처리
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
8 | 8 |
import shapely |
9 | 9 |
from AppDocData import AppDocData |
10 | 10 | |
11 |
#sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Shapes')) |
|
12 |
#import QEngineeringLineItem |
|
13 | ||
14 | 11 |
class LineNoTracer: |
15 | 12 |
''' |
16 | 13 |
@history 2018.04.26 Jeongwoo Variable name changed (texts → lineNos) |
... | ... | |
26 | 23 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
27 | 24 | |
28 | 25 |
''' |
26 |
@brief find primary lines connected to given line no |
|
27 |
@author humkyung |
|
28 |
''' |
|
29 |
def findPrimaryLines(self, lineno): |
|
30 |
from QEngineeringLineItem import QEngineeringLineItem |
|
31 |
from QEngineeringRunItem import QEngineeringRunItem |
|
32 | ||
33 |
connectedItems = [] |
|
34 |
if 1 == len(lineno.conns): |
|
35 |
connectedItems = self.findConnectedObjects(lineno.conns[0], toler=10) |
|
36 |
for item in connectedItems: item.owner = lineno # set item's owner |
|
37 |
|
|
38 |
pipeRun = QEngineeringRunItem() |
|
39 |
pipeRun.items = connectedItems |
|
40 |
lineno.runs.append(pipeRun) |
|
41 | ||
42 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
43 |
|
|
44 |
maxLength = None |
|
45 |
maxLengthItem = None |
|
46 |
for line in connectedLines: |
|
47 |
length = line.length() |
|
48 |
if maxLength is None or maxLength < length: |
|
49 |
maxLength = length |
|
50 |
maxLengthItem = line |
|
51 | ||
52 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None |
|
53 | ||
54 |
return connectedItems |
|
55 | ||
56 |
''' |
|
57 |
@brief find secondary lines |
|
58 |
@author humkyung |
|
59 |
''' |
|
60 |
def findSecondaryLines(self, lines): |
|
61 |
from QEngineeringLineItem import QEngineeringLineItem |
|
62 |
from QEngineeringRunItem import QEngineeringRunItem |
|
63 | ||
64 |
foundCount = 1 |
|
65 |
while foundCount: |
|
66 |
foundCount = 0 |
|
67 |
notMatches = [] |
|
68 |
for line in lines: |
|
69 |
if line.owner is not None: continue |
|
70 | ||
71 |
matches = [x for x in self._lines if x.owner is not None and x.isConnectable(line)] |
|
72 |
if matches: |
|
73 |
foundCount += 1 |
|
74 |
connectedItems = self.findConnectedObjects(line, toler=10) |
|
75 |
for item in connectedItems: item.owner = matches[0].owner # set item's owner |
|
76 | ||
77 |
pipeRun = QEngineeringRunItem() |
|
78 |
pipeRun.items = connectedItems |
|
79 |
if pipeRun.items is not None and len(pipeRun.items) > 0: |
|
80 |
matches[0].owner.runs.append(pipeRun) |
|
81 | ||
82 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
83 |
|
|
84 |
maxLength = None |
|
85 |
maxLengthItem = None |
|
86 |
for line in connectedLines: |
|
87 |
length = line.length() |
|
88 |
if maxLength is None or maxLength < length: |
|
89 |
maxLength = length |
|
90 |
maxLengthItem = line |
|
91 | ||
92 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None |
|
93 |
else: |
|
94 |
notMatches.append(line) |
|
95 |
lines = notMatches |
|
96 | ||
97 |
''' |
|
29 | 98 |
@brief trace line no |
30 | 99 |
@author humkyung |
31 | 100 |
@date 2018.04.16 |
... | ... | |
41 | 110 |
from QEngineeringLineItem import QEngineeringLineItem |
42 | 111 |
from SymbolSvgItem import SymbolSvgItem |
43 | 112 |
from QEngineeringRunItem import QEngineeringRunItem |
113 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
44 | 114 | |
45 | 115 |
try: |
46 | 116 |
docData = AppDocData.instance() |
... | ... | |
70 | 140 |
|
71 | 141 |
# find primary lines |
72 | 142 |
for lineno in docData.lineNos: |
73 |
if 1 == len(lineno.conns): |
|
74 |
connectedItems = self.findConnectedObjects(lineno.conns[0], toler=10) |
|
75 |
for item in connectedItems: item.owner = lineno # set item's owner |
|
76 |
|
|
77 |
pipeRun = QEngineeringRunItem() |
|
78 |
pipeRun.items = connectedItems |
|
79 |
lineno.runs.append(pipeRun) |
|
80 | ||
81 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
82 |
|
|
83 |
maxLength = None |
|
84 |
maxLengthItem = None |
|
85 |
for line in connectedLines: |
|
86 |
length = line.length() |
|
87 |
if maxLength is None or maxLength < length: |
|
88 |
maxLength = length |
|
89 |
maxLengthItem = line |
|
90 | ||
91 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None |
|
143 |
self.findPrimaryLines(lineno) |
|
92 | 144 | |
93 | 145 |
# find secondary lines |
94 | 146 |
lines = self._lines |
95 |
foundCount = 1 |
|
96 |
while foundCount: |
|
97 |
foundCount = 0 |
|
98 |
notMatches = [] |
|
99 |
for line in lines: |
|
100 |
if line.owner is not None: continue |
|
101 | ||
102 |
matches = [x for x in self._lines if x.owner is not None and x.isConnectable(line)] |
|
103 |
if matches: |
|
104 |
foundCount += 1 |
|
105 |
connectedItems = self.findConnectedObjects(line, toler=10) |
|
106 |
for item in connectedItems: item.owner = matches[0].owner # set item's owner |
|
107 | ||
108 |
pipeRun = QEngineeringRunItem() |
|
109 |
pipeRun.items = connectedItems |
|
110 |
if pipeRun.items is not None and len(pipeRun.items) > 0: |
|
111 |
matches[0].owner.runs.append(pipeRun) |
|
112 | ||
113 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
114 |
|
|
115 |
maxLength = None |
|
116 |
maxLengthItem = None |
|
117 |
for line in connectedLines: |
|
118 |
length = line.length() |
|
119 |
if maxLength is None or maxLength < length: |
|
120 |
maxLength = length |
|
121 |
maxLengthItem = line |
|
122 | ||
123 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None |
|
124 |
else: |
|
125 |
notMatches.append(line) |
|
126 |
lines = notMatches |
|
147 |
self.findSecondaryLines(lines) |
|
148 | ||
149 |
### make trim lines |
|
150 |
orphanLines = [line for line in self._lines if line.owner is None] |
|
151 |
if orphanLines: |
|
152 |
orphanLines = sorted(orphanLines, key=lambda param:param.length(), reverse=True) |
|
153 |
while len(orphanLines) > 0: |
|
154 |
trimLineNo = QEngineeringTrimLineNoTextItem() |
|
155 |
trimLineNo.conns.append(orphanLines[0]) |
|
156 |
orphanLines[0].owner = trimLineNo |
|
157 |
connectedItems = self.findPrimaryLines(trimLineNo) |
|
158 |
for item in connectedItems: |
|
159 |
if item in orphanLines: orphanLines.remove(item) |
|
160 | ||
161 |
self.findSecondaryLines(orphanLines) |
|
162 |
for item in orphanLines[:]: |
|
163 |
if item.owner is not None: orphanLines.remove(item) |
|
164 | ||
165 |
docData.lineNos.append(trimLineNo) |
|
166 | ||
127 | 167 |
except Exception as ex: |
128 | 168 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
129 | 169 |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
502 | 502 |
lineNos.append(item) |
503 | 503 |
elif type(item) is QEngineeringLineItem: |
504 | 504 |
lines.append(item) |
505 | ||
505 |
|
|
506 | 506 |
# trace line no |
507 | 507 |
tracer = LineNoTracer(symbols, lines, lineNos) |
508 | 508 |
tracer.execute() |
... | ... | |
510 | 510 | |
511 | 511 |
# construct line no item |
512 | 512 |
docData = AppDocData.instance() |
513 |
for text in docData.lineNos:
|
|
514 |
item = self.resultTreeWidget.addTreeItem(self.resultTreeWidget.root, text)
|
|
515 |
connectedItems = text.getConnectedItems()
|
|
513 |
for lineno in docData.lineNos:
|
|
514 |
item = self.resultTreeWidget.addTreeItem(self.resultTreeWidget.root, lineno)
|
|
515 |
connectedItems = lineno.getConnectedItems()
|
|
516 | 516 |
for connectedItem in connectedItems: |
517 | 517 |
if issubclass(type(connectedItem), SymbolSvgItem): self.resultTreeWidget.addTreeItem(item, connectedItem) |
518 | 518 |
# up to here |
... | ... | |
532 | 532 |
self.drawDetectedSymbolItem(symbolList) |
533 | 533 |
self.drawDetectedTextItem(textInfoList) |
534 | 534 |
self.drawDetectedNoteItem(noteTextInfoList) |
535 |
|
|
535 | ||
536 |
''' |
|
537 |
history humkyung 2018.06.09 check length of original and connection point is 2 while parsing |
|
538 |
''' |
|
536 | 539 |
def drawDetectedSymbolItem(self, symbolList): |
537 | 540 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
538 | 541 |
from SymbolSvgItem import SymbolSvgItem |
... | ... | |
547 | 550 |
name = symbol.getName() |
548 | 551 |
angle = round(math.radians(symbol.getRotatedAngle()), 2) |
549 | 552 |
type = symbol.getType() |
550 |
origin = [pt[0] + float(symbol.getOriginalPoint().split(',')[0]), pt[1] + float(symbol.getOriginalPoint().split(',')[1])] |
|
553 |
origin = [0,0] |
|
554 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
|
555 |
tokens = symbol.getOriginalPoint().split(',') |
|
556 |
origin = [pt[0] + float(tokens[0]), pt[1] + float(tokens[1])] |
|
551 | 557 |
connPts = [] |
552 | 558 |
if symbol.getConnectionPoint() is not None: |
553 |
connPts = [(pt[0] + float(x.split(',')[0]), pt[1] + float(x.split(',')[1])) for x in symbol.getConnectionPoint().split('/')] |
|
559 |
connPts = [(pt[0] + float(x.split(',')[0]), pt[1] + float(x.split(',')[1])) for x in symbol.getConnectionPoint().split('/') if 2 == len(x.split(','))]
|
|
554 | 560 |
parentSymbol = symbol.getBaseSymbol() |
555 | 561 |
childSymbol = symbol.getAdditionalSymbol() |
556 | 562 |
|
DTI_PID/DTI_PID/ProjectDialog.py | ||
---|---|---|
21 | 21 |
self.ui.setupUi(self) |
22 | 22 |
self.initComboBox() |
23 | 23 |
self.ui.toolButton.clicked.connect(self.addProjectClick) |
24 |
self.setWindowTitle('프로젝트') |
|
24 | 25 | |
25 | 26 |
def initComboBox(self): |
26 | 27 |
from AppDocData import AppDocData |
... | ... | |
37 | 38 |
return self.selectedProject |
38 | 39 | |
39 | 40 |
def accept(self): |
40 |
print("accepted") |
|
41 | 41 |
self.selectedProject = self.ui.comboBox.currentData() |
42 | 42 |
AppDocData.instance().updateProjectUpdatedDate(self.selectedProject.getId()) |
43 | 43 |
QDialog.accept(self) |
44 | 44 | |
45 | 45 |
def reject(self): |
46 |
print("rejected") |
|
47 | 46 |
self.selectedProject = None |
48 | 47 |
QDialog.reject(self) |
49 | 48 |
DTI_PID/DTI_PID/QRecognitionDialog.py | ||
---|---|---|
173 | 173 |
''' |
174 | 174 |
@history 2018.05.29 Jeongwoo Call parent's method |
175 | 175 |
2018.05.30 Jeongwoo Change method name |
176 |
humkyung 2018.06.09 set progressbar value to maximum |
|
176 | 177 |
''' |
177 | 178 |
def drawDetectedItems(self, symbolList, textInfoList, noteTextInfoList): |
179 |
self.ui.progressBar.setValue(self.ui.progressBar.maximum()) |
|
178 | 180 |
self.parent.drawDetectedItems(symbolList, textInfoList, noteTextInfoList) |
DTI_PID/DTI_PID/QResultTreeWidget.py | ||
---|---|---|
12 | 12 |
from QEngineeringTextItem import QEngineeringTextItem |
13 | 13 |
from QEngineeringNoteItem import QEngineeringNoteItem |
14 | 14 |
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem |
15 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
15 | 16 |
from AppDocData import AppDocData |
16 | 17 |
import os |
17 | 18 |
import re |
... | ... | |
46 | 47 |
itemPosition = self.mapTo(self, position) |
47 | 48 |
item = self.itemAt(itemPosition) |
48 | 49 |
data = item.data(0, self.TREE_DATA_ROLE) |
49 |
if len(indexes) > 0 and data is not None and type(data) is QEngineeringLineNoTextItem:
|
|
50 |
if len(indexes) > 0 and data is not None and issubclass(type(data), QEngineeringLineNoTextItem):
|
|
50 | 51 |
index = indexes[0] |
51 | 52 |
menu = QMenu() |
52 | 53 |
pickColorAction = QAction(self.tr("색상 설정")) |
... | ... | |
93 | 94 |
@date 18.04.11 |
94 | 95 |
@history 2018.04.26 Jeongwoo Add Child [SYMBOLS, NOTES] into root item |
95 | 96 |
2018.05.09 Jeongwoo Change method to add default tree items |
97 |
humkyung 2018.06.10 add tree item for Line No |
|
96 | 98 |
''' |
97 | 99 |
def setCurrentPID(self, baseName): |
98 | 100 |
self.clear() |
99 | 101 |
self.root = QTreeWidgetItem(self, [os.path.splitext(baseName)[0]]) |
102 |
self.root.addChild(QTreeWidgetItem(['LINE NO'])) |
|
103 |
self.LineNoTreeItem = self.root.child(0) |
|
100 | 104 |
self.root.addChild(QTreeWidgetItem(['EQUIPMENTS'])) |
101 | 105 |
self.root.addChild(QTreeWidgetItem(['SYMBOLS'])) |
102 | 106 |
self.root.addChild(QTreeWidgetItem(['NOTES'])) |
... | ... | |
168 | 172 |
item.setForeground(0, brush) |
169 | 173 |
item.setFont(0, item.font(0)) |
170 | 174 |
child.treeItem = item |
171 |
self.root.insertChild(0, item) |
|
175 |
self.LineNoTreeItem.addChild(item) |
|
176 |
elif type(child) is QEngineeringTrimLineNoTextItem: |
|
177 |
item = QTreeWidgetItem(['Trim Line']) |
|
178 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
|
179 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
180 |
item.setCheckState(0, Qt.Unchecked) |
|
181 |
brush = QBrush() |
|
182 |
brush.setColor(QColor(child.getColor())) |
|
183 |
item.setForeground(0, brush) |
|
184 |
item.setFont(0, item.font(0)) |
|
185 |
child.treeItem = item |
|
186 |
self.LineNoTreeItem.addChild(item) |
|
172 | 187 |
elif (type(child) is QEngineeringNoteItem): |
173 | 188 |
item = QTreeWidgetItem([child.text()]) |
174 | 189 |
item.setData(0, self.TREE_DATA_ROLE, child) |
... | ... | |
182 | 197 |
data = item.data(0, self.TREE_DATA_ROLE) |
183 | 198 |
if data is not None and (data == child) and (parent is not item.parent()): |
184 | 199 |
parentData = parent.data(0, self.TREE_DATA_ROLE) |
185 |
if type(parentData) is QEngineeringLineNoTextItem:
|
|
200 |
if issubclass(type(parentData), QEngineeringLineNoTextItem):
|
|
186 | 201 |
for index in range(len(parentData.runs)): |
187 | 202 |
runGroup = parentData.runs[index] |
188 | 203 |
if data in runGroup.items: |
DTI_PID/DTI_PID/QSymbolEditorDialog.py | ||
---|---|---|
9 | 9 |
import sys |
10 | 10 |
import symbol, SymbolBase |
11 | 11 |
import potrace |
12 |
import numpy as np |
|
13 |
import cv2 |
|
12 | 14 | |
13 | 15 |
import UI_SymbolEditor |
14 | 16 |
from AppDocData import AppDocData |
15 | 17 | |
16 | ||
17 | 18 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands') |
18 | 19 |
import CropCommand, HandCommand, ZoomCommand, PenCommand, EraserCommand, AreaEraserCommand, OriginalPointCommand, ConnectionPointCommand, AreaZoomCommand, FitImageCommand, RemoveTextCommand |
19 | 20 | |
... | ... | |
28 | 29 |
''' |
29 | 30 |
def __init__(self, parent, image, project, selectedSymbol = None): |
30 | 31 |
QDialog.__init__(self, parent) |
31 |
self.image = image |
|
32 |
self.selectedSymbol = selectedSymbol |
|
33 |
self.project = project |
|
34 |
self.ui = UI_SymbolEditor.Ui_Dialog() |
|
35 |
self.ui.setupUi(self) |
|
36 |
self.setupImageViewer() |
|
37 |
self.setupTools() |
|
38 |
self.initForms() |
|
39 |
self.initContents() |
|
40 |
self.isAccepted = False |
|
41 |
self.offsetX = 0 |
|
42 |
self.offsetY = 0 |
|
43 |
self.newSym = None |
|
32 | ||
33 |
try: |
|
34 |
''' |
|
35 |
#cvImage = self.convertQImageToMat(image) |
|
36 |
cvImage = cv2.cvtColor(self.convertQImageToMat(image), cv2.COLOR_BGR2GRAY) |
|
37 |
binaryImg,mask = cv2.threshold(cvImage, 127, 255, cv2.THRESH_BINARY)# + cv2.THRESH_OTSU) |
|
38 | ||
39 |
contourImg = np.ones(cvImage.shape, np.uint8) |
|
40 | ||
41 |
_image, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) |
|
42 |
maxArea = None |
|
43 |
maxAreaContour = None |
|
44 |
for contour in contours: |
|
45 |
area = cv2.contourArea(contour, True) |
|
46 |
#cv2.drawContours(contourImg, [contour], -1, 0, -1) |
|
47 |
cv2.drawContours(contourImg, [contour], -1, 255, -1) |
|
48 |
#maxArea = area |
|
49 |
#maxAreaContour = contour |
|
50 |
|
|
51 |
for contour in contours: |
|
52 |
area = cv2.contourArea(contour, True) |
|
53 |
if area < 0: |
|
54 |
cv2.drawContours(contourImg, [contour], -1, 255, -1) |
|
55 | ||
56 |
cv2.imwrite('d:/temp/temp.png', contourImg) |
|
57 | ||
58 |
self.image = QImage(contourImg, contourImg.shape[1],\ |
|
59 |
contourImg.shape[0], contourImg.shape[1], QImage.Format_Mono) |
|
60 | ||
61 |
#self.image = QImage(contourImg, contourImg.shape[1],\ |
|
62 |
# contourImg.shape[0], contourImg.shape[1] * 3, QImage.Format_RGB888) |
|
63 |
''' |
|
64 | ||
65 |
self.image = image |
|
66 |
self.selectedSymbol = selectedSymbol |
|
67 |
self.project = project |
|
68 |
self.ui = UI_SymbolEditor.Ui_Dialog() |
|
69 |
self.ui.setupUi(self) |
|
70 |
self.setupImageViewer() |
|
71 |
self.setupTools() |
|
72 |
self.initForms() |
|
73 |
self.initContents() |
|
74 |
self.isAccepted = False |
|
75 |
self.offsetX = 0 |
|
76 |
self.offsetY = 0 |
|
77 |
self.newSym = None |
|
78 | ||
79 |
self.setWindowTitle('심볼 편집기') |
|
80 |
except Exception as ex: |
|
81 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
82 | ||
83 |
def convertQImageToMat(self, incomingImage): |
|
84 |
''' Converts a QImage into an opencv MAT format ''' |
|
85 | ||
86 |
try: |
|
87 |
incomingImage = incomingImage.convertToFormat(QImage.Format_RGBA8888) |
|
88 | ||
89 |
width = incomingImage.width() |
|
90 |
height = incomingImage.height() |
|
91 | ||
92 |
ptr = incomingImage.bits() |
|
93 |
ptr.setsize(incomingImage.byteCount()) |
|
94 |
arr = np.array(ptr).reshape(height, width, 4) # Copies the data |
|
95 |
return arr |
|
96 |
except Exception as ex: |
|
97 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
44 | 98 | |
45 | 99 |
''' |
46 | 100 |
@brief Set up QtImageViewer and QImage |
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py | ||
---|---|---|
344 | 344 |
if (self.isVertical() and (dx < 0.001 or math.fabs(dx - 1) < 0.001)) or (self.isHorizontal() and (dx < 0.001 or math.fabs(dx - 1) < 0.001)): continue |
345 | 345 |
cv2.line(img,(x1,y1),(x2,y2),(0,0,255),2) |
346 | 346 | |
347 |
cv2.imshow('img', img) |
|
348 |
cv2.waitKey(0) |
|
349 |
cv2.destroyAllWindows() |
|
347 |
#cv2.imshow('img', img)
|
|
348 |
#cv2.waitKey(0)
|
|
349 |
#cv2.destroyAllWindows()
|
|
350 | 350 |
except Exception as ex: |
351 | 351 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
352 | 352 |
DTI_PID/DTI_PID/Shapes/QEngineeringTrimLineNoTextItem.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import os.path |
|
3 |
import sys |
|
4 |
import copy |
|
5 |
try: |
|
6 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
7 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
|
8 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
|
9 |
except ImportError: |
|
10 |
try: |
|
11 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
12 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont |
|
13 |
except ImportError: |
|
14 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
|
15 | ||
16 |
from QGraphicsPolylineItem import QGraphicsPolylineItem |
|
17 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
18 |
import QOcrResultDialog |
|
19 |
from AppDocData import AppDocData |
|
20 |
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem |
|
21 | ||
22 |
class QEngineeringTrimLineNoTextItem(QEngineeringLineNoTextItem): |
|
23 | ||
24 |
''' |
|
25 |
''' |
|
26 |
def __init__(self, parent=None): |
|
27 |
import uuid |
|
28 |
|
|
29 |
QEngineeringLineNoTextItem.__init__(self, parent) |
|
30 |
self.loc = (0, 0) |
|
31 |
self.size = (1, 1) |
|
32 |
self.angle = 0 |
|
33 |
self.setPlainText('Trim Line') |
|
34 |
self.setVisible(False) |
|
35 | ||
36 |
''' |
|
37 |
@brief generate xml code |
|
38 |
@author humkyung |
|
39 |
@date 2018.06.09 |
|
40 |
''' |
|
41 |
def toXml(self): |
|
42 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
43 |
from QEngineeringLineItem import QEngineeringLineItem |
|
44 |
from SymbolSvgItem import SymbolSvgItem |
|
45 | ||
46 |
try: |
|
47 |
node = Element('TRIM_LINE_NO') |
|
48 |
uidNode = Element('UID') |
|
49 |
uidNode.text = str(self.uid) |
|
50 |
node.append(uidNode) |
|
51 | ||
52 |
for run in self.runs: |
|
53 |
node.append(run.toXml()) |
|
54 |
except Exception as ex: |
|
55 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
56 | ||
57 |
return node |
내보내기 Unified diff