프로젝트

일반

사용자정보

개정판 a56a12dd

IDa56a12dd0f5f510edc521896eb066dd7604318fb
상위 1d7af5dc
하위 343f563a

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

issue #000: fix symbol in tree when load xml

Change-Id: If0cc94d5f1d402e2cdb4cf4b58b41f6926811ddf

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
1666 1666
            for line in appDocData.lines:
1667 1667
                self.graphicsView.scene.addItem(line)
1668 1668
                line.transfer.onRemoved.connect(self.itemRemoved)
1669
                for conn in line.connectors:
1670
                    conn.transfer.onPosChanged.connect(line.onConnectorPosChaned)
1669
                #for conn in line.connectors:
1670
                #    conn.transfer.onPosChanged.connect(line.onConnectorPosChaned)
1671 1671

  
1672 1672
            for unknown in appDocData.unknowns + appDocData.lineIndicators:
1673 1673
                self.graphicsView.scene.addItem(unknown)
......
2268 2268
                if item is not None:
2269 2269
                    item.transfer.onRemoved.connect(self.itemRemoved)
2270 2270
                    symbols.append(item)
2271
                    docData.symbols.append(item)     
2272
                    self.addSvgItemToScene(item)         
2271
                    docData.symbols.append(item)
2272
                    self.addSvgItemToScene(item)
2273 2273
                else:
2274 2274
                    pt = [float(x) for x in symbol.find('LOCATION').text.split(',')]
2275 2275
                    size = [float(x) for x in symbol.find('SIZE').text.split(',')]
......
2343 2343
                
2344 2344
            QApplication.processEvents()
2345 2345

  
2346
            """ add tree widget """
2347
            for item in symbols:
2348
                self.itemTreeWidget.addTreeItem(self.itemTreeWidget.root, item)
2346
            #""" add tree widget """
2347
            #for item in symbols:
2348
            #    docData.symbols.append(item)
2349
            #    self.addSvgItemToScene(item)
2350
            #    self.itemTreeWidget.addTreeItem(self.itemTreeWidget.root, item)
2349 2351

  
2350 2352
            for line_no_node in root.find('LINENOS').iter('LINE_NO'):
2351 2353
                line_no = QEngineeringLineNoTextItem.fromXml(line_no_node)
DTI_PID/DTI_PID/RecognitionDialog.py
19 19
from EngineeringUnknownItem import QEngineeringUnknownItem
20 20
from EngineeringErrorItem import QEngineeringErrorItem
21 21
from EngineeringEndBreakItem import QEngineeringEndBreakItem
22
from EngineeringLineItem import QEngineeringLineItem
23
from EngineeringTextItem import QEngineeringTextItem
24
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
25
from LineDetector import LineDetector
22 26
from symbol import Symbol
23 27

  
24 28
from MainWindow import MainWindow
......
413 417
                   
414 418
                    appDocData.imgName = os.path.splitext(os.path.basename(mainRes))[0]
415 419
                else:
416
                    pass
420
                    textItems = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)]
421
                    appDocData.texts.extend(textItems)
422
                    appDocData.allItems.extend(textItems)
423
                    
424
                    lineNoTextItems = [item for item in textItems if type(item) is QEngineeringLineNoTextItem]
425
                    for lineNoTextItem in lineNoTextItems:
426
                        lineNoTextItem.set_property('Freeze', False)
427
                        lineNoTextItem.freeze_item.update_freeze(item.prop('Freeze'))
428
                        lineNoTextItem.explode()
429

  
430
                    for textItem in textItems:
431
                        textItem.owner = None
432
                        worker.graphicsView.scene.removeItem(textItem)
417 433
    
418 434
                worker.updateBatchProgress.emit(len(srcList), 2)
419 435

  
......
439 455
                if isLineChecked:
440 456
                    Worker.recognizeLine(mainRes, listWidget, worker.graphicsView, worker, batch)
441 457
                else:
442
                    pass
458
                    lineItems = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), QEngineeringLineItem)]
459
                    appDocData.lines.extend(lineItems)
460
                    appDocData.allItems.extend(lineItems)
461

  
462
                    for lineItem in lineItems:
