프로젝트

일반

사용자정보

개정판 acc6b10d

IDacc6b10d4c7e577ce381d0b3c937f27a45c8fe14
상위 11fc81ee
하위 45e2d536

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

issue #478: fix text item include line no

Change-Id: Id866dba03968b37be950ad870d6cf739536b7192

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1724 1724
                    else:
1725 1725
                        res.append(pipeSize)
1726 1726

  
1727
                if sizeUnit == 'Inch':
1727
                if 'Inch' in sizeUnit:
1728 1728
                    res = sorted(res, key=lambda param:len(param.inchStr), reverse=True)
1729 1729
                else:
1730 1730
                    res = sorted(res, key=lambda param:len(param.metricStr), reverse=True)
DTI_PID/DTI_PID/OcrResultDialog.py
217 217

  
218 218
            # try to detect text if there is no result of detection or
219 219
            # count of text info list not match with count of split text
220
            if not self.textInfoList or (len(self.textInfoList) != len(splitText)):
220
            if isSplit and self.textInfoList and (len(self.textInfoList) == len(splitText)):
221
                for index in range(len(self.textInfoList)):
222
                    self.textInfoList[index].setText(splitText[index])
223
            elif isSplit and not self.textInfoList:
221 224
                self.detect_text()
225
                if len(self.textInfoList) == len(splitText[index]):
226
                    for index in range(len(self.textInfoList)):
227
                        self.textInfoList[index].setText(splitText[index])
228
                else:
229
                    self.textInfoList = self.getMergedTextInfo(text)
230
            else:
231
                self.textInfoList = self.getMergedTextInfo(text)
222 232

  
223
            if not isSplit:
233
                '''
224 234
                minX, minY, maxX, maxY = sys.maxsize, sys.maxsize, 0, 0
225 235
                for textInfo in self.textInfoList:
226 236
                    x, y, w, h = textInfo.getX(), textInfo.getY(), textInfo.getW(), textInfo.getH()
......
230 240
                    maxY = max(y + h, maxY)
231 241

  
232 242
                self.textInfoList = [TextInfo(text, minX, minY, maxX - minX, maxY - minY, 0)]
243
                '''
233 244

  
245
            '''
234 246
            if self.textInfoList:
235 247
                if self._text_item:
236 248
                    textInfo = self.textInfoList[0]
......
264 276
                    self._text_item.update_shape()
265 277

  
266 278
                    self.textInfoList = self.textInfoList[1:]
279
            '''                   
267 280

  
268
                QDialog.accept(self)
281
            QDialog.accept(self)
269 282

  
270 283
        except Exception as ex:
271 284
            from App import App
......
273 286
                                                           sys.exc_info()[-1].tb_lineno)
274 287
            App.mainWnd().addMessage.emit(MessageType.Error, message)
275 288

  
289
    def getMergedTextInfo(self, text):
290
        import cv2
291
        from TextInfo import TextInfo
292

  
293
        buffer = QBuffer()
294
        buffer.open(QBuffer.ReadWrite)
295
        self.image.save(buffer, "PNG")
296
        pyImage = Image.open(io.BytesIO(buffer.data()))
297
        img = np.array(pyImage)
298

  
299
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
300
        imgNot = np.ones(img.shape, np.uint8)
301
        cv2.bitwise_not(img, imgNot)
302
        imgNot = cv2.dilate(imgNot, np.ones((8, 8), np.uint8))
303

  
304
        contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
305
        minX, minY, maxX, maxY = sys.maxsize, sys.maxsize, 0, 0
306
        if len(contours) is 0:
307
            minX, minY, maxX, maxY = self.boundingBox.x(), self.boundingBox.y(), self.boundingBox.x() + self.image.width(), self.boundingBox.y() + self.image.height()
308
        else:
309
            minX, minY, maxX, maxY = sys.maxsize, sys.maxsize, 0, 0
310
            for cnt in contours:
311
                x, y, w, h = cv2.boundingRect(cnt)
312
                minX = min(x, minX)
313
                minY = min(y, minY)
314
                maxX = max(x + w, maxX)
315
                maxY = max(y + h, maxY)
316
            minX, minY, maxX, maxY = minX + self.boundingBox.x(), minY + self.boundingBox.y(), maxX + self.boundingBox.x(), maxY + self.boundingBox.y()
317

  
318
        return [TextInfo(text, minX, minY, maxX - minX, maxY - minY, 0)]
319

  
276 320
    def reject(self):
277 321
        self.isAccepted = False
278 322
        self.textInfoList = None
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
312 312
                        item.area = self.area
313 313
                        item.addTextItemToScene(scene)
314 314
                        item.transfer.onRemoved.connect(scene.parent().parent().parent().itemRemoved)
315

  
316
                self.transfer.onRemoved.emit(self)
315 317
        except Exception as ex:
316 318
            message = 'error occurred({}) in {}:{}'.format(self.tr('Fail to create text'),
317 319
                                                           sys.exc_info()[-1].tb_frame.f_code.co_filename,
DTI_PID/DTI_PID/SpecBreakDialog.py
74 74
        configs = docData.getConfigs('Line No', 'Size Unit')
75 75
        tableDatas = docData.getNomialPipeSizeData()
76 76
        for pipeSize in tableDatas:
77
            if configs[0].value == 'Metric':
77
            if 'Metric' in configs[0].value:
78 78
                valueComboBox.addItem('' if pipeSize.metricStr is None else pipeSize.metricStr)
79 79
            else:
80 80
                valueComboBox.addItem('' if pipeSize.inchStr is None else pipeSize.inchStr)

내보내기 Unified diff

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