프로젝트

일반

사용자정보

개정판 94302d85

ID94302d85dba63e7fa15297509a8ea00ec32d3743
상위 f232adfd
하위 0c39e9b4, e45466a7

함의성이(가) 5년 이상 전에 추가함

issue #663: fix recognize arrow mark and add default line type and add item binding step

Change-Id: Iae8307e1121b868010004b589abf482c2db96fa6

차이점 보기:

DTI_PID/DTI_PID/ConfigurationDialog.py
99 99
        self.ui.smallLineMinLengthSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.smallLineMinLengthSpinBox.setValue(25)
100 100
        configs = docData.getConfigs('Line Detector', 'Length to connect line')
101 101
        if configs: self.ui.spinBoxLengthToConnectLine.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxLengthToConnectLine.setValue(20)
102
        
103
        configs = docData.getConfigs('Line', 'Default Type')
104
        for lineType in LineTypeConditions.items():
105
            self.ui.comboBoxLineType.addItem(lineType.name)
106
        value = configs[0].value if 1 == len(configs) else ''
107
        if value:
108
            at = self.ui.comboBoxLineType.findText(value)
109
            self.ui.comboBoxLineType.setCurrentIndex(at)
110
        else:
111
            at = self.ui.comboBoxLineType.findText('Secondary')
112
            self.ui.comboBoxLineType.setCurrentIndex(at)
102 113

  
103 114
        properties = docData.getLineProperties()
104 115
        if properties:
......
638 649
            configs.append(Config('Sliding Window', 'Height', self.ui.spinBoxHeight.value()))
639 650
            configs.append(Config('Small Line Minimum Length', 'Min Length', self.ui.smallLineMinLengthSpinBox.value()))
640 651
            configs.append(Config('Line Detector', 'Length to connect line', self.ui.spinBoxLengthToConnectLine.value()))
652
            configs.append(Config('Line', 'Default Type', self.ui.comboBoxLineType.currentText()))
641 653
            configs.append(Config('Note No Tag Rule', 'Note No Expression', self.ui.lineEditNoteNoExpression.text()))
642 654
            configs.append(Config('Note No Tag Rule', 'Note No Symbol Name', self.ui.lineEditNoteNoSymbolName.text()))
643 655
            configs.append(Config('OPC Tag Rule', 'From Prefix', self.ui.lineEditOPCFromPrefix.text()))
DTI_PID/DTI_PID/Configuration_UI.py
86 86
        self.gridLayout_5.setObjectName("gridLayout_5")
87 87
        self.gridLayout_11 = QtWidgets.QGridLayout()
88 88
        self.gridLayout_11.setObjectName("gridLayout_11")
89
        self.spinBoxMaxArea = QtWidgets.QSpinBox(self.groupBox)
90
        self.spinBoxMaxArea.setMinimumSize(QtCore.QSize(100, 0))
91
        self.spinBoxMaxArea.setObjectName("spinBoxMaxArea")
92
        self.gridLayout_11.addWidget(self.spinBoxMaxArea, 0, 3, 1, 1)
93
        self.spinBoxLengthToConnectLine = QtWidgets.QSpinBox(self.groupBox)
94
        self.spinBoxLengthToConnectLine.setProperty("value", 20)
95
        self.spinBoxLengthToConnectLine.setObjectName("spinBoxLengthToConnectLine")
96
        self.gridLayout_11.addWidget(self.spinBoxLengthToConnectLine, 3, 1, 1, 1)
97
        self.label_5 = QtWidgets.QLabel(self.groupBox)
98
        self.label_5.setAlignment(QtCore.Qt.AlignCenter)
99
        self.label_5.setObjectName("label_5")
100
        self.gridLayout_11.addWidget(self.label_5, 0, 2, 1, 1)
101
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
102
        self.gridLayout_11.addItem(spacerItem, 0, 4, 1, 1)
89 103
        self.smallLineMinLengthSpinBox = QtWidgets.QSpinBox(self.groupBox)
90 104
        self.smallLineMinLengthSpinBox.setMinimumSize(QtCore.QSize(100, 0))
91 105
        self.smallLineMinLengthSpinBox.setObjectName("smallLineMinLengthSpinBox")
......
97 111
        self.spinBoxMinArea.setMinimumSize(QtCore.QSize(100, 0))
98 112
        self.spinBoxMinArea.setObjectName("spinBoxMinArea")
99 113
        self.gridLayout_11.addWidget(self.spinBoxMinArea, 0, 1, 1, 1)