463
                        lineItem.owner = None
464
                        for conn in lineItem.connectors:
465
                            conn.connectedItem = None
466
                        worker.graphicsView.scene.removeItem(lineItem)
467

  
468
                    listWidget.addItem('Connecting lines')
469
                    area = appDocData.getArea('Drawing')
470
                    detector = LineDetector(area.img)
471
                    symbols = appDocData.symbols
472
                    configs = appDocData.getConfigs('Line Detector', 'Length to connect line')
473
                    toler = int(configs[0].value) if configs else 20
474
                    if appDocData.lines:
475
                        # connect line to symbol
476
                        try:
477
                            for line in appDocData.lines:
478
                                matches = [symbol for symbol in symbols if symbol.is_connectable(line, toler=toler)]
479
                                for symbol in matches:
480
                                    detector.connectLineToSymbol(line, symbol, toler=5)
481
                        except Exception as ex:
482
                            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
483
                            worker.displayLog.emit(MessageType.Error, message)
484
                        # up to here
485

  
486
                        # connect line to line
487
                        configs = appDocData.getConfigs('Line Detector', 'Length to connect line')
488
                        toler = int(configs[0].value) if configs else 20
489
                        try:
490
                            for line in appDocData.lines:
491
                                matches = [it for it in appDocData.lines if (it is not line) and (not line.isParallel(it))]
492

  
493
                                # get closest line
494
                                selected = []
495
                                for match in matches:
496
                                    dist = [line.distanceTo(match.startPoint()), line.distanceTo(match.endPoint())]
497
                                    if dist[0] < toler or dist[1] < toler:
498
                                        selected.append(match)
499
                                # up to here
500

  
501
                                for match in matches:
502
                                    detector.connectLineToLine(match, line, toler)
503
                        except Exception as ex:
504
                            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
505
                            worker.displayLog.emit(MessageType.Error, message)
506
                        # up to here
443 507

  
444 508
                createUnknownItems(mainRes)
445 509

  
......
1493 1557
        self.ui.recognizeButton.clicked.connect(self.recognizeButtonClicked)
1494 1558
        self.ui.lineCheckBox.stateChanged.connect(self.checkBoxChanged)
1495 1559
        self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxChanged)
1560
        self.ui.checkBoxText.stateChanged.connect(self.checkBoxChanged)
1496 1561
        self.isAccepted = False
1497 1562
        self.batch = batch
1498 1563

  
......
1518 1583
        if checkState is int(Qt.Checked):
1519 1584
            if self.ui.lineCheckBox.isChecked() and not self.ui.checkBoxSymbol.isChecked():
1520 1585
                self.ui.checkBoxSymbol.setCheckState(Qt.Checked)
1586
            elif self.ui.checkBoxText.isChecked() and not self.ui.checkBoxSymbol.isChecked():
1587
                self.ui.checkBoxSymbol.setCheckState(Qt.Checked)
1521 1588
        elif checkState is int(Qt.Unchecked):
1522 1589
            if self.ui.lineCheckBox.isChecked() and not self.ui.checkBoxSymbol.isChecked():
1523 1590
                self.ui.lineCheckBox.setCheckState(Qt.Unchecked)
1591
            elif self.ui.checkBoxText.isChecked() and not self.ui.checkBoxSymbol.isChecked():
1592
                self.ui.checkBoxText.setCheckState(Qt.Unchecked)
1524 1593

  
1525 1594

  
1526 1595
    '''
......
1542 1611
        @author     humkyung
1543 1612
        @history    humkyung 2018.10.05 clear imgSrc before recognizing
1544 1613
        """ 
1545
        if self.ui.checkBoxSymbol.isChecked() or self.ui.checkBoxText.isChecked():# or self.ui.lineCheckBox.isChecked():
1614
        if self.ui.checkBoxSymbol.isChecked():# or self.ui.checkBoxText.isChecked() or self.ui.lineCheckBox.isChecked():
1546 1615
            appDocData = AppDocData.instance()
1547 1616
            appDocData.imgSrc = None
1548 1617
            area = appDocData.getArea('Drawing')

내보내기 Unified diff

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