프로젝트

일반

사용자정보

개정판 6e953094

ID6e9530941fbb2767e45c6ba175b829521ebd15d7
상위 9f27c190
하위 b25fca04

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

issue #501: isolate drawing part and remove scene dependency

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
104 104
        self.lines = []
105 105
        self.texts = []
106 106
        self.symbols = []
107
        self.unknowns = []
107 108
        self._colors = None
108 109
        self._lineNoProperties = None
109 110
        self._lineTypes = None
......
130 131
        self.lines.clear()
131 132
        self.texts.clear()
132 133
        self.symbols.clear()
134
        self.unknowns.clear()
133 135
        self._colors = None
134 136
        self._lineNoProperties = None
135 137
        self._lineTypes = None
DTI_PID/DTI_PID/MainWindow.py
444 444
        if docData.imgName is None:
445 445
            self.showImageSelectionMessageBox()
446 446
            return
447
        result = xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.graphicsView.scene)
447
        result = xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight)
448 448
        
449 449
        if len(self.removedItems['LINE']):
450 450
            docData.deleteLineDataList_LineNo(self.removedItems['LINE'])
......
1253 1253
                    2018.11.05  euisung     add db delete process before save
1254 1254
                    2018.11.12  euisung     add title block properties
1255 1255
                    2018.11.12  euisung     db part move new method to dbUpdate
1256
                    2018.11.26  euisung     isolate scene adding part -> drawDetectedItemsToSecene()
1256 1257
    '''
1257 1258
    def drawDetectedItems(self, symbolList, textInfoList, otherTextInfoList, titleBlockTextInfoList):
1258 1259
        try:
......
1268 1269
            QApplication.processEvents()
1269 1270
            self.drawDetectedTitleBlockTextItem(titleBlockTextInfoList)
1270 1271

  
1271
            self.drawDetectedItemsToSecene()
1272

  
1273 1272
            self.dbUpdate()
1274 1273
            self.saveToXml(False)
1275 1274

  
......
1296 1295
        for text in appDocData.texts:
1297 1296
            self.addTextItemToScene(text)
1298 1297

  
1298
        for line in appDocData.lines:
1299
            self.graphicsView.scene.addItem(line)
1300

  
1301
        for unknown in appDocData.unknowns:
1302
            self.addUnknownItemToScene(unknown)
1303
                   
1304

  
1299 1305
    def postDetectLineProcess(self):
1300 1306
        '''
1301 1307
            @brief  check allowables among undetected items
......
1343 1349
            @brief  draw title block
1344 1350
            @author euisung
1345 1351
            @date   2018.11.12
1352
            @history     2018.11.26  euisung     remove scene dependency
1346 1353
        '''
1347 1354
        from TextItemFactory import TextItemFactory
1348 1355
        import math
......
1375 1382
        @brief      
1376 1383
        @author     humkyung
1377 1384
        @date       2018.08.23
1385
        @history    2018.11.26  euisung     remove scene dependency
1386
                    2018.11.26  euisung     isolate scene adding part -> drawDetectedItemsToSecene()
1378 1387
    '''
1379 1388
    def drawDetectedLines(self, lineList, worker):
1380
        area = AppDocData.instance().getArea('Drawing')
1389
        appDocData = AppDocData.instance()
1390
        area = appDocData.getArea('Drawing')
1381 1391

  
1382
        lines = []
1383 1392
        for pts in lineList:
1384 1393
            processLine = QEngineeringLineItem(vertices=[(area.x + param[0], area.y + param[1]) for param in pts])
1385 1394
            processLine.area = 'Drawing'
1386
            self.graphicsView.scene.addItem(processLine)
1387
            lines.append(processLine)
1395
            #self.graphicsView.scene.addItem(processLine)
1396
            appDocData.lines.append(processLine)
1388 1397

  
1389 1398
            if processLine.length() > 100: # TODO: check critical length
1390 1399
                processLine.addFlowArrow()
......
1395 1404

  
1396 1405
    '''
1397 1406
        history     2018.06.09  humkyung    check length of original and connection point is 2 while parsing
1407
                    2018.11.26  euisung     remove scene dependency
1398 1408
    '''
1399 1409
    def drawDetectedSymbolItem(self, symbolList):
1400 1410
        from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
......
1454 1464

  
1455 1465
    '''
1456 1466
        @history    2018.06.08  Jeongwoo    Add parameter on round method
1457
        @history    2018.11.02  euisung    Add save note text item
1458
        @history    2018.11.05  euisung    delete save note text item and move to drawDetectedItems()
1467
        @history    2018.11.02  euisung     Add save note text item
1468
        @history    2018.11.05  euisung     delete save note text item and move to drawDetectedItems()
1469
                    2018.11.26  euisung     remove scene dependency
1459 1470
    '''
