개정판 6ee64d77
issue #000
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
141 | 141 |
@date 18.04.27 |
142 | 142 |
@history humkyung 2018.07.08 change method name to onNoteClicked |
143 | 143 |
''' |
144 |
@pyqtSlot(str, list)
|
|
144 |
@pyqtSlot(str, dict)
|
|
145 | 145 |
def onNoteClicked(self, noteNoStr, noteContentsList): |
146 | 146 |
self.noteChanged(noteNoStr, noteContentsList) |
147 | 147 |
|
... | ... | |
171 | 171 |
@date 18.04.27 |
172 | 172 |
''' |
173 | 173 |
def noteChanged(self, noteNoStr, noteContentsList): |
174 |
self.initTitleCell(QEngineeringNoteItem()) |
|
175 | 174 |
self.initNoteCell(noteNoStr, noteContentsList) |
176 | 175 |
|
177 | 176 |
''' |
... | ... | |
409 | 408 |
@date 18.04.27 |
410 | 409 |
''' |
411 | 410 |
def initNoteCell(self, noteNoStr, noteContentsList): |
412 |
row = self.rowCount()
|
|
413 |
self.setRowCount(row + len(noteContentsList)) |
|
411 |
self.setRowCount(0)
|
|
412 |
|
|
414 | 413 |
for key in noteContentsList: |
414 |
row = self.rowCount() |
|
415 |
self.setRowCount(row + len(noteContentsList[key])) |
|
416 |
item = QTableWidgetItem(key) |
|
417 |
self.setItem(row, 0, item) |
|
418 |
|
|
415 | 419 |
for index in range(len(noteContentsList[key])): |
416 |
item = QTableWidgetItem(key) |
|
417 |
item.setFlags(Qt.ItemIsEnabled) |
|
418 |
self.setItem(row, 0, item) |
|
419 | 420 |
self.setItem(row, 1, QTableWidgetItem(noteContentsList[key][index])) |
421 |
row = row + 1 |
|
422 |
|
|
423 |
for index in range(self.rowCount()): |
|
424 |
item = self.item(index, 0) |
|
425 |
if item is not None: |
|
426 |
item.setFlags(Qt.ItemIsEnabled) |
|
427 |
item.setBackground(QColor(220, 220, 220)) |
|
420 | 428 |
|
421 | 429 |
''' |
422 | 430 |
@brief Initialize Line No Contents Cell |
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
30 | 30 |
|
31 | 31 |
#Add Signal |
32 | 32 |
singleClicked = pyqtSignal(SymbolSvgItem) |
33 |
noteNoSingleClicked = pyqtSignal(str, list)
|
|
33 |
noteNoSingleClicked = pyqtSignal(str, dict)
|
|
34 | 34 |
lineNoSingleClicked = pyqtSignal(QEngineeringLineNoTextItem) |
35 | 35 |
drawingClicked = pyqtSignal(Drawing) |
36 | 36 |
|
... | ... | |
182 | 182 |
self.root.setData(0, self.TREE_DATA_ROLE, appDocData.activeDrawing) |
183 | 183 |
child = self.root.addChild(QTreeWidgetItem(['LINE NO'])) |
184 | 184 |
self.LineNoTreeItem = self.root.child(self.root.childCount() - 1) |
185 |
child = self.root.addChild(QTreeWidgetItem(['EQUIPMENTS'])) |
|
186 |
child = self.root.addChild(QTreeWidgetItem(['SYMBOLS'])) |
|
187 |
child = self.root.addChild(QTreeWidgetItem(['NOTES'])) |
|
188 |
child = self.root.addChild(QTreeWidgetItem(['UNKNOWN'])) |
|
185 |
self.root.addChild(QTreeWidgetItem(['EQUIPMENTS'])) |
|
186 |
self.EqpTreeItem = self.root.child(self.root.childCount() - 1) |
|
187 |
self.root.addChild(QTreeWidgetItem(['SYMBOLS'])) |
|
188 |
self.SymbolsTreeItem = self.root.child(self.root.childCount() - 1) |
|
189 |
self.root.addChild(QTreeWidgetItem(['NOTES'])) |
|
190 |
self.NotesTreeItem = self.root.child(self.root.childCount() - 1) |
|
191 |
self.root.addChild(QTreeWidgetItem(['UNKNOWN'])) |
|
189 | 192 |
self.UnknownTreeItem = self.root.child(self.root.childCount() - 1) |
190 | 193 |
|
191 | 194 |
for idx in range(self.root.childCount()): |
... | ... | |
235 | 238 |
if (not hasattr(child, 'treeItem')) or (child.treeItem is None): |
236 | 239 |
if issubclass(type(child), SymbolSvgItem): |
237 | 240 |
if AppDocData.instance().isEquipmentType(child.type): |
238 |
symbolsRootItem = self.findItems('EQUIPMENTS', Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
239 |
symbolsRootItem = symbolsRootItem[0] |
|
240 |
item = QTreeWidgetItem(symbolsRootItem, [child.name]) |
|
241 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
241 | 242 |
item.setData(0, self.TREE_DATA_ROLE, child) |
242 | 243 |
elif child.type == 'Nozzles': |
243 |
eqpRootTreeItem = self.findItems('EQUIPMENTS', Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
244 |
for i in range(eqpRootTreeItem[0].childCount()): |
|
244 |
for i in range(self.EqpTreeItem.childCount()): |
|
245 | 245 |
eqpTreeItem = eqpRootTreeItem[0].child(i) |
246 | 246 |
eqpSymbol = eqpTreeItem.data(0, self.TREE_DATA_ROLE) |
247 | 247 |
if child.owner is eqpSymbol: |
... | ... | |
251 | 251 |
break |
252 | 252 |
|
253 | 253 |
if item is None: |
254 |
symbolsRootItem = self.findItems('SYMBOLS', Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
255 |
symbolsRootItem = symbolsRootItem[0] |
|
256 |
item = QTreeWidgetItem(symbolsRootItem, [child.name]) |
|
254 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
257 | 255 |
else: |
258 |
symbolsRootItem = self.findItems('SYMBOLS', Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
259 |
symbolsRootItem = symbolsRootItem[0] |
|
260 |
item = QTreeWidgetItem(symbolsRootItem, [child.name]) |
|
256 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
261 | 257 |
|
262 | 258 |
if item is not None: |
263 | 259 |
iconPath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), child.type , child.name + ".svg") |
... | ... | |
268 | 264 |
item.setForeground(0, brush) |
269 | 265 |
item.setFont(0, item.font(0)) |
270 | 266 |
child.treeItem = item |
271 |
symbolsRootItem.addChild(item)
|
|
272 |
symbolsRootItem.sortChildren(0, Qt.AscendingOrder) # sort childrens
|
|
267 |
self.SymbolsTreeItem.addChild(item)
|
|
268 |
self.SymbolsTreeItem.sortChildren(0, Qt.AscendingOrder) # sort childrens
|
|
273 | 269 |
elif type(child) is QEngineeringLineNoTextItem: |
274 | 270 |
item = QTreeWidgetItem([child.text()]) |
275 | 271 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
... | ... | |
355 | 351 |
or (type(item) is QEngineeringUnknownItem)) and (not hasattr(item, 'treeItem') or item.treeItem is None)] # Sublist includes SymbolSvgItem |
356 | 352 |
first = [item for item in changedSceneItems if item.owner is None] |
357 | 353 |
second = [item for item in changedSceneItems if item.owner is not None] |
358 |
self.initResultTreeWidget(first + second) |
|
354 |
if first + second: self.initResultTreeWidget(first + second)
|
|
359 | 355 |
finally: |
360 |
if hasattr(self, 'LineNoTreeItem'): |
|
361 |
self.LineNoTreeItem.setText(0, 'LINE NO({})'.format(self.LineNoTreeItem.childCount())) |
|
356 |
self.update_item_count() |
|
362 | 357 |
|
363 | 358 |
''' |
364 | 359 |
@brief Initialize TreeWidget |
... | ... | |
373 | 368 |
def initResultTreeWidget(self, items): |
374 | 369 |
for item in items: |
375 | 370 |
if (type(item) is QEngineeringNoteItem): |
376 |
notesRootItem = self.findItems('NOTES', Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
377 |
notesRootItem = notesRootItem[0] |
|
378 |
|
|
379 |
self.addTreeItem(notesRootItem, item) |
|
371 |
self.addTreeItem(self.NotesTreeItem, item) |
|
380 | 372 |
else: |
381 | 373 |
self.addTreeItem(self.root, item) |
382 | 374 |
|
383 |
notesRootItem = self.findItems('NOTES', Qt.MatchExactly|Qt.MatchRecursive, 0)
|
|
384 |
if notesRootItem is not None and len(notesRootItem) > 0:
|
|
385 |
notesRootItem[0].sortChildren(0, Qt.AscendingOrder) |
|
375 |
if self.NotesTreeItem is not None:
|
|
376 |
self.NotesTreeItem.sortChildren(0, Qt.AscendingOrder)
|
|
377 |
|
|
386 | 378 |
self.expandAll() |
387 | 379 |
|
388 | 380 |
''' |
... | ... | |
574 | 566 |
''' |
575 | 567 |
@pyqtSlot(QGraphicsItem) |
576 | 568 |
def itemRemoved(self, item): |
577 |
foundItem = self.findItemByData(item) |
|
578 |
if foundItem is not None: |
|
579 |
foundItem.parent().removeChild(foundItem) |
|
569 |
try: |
|
570 |
foundItem = self.findItemByData(item) |
|
571 |
if foundItem is not None: |
|
572 |
foundItem.parent().removeChild(foundItem) |
|
573 |
finally: |
|
574 |
self.update_item_count() |
|
575 |
|
|
576 |
def update_item_count(self): |
|
577 |
""" |
|
578 |
update items count |
|
579 |
""" |
|
580 |
if hasattr(self, 'LineNoTreeItem'): |
|
581 |
self.LineNoTreeItem.setText(0, 'LINE NO({})'.format(self.LineNoTreeItem.childCount())) |
|
582 |
if hasattr(self, 'EqpTreeItem'): |
|
583 |
self.EqpTreeItem.setText(0, 'EQUIPMENTS({})'.format(self.EqpTreeItem.childCount())) |
|
584 |
if hasattr(self, 'SymbolsTreeItem'): |
|
585 |
self.SymbolsTreeItem.setText(0, 'SYMBOLS({})'.format(self.SymbolsTreeItem.childCount())) |
|
586 |
if hasattr(self, 'NotesTreeItem'): |
|
587 |
self.NotesTreeItem.setText(0, 'NOTES({})'.format(self.NotesTreeItem.childCount())) |
|
588 |
if hasattr(self, 'UnknownTreeItem'): |
|
589 |
self.UnknownTreeItem.setText(0, 'UNKNOWN({})'.format(self.UnknownTreeItem.childCount())) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
179 | 179 |
self.actionZoom.triggered.connect(self.onAreaZoom) |
180 | 180 |
self.actionFitWindow.triggered.connect(self.fitWindow) |
181 | 181 |
self.actionpdf_to_image.triggered.connect(self.onConvertPDFToImage) |
182 |
self.graphicsView.scene.changed.connect(lambda: self.resultTreeWidget.sceneChanged(self.graphicsView.scene.items())) |
|
182 |
#self.graphicsView.scene.changed.connect(lambda: self.resultTreeWidget.sceneChanged(self.graphicsView.scene.items()))
|
|
183 | 183 |
self.graphicsView.scene.changed.connect(self.onSceneChanged) |
184 | 184 |
self.graphicsView.scene.selectionChanged.connect(self.onSelectionChanged) |
185 | 185 |
self.actionInitialize.triggered.connect(self.onInitializeScene) |
... | ... | |
371 | 371 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
372 | 372 |
self.labelTextStatus.setText("<font color='blue'>텍스트 : {}</font>".format(len(items))) |
373 | 373 |
|
374 |
self.resultTreeWidget.sceneChanged(self.graphicsView.scene.items()) |
|
375 |
|
|
374 | 376 |
def dbUpdate(self): |
375 | 377 |
''' |
376 | 378 |
@brief db update when save or recognition |
DTI_PID/DTI_PID/OcrResultDialog.py | ||
---|---|---|
141 | 141 |
docData = AppDocData.instance() |
142 | 142 |
whiteCharList = docData.getConfigs('Text Recognition', 'White Character List') |
143 | 143 |
if len(whiteCharList) is 0: |
144 |
self.textInfoList = TOCR.getTextInfo(img, (round(self.boundingBox.x()), round(self.boundingBox.y())), 0, language='eng')
|
|
144 |
self.textInfoList = TOCR.getTextInfo(img, (round(self.boundingBox.x()), round(self.boundingBox.y())), 0, language=docData.OCRData)
|
|
145 | 145 |
else: |
146 |
self.textInfoList = TOCR.getTextInfo(img, (round(self.boundingBox.x()), round(self.boundingBox.y())), 0, language='eng', conf = whiteCharList[0].value)
|
|
146 |
self.textInfoList = TOCR.getTextInfo(img, (round(self.boundingBox.x()), round(self.boundingBox.y())), 0, language=docData.OCRData, conf = whiteCharList[0].value)
|
|
147 | 147 |
|
148 | 148 |
if self.textInfoList is not None and len(self.textInfoList) > 0: |
149 | 149 |
self.ui.detectResultTextEdit.setText(self.getPlainText(self.textInfoList)) |
... | ... | |
152 | 152 |
else: |
153 | 153 |
self.ui.detectResultTextEdit.setText("Not Found") |
154 | 154 |
except Exception as ex: |
155 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
155 |
from App import App |
|
156 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
157 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
156 | 158 |
|
157 | 159 |
def getPlainText(self, textInfoList): |
158 | 160 |
text = '' |
DTI_PID/DTI_PID/TextDetector.py | ||
---|---|---|
67 | 67 |
for contour in contours: |
68 | 68 |
# remove too big one or horizontal/vertical line |
69 | 69 |
[x, y, w, h] = cv2.boundingRect(contour) |
70 |
if (w > maxTextSize and h > maxTextSize) or (w <= minSize and h > maxTextSize) or\ |
|
71 |
(w > maxTextSize and h <= minSize) or (w <= minSize and h <= minSize): continue |
|
72 |
|
|
73 | 70 |
area = cv2.contourArea(contour, True) |
71 |
|
|
72 |
if area >= 0: |
|
73 |
if (w > maxTextSize and h > maxTextSize) or (w <= minSize and h > maxTextSize) or\ |
|
74 |
(w > maxTextSize and h <= minSize) or (w <= minSize and h <= minSize): continue |
|
75 |
|
|
74 | 76 |
if area >= 0: |
75 | 77 |
cv2.drawContours(contourImg, [contour], -1, (0,0,0), -1) |
76 | 78 |
cv2.drawContours(contourImg, [contour], -1, (255,255,255), 1) |
내보내기 Unified diff