프로젝트

일반

사용자정보

개정판 86fc75ab

ID86fc75abce099540de287276ee784234facafaf1
상위 43f6ca32
하위 0f607bdb

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

issue #000: fix LineNoTracer size and oper code association

Change-Id: I974bd6a520d064348a3a5bed47dea7d4ad12b003

차이점 보기:

DTI_PID/DTI_PID/LineNoTracer.py
438 438
    from EngineeringVendorItem import QEngineeringVendorItem
439 439
    from EngineeringEndBreakItem import QEngineeringEndBreakItem
440 440
    from EngineeringReservedWordTextItem import QEngineeringReservedWordTextItem
441
    from QEngineeringSizeTextItem import QEngineeringSizeTextItem
442
    from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem
441 443
    from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem
442 444

  
443 445
    try:
......
512 514
        for valve in valves:
513 515
            valve.connectAttribute(labels, clear=False)
514 516

  
515
        """ try to find reserved word's owner """
517
        """ try to find text item's owner """
516 518
        texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringReservedWordTextItem]
517
        for reservedWord in texts:
518
            reservedWord.findOwner(lines)
519
        for text in texts:
520
            text.findOwner(lines)
521
        texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringSizeTextItem or type(item) is QEngineeringSizeTextItem or type(item) is QEngineeringValveOperCodeTextItem]            
522
        for text in texts:
523
            text.findOwner(symbols)
519 524

  
520 525
        """ update line type """
521 526
        if update_line_type == True:
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py
79 79
            self._associations.clear()
80 80

  
81 81
        try:
82
            configs = AppDocData.instance().getConfigs('Size', 'Delimiter')
83
            delimiter = configs[0].value if configs else 'X'
82
            #configs = AppDocData.instance().getConfigs('Size', 'Delimiter')
83
            #delimiter = configs[0].value if configs else 'X'
84 84
            configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio')
85 85
            ratio = float(configs[0].value) if 1 == len(configs) else 1.5
86 86

  
......
90 90
            minDist = None
91 91
            selected = None
92 92
            for attr in attributes:
93
                if type(attr) is QEngineeringSizeTextItem and (delimiter in attr.text().upper()):
93
                # size text and operation code text will find onwer themselves in findowner method
94
                if False:# type(attr) is QEngineeringSizeTextItem and (delimiter in attr.text().upper()):
94 95
                    dx = attr.center().x() - center.x()
95 96
                    dy = attr.center().y() - center.y()
96 97
                    length = math.sqrt(dx*dx + dy*dy)
DTI_PID/DTI_PID/Shapes/EngineeringValveOperCodeTextItem.py
19 19
from EngineeringPolylineItem import QEngineeringPolylineItem
20 20
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
21 21
import OcrResultDialog
22
from AppDocData import AppDocData
22
from AppDocData import AppDocData, MessageType
23 23
from EngineeringTextItem import QEngineeringTextItem
24
from SymbolSvgItem import SymbolSvgItem
24 25

  
25 26
class QEngineeringValveOperCodeTextItem(QEngineeringTextItem):
26 27
    """
......
30 31
        import uuid
31 32

  
32 33
        QEngineeringTextItem.__init__(self, parent)
33
        self.type = 'VALVE OPER CODE'
34
        self.type = 'VALVE OPER CODE'
35

  
36
    def findOwner(self, symbols):
37
        import math
38

  
39
        try:
40
            minDist = None
41
            selected = None
42

  
43
            configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio')
44
            ratio = float(configs[0].value) if 1 == len(configs) else 1.5
45

  
46
            dist = (self.sceneBoundingRect().height() + self.sceneBoundingRect().width()) * ratio / 2
47
            center = self.sceneBoundingRect().center()
48

  
49
            for symbol in symbols:
50
                if type(symbol) is SymbolSvgItem:                    
51
                    dx = symbol.center().x() - center.x()
52
                    dy = symbol.center().y() - center.y()
53
                    length = math.sqrt(dx*dx + dy*dy)
54
                    if (length < dist) and (minDist is None or length < minDist):
55
                        minDist = length
56
                        selected = symbol
57

  
58
            if selected is not None:
59
                selected.add_assoc_item(self)
60
                self.owner = selected
61

  
62
        except Exception as ex:
63
            from App import App 
64
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
65
            App.mainWnd().addMessage.emit(MessageType.Error, message)
DTI_PID/DTI_PID/Shapes/QEngineeringSizeTextItem.py
16 16
from EngineeringPolylineItem import QEngineeringPolylineItem
17 17
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
18 18
import OcrResultDialog
19
from AppDocData import AppDocData
19
from AppDocData import AppDocData, MessageType
20 20
from EngineeringTextItem import QEngineeringTextItem
21
from SymbolSvgItem import SymbolSvgItem
22
from EngineeringReducerItem import QEngineeringReducerItem
21 23

  
22 24
class QEngineeringSizeTextItem(QEngineeringTextItem):
23 25

  
......
25 27
        import uuid
26 28

  
27 29
        QEngineeringTextItem.__init__(self, parent)
28
        self.type = 'SIZE'
30
        self.type = 'SIZE'
31

  
32
    def findOwner(self, symbols):
33
        import math
34

  
35
        try:
36
            minDist = None
37
            selected = None
38

  
39
            configs = AppDocData.instance().getConfigs('Size', 'Delimiter')
40
            delimiter = configs[0].value.upper() if configs else 'X'
41
            configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio')
42
            ratio = float(configs[0].value) if 1 == len(configs) else 1.5
43

  
44
            dist = (self.sceneBoundingRect().height() + self.sceneBoundingRect().width()) * ratio / 2
45
            center = self.sceneBoundingRect().center()
46

  
47
            for symbol in symbols:
48
                if delimiter in self.text().upper() and type(symbol) is QEngineeringReducerItem:
49
                    dx = symbol.center().x() - center.x()
50
                    dy = symbol.center().y() - center.y()
51
                    length = math.sqrt(dx*dx + dy*dy)
52
                    if (length < dist) and (minDist is None or length < minDist):
53
                        minDist = length
54
                        selected = symbol
55

  
56
                elif not delimiter in self.text().upper() and type(symbol) is SymbolSvgItem:
57
                    dx = symbol.center().x() - center.x()
58
                    dy = symbol.center().y() - center.y()
59
                    length = math.sqrt(dx*dx + dy*dy)
60
                    if (length < dist) and (minDist is None or length < minDist):
61
                        minDist = length
62
                        selected = symbol
63

  
64
            if selected is not None:
65
                selected.add_assoc_item(self)
66
                self.owner = selected
67

  
68
        except Exception as ex:
69
            from App import App 
70
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
71
            App.mainWnd().addMessage.emit(MessageType.Error, message)
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
727 727
        try:
728 728
            configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio')
729 729
            ratio = float(configs[0].value) if 1 == len(configs) else 1.5
730
            
730 731
            dist = max(self.sceneBoundingRect().height(), self.sceneBoundingRect().width()) * ratio
731 732
            center = self.sceneBoundingRect().center()
732 733

  
733 734
            minDist = None
734 735
            selected = None
735 736
            for attr in attributes:
736
                if type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem:
737
                # size text and operation code text will find onwer themselves in findowner method
738
                if False:# type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem:
737 739
                    dx = attr.center().x() - center.x()
738 740
                    dy = attr.center().y() - center.y()
739 741
                    length = math.sqrt(dx*dx + dy*dy)

내보내기 Unified diff

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