개정판 b069732d
issue #506: 텍스트 아이템, 텏스트 데이타 리스트 다이얼로그에 엔터키 적용
Change-Id: I82fb15b715d403254f1eaa7a0a3307c50a156384
DTI_PID/DTI_PID/Configuration_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file './UI/Configuration.ui'
|
|
3 |
# Form implementation generated from reading ui file '.\UI\Configuration.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
5 |
# Created by: PyQt5 UI code generator 5.14.1
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
9 |
|
|
9 | 10 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 | 11 |
|
12 |
|
|
11 | 13 |
class Ui_ConfigurationDialog(object): |
12 | 14 |
def setupUi(self, ConfigurationDialog): |
13 | 15 |
ConfigurationDialog.setObjectName("ConfigurationDialog") |
... | ... | |
148 | 150 |
self.comboBoxOCRData.setMaximumSize(QtCore.QSize(200, 16777215)) |
149 | 151 |
self.comboBoxOCRData.setObjectName("comboBoxOCRData") |
150 | 152 |
self.gridLayout_25.addWidget(self.comboBoxOCRData, 0, 1, 1, 1) |
151 |
self.lineEditWhiteCharList = QtWidgets.QLineEdit(self.groupBoxText) |
|
152 |
self.lineEditWhiteCharList.setObjectName("lineEditWhiteCharList") |
|
153 |
self.gridLayout_25.addWidget(self.lineEditWhiteCharList, 1, 1, 1, 1) |
|
154 | 153 |
self.lineEditSingleText = QtWidgets.QLineEdit(self.groupBoxText) |
155 | 154 |
self.lineEditSingleText.setObjectName("lineEditSingleText") |
156 | 155 |
self.gridLayout_25.addWidget(self.lineEditSingleText, 2, 1, 1, 1) |
156 |
self.lineEditWhiteCharList = QtWidgets.QLineEdit(self.groupBoxText) |
|
157 |
self.lineEditWhiteCharList.setObjectName("lineEditWhiteCharList") |
|
158 |
self.gridLayout_25.addWidget(self.lineEditWhiteCharList, 1, 1, 1, 3) |
|
157 | 159 |
self.gridLayout_14.addLayout(self.gridLayout_25, 0, 0, 1, 1) |
158 | 160 |
self.gridLayout_2.addWidget(self.groupBoxText, 0, 1, 1, 1) |
159 | 161 |
self.groupBoxAttribute = QtWidgets.QGroupBox(self.Recognition) |
... | ... | |
737 | 739 |
self.radioButtonSaveUnknownYes.setText(_translate("ConfigurationDialog", "Yes")) |
738 | 740 |
self.radioButtonSaveUnknownNo.setText(_translate("ConfigurationDialog", "No")) |
739 | 741 |
self.pushButtonClearAccessInfo.setText(_translate("ConfigurationDialog", "Clear")) |
740 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabETC), _translate("ConfigurationDialog", "etc")) |
|
741 |
|
|
742 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabETC), _translate("ConfigurationDialog", "ETC")) |
|
742 | 743 |
import MainWindow_rc |
743 |
|
|
744 |
if __name__ == "__main__": |
|
745 |
import sys |
|
746 |
app = QtWidgets.QApplication(sys.argv) |
|
747 |
ConfigurationDialog = QtWidgets.QDialog() |
|
748 |
ui = Ui_ConfigurationDialog() |
|
749 |
ui.setupUi(ConfigurationDialog) |
|
750 |
ConfigurationDialog.show() |
|
751 |
sys.exit(app.exec_()) |
|
752 |
|
DTI_PID/DTI_PID/OcrResultDialog.py | ||
---|---|---|
45 | 45 |
self.graphicsView = QtImageViewer.QtImageViewer(App.mainWnd()) |
46 | 46 |
self.graphicsView.useDefaultCommand() # USE DEFAULT COMMAND |
47 | 47 |
self.graphicsView.setImage(self.image) |
48 |
self.graphicsView.zoomImage(False, event=None) |
|
48 | 49 |
self.ui.horizontalLayoutGraphicsView.addWidget(self.graphicsView) |
49 | 50 |
|
50 | 51 |
self.ui.counterClockPushButton_2.clicked.connect(lambda: self.rotateImage(True)) |
... | ... | |
71 | 72 |
self.ui.detectResultTextEdit.setPlainText(text) |
72 | 73 |
self.ui.checkBoxSeperate.setChecked(False) |
73 | 74 |
|
74 |
|
|
75 | 75 |
self.isAccepted = False |
76 | 76 |
|
77 | 77 |
''' |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
167 | 167 |
''' |
168 | 168 |
|
169 | 169 |
def keyPressEvent(self, event): |
170 |
if event.key() == Qt.Key_R: |
|
170 |
if Qt.Key_Return == event.key(): |
|
171 |
self.edit_text() |
|
172 |
elif event.key() == Qt.Key_R: |
|
171 | 173 |
# degree 0 |
172 | 174 |
if 0 == self.angle: |
173 | 175 |
self.angle = 1.57 |
174 | 176 |
# degree 90 |
175 |
elif (1.57 == self.angle):
|
|
177 |
elif 1.57 == self.angle:
|
|
176 | 178 |
self.angle = 3.14 |
177 | 179 |
# degree 180 |
178 | 180 |
elif 3.14 == self.angle: |
... | ... | |
186 | 188 |
self.size = [height, width] |
187 | 189 |
|
188 | 190 |
self.rotate() |
189 |
elif event.key() == Qt.Key_Up: ### translate up/down/left/right symbol
|
|
191 |
elif event.key() == Qt.Key_Up: # translate up/down/left/right symbol |
|
190 | 192 |
self.loc[1] = self.loc[1] - 1 |
191 | 193 |
self.rotate() |
192 | 194 |
elif event.key() == Qt.Key_Down: |
... | ... | |
270 | 272 |
rect.moveTo(self.loc[0], self.loc[1]) |
271 | 273 |
return rect |
272 | 274 |
|
273 |
''' |
|
274 |
@brief Double click event, Show QOcrResultDialog |
|
275 |
@author Jeongwoo |
|
276 |
@date 18.04.23 |
|
277 |
@history 18.06.20 Jeongwoo Resize QRect added 1 |
|
278 |
''' |
|
279 |
|
|
280 |
def mouseDoubleClickEvent(self, event, isDataList=False): |
|
275 |
def edit_text(self): |
|
276 |
"""edit text by using ocr dialog""" |
|
281 | 277 |
from TextItemFactory import TextItemFactory |
282 |
if event.buttons() == Qt.LeftButton: |
|
283 |
from OcrResultDialog import QOcrResultDialog |
|
284 |
# dialog = QOcrResultDialog(None, AppDocData.instance().getCurrentPidSource().getQImageOnRect( |
|
285 |
# QRect(self.loc[0] - 3, self.loc[1] - 3, self.size[0] + 6, self.size[1] + 6)), |
|
286 |
# QRect(self.loc[0], self.loc[1], self.size[0], self.size[1]), True, self.text()) |
|
278 |
from OcrResultDialog import QOcrResultDialog |
|
279 |
|
|
280 |
item = None |
|
281 |
try: |
|
287 | 282 |
dialog = QOcrResultDialog(None, self.scene().parent().image().copy(self.loc[0] - 3, self.loc[1] - 3, |
288 | 283 |
self.size[0] + 6, self.size[1] + 6), |
289 | 284 |
QRect(self.loc[0], self.loc[1], self.size[0], self.size[1]), True, self.text()) |
... | ... | |
309 | 304 |
item.transfer.onRemoved.connect(scene.parent().parent().parent().itemRemoved) |
310 | 305 |
|
311 | 306 |
self.transfer.onRemoved.emit(self) |
312 |
if isDataList: |
|
313 |
return item |
|
314 |
else: |
|
315 |
message = 'error occurred({}) in {}:{}'.format('텍스트 생성에 실패했습니다.', |
|
316 |
sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
317 |
sys.exc_info()[-1].tb_lineno) |
|
318 |
self.addMessage.emit(MessageType.Normal, message) |
|
307 |
except Exception as ex: |
|
308 |
message = 'error occurred({}) in {}:{}'.format(self.tr('Fail to create text'), |
|
309 |
sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
310 |
sys.exc_info()[-1].tb_lineno) |
|
311 |
self.addMessage.emit(MessageType.Normal, message) |
|
312 |
|
|
313 |
return item |
|
314 |
|
|
315 |
''' |
|
316 |
@brief Double click event, Show QOcrResultDialog |
|
317 |
@author Jeongwoo |
|
318 |
@date 18.04.23 |
|
319 |
@history 18.06.20 Jeongwoo Resize QRect added 1 |
|
320 |
''' |
|
321 |
|
|
322 |
def mouseDoubleClickEvent(self, event): |
|
323 |
if event.buttons() == Qt.LeftButton: |
|
324 |
self.edit_text() |
|
319 | 325 |
|
320 | 326 |
''' |
321 | 327 |
@brief rotate text |
DTI_PID/DTI_PID/TextDataListDialog.py | ||
---|---|---|
13 | 13 |
|
14 | 14 |
|
15 | 15 |
class QTextDataListDialog(QDialog): |
16 |
""" |
|
17 |
This is text image data list dialog class |
|
18 |
""" |
|
16 |
""" This is text image data list dialog class """ |
|
19 | 17 |
|
20 | 18 |
def __init__(self, parent): |
21 | 19 |
QDialog.__init__(self, parent) |
... | ... | |
90 | 88 |
|
91 | 89 |
try: |
92 | 90 |
if self.integrityCheck(textItem): |
93 |
newTextItem = textItem.mouseDoubleClickEvent(forDoubleClicked(), True)
|
|
91 |
newTextItem = textItem.edit_text()
|
|
94 | 92 |
if newTextItem is not None: |
95 | 93 |
self.ui.tableWidget.item(row, col).tag = newTextItem |
96 | 94 |
self.ui.tableWidget.item(row, col).setText(newTextItem.text()) |
... | ... | |
144 | 142 |
|
145 | 143 |
def keyPressEvent(self, event): |
146 | 144 |
try: |
147 |
if event.key() == Qt.Key_Delete: |
|
145 |
if Qt.Key_Return == event.key(): |
|
146 |
self.pushButtonEditClicked() |
|
147 |
elif event.key() == Qt.Key_Delete: |
|
148 | 148 |
self.pushButtonDeleteClicked() |
149 | 149 |
|
150 | 150 |
try: |
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
300 | 300 |
</property> |
301 | 301 |
</widget> |
302 | 302 |
</item> |
303 |
<item row="1" column="1"> |
|
304 |
<widget class="QLineEdit" name="lineEditWhiteCharList"/> |
|
305 |
</item> |
|
306 | 303 |
<item row="2" column="1"> |
307 | 304 |
<widget class="QLineEdit" name="lineEditSingleText"/> |
308 | 305 |
</item> |
306 |
<item row="1" column="1" colspan="3"> |
|
307 |
<widget class="QLineEdit" name="lineEditWhiteCharList"/> |
|
308 |
</item> |
|
309 | 309 |
</layout> |
310 | 310 |
</item> |
311 | 311 |
</layout> |
... | ... | |
1165 | 1165 |
</widget> |
1166 | 1166 |
<widget class="QWidget" name="tabETC"> |
1167 | 1167 |
<attribute name="title"> |
1168 |
<string>etc</string>
|
|
1168 |
<string>ETC</string>
|
|
1169 | 1169 |
</attribute> |
1170 | 1170 |
<layout class="QGridLayout" name="gridLayout_22"> |
1171 | 1171 |
<item row="3" column="0"> |
... | ... | |
1415 | 1415 |
</connection> |
1416 | 1416 |
</connections> |
1417 | 1417 |
<buttongroups> |
1418 |
<buttongroup name="buttonGroup_2"/> |
|
1419 | 1418 |
<buttongroup name="buttonGroup_3"/> |
1420 |
<buttongroup name="buttonGroup"/> |
|
1421 | 1419 |
<buttongroup name="buttonGroup_4"/> |
1420 |
<buttongroup name="buttonGroup"/> |
|
1422 | 1421 |
<buttongroup name="buttonGroup_5"/> |
1422 |
<buttongroup name="buttonGroup_2"/> |
|
1423 | 1423 |
</buttongroups> |
1424 | 1424 |
</ui> |
내보내기 Unified diff