100
        self.label_16 = QtWidgets.QLabel(self.groupBox)
101
        self.label_16.setObjectName("label_16")
102
        self.gridLayout_11.addWidget(self.label_16, 2, 0, 1, 1)
103 114
        self.label_9 = QtWidgets.QLabel(self.groupBox)
104 115
        self.label_9.setObjectName("label_9")
105 116
        self.gridLayout_11.addWidget(self.label_9, 3, 0, 1, 1)
117
        self.label_16 = QtWidgets.QLabel(self.groupBox)
118
        self.label_16.setObjectName("label_16")
119
        self.gridLayout_11.addWidget(self.label_16, 2, 0, 1, 1)
106 120
        self.spinBoxHeight = QtWidgets.QSpinBox(self.groupBox)
107 121
        self.spinBoxHeight.setMinimumSize(QtCore.QSize(100, 0))
108 122
        self.spinBoxHeight.setObjectName("spinBoxHeight")
109 123
        self.gridLayout_11.addWidget(self.spinBoxHeight, 1, 2, 1, 1)
110
        self.label = QtWidgets.QLabel(self.groupBox)
111
        self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
112
        self.label.setObjectName("label")
113
        self.gridLayout_11.addWidget(self.label, 1, 0, 1, 1)
114 124
        self.spinBoxWidth = QtWidgets.QSpinBox(self.groupBox)
115 125
        self.spinBoxWidth.setMinimumSize(QtCore.QSize(100, 0))
116 126
        self.spinBoxWidth.setObjectName("spinBoxWidth")
117 127
        self.gridLayout_11.addWidget(self.spinBoxWidth, 1, 1, 1, 1)
118
        self.spinBoxLengthToConnectLine = QtWidgets.QSpinBox(self.groupBox)
119
        self.spinBoxLengthToConnectLine.setProperty("value", 20)
120
        self.spinBoxLengthToConnectLine.setObjectName("spinBoxLengthToConnectLine")
121
        self.gridLayout_11.addWidget(self.spinBoxLengthToConnectLine, 3, 1, 1, 1)
122
        self.spinBoxMaxArea = QtWidgets.QSpinBox(self.groupBox)
123
        self.spinBoxMaxArea.setMinimumSize(QtCore.QSize(100, 0))
124
        self.spinBoxMaxArea.setObjectName("spinBoxMaxArea")
125
        self.gridLayout_11.addWidget(self.spinBoxMaxArea, 0, 3, 1, 1)
126
        self.label_5 = QtWidgets.QLabel(self.groupBox)
127
        self.label_5.setAlignment(QtCore.Qt.AlignCenter)
128
        self.label_5.setObjectName("label_5")
129
        self.gridLayout_11.addWidget(self.label_5, 0, 2, 1, 1)
130
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
131
        self.gridLayout_11.addItem(spacerItem, 0, 4, 1, 1)
128
        self.label = QtWidgets.QLabel(self.groupBox)
129
        self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
130
        self.label.setObjectName("label")
131
        self.gridLayout_11.addWidget(self.label, 1, 0, 1, 1)
132
        self.label_28 = QtWidgets.QLabel(self.groupBox)
133
        self.label_28.setObjectName("label_28")
134
        self.gridLayout_11.addWidget(self.label_28, 4, 0, 1, 1)
135
        self.comboBoxLineType = QtWidgets.QComboBox(self.groupBox)
136
        self.comboBoxLineType.setObjectName("comboBoxLineType")
137
        self.gridLayout_11.addWidget(self.comboBoxLineType, 4, 1, 1, 2)
132 138
        self.gridLayout_5.addLayout(self.gridLayout_11, 0, 0, 1, 1)
133 139
        self.gridLayout_2.addWidget(self.groupBox, 3, 1, 1, 1)
134 140
        self.groupBoxLineNo = QtWidgets.QGroupBox(self.Recognition)
......
539 545
        self.label_24.setText(_translate("ConfigurationDialog", "Line Flow Mark Position(Percent) : "))
540 546
        self.label_26.setText(_translate("ConfigurationDialog", "Line Flow Mark Minimum Line Length : "))
541 547
        self.groupBox.setTitle(_translate("ConfigurationDialog", "Line Detection"))
548
        self.label_5.setText(_translate("ConfigurationDialog", "< Area < "))
542 549
        self.label_4.setText(_translate("ConfigurationDialog", "Ignore Small Object Size : "))
543
        self.label_16.setText(_translate("ConfigurationDialog", "Small Line Minimum Length"))