1460 1471
    def drawDetectedTextItem(self, textInfoList):
1461 1472
        from TextItemFactory import TextItemFactory
......
1529 1540
        @history    2018.06.14  Jeongwoo    Change method to add unknown item
1530 1541
                    2018.06.18  Jeongwoo    Add connect on unknown item
1531 1542
                                            Add [transfer] for using pyqtSignal
1543
                    2018.11.26  euisung     remove scene dependency
1544
                    2018.11.26  euisung     isolate scene adding part -> drawDetectedItemsToSecene()
1532 1545
    '''
1533 1546
    def drawUnknownItems(self):
1534 1547
        from QEngineeringFlowArrowItem import QEngineeringFlowArrowItem 
......
1546 1559
                imgDiff = cv2.threshold(cv2.cvtColor(cv2.imread(diffFilePath, 1), cv2.COLOR_BGR2GRAY), 127, 255, cv2.THRESH_BINARY)[1]
1547 1560

  
1548 1561
                ## remove line
1549
                lines = [item for item in self.graphicsView.scene.items() if (type(item) is QEngineeringLineItem)]
1562
                lines = docData.lines
1550 1563
                for line in lines:
1551 1564
                    line.drawToImage(imgDiff, 255, thickness)
1552 1565
                cv2.imwrite(diffFilePath, imgDiff)
......
1586 1599

  
1587 1600
                for item in diffItems:
1588 1601
                    item.transfer.onRemoved.connect(self.itemRemoved)
1589
                    self.addUnknownItemToScene(item)
1602
                    #self.addUnknownItemToScene(item)
1603
                    docData.unknowns.append(item)
1590 1604

  
1591 1605
                notFilePath = os.path.join(project.getTempPath(), "NOT_" + os.path.basename(self.path))
1592 1606
                cv2.imwrite(notFilePath, imgNot)
DTI_PID/DTI_PID/RecognitionDialog.py
1402 1402
        @history    2018.05.25  Jeongwoo    Moved from MainWindow
1403 1403
                    2018.05.30  Jeongwoo    Remove self.xmlPath variable and Add writeXmlOnScene
1404 1404
                    2018.06.14  Jeongwoo    Change sentence order
1405
                    2018.11.26  euisung     add drawing part
1405 1406
    '''
1406 1407
    def dlgExit(self):
1407 1408
        import timeit
......
1411 1412
            self.ui.buttonBox.setEnabled(True)
1412 1413
            docData = AppDocData.instance()
1413 1414

  
1415
            docData.unknowns.clear()
1414 1416
            self.parent.drawUnknownItems()
1415 1417

  
1418
            self.parent.drawDetectedItemsToSecene()
1416 1419
            self.parent.saveToXml(False)
1417 1420
        except Exception as ex:
1418 1421
            from App import App
DTI_PID/DTI_PID/XmlGenerator.py
357 357
    @history    2018.05.30  Jeongwoo    Create node by item object
358 358
                2018.06.12  Jeongwoo    Add if-statement for QEngineeringLineNoTextItem data node
359 359
                2018.06.14  Jeongwoo    Add if-statement for QEngineeringUnknownItem data node
360
                2018.11.26  euisung     remove scene dependency
360 361
'''
361
def writeXmlOnScene(pidName, pidWidth, pidHeight, scene):
362
def writeXmlOnScene(pidName, pidWidth, pidHeight):
362 363
    from EngineeringNoteItem import QEngineeringNoteItem
363 364
    from EngineeringTextItem import QEngineeringTextItem
364 365
    from EngineeringLineItem import QEngineeringLineItem
......
367 368
    from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem
368 369
    from SymbolSvgItem import SymbolSvgItem
369 370

  
371
    appDocData = AppDocData.instance()
372
    items = []
373
    items = appDocData.equipments + appDocData.symbols + appDocData.texts + appDocData.lines + appDocData.unknowns
370 374
    path = os.path.join(AppDocData.instance().getCurrentProject().getTempPath(), pidName + '.xml')
371 375

  
372 376
    xml = Element(ROOT_NODE_NAME) # Root Node
......
392 396
        resultDic["Unknown Item"] = [0, []]
393 397
        resultDic["Trim Line Item"] = [0, []]
394 398

  
395
        for item in scene.items():
399
        for item in items:
396 400
            if issubclass(type(item), SymbolSvgItem):
397 401
                symbolNode = item.toXml()
398 402
                if type(symbolNode) is str:

내보내기 Unified diff

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