개정판 49ba3f48
issue #480: 라인과 심볼, 라인과 라인을 연결한다
Change-Id: I95d6b51c254c6f2220265116a467d4119b14a491
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
91 | 91 |
|
92 | 92 |
configs = docData.getConfigs('Small Line Minimum Length', 'Min Length') |
93 | 93 |
self.ui.smallLineMinLengthSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.smallLineMinLengthSpinBox.setValue(10) |
94 |
configs = docData.getConfigs('Line Detector', 'Length to connect line') |
|
95 |
if configs: self.ui.spinBoxLengthToConnectLine.setValue(int(configs[0].value)) |
|
94 | 96 |
|
95 | 97 |
properties = docData.getLineProperties() |
96 | 98 |
if properties: |
... | ... | |
187 | 189 |
lineTransparentSpinBox.setSingleStep(10) |
188 | 190 |
if matches: |
189 | 191 |
tokens = matches[0].value.split(',') |
190 |
lineTransparentSpinBox.setValue(int(tokens[3]) if len(tokens) == 4 else int(tokens[2]))
|
|
192 |
lineTransparentSpinBox.setValue(int(tokens[3]) if len(tokens) == 4 else 100)
|
|
191 | 193 |
else: |
192 | 194 |
lineTransparentSpinBox.setValue(100) |
193 | 195 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 4, lineTransparentSpinBox) |
... | ... | |
581 | 583 |
configs.append(Config('Sliding Window', 'Width', self.ui.spinBoxWidth.value())) |
582 | 584 |
configs.append(Config('Sliding Window', 'Height', self.ui.spinBoxHeight.value())) |
583 | 585 |
configs.append(Config('Small Line Minimum Length', 'Min Length', self.ui.smallLineMinLengthSpinBox.value())) |
586 |
configs.append(Config('Line Detector', 'Length to connect line', self.ui.spinBoxLengthToConnectLine.value())) |
|
584 | 587 |
configs.append(Config('Note No Tag Rule', 'Note No Expression', self.ui.lineEditNoteNoExpression.text())) |
585 | 588 |
configs.append(Config('Note No Tag Rule', 'Note No Symbol Name', self.ui.lineEditNoteNoSymbolName.text())) |
586 | 589 |
configs.append(Config('Text Recognition', 'White Character List', self.ui.lineEditWhiteCharList.text())) |
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.12
|
|
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
9 | 9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 | 10 |
|
11 |
|
|
12 | 11 |
class Ui_ConfigurationDialog(object): |
13 | 12 |
def setupUi(self, ConfigurationDialog): |
14 | 13 |
ConfigurationDialog.setObjectName("ConfigurationDialog") |
... | ... | |
50 | 49 |
self.groupBox.setObjectName("groupBox") |
51 | 50 |
self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox) |
52 | 51 |
self.gridLayout_5.setObjectName("gridLayout_5") |
53 |
self.horizontalLayout_6 = QtWidgets.QHBoxLayout() |
|
54 |
self.horizontalLayout_6.setObjectName("horizontalLayout_6") |
|
52 |
self.gridLayout_11 = QtWidgets.QGridLayout() |
|
53 |
self.gridLayout_11.setObjectName("gridLayout_11") |
|
54 |
self.smallLineMinLengthSpinBox = QtWidgets.QSpinBox(self.groupBox) |
|
55 |
self.smallLineMinLengthSpinBox.setMinimumSize(QtCore.QSize(100, 0)) |
|
56 |
self.smallLineMinLengthSpinBox.setObjectName("smallLineMinLengthSpinBox") |
|
57 |
self.gridLayout_11.addWidget(self.smallLineMinLengthSpinBox, 2, 1, 1, 1) |
|
55 | 58 |
self.label_4 = QtWidgets.QLabel(self.groupBox) |
56 | 59 |
self.label_4.setObjectName("label_4") |
57 |
self.horizontalLayout_6.addWidget(self.label_4)
|
|
60 |
self.gridLayout_11.addWidget(self.label_4, 0, 0, 1, 1)
|
|
58 | 61 |
self.spinBoxMinArea = QtWidgets.QSpinBox(self.groupBox) |
59 | 62 |
self.spinBoxMinArea.setMinimumSize(QtCore.QSize(100, 0)) |
60 | 63 |
self.spinBoxMinArea.setObjectName("spinBoxMinArea") |
61 |
self.horizontalLayout_6.addWidget(self.spinBoxMinArea) |
|
62 |
self.label_5 = QtWidgets.QLabel(self.groupBox) |
|
63 |
self.label_5.setObjectName("label_5") |
|
64 |
self.horizontalLayout_6.addWidget(self.label_5, 0, QtCore.Qt.AlignHCenter) |
|
65 |
self.spinBoxMaxArea = QtWidgets.QSpinBox(self.groupBox) |
|
66 |
self.spinBoxMaxArea.setMinimumSize(QtCore.QSize(100, 0)) |
|
67 |
self.spinBoxMaxArea.setObjectName("spinBoxMaxArea") |
|
68 |
self.horizontalLayout_6.addWidget(self.spinBoxMaxArea) |
|
69 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
70 |
self.horizontalLayout_6.addItem(spacerItem) |
|
71 |
self.gridLayout_5.addLayout(self.horizontalLayout_6, 2, 0, 1, 1) |
|
72 |
self.horizontalLayout_12 = QtWidgets.QHBoxLayout() |
|
73 |
self.horizontalLayout_12.setObjectName("horizontalLayout_12") |
|
64 |
self.gridLayout_11.addWidget(self.spinBoxMinArea, 0, 1, 1, 1) |
|
74 | 65 |
self.label_16 = QtWidgets.QLabel(self.groupBox) |
75 | 66 |
self.label_16.setObjectName("label_16") |
76 |
self.horizontalLayout_12.addWidget(self.label_16) |
|
77 |
self.smallLineMinLengthSpinBox = QtWidgets.QSpinBox(self.groupBox) |
|
78 |
self.smallLineMinLengthSpinBox.setMinimumSize(QtCore.QSize(100, 0)) |
|
79 |
self.smallLineMinLengthSpinBox.setObjectName("smallLineMinLengthSpinBox") |
|
80 |
self.horizontalLayout_12.addWidget(self.smallLineMinLengthSpinBox) |
|
81 |
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
82 |
self.horizontalLayout_12.addItem(spacerItem1) |
|
83 |
self.gridLayout_5.addLayout(self.horizontalLayout_12, 4, 0, 1, 1) |
|
84 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
85 |
self.horizontalLayout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint) |
|
86 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
67 |
self.gridLayout_11.addWidget(self.label_16, 2, 0, 1, 1) |
|
68 |
self.label_9 = QtWidgets.QLabel(self.groupBox) |
|
69 |
self.label_9.setObjectName("label_9") |
|
70 |
self.gridLayout_11.addWidget(self.label_9, 3, 0, 1, 1) |
|
71 |
self.spinBoxHeight = QtWidgets.QSpinBox(self.groupBox) |
|
72 |
self.spinBoxHeight.setMinimumSize(QtCore.QSize(100, 0)) |
|
73 |
self.spinBoxHeight.setObjectName("spinBoxHeight") |
|
74 |
self.gridLayout_11.addWidget(self.spinBoxHeight, 1, 2, 1, 1) |
|
87 | 75 |
self.label = QtWidgets.QLabel(self.groupBox) |
88 | 76 |
self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) |
89 | 77 |
self.label.setObjectName("label") |
90 |
self.horizontalLayout.addWidget(self.label)
|
|
78 |
self.gridLayout_11.addWidget(self.label, 1, 0, 1, 1)
|
|
91 | 79 |
self.spinBoxWidth = QtWidgets.QSpinBox(self.groupBox) |
92 | 80 |
self.spinBoxWidth.setMinimumSize(QtCore.QSize(100, 0)) |
93 | 81 |
self.spinBoxWidth.setObjectName("spinBoxWidth") |
94 |
self.horizontalLayout.addWidget(self.spinBoxWidth) |
|
95 |
self.spinBoxHeight = QtWidgets.QSpinBox(self.groupBox) |
|
96 |
self.spinBoxHeight.setMinimumSize(QtCore.QSize(100, 0)) |
|
97 |
self.spinBoxHeight.setObjectName("spinBoxHeight") |
|
98 |
self.horizontalLayout.addWidget(self.spinBoxHeight) |
|
99 |
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
100 |
self.horizontalLayout.addItem(spacerItem2) |
|
101 |
self.gridLayout_5.addLayout(self.horizontalLayout, 3, 0, 1, 1) |
|
82 |
self.gridLayout_11.addWidget(self.spinBoxWidth, 1, 1, 1, 1) |
|
83 |
self.spinBoxLengthToConnectLine = QtWidgets.QSpinBox(self.groupBox) |
|
84 |
self.spinBoxLengthToConnectLine.setProperty("value", 20) |
|
85 |
self.spinBoxLengthToConnectLine.setObjectName("spinBoxLengthToConnectLine") |
|
86 |
self.gridLayout_11.addWidget(self.spinBoxLengthToConnectLine, 3, 1, 1, 1) |
|
87 |
self.spinBoxMaxArea = QtWidgets.QSpinBox(self.groupBox) |
|
88 |
self.spinBoxMaxArea.setMinimumSize(QtCore.QSize(100, 0)) |
|
89 |
self.spinBoxMaxArea.setObjectName("spinBoxMaxArea") |
|
90 |
self.gridLayout_11.addWidget(self.spinBoxMaxArea, 0, 3, 1, 1) |
|
91 |
self.label_5 = QtWidgets.QLabel(self.groupBox) |
|
92 |
self.label_5.setAlignment(QtCore.Qt.AlignCenter) |
|
93 |
self.label_5.setObjectName("label_5") |
|
94 |
self.gridLayout_11.addWidget(self.label_5, 0, 2, 1, 1) |
|
95 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
96 |
self.gridLayout_11.addItem(spacerItem, 0, 4, 1, 1) |
|
97 |
self.gridLayout_5.addLayout(self.gridLayout_11, 0, 0, 1, 1) |
|
102 | 98 |
self.gridLayout_2.addWidget(self.groupBox, 3, 1, 1, 1) |
103 | 99 |
self.groupBoxLineNo = QtWidgets.QGroupBox(self.Recognition) |
104 | 100 |
self.groupBoxLineNo.setObjectName("groupBoxLineNo") |
... | ... | |
117 | 113 |
self.pushButtonLineNoAttribute.setMaximumSize(QtCore.QSize(16777215, 24)) |
118 | 114 |
self.pushButtonLineNoAttribute.setObjectName("pushButtonLineNoAttribute") |
119 | 115 |
self.horizontalLayout_2.addWidget(self.pushButtonLineNoAttribute) |
120 |
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
121 |
self.horizontalLayout_2.addItem(spacerItem3)
|
|
116 |
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
117 |
self.horizontalLayout_2.addItem(spacerItem1)
|
|
122 | 118 |
self.pushButtonAddProperty = QtWidgets.QPushButton(self.groupBoxLineNo) |
123 | 119 |
self.pushButtonAddProperty.setMinimumSize(QtCore.QSize(50, 0)) |
124 | 120 |
self.pushButtonAddProperty.setMaximumSize(QtCore.QSize(50, 16777215)) |
... | ... | |
155 | 151 |
self.comboBoxOCRData.setMaximumSize(QtCore.QSize(200, 16777215)) |
156 | 152 |
self.comboBoxOCRData.setObjectName("comboBoxOCRData") |
157 | 153 |
self.horizontalLayout_14.addWidget(self.comboBoxOCRData) |
158 |
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
159 |
self.horizontalLayout_14.addItem(spacerItem4)
|
|
154 |
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
155 |
self.horizontalLayout_14.addItem(spacerItem2)
|
|
160 | 156 |
self.verticalLayout_5.addLayout(self.horizontalLayout_14) |
161 | 157 |
self.horizontalLayout_11 = QtWidgets.QHBoxLayout() |
162 | 158 |
self.horizontalLayout_11.setObjectName("horizontalLayout_11") |
... | ... | |
183 | 179 |
self.spinBoxShrinkSize.setMinimumSize(QtCore.QSize(100, 0)) |
184 | 180 |
self.spinBoxShrinkSize.setObjectName("spinBoxShrinkSize") |
185 | 181 |
self.horizontalLayout_15.addWidget(self.spinBoxShrinkSize) |
186 |
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
187 |
self.horizontalLayout_15.addItem(spacerItem5)
|
|
182 |
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
183 |
self.horizontalLayout_15.addItem(spacerItem3)
|
|
188 | 184 |
self.verticalLayout_5.addLayout(self.horizontalLayout_15) |
189 | 185 |
self.horizontalLayout_13 = QtWidgets.QHBoxLayout() |
190 | 186 |
self.horizontalLayout_13.setObjectName("horizontalLayout_13") |
... | ... | |
213 | 209 |
self.maxTextSizeSpinBox.setProperty("value", 60) |
214 | 210 |
self.maxTextSizeSpinBox.setObjectName("maxTextSizeSpinBox") |
215 | 211 |
self.horizontalLayout_13.addWidget(self.maxTextSizeSpinBox) |
216 |
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
217 |
self.horizontalLayout_13.addItem(spacerItem6)
|
|
212 |
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
213 |
self.horizontalLayout_13.addItem(spacerItem4)
|
|
218 | 214 |
self.verticalLayout_5.addLayout(self.horizontalLayout_13) |
219 | 215 |
self.horizontalLayout_17 = QtWidgets.QHBoxLayout() |
220 | 216 |
self.horizontalLayout_17.setObjectName("horizontalLayout_17") |
... | ... | |
225 | 221 |
self.spinBoxMergeSize.setMinimumSize(QtCore.QSize(100, 0)) |
226 | 222 |
self.spinBoxMergeSize.setObjectName("spinBoxMergeSize") |
227 | 223 |
self.horizontalLayout_17.addWidget(self.spinBoxMergeSize) |
228 |
spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
229 |
self.horizontalLayout_17.addItem(spacerItem7)
|
|
224 |
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
225 |
self.horizontalLayout_17.addItem(spacerItem5)
|
|
230 | 226 |
self.verticalLayout_5.addLayout(self.horizontalLayout_17) |
231 | 227 |
self.gridLayout_14.addLayout(self.verticalLayout_5, 0, 0, 1, 1) |
232 | 228 |
self.gridLayout_2.addWidget(self.groupBoxText, 0, 1, 1, 1) |
... | ... | |
422 | 418 |
ConfigurationDialog.setTabOrder(self.minTextSizeSpinBox, self.maxTextSizeSpinBox) |
423 | 419 |
ConfigurationDialog.setTabOrder(self.maxTextSizeSpinBox, self.spinBoxMergeSize) |
424 | 420 |
ConfigurationDialog.setTabOrder(self.spinBoxMergeSize, self.lineEditSizeDelimiter) |
425 |
ConfigurationDialog.setTabOrder(self.lineEditSizeDelimiter, self.spinBoxMinArea) |
|
426 |
ConfigurationDialog.setTabOrder(self.spinBoxMinArea, self.spinBoxMaxArea) |
|
427 |
ConfigurationDialog.setTabOrder(self.spinBoxMaxArea, self.spinBoxWidth) |
|
428 |
ConfigurationDialog.setTabOrder(self.spinBoxWidth, self.spinBoxHeight) |
|
429 |
ConfigurationDialog.setTabOrder(self.spinBoxHeight, self.smallLineMinLengthSpinBox) |
|
430 |
ConfigurationDialog.setTabOrder(self.smallLineMinLengthSpinBox, self.pushButtonAddProperty) |
|
421 |
ConfigurationDialog.setTabOrder(self.lineEditSizeDelimiter, self.pushButtonAddProperty) |
|
431 | 422 |
ConfigurationDialog.setTabOrder(self.pushButtonAddProperty, self.lineEdit_2) |
432 | 423 |
ConfigurationDialog.setTabOrder(self.lineEdit_2, self.tableWidgetLineTypes) |
433 | 424 |
ConfigurationDialog.setTabOrder(self.tableWidgetLineTypes, self.fontComboBox) |
... | ... | |
447 | 438 |
self.label_6.setText(_translate("ConfigurationDialog", "Size Delimiter : ")) |
448 | 439 |
self.groupBox.setTitle(_translate("ConfigurationDialog", "Line Detection")) |
449 | 440 |
self.label_4.setText(_translate("ConfigurationDialog", "Ignore Small Object Size : ")) |
450 |
self.label_5.setText(_translate("ConfigurationDialog", " < Area < ")) |
|
451 | 441 |
self.label_16.setText(_translate("ConfigurationDialog", "Small Line Minimum Length")) |
442 |
self.label_9.setText(_translate("ConfigurationDialog", "Length to connect line")) |
|
452 | 443 |
self.label.setText(_translate("ConfigurationDialog", "Sliding Window Size(WxH) : ")) |
444 |
self.label_5.setText(_translate("ConfigurationDialog", " < Area < ")) |
|
453 | 445 |
self.groupBoxLineNo.setTitle(_translate("ConfigurationDialog", "Line No")) |
454 | 446 |
self.pushButtonLineNoAttribute.setText(_translate("ConfigurationDialog", "Line No Attribute")) |
455 | 447 |
self.pushButtonAddProperty.setText(_translate("ConfigurationDialog", "Add")) |
... | ... | |
487 | 479 |
self.radioButtonProperty.setText(_translate("ConfigurationDialog", "Property")) |
488 | 480 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabLineColor), _translate("ConfigurationDialog", "Line No Color")) |
489 | 481 |
|
490 |
|
|
491 | 482 |
import MainWindow_rc |
492 | 483 |
|
493 |
|
|
494 | 484 |
if __name__ == "__main__": |
495 | 485 |
import sys |
496 | 486 |
app = QtWidgets.QApplication(sys.argv) |
... | ... | |
499 | 489 |
ui.setupUi(ConfigurationDialog) |
500 | 490 |
ConfigurationDialog.show() |
501 | 491 |
sys.exit(app.exec_()) |
492 |
|
DTI_PID/DTI_PID/LineDetector.py | ||
---|---|---|
415 | 415 |
rhs[1][0] = pt.x |
416 | 416 |
rhs[1][1] = pt.y |
417 | 417 |
except Exception as ex: |
418 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[1].tb_lineno)) |
|
418 |
from App import App |
|
419 |
from AppDocData import MessageType |
|
420 |
|
|
421 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
422 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
419 | 423 |
|
420 | 424 |
def isExternalPoint(self, line, pt): |
425 |
""" check given pt is located outside of line """ |
|
421 | 426 |
try: |
422 | 427 |
dx = line[1][0] - line[0][0] |
423 | 428 |
dy = line[1][1] - line[0][1] |
... | ... | |
437 | 442 |
|
438 | 443 |
return False |
439 | 444 |
except Exception as ex: |
440 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[1].tb_lineno)) |
|
445 |
from App import App |
|
446 |
from AppDocData import MessageType |
|
447 |
|
|
448 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
449 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
441 | 450 |
|
442 | 451 |
''' |
443 | 452 |
@brief detech line thickness |
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
81 | 81 |
if self.isSymbolChecked or self.isTextChecked: |
82 | 82 |
Worker.executeRecognition(self.createDetectedItems, self.path, self.listWidget, self.isLineChecked, self, self.batch, self.createUnknownItems) |
83 | 83 |
|
84 |
#TODO: connect line to symbol |
|
84 | 85 |
#if self.isLineChecked: |
85 | 86 |
# Worker.recognizeLine(self.drawDetectedLines, self.path, self.listWidget, self.graphicsView, self) |
86 | 87 |
except Exception as ex: |
... | ... | |
414 | 415 |
connectedLines = [] |
415 | 416 |
|
416 | 417 |
area = appDocData.getArea('Drawing') |
417 |
#print(area.img.shape) |
|
418 | 418 |
area.img = worker.removeSmallObjects(area.img) |
419 | 419 |
detector = LineDetector(area.img) |
420 | 420 |
|
... | ... | |
425 | 425 |
res = detector.detectConnectedLine(item, round(area.x), round(area.y)) |
426 | 426 |
if res is not None: |
427 | 427 |
connectedLines.extend(res) |
428 |
#print(connectedLines) |
|
428 |
|
|
429 |
# line detection without symbol connection point info |
|
430 |
remainLines = detector.detectLineWithoutSymbol(path, round(area.x), round(area.y)) |
|
431 |
connectedLines.extend([[[line[0][0]-round(area.x),line[0][1]-round(area.y)],[line[1][0]-round(area.x),line[1][1]-round(area.y)],10] for line in remainLines]) |
|
432 |
|
|
429 | 433 |
listWidget.addItem('Connecting lines') |
430 | 434 |
if len(connectedLines) > 1: |
431 |
detector.mergeLines(connectedLines, toler=5) |
|
435 |
configs = appDocData.getConfigs('Line Detector', 'Length to connect line') |
|
436 |
toler = int(configs[0].value) if configs else 20 |
|
437 |
|
|
438 |
#detector.mergeLines(connectedLines, toler=5) |
|
432 | 439 |
# connect line to symbol |
433 | 440 |
try: |
434 | 441 |
for line in connectedLines: |
435 |
matches = [symbol for symbol in symbols if symbol.isConnectable(line, (round(area.x), round(area.y)), toler=20)]
|
|
442 |
matches = [symbol for symbol in symbols if symbol.isConnectable(line, (round(area.x), round(area.y)), toler=toler)]
|
|
436 | 443 |
for symbol in matches: |
437 | 444 |
detector.connectLineToSymbol(line, (round(area.x), round(area.y)), symbol) |
438 | 445 |
except Exception as ex: |
439 | 446 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
440 | 447 |
worker.displayLog.emit(MessageType.Error, message) |
441 | 448 |
# up to here |
442 |
|
|
449 |
|
|
443 | 450 |
# connect line to line |
444 |
toler = 10 |
|
451 |
configs = appDocData.getConfigs('Line Detector', 'Length to connect line') |
|
452 |
toler = int(configs[0].value) if configs else 20 |
|
445 | 453 |
try: |
446 | 454 |
for line in connectedLines: |
447 |
matches = [it for it in connectedLines if (it is not line) and (not detector.isParallel(line, it))] |
|
448 |
|
|
455 |
#matches = [it for it in connectedLines if (it is not line) and (not detector.isParallel(line, it))] |
|
456 |
matches = [it for it in connectedLines if (it is not line)] |
|
457 |
|
|
449 | 458 |
# get closest line |
459 |
""" |
|
450 | 460 |
selected = [] |
451 |
#print(line) |
|
452 | 461 |
shapelyLine = LineString(line[:-1]) |
453 | 462 |
for match in matches: |
454 | 463 |
dist = [shapelyLine.distance(Point(match[0][0], match[0][1])),shapelyLine.distance(Point(match[1][0], match[1][1]))] |
455 | 464 |
if dist[0] < toler or dist[1] < toler: |
456 | 465 |
selected.append(match) |
466 |
""" |
|
457 | 467 |
# up to here |
458 |
|
|
459 |
for match in selected:
|
|
468 |
|
|
469 |
for match in matches:
|
|
460 | 470 |
detector.connectLineToLine(match, line, toler) |
461 | 471 |
except Exception as ex: |
462 | 472 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
463 | 473 |
worker.displayLog.emit(MessageType.Error, message) |
464 | 474 |
# up to here |
465 |
|
|
475 |
|
|
466 | 476 |
listWidget.addItem(worker.tr('Creating lines...')) |
467 | 477 |
|
468 | 478 |
for pts in connectedLines: |
469 |
#print([area.x + pts[0][0], area.y + pts[0][1],area.x + pts[1][0], area.y + pts[1][1]]) |
|
470 | 479 |
processLine = QEngineeringLineItem(vertices=[(area.x + param[0], area.y + param[1]) for param in pts[:-1]], thickness=pts[2]) |
471 | 480 |
processLine.area = 'Drawing' |
472 | 481 |
|
... | ... | |
476 | 485 |
if processLine.length() > 100: # TODO: check critical length |
477 | 486 |
processLine.addFlowArrow() |
478 | 487 |
|
479 |
# line detection without symbol connection point info |
|
480 |
remainLine = detector.detectLineWithoutSymbol(path, round(area.x), round(area.y)) |
|
481 |
|
|
482 |
i = 0 |
|
483 |
for pts in remainLine: |
|
484 |
#print(i) |
|
485 |
#print(pts) |
|
486 |
i = i + 1 |
|
487 |
processLine = QEngineeringLineItem(vertices=[(param[0], param[1]) for param in pts[:]]) |
|
488 |
processLine.area = 'Drawing' |
|
489 |
|
|
490 |
appDocData.lines.append(processLine) |
|
491 |
appDocData.allItems.append(processLine) |
|
492 |
|
|
493 |
if processLine.length() > 100: # TODO: check critical length |
|
494 |
processLine.addFlowArrow() |
|
495 |
|
|
496 | 488 |
except Exception as ex: |
497 | 489 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
498 | 490 |
worker.displayLog.emit(MessageType.Error, message) |
DTI_PID/DTI_PID/TextItemFactory.py | ||
---|---|---|
49 | 49 |
try: |
50 | 50 |
text = textInfo.getText() |
51 | 51 |
docData = AppDocData.instance() |
52 |
|
|
53 |
""" create normal text item if it is not in drawing area """ |
|
54 |
area = docData.getArea('Drawing') |
|
55 |
if not area.contains([textInfo.getX(), textInfo.getY()]): |
|
56 |
item = QEngineeringTextItem() |
|
57 |
item.setToolTip(text) |
|
58 |
item.setPlainText(text) |
|
59 |
|
|
52 | 60 |
configs = docData.getConfigs('Size', 'Delimiter') |
53 | 61 |
sizeDelimiter = configs[0].value.upper() if 1 == len(configs) else None |
54 | 62 |
|
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
75 | 75 |
<string>Line Detection</string> |
76 | 76 |
</property> |
77 | 77 |
<layout class="QGridLayout" name="gridLayout_5"> |
78 |
<item row="2" column="0"> |
|
79 |
<layout class="QHBoxLayout" name="horizontalLayout_6"> |
|
80 |
<item> |
|
81 |
<widget class="QLabel" name="label_4"> |
|
82 |
<property name="text"> |
|
83 |
<string>Ignore Small Object Size : </string> |
|
84 |
</property> |
|
85 |
</widget> |
|
86 |
</item> |
|
87 |
<item> |
|
88 |
<widget class="QSpinBox" name="spinBoxMinArea"> |
|
78 |
<item row="0" column="0"> |
|
79 |
<layout class="QGridLayout" name="gridLayout_11"> |
|
80 |
<item row="2" column="1"> |
|
81 |
<widget class="QSpinBox" name="smallLineMinLengthSpinBox"> |
|
89 | 82 |
<property name="minimumSize"> |
90 | 83 |
<size> |
91 | 84 |
<width>100</width> |
... | ... | |
94 | 87 |
</property> |
95 | 88 |
</widget> |
96 | 89 |
</item> |
97 |
<item alignment="Qt::AlignHCenter">
|
|
98 |
<widget class="QLabel" name="label_5">
|
|
90 |
<item row="0" column="0">
|
|
91 |
<widget class="QLabel" name="label_4">
|
|
99 | 92 |
<property name="text"> |
100 |
<string> < Area < </string>
|
|
93 |
<string>Ignore Small Object Size : </string>
|
|
101 | 94 |
</property> |
102 | 95 |
</widget> |
103 | 96 |
</item> |
104 |
<item> |
|
105 |
<widget class="QSpinBox" name="spinBoxMaxArea">
|
|
97 |
<item row="0" column="1">
|
|
98 |
<widget class="QSpinBox" name="spinBoxMinArea">
|
|
106 | 99 |
<property name="minimumSize"> |
107 | 100 |
<size> |
108 | 101 |
<width>100</width> |
... | ... | |
111 | 104 |
</property> |
112 | 105 |
</widget> |
113 | 106 |
</item> |
114 |
<item> |
|
115 |
<spacer name="horizontalSpacer_6"> |
|
116 |
<property name="orientation"> |
|
117 |
<enum>Qt::Horizontal</enum> |
|
118 |
</property> |
|
119 |
<property name="sizeHint" stdset="0"> |
|
120 |
<size> |
|
121 |
<width>40</width> |
|
122 |
<height>20</height> |
|
123 |
</size> |
|
124 |
</property> |
|
125 |
</spacer> |
|
126 |
</item> |
|
127 |
</layout> |
|
128 |
</item> |
|
129 |
<item row="4" column="0"> |
|
130 |
<layout class="QHBoxLayout" name="horizontalLayout_12"> |
|
131 |
<item> |
|
107 |
<item row="2" column="0"> |
|
132 | 108 |
<widget class="QLabel" name="label_16"> |
133 | 109 |
<property name="text"> |
134 | 110 |
<string>Small Line Minimum Length</string> |
135 | 111 |
</property> |
136 | 112 |
</widget> |
137 | 113 |
</item> |
138 |
<item> |
|
139 |
<widget class="QSpinBox" name="smallLineMinLengthSpinBox"> |
|
114 |
<item row="3" column="0"> |
|
115 |
<widget class="QLabel" name="label_9"> |
|
116 |
<property name="text"> |
|
117 |
<string>Length to connect line</string> |
|
118 |
</property> |
|
119 |
</widget> |
|
120 |
</item> |
|
121 |
<item row="1" column="2"> |
|
122 |
<widget class="QSpinBox" name="spinBoxHeight"> |
|
140 | 123 |
<property name="minimumSize"> |
141 | 124 |
<size> |
142 | 125 |
<width>100</width> |
... | ... | |
145 | 128 |
</property> |
146 | 129 |
</widget> |
147 | 130 |
</item> |
148 |
<item> |
|
149 |
<spacer name="horizontalSpacer_8"> |
|
150 |
<property name="orientation"> |
|
151 |
<enum>Qt::Horizontal</enum> |
|
152 |
</property> |
|
153 |
<property name="sizeHint" stdset="0"> |
|
154 |
<size> |
|
155 |
<width>40</width> |
|
156 |
<height>20</height> |
|
157 |
</size> |
|
158 |
</property> |
|
159 |
</spacer> |
|
160 |
</item> |
|
161 |
</layout> |
|
162 |
</item> |
|
163 |
<item row="3" column="0"> |
|
164 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
165 |
<property name="sizeConstraint"> |
|
166 |
<enum>QLayout::SetNoConstraint</enum> |
|
167 |
</property> |
|
168 |
<item> |
|
131 |
<item row="1" column="0"> |
|
169 | 132 |
<widget class="QLabel" name="label"> |
170 | 133 |
<property name="text"> |
171 | 134 |
<string>Sliding Window Size(WxH) : </string> |
... | ... | |
175 | 138 |
</property> |
176 | 139 |
</widget> |
177 | 140 |
</item> |
178 |
<item> |
|
141 |
<item row="1" column="1">
|
|
179 | 142 |
<widget class="QSpinBox" name="spinBoxWidth"> |
180 | 143 |
<property name="minimumSize"> |
181 | 144 |
<size> |
... | ... | |
185 | 148 |
</property> |
186 | 149 |
</widget> |
187 | 150 |
</item> |
188 |
<item> |
|
189 |
<widget class="QSpinBox" name="spinBoxHeight"> |
|
151 |
<item row="3" column="1"> |
|
152 |
<widget class="QSpinBox" name="spinBoxLengthToConnectLine"> |
|
153 |
<property name="value"> |
|
154 |
<number>20</number> |
|
155 |
</property> |
|
156 |
</widget> |
|
157 |
</item> |
|
158 |
<item row="0" column="3"> |
|
159 |
<widget class="QSpinBox" name="spinBoxMaxArea"> |
|
190 | 160 |
<property name="minimumSize"> |
191 | 161 |
<size> |
192 | 162 |
<width>100</width> |
... | ... | |
195 | 165 |
</property> |
196 | 166 |
</widget> |
197 | 167 |
</item> |
198 |
<item> |
|
199 |
<spacer name="horizontalSpacer_7"> |
|
168 |
<item row="0" column="2"> |
|
169 |
<widget class="QLabel" name="label_5"> |
|
170 |
<property name="text"> |
|
171 |
<string> < Area < </string> |
|
172 |
</property> |
|
173 |
<property name="alignment"> |
|
174 |
<set>Qt::AlignCenter</set> |
|
175 |
</property> |
|
176 |
</widget> |
|
177 |
</item> |
|
178 |
<item row="0" column="4"> |
|
179 |
<spacer name="horizontalSpacer_2"> |
|
200 | 180 |
<property name="orientation"> |
201 | 181 |
<enum>Qt::Horizontal</enum> |
202 | 182 |
</property> |
... | ... | |
863 | 843 |
<tabstop>maxTextSizeSpinBox</tabstop> |
864 | 844 |
<tabstop>spinBoxMergeSize</tabstop> |
865 | 845 |
<tabstop>lineEditSizeDelimiter</tabstop> |
866 |
<tabstop>spinBoxMinArea</tabstop> |
|
867 |
<tabstop>spinBoxMaxArea</tabstop> |
|
868 |
<tabstop>spinBoxWidth</tabstop> |
|
869 |
<tabstop>spinBoxHeight</tabstop> |
|
870 |
<tabstop>smallLineMinLengthSpinBox</tabstop> |
|
871 | 846 |
<tabstop>pushButtonAddProperty</tabstop> |
872 | 847 |
<tabstop>lineEdit_2</tabstop> |
873 | 848 |
<tabstop>tableWidgetLineTypes</tabstop> |
내보내기 Unified diff