544 550
        self.label_9.setText(_translate("ConfigurationDialog", "Length to Connect Line"))
551
        self.label_16.setText(_translate("ConfigurationDialog", "Small Line Minimum Length"))
545 552
        self.label.setText(_translate("ConfigurationDialog", "Sliding Window Size(WxH) : "))
546
        self.label_5.setText(_translate("ConfigurationDialog", "< Area < "))
553
        self.label_28.setText(_translate("ConfigurationDialog", "Default Line Type"))
547 554
        self.groupBoxLineNo.setTitle(_translate("ConfigurationDialog", "Line No"))
548 555
        self.pushButtonLineNoAttribute.setText(_translate("ConfigurationDialog", "Line No Attribute"))
549 556
        self.pushButtonAddProperty.setText(_translate("ConfigurationDialog", "Add"))
DTI_PID/DTI_PID/LineDetector.py
501 501
            if ([1,0] == dir):
502 502
                image = self._image[(pt[1]-yHalf):(pt[1]+yHalf), pt[0]:self.width]
503 503
                imgWidth, imgHeight = image.shape[::-1]
504
                i = 0
504
                index = 0
505 505
                for i in range(imgWidth-windowSize[0]):
506 506
                    window = image[0:windowSize[1], i:i+windowSize[0]]
507 507
                    if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break
508
                if i > lineMinLength:
508
                    index += 1
509
                if index > lineMinLength:
509 510
                    #self._image[(pt[1]-yHalf):(pt[1]+yHalf), pt[0]:(pt[0]+i)] = white
510 511
                    cv2.line(self._image, (pt[0],pt[1]), (pt[0]+i,pt[1]), 255, thickness)
511 512
                    return [[pt[0], pt[1]], [pt[0] + i - round(thickness*0.5), pt[1]]]
512 513
            elif ([-1,0] == dir):
513 514
                image = self._image[(pt[1]-yHalf):(pt[1]+yHalf), 0:pt[0]]
514 515
                imgWidth, imgHeight = image.shape[::-1]
515
                i = 0
516
                index = 0
516 517
                for i in range(imgWidth-windowSize[0], -1, -1):
517 518
                    window = image[0:windowSize[1], i:i+windowSize[0]]
518 519
                    if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break
519
                if abs(pt[0] - i - windowSize[0]) > lineMinLength: 
520
                    index += 1
521
                if index > lineMinLength: 
520 522
                    #self._image[int(pt[1]-yHalf):int(pt[1]+yHalf), (i+windowSize[0]+yHalf):pt[0]] = white
521 523
                    cv2.line(self._image, (i+windowSize[0],pt[1]), (pt[0],pt[1]), 255, thickness)
522 524
                    return [[pt[0], pt[1]], [i+windowSize[0]+round(thickness*0.5), pt[1]]]
......
527 529

  
528 530
                image = self._image[pt[1]:self.height, int(pt[0]-xHalf):int(pt[0]+xHalf)]
529 531
                imgWidth, imgHeight = image.shape[::-1]
530
                i = 0
532
                index = 0
531 533
                for i in range(imgHeight-windowSize[1]):
532 534
                    window = image[i:i+windowSize[1], 0:windowSize[0]]
533 535
                    if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break
534
                if i > lineMinLength:
536
                    index += 1
537
                if index > lineMinLength:
535 538
                    #self._image[(pt[1]):(pt[1]+i), (pt[0]-xHalf):(pt[0]+xHalf)] = white
536 539
                    cv2.line(self._image, (pt[0],pt[1]), (pt[0],pt[1]+i), 255, thickness)
537 540
                    return [[pt[0], pt[1]], [pt[0], pt[1] + i - round(thickness*0.5)]]
......
542 545

  
543 546
                image = self._image[0:pt[1], (pt[0]-xHalf):(pt[0]+xHalf)]
544 547
                imgWidth, imgHeight = image.shape[::-1]
545
                i = 0
548
                index = 0
546 549
                for i in range(imgHeight-windowSize[1], -1, -1):
547 550
                    window = image[i:i+windowSize[1], 0:windowSize[0]]
548 551
                    if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break
549
                if abs(pt[1] - i - windowSize[1]) > lineMinLength:
552
                    index += 1
553
                if index > lineMinLength:
550 554
                    #self._image[(i+windowSize[1]):pt[1], (pt[0]-xHalf):(pt[0]+xHalf)] = white
551 555
                    cv2.line(self._image, (pt[0],i+windowSize[1]), (pt[0],pt[1]), 255, thickness)
