개정판 471b049e
AreaOcrCommand의 MouseReleaseEvent 발생 시 ImageViewer 내 이미지 보유 여부 검사 / MainWindow에서 이미지 선택 다이얼로그 출력 시 ImageViewer 에 DefaultCommand 적용
DTI_PID/DTI_PID/Commands/AreaOcrCommand.py | ||
---|---|---|
33 | 33 |
humkyung 2018.04.20 set item's location with selection box |
34 | 34 |
Jeongwoo 2018.04.25 Add if state with QEngineeringNoteItem |
35 | 35 |
Jeongwoo 2018.04.26 Change method to create TextItem with TextItemFactory |
36 |
Jeongwoo 2018.05.02 Add Checking imageViewer has image if-statement, when mouseReleaseEvent happen |
|
36 | 37 |
''' |
37 | 38 |
def execute(self, param): |
38 | 39 |
print(param[0]) |
... | ... | |
51 | 52 |
self.imageViewer.scene.setSelectionArea(QPainterPath()) # Clear current selection area. |
52 | 53 |
if selectionBBox.isValid(): |
53 | 54 |
print("Area Selected") |
54 |
image = self.imageViewer.image().copy(selectionBBox.toAlignedRect()) |
|
55 |
dialog = QOcrResultDialog.QOcrResultDialog(self.imageViewer, image, selectionBBox) |
|
56 |
(isAccept, textInfoList) = dialog.showDialog() |
|
55 |
if self.imageViewer.hasImage(): |
|
56 |
image = self.imageViewer.image().copy(selectionBBox.toAlignedRect()) |
|
57 |
dialog = QOcrResultDialog.QOcrResultDialog(self.imageViewer, image, selectionBBox) |
|
58 |
(isAccept, textInfoList) = dialog.showDialog() |
|
57 | 59 |
|
58 |
if isAccept: |
|
59 |
if textInfoList is not None and len(textInfoList) > 0: |
|
60 |
docData = AppDocData.instance() |
|
61 |
configs = docData.getConfigs('Line No', 'Delimiter') |
|
62 |
delimiter = configs[0].value if 1 == len(configs) else '-' |
|
63 |
lineNoconfigs = docData.getConfigs('Line No', 'Configuration') |
|
64 |
for textInfo in textInfoList: |
|
65 |
print("Accepted") |
|
66 |
x = textInfo.getX() |
|
67 |
y = textInfo.getY() |
|
68 |
angle = textInfo.getAngle() |
|
69 |
text = textInfo.getText() |
|
70 |
width = textInfo.getW() |
|
71 |
height = textInfo.getH() |
|
72 |
item = TextItemFactory.instance().createTextItem(text, delimiter, lineNoconfigs) |
|
73 |
item.loc = (x, y)#(int(selectionBBox.x() + x), int(selectionBBox.y() + y)) |
|
74 |
item.size = (width, height) |
|
75 |
item.angle = angle |
|
76 |
item.setPlainText(text) |
|
77 |
item.setDefaultTextColor(Qt.blue) |
|
78 |
item.addTextItemToScene(self.imageViewer.scene) |
|
79 |
else: |
|
80 |
QMessageBox.about(self.imageViewer, "알림", "텍스트 검출 실패") |
|
60 |
if isAccept: |
|
61 |
if textInfoList is not None and len(textInfoList) > 0: |
|
62 |
docData = AppDocData.instance() |
|
63 |
configs = docData.getConfigs('Line No', 'Delimiter') |
|
64 |
delimiter = configs[0].value if 1 == len(configs) else '-' |
|
65 |
lineNoconfigs = docData.getConfigs('Line No', 'Configuration') |
|
66 |
for textInfo in textInfoList: |
|
67 |
print("Accepted") |
|
68 |
x = textInfo.getX() |
|
69 |
y = textInfo.getY() |
|
70 |
angle = textInfo.getAngle() |
|
71 |
text = textInfo.getText() |
|
72 |
width = textInfo.getW() |
|
73 |
height = textInfo.getH() |
|
74 |
item = TextItemFactory.instance().createTextItem(text, delimiter, lineNoconfigs) |
|
75 |
item.loc = (x, y)#(int(selectionBBox.x() + x), int(selectionBBox.y() + y)) |
|
76 |
item.size = (width, height) |
|
77 |
item.angle = angle |
|
78 |
item.setPlainText(text) |
|
79 |
item.setDefaultTextColor(Qt.blue) |
|
80 |
item.addTextItemToScene(self.imageViewer.scene) |
|
81 |
else: |
|
82 |
QMessageBox.about(self.imageViewer, "알림", "텍스트 검출 실패") |
|
83 |
else: |
|
84 |
QMessageBox.about(self.imageViewer, "알림", "부적절한 이미지입니다.\n이미지를 확인해주세요.") |
|
81 | 85 |
finally: |
82 | 86 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
83 | 87 |
pass |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
180 | 180 |
@date 2018.??.?? |
181 | 181 |
@history 18.04.23 Jeongwoo Add AppDocData.instance().setCurrentPidSource |
182 | 182 |
18.04.23 Jeongwoo Add Store Set Current Pid Image on AppDocData |
183 |
18.05.02 Jeongwoo Add useDefaultCommand() |
|
183 | 184 |
''' |
184 | 185 |
def openImageDrawing(self, MainWindow): |
185 | 186 |
import random |
... | ... | |
187 | 188 |
try: |
188 | 189 |
self.graphicsView.clearImage() |
189 | 190 |
self.graphicsView.scene.clear() |
191 |
self.graphicsView.useDefaultCommand() |
|
190 | 192 |
self.path = self.graphicsView.loadImageFromFile() |
191 | 193 |
if os.path.isfile(self.path): |
192 | 194 |
baseName = os.path.basename(self.path) |
내보내기 Unified diff