개정판 d35a6081
issue #478: text data list on going
Change-Id: I60ec5163eb1fe2f51f7f4c1a5813a78ffc02ee2c
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
39 | 39 |
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
40 | 40 |
from EngineeringTextItem import QEngineeringTextItem |
41 | 41 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
42 |
from EngineeringTextItem import QEngineeringTextItem |
|
43 | 42 |
from EngineeringNoteItem import QEngineeringNoteItem |
44 | 43 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
45 | 44 |
from EngineeringUnknownItem import QEngineeringUnknownItem |
... | ... | |
55 | 54 |
from UserInputAttribute import UserInputAttribute |
56 | 55 |
from TextItemFactory import TextItemFactory |
57 | 56 |
from TrainingImageListDialog import QTrainingImageListDialog |
57 |
from TextDataListDialog import QTextDataListDialog |
|
58 | 58 | |
59 | 59 |
class MainWindow(QMainWindow, MainWindow_UI.Ui_MainWindow, SingletonInstane): |
60 | 60 |
""" |
... | ... | |
176 | 176 |
self.pushButtonClearLog.clicked.connect(self.onClearLog) |
177 | 177 |
self.actionHMB_DATA.triggered.connect(self.onHMBData) |
178 | 178 |
self.actionItem_Data_List.triggered.connect(self.showItemDataList) |
179 |
self.actionText_Data_List.triggered.connect(self.showTextDataList) |
|
179 | 180 |
self.actionCodeTable.triggered.connect(self.onShowCodeTable) |
180 | 181 |
self.actionImage_Drawing.triggered.connect(self.onViewImageDrawing) |
181 | 182 |
self.actionValidate.triggered.connect(self.onValidation) |
... | ... | |
948 | 949 |
self.dlgLineDataList = QItemDataExportDialog(self) |
949 | 950 |
self.dlgLineDataList.exec_() |
950 | 951 | |
952 |
def showTextDataList(self): |
|
953 |
''' |
|
954 |
@brief show all text item in scene |
|
955 |
@author euisung |
|
956 |
@date 2019.04.18 |
|
957 |
''' |
|
958 |
try: |
|
959 |
if not self.graphicsView.hasImage(): |
|
960 |
self.showImageSelectionMessageBox() |
|
961 |
return |
|
962 | ||
963 |
dialog = QTextDataListDialog(self) |
|
964 |
dialog.exec_() |
|
965 |
except Exception as ex: |
|
966 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
967 |
self.addMessage.emit(MessageType.Error, message) |
|
968 | ||
951 | 969 |
''' |
952 | 970 |
@brief Show Image Selection Guide MessageBox |
953 | 971 |
@author Jeongwoo |
DTI_PID/DTI_PID/MainWindow_UI.py | ||
---|---|---|
418 | 418 |
self.actionViewInconsistency.setCheckable(True) |
419 | 419 |
self.actionViewInconsistency.setChecked(True) |
420 | 420 |
self.actionViewInconsistency.setObjectName("actionViewInconsistency") |
421 |
self.actionText_Data_List = QtWidgets.QAction(MainWindow) |
|
422 |
self.actionText_Data_List.setObjectName("actionText_Data_List") |
|
421 | 423 |
self.menu.addAction(self.actionOpen) |
422 | 424 |
self.menu.addAction(self.actionArea) |
423 | 425 |
self.menu.addAction(self.actionConfiguration) |
... | ... | |
428 | 430 |
self.menu.addAction(self.actionClose) |
429 | 431 |
self.menu_2.addAction(self.actionHMB_DATA) |
430 | 432 |
self.menu_2.addAction(self.actionItem_Data_List) |
433 |
self.menu_2.addAction(self.actionText_Data_List) |
|
431 | 434 |
self.menu_2.addSeparator() |
432 | 435 |
self.menu_2.addAction(self.actionCodeTable) |
433 | 436 |
self.menu_2.addAction(self.actionOCR_Training) |
... | ... | |
541 | 544 |
self.actioncoffee.setText(_translate("MainWindow", "coffee")) |
542 | 545 |
self.actionEnglish.setText(_translate("MainWindow", "English")) |
543 | 546 |
self.actionViewInconsistency.setText(_translate("MainWindow", "Inconsistency")) |
547 |
self.actionText_Data_List.setText(_translate("MainWindow", "Text Data List")) |
|
544 | 548 | |
545 | 549 |
import MainWindow_rc |
546 | 550 |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
268 | 268 |
item.transfer.onRemoved.connect(scene.parent().parent().parent().itemRemoved) |
269 | 269 | |
270 | 270 |
self.transfer.onRemoved.emit(self) |
271 |
return item |
|
271 | 272 |
else: |
272 | 273 |
message = 'error occured({}) in {}:{}'.format('텍스트 생성에 실패했습니다.', sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
273 | 274 |
self.addMessage.emit(MessageType.Normal, message) |
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
37 | 37 |
QDialog.__init__(self, parent) |
38 | 38 | |
39 | 39 |
try: |
40 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
|
40 | 41 |
self.image = image |
41 | 42 |
self.selectedSymbol = selectedSymbol |
42 | 43 |
self.project = project |
DTI_PID/DTI_PID/TextDataListDialog.py | ||
---|---|---|
1 |
import sys |
|
2 |
from PyQt5.QtCore import * |
|
3 |
from PyQt5.QtGui import * |
|
4 |
from PyQt5.QtWidgets import * |
|
5 |
from AppDocData import AppDocData, Source |
|
6 |
import TextDataList_UI |
|
7 |
from EngineeringTextItem import QEngineeringTextItem |
|
8 | ||
9 |
class forDoubleClicked(): |
|
10 |
def buttons(self): |
|
11 |
return Qt.LeftButton |
|
12 | ||
13 |
class QTextDataListDialog(QDialog): |
|
14 |
""" |
|
15 |
This is text image data list dialog class |
|
16 |
""" |
|
17 | ||
18 |
def __init__(self, parent): |
|
19 |
QDialog.__init__(self, parent) |
|
20 |
self.parent = parent |
|
21 |
self.graphicsView = parent.graphicsView |
|
22 |
self.textItems = [textItem for textItem in self.graphicsView.items() if type(textItem) is QEngineeringTextItem] |
|
23 | ||
24 |
self.ui = TextDataList_UI.Ui_TextDataList() |
|
25 |
self.ui.setupUi(self) |
|
26 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
|
27 | ||
28 |
# for List |
|
29 |
self.ui.tableWidget.setSelectionMode(QAbstractItemView.SingleSelection) |
|
30 |
self.ui.tableWidget.setColumnCount(3) |
|
31 | ||
32 |
## column header 명 설정 |
|
33 |
self.ui.tableWidget.setHorizontalHeaderLabels([self.tr('No.'), self.tr('Text Image'), self.tr('Recognized Text')]) |
|
34 |
self.ui.tableWidget.horizontalHeaderItem(1).setSizeHint(QSize(30, 30)) |
|
35 |
self.ui.tableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents) |
|
36 |
self.ui.tableWidget.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) |
|
37 |
self.ui.tableWidget.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch) |
|
38 |
self.ui.tableWidget.resizeColumnsToContents() |
|
39 |
self.ui.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) |
|
40 | ||
41 |
# connect signals and slots |
|
42 |
self.ui.tableWidget.cellDoubleClicked.connect(self.listCellDoubleClicked) |
|
43 |
self.ui.pushButtonEdit.clicked.connect(self.pushButtonEditClicked) |
|
44 | ||
45 |
self.ui.tableWidget.verticalHeader().setDefaultSectionSize(60) |
|
46 |
self.ui.tableWidget.setRowCount(len(self.textItems)) |
|
47 |
row = 0 |
|
48 |
allowed_error = 0.001 |
|
49 |
for textItem in self.textItems: |
|
50 |
self.ui.tableWidget.setItem(row, 0, QTableWidgetItem(str(row + 1))) |
|
51 | ||
52 |
imageWidget = QTableWidgetItem() |
|
53 |
textImage = AppDocData.instance().getCurrentPidSource().getQImageOnRect(QRect(textItem.loc[0] - 3, textItem.loc[1] - 3, textItem.size[0] + 6, textItem.size[1] + 6)) |
|
54 |
if abs(textItem.angle - 0) <= allowed_error: |
|
55 |
pass |
|
56 |
elif abs(textItem.angle - 1.57) <= allowed_error: |
|
57 |
transform = QTransform() |
|
58 |
transform.rotate(-90) |
|
59 |
textImage.transformed(transform) |
|
60 |
textImage = textImage.scaled(350, 60, Qt.KeepAspectRatio, Qt.SmoothTransformation) |
|
61 |
imageWidget.setData(Qt.DecorationRole, textImage) |
|
62 |
self.ui.tableWidget.setItem(row, 1, imageWidget) |
|
63 | ||
64 |
textWidget = QTableWidgetItem(textItem.text()) |
|
65 |
textWidget.tag = textItem |
|
66 |
self.ui.tableWidget.setItem(row, 2, textWidget) |
|
67 | ||
68 |
row = row + 1 |
|
69 | ||
70 |
def listCellDoubleClicked(self, row, col): |
|
71 |
self.pushButtonEditClicked() |
|
72 | ||
73 |
def pushButtonEditClicked(self): |
|
74 |
try: |
|
75 |
row = self.ui.tableWidget.selectedIndexes()[0].row() |
|
76 |
col = 2 |
|
77 |
textItem = self.ui.tableWidget.item(row, col).tag |
|
78 |
except: |
|
79 |
return |
|
80 | ||
81 |
try: |
|
82 |
newTextItem = textItem.mouseDoubleClickEvent(forDoubleClicked()) |
|
83 |
if newTextItem is not None: |
|
84 |
self.ui.tableWidget.item(row, col).tag = newTextItem |
|
85 |
self.ui.tableWidget.item(row, col).setText(newTextItem.text()) |
|
86 | ||
87 |
except Exception as ex: |
|
88 |
from App import App |
|
89 |
from AppDocData import MessageType |
|
90 | ||
91 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
92 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
DTI_PID/DTI_PID/TextDataList_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 | ||
3 |
# Form implementation generated from reading ui file './UI/TextDataList.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.11.3 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 | ||
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
10 | ||
11 |
class Ui_TextDataList(object): |
|
12 |
def setupUi(self, TextDataList): |
|
13 |
TextDataList.setObjectName("TextDataList") |
|
14 |
TextDataList.resize(1160, 775) |
|
15 |
self.gridLayout = QtWidgets.QGridLayout(TextDataList) |
|
16 |
self.gridLayout.setObjectName("gridLayout") |
|
17 |
self.verticalLayout = QtWidgets.QVBoxLayout() |
|
18 |
self.verticalLayout.setObjectName("verticalLayout") |
|
19 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
20 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
21 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
22 |
self.horizontalLayout.addItem(spacerItem) |
|
23 |
self.pushButtonEdit = QtWidgets.QPushButton(TextDataList) |
|
24 |
self.pushButtonEdit.setObjectName("pushButtonEdit") |
|
25 |
self.horizontalLayout.addWidget(self.pushButtonEdit) |
|
26 |
self.verticalLayout.addLayout(self.horizontalLayout) |
|
27 |
self.tableWidget = QtWidgets.QTableWidget(TextDataList) |
|
28 |
self.tableWidget.setObjectName("tableWidget") |
|
29 |
self.tableWidget.setColumnCount(3) |
|
30 |
self.tableWidget.setRowCount(0) |
|
31 |
item = QtWidgets.QTableWidgetItem() |
|
32 |
self.tableWidget.setHorizontalHeaderItem(0, item) |
|
33 |
item = QtWidgets.QTableWidgetItem() |
|
34 |
self.tableWidget.setHorizontalHeaderItem(1, item) |
|
35 |
item = QtWidgets.QTableWidgetItem() |
|
36 |
self.tableWidget.setHorizontalHeaderItem(2, item) |
|
37 |
self.verticalLayout.addWidget(self.tableWidget) |
|
38 |
self.buttonBox = QtWidgets.QDialogButtonBox(TextDataList) |
|
39 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
40 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
41 |
self.buttonBox.setObjectName("buttonBox") |
|
42 |
self.verticalLayout.addWidget(self.buttonBox) |
|
43 |
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) |
|
44 | ||
45 |
self.retranslateUi(TextDataList) |
|
46 |
self.buttonBox.accepted.connect(TextDataList.accept) |
|
47 |
self.buttonBox.rejected.connect(TextDataList.reject) |
|
48 |
QtCore.QMetaObject.connectSlotsByName(TextDataList) |
|
49 | ||
50 |
def retranslateUi(self, TextDataList): |
|
51 |
_translate = QtCore.QCoreApplication.translate |
|
52 |
TextDataList.setWindowTitle(_translate("TextDataList", "Text Data List")) |
|
53 |
self.pushButtonEdit.setText(_translate("TextDataList", "Edit")) |
|
54 |
item = self.tableWidget.horizontalHeaderItem(0) |
|
55 |
item.setText(_translate("TextDataList", "No.")) |
|
56 |
item = self.tableWidget.horizontalHeaderItem(1) |
|
57 |
item.setText(_translate("TextDataList", "Text Image")) |
|
58 |
item = self.tableWidget.horizontalHeaderItem(2) |
|
59 |
item.setText(_translate("TextDataList", "Recognized Text")) |
|
60 | ||
61 | ||
62 |
if __name__ == "__main__": |
|
63 |
import sys |
|
64 |
app = QtWidgets.QApplication(sys.argv) |
|
65 |
TextDataList = QtWidgets.QDialog() |
|
66 |
ui = Ui_TextDataList() |
|
67 |
ui.setupUi(TextDataList) |
|
68 |
TextDataList.show() |
|
69 |
sys.exit(app.exec_()) |
|
70 |
DTI_PID/DTI_PID/UI/MainWindow.ui | ||
---|---|---|
69 | 69 |
</property> |
70 | 70 |
<addaction name="actionHMB_DATA"/> |
71 | 71 |
<addaction name="actionItem_Data_List"/> |
72 |
<addaction name="actionText_Data_List"/> |
|
72 | 73 |
<addaction name="separator"/> |
73 | 74 |
<addaction name="actionCodeTable"/> |
74 | 75 |
<addaction name="actionOCR_Training"/> |
... | ... | |
898 | 899 |
<string>Inconsistency</string> |
899 | 900 |
</property> |
900 | 901 |
</action> |
902 |
<action name="actionText_Data_List"> |
|
903 |
<property name="text"> |
|
904 |
<string>Text Data List</string> |
|
905 |
</property> |
|
906 |
</action> |
|
901 | 907 |
</widget> |
902 | 908 |
<resources> |
903 | 909 |
<include location="../res/MainWindow.qrc"/> |
DTI_PID/DTI_PID/UI/TextDataList.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>TextDataList</class> |
|
4 |
<widget class="QDialog" name="TextDataList"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>1160</width> |
|
10 |
<height>775</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>Text Data List</string> |
|
15 |
</property> |
|
16 |
<layout class="QGridLayout" name="gridLayout"> |
|
17 |
<item row="0" column="0"> |
|
18 |
<layout class="QVBoxLayout" name="verticalLayout"> |
|
19 |
<item> |
|
20 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
21 |
<item> |
|
22 |
<spacer name="horizontalSpacer"> |
|
23 |
<property name="orientation"> |
|
24 |
<enum>Qt::Horizontal</enum> |
|
25 |
</property> |
|
26 |
<property name="sizeHint" stdset="0"> |
|
27 |
<size> |
|
28 |
<width>40</width> |
|
29 |
<height>20</height> |
|
30 |
</size> |
|
31 |
</property> |
|
32 |
</spacer> |
|
33 |
</item> |
|
34 |
<item> |
|
35 |
<widget class="QPushButton" name="pushButtonEdit"> |
|
36 |
<property name="text"> |
|
37 |
<string>Edit</string> |
|
38 |
</property> |
|
39 |
</widget> |
|
40 |
</item> |
|
41 |
</layout> |
|
42 |
</item> |
|
43 |
<item> |
|
44 |
<widget class="QTableWidget" name="tableWidget"> |
|
45 |
<column> |
|
46 |
<property name="text"> |
|
47 |
<string>No.</string> |
|
48 |
</property> |
|
49 |
</column> |
|
50 |
<column> |
|
51 |
<property name="text"> |
|
52 |
<string>Text Image</string> |
|
53 |
</property> |
|
54 |
</column> |
|
55 |
<column> |
|
56 |
<property name="text"> |
|
57 |
<string>Recognized Text</string> |
|
58 |
</property> |
|
59 |
</column> |
|
60 |
</widget> |
|
61 |
</item> |
|
62 |
<item> |
|
63 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
64 |
<property name="orientation"> |
|
65 |
<enum>Qt::Horizontal</enum> |
|
66 |
</property> |
|
67 |
<property name="standardButtons"> |
|
68 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
69 |
</property> |
|
70 |
</widget> |
|
71 |
</item> |
|
72 |
</layout> |
|
73 |
</item> |
|
74 |
</layout> |
|
75 |
</widget> |
|
76 |
<resources/> |
|
77 |
<connections> |
|
78 |
<connection> |
|
79 |
<sender>buttonBox</sender> |
|
80 |
<signal>accepted()</signal> |
|
81 |
<receiver>TextDataList</receiver> |
|
82 |
<slot>accept()</slot> |
|
83 |
<hints> |
|
84 |
<hint type="sourcelabel"> |
|
85 |
<x>248</x> |
|
86 |
<y>254</y> |
|
87 |
</hint> |
|
88 |
<hint type="destinationlabel"> |
|
89 |
<x>157</x> |
|
90 |
<y>274</y> |
|
91 |
</hint> |
|
92 |
</hints> |
|
93 |
</connection> |
|
94 |
<connection> |
|
95 |
<sender>buttonBox</sender> |
|
96 |
<signal>rejected()</signal> |
|
97 |
<receiver>TextDataList</receiver> |
|
98 |
<slot>reject()</slot> |
|
99 |
<hints> |
|
100 |
<hint type="sourcelabel"> |
|
101 |
<x>316</x> |
|
102 |
<y>260</y> |
|
103 |
</hint> |
|
104 |
<hint type="destinationlabel"> |
|
105 |
<x>286</x> |
|
106 |
<y>274</y> |
|
107 |
</hint> |
|
108 |
</hints> |
|
109 |
</connection> |
|
110 |
</connections> |
|
111 |
</ui> |
내보내기 Unified diff