552 556
                    return [[pt[0], pt[1]], [pt[0], i+windowSize[1]+round(thickness*0.5)]]
DTI_PID/DTI_PID/MainWindow.py
2504 2504
            self.graphicsView.scene.update(self.graphicsView.sceneRect())
2505 2505
            for item in self.graphicsView.scene.items():
2506 2506
                item.setVisible(True)
2507

  
2508
            
2507
                
2508
                # binding items
2509
                if hasattr(item, 'owner'):
2510
                    item.owner
2511
                if hasattr(item, 'connectors'):
2512
                    for connector in item.connectors:
2513
                        connector.connectedItem
2509 2514

  
2510 2515
        except Exception as ex:
2511 2516
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
DTI_PID/DTI_PID/RecognitionDialog.py
412 412
                    textInfoList = textDetector.textInfoList.copy() if textDetector.textInfoList is not None else None
413 413
                    otherTextInfoList = textDetector.otherTextInfoList.copy() if textDetector.otherTextInfoList is not None else None
414 414
                    titleBlockTextInfoList = textDetector.titleBlockTextInfoList.copy() if textDetector.titleBlockTextInfoList is not None else None
415

  
416
                    for index in range(len(textInfoList) - 1, -1, -1):
417
                        if len(textInfoList[index].getText()) is 1:
418
                            textInfoList.pop(index)
419
    
415
   
420 416
                    appDocData.imgWidth, appDocData.imgHeight = appDocData.imgSrc.shape[::-1]
421 417
                    Worker.drawFoundSymbolsOnCanvas(mainRes, textInfoList, listWidget)
422 418
     
......
584 580
                        connectedLines.extend(res)
585 581

  
586 582
            # line detection without symbol connection point info
587
            remainLines = detector.detectLineWithoutSymbol(area)
583
            remainLines = []#detector.detectLineWithoutSymbol(area)
588 584
            windowSize = appDocData.getSlidingWindowSize()
589 585
            thickness = int(windowSize[1])
590 586
            for line in remainLines:
......
598 594
            for pts in connectedLines:
599 595
                processLine = QEngineeringLineItem(vertices=[(area.x + param[0], area.y + param[1]) for param in pts[:-1]], thickness=pts[2])
600 596
                processLine.area = 'Drawing'
601
                processLine.lineType = 'Secondary'
602 597

  
603 598
                appDocData.lines.append(processLine)
604 599
                appDocData.allItems.append(processLine)
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
36 36
        import uuid
37 37
        from EngineeringConnectorItem import QEngineeringConnectorItem
38 38
        from SymbolAttr import SymbolProp
39
        from AppDocData import AppDocData
39 40

  
40 41
        try:
41 42
            QGraphicsLineItem.__init__(self, parent)
......
49 50

  
50 51
            self._owner = None
51 52
            self._flowMark = None
52
            self._lineType = 'Secondary'  # defulat line type is 'Secondary'
53
            configs = AppDocData.instance().getConfigs('Line', 'Default Type')
54
            self._lineType = None
55
            self.lineType = configs[0].value if 1 == len(configs) else 'Secondary' # defulat line type is 'Secondary'
56

  
53 57
            self._properties = \
54 58
                {\
55 59
                    SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'):None,\
......
90 94
                tooltip = '<b>{}</b><br>({},{})-({},{})'.format(str(self.uid), vertices[0][0], vertices[0][1], vertices[1][0], vertices[1][1])
91 95
                self.setToolTip(tooltip)
92 96
        except Exception as ex:
93
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
97
            from App import App
98
            from AppDocData import MessageType
99

  
100
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
101
            App.mainWnd().addMessage.emit(MessageType.Error, message)
94 102

  
95 103
    def __str__(self):
96 104
        """ return string represent uuid """
DTI_PID/DTI_PID/TextDetector.py
287 287
                    if data: self.textInfoList.extend(data)
288 288
                pool.shutdown(wait = True)
289 289

  
290
                for index in range(len(self.textInfoList) - 1, -1, -1):
291
                    if len(self.textInfoList[index].getText()) is 1:
292
                        self.textInfoList.pop(index)
293

  
290 294
                if onlyTextArea:
291 295
                    return
292 296
                # parse texts in area except Drawing area
DTI_PID/DTI_PID/UI/Configuration.ui
155 155
         <layout class="QGridLayout" name="gridLayout_5">
156 156
          <item row="0" column="0">
157 157
           <layout class="QGridLayout" name="gridLayout_11">
158
            <item row="0" column="3">
159
             <widget class="QSpinBox" name="spinBoxMaxArea">
160
              <property name="minimumSize">
161
               <size>
162
                <width>100</width>
163
                <height>0</height>
164
               </size>
165
              </property>
166
             </widget>
167
            </item>
168
            <item row="3" column="1">
169
             <widget class="QSpinBox" name="spinBoxLengthToConnectLine">
170
              <property name="value">
171
               <number>20</number>
172
              </property>
173
             </widget>
174
            </item>
175
            <item row="0" column="2">
176
             <widget class="QLabel" name="label_5">
177
              <property name="text">
178
               <string>&lt; Area &lt; </string>
179
              </property>
180
              <property name="alignment">
181
               <set>Qt::AlignCenter</set>
182
              </property>
183
             </widget>
184
            </item>
185
            <item row="0" column="4">
186
             <spacer name="horizontalSpacer_2">
187
              <property name="orientation">
188
               <enum>Qt::Horizontal</enum>
189
              </property>
190
              <property name="sizeHint" stdset="0">
191
               <size>
192
                <width>40</width>
193
                <height>20</height>
194
               </size>
195
              </property>
196
             </spacer>
197
            </item>
158 198
            <item row="2" column="1">
159 199
             <widget class="QSpinBox" name="smallLineMinLengthSpinBox">
160 200
              <property name="minimumSize">
......
182 222
              </property>
183 223
             </widget>
184 224
            </item>
185
            <item row="2" column="0">
186
             <widget class="QLabel" name="label_16">
225
            <item row="3" column="0">
226
             <widget class="QLabel" name="label_9">
187 227
              <property name="text">
188
               <string>Small Line Minimum Length</string>
228
               <string>Length to Connect Line</string>
189 229
              </property>
190 230
             </widget>
191 231
            </item>
192
            <item row="3" column="0">
193
             <widget class="QLabel" name="label_9">
232
            <item row="2" column="0">
233
             <widget class="QLabel" name="label_16">
194 234
              <property name="text">
195
               <string>Length to Connect Line</string>
235
               <string>Small Line Minimum Length</string>
196 236
              </property>
197 237
             </widget>
198 238
            </item>
......
206 246
              </property>
207 247
             </widget>
208 248
            </item>
209
            <item row="1" column="0">
210
             <widget class="QLabel" name="label">
211
              <property name="text">
212
               <string>Sliding Window Size(WxH) : </string>
213
              </property>
214
              <property name="alignment">
215
               <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
216
              </property>
217
             </widget>
218
            </item>
219 249
            <item row="1" column="1">
220 250
             <widget class="QSpinBox" name="spinBoxWidth">
221 251
              <property name="minimumSize">
......
226 256
              </property>
227 257
             </widget>
228 258
            </item>
229
            <item row="3" column="1">
230
             <widget class="QSpinBox" name="spinBoxLengthToConnectLine">
231
              <property name="value">
232
               <number>20</number>
259
            <item row="1" column="0">
260
             <widget class="QLabel" name="label">
261
              <property name="text">
262
               <string>Sliding Window Size(WxH) : </string>
233 263
              </property>
234
             </widget>
235
            </item>
236
            <item row="0" column="3">
237
             <widget class="QSpinBox" name="spinBoxMaxArea">
238
              <property name="minimumSize">
239
               <size>
240
                <width>100</width>
241
                <height>0</height>
242
               </size>
264
              <property name="alignment">
265
               <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
243 266
              </property>
244 267
             </widget>
245 268
            </item>
246
            <item row="0" column="2">
247
             <widget class="QLabel" name="label_5">
269
            <item row="4" column="0">
270
             <widget class="QLabel" name="label_28">
248 271
              <property name="text">
249
               <string>&lt; Area &lt; </string>
250
              </property>
251
              <property name="alignment">
252
               <set>Qt::AlignCenter</set>
272
               <string>Default Line Type</string>
253 273
              </property>
254 274
             </widget>
255 275
            </item>
256
            <item row="0" column="4">
257
             <spacer name="horizontalSpacer_2">
258
              <property name="orientation">
259
               <enum>Qt::Horizontal</enum>
260
              </property>
261
              <property name="sizeHint" stdset="0">
262
               <size>
263
                <width>40</width>
264
                <height>20</height>
265
               </size>
266
              </property>
267
             </spacer>
276
            <item row="4" column="1" colspan="2">
277
             <widget class="QComboBox" name="comboBoxLineType"/>
268 278
            </item>
269 279
           </layout>
270 280
          </item>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)