프로젝트

일반

사용자정보

개정판 1f2d866f

ID1f2d866f2fdd38bb7d036048e40e358a622e2e00
상위 9817de32
하위 d2ca6c25

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

issue #901: fix text determine

Change-Id: I373024df4144645f2dc48b72c31ecbf6b96ce6ee

차이점 보기:

DTI_PID/DTI_PID/CodeTables.py
20 20

  
21 21
    def find_starts_with(self, text, size_unit='Inch'):
22 22
        """ find text in table """
23
        if self.name == "NOMINALDIAMETER":
24
            """ uid, code, metric, inch, inchstr, allowable_inch_str, metricstr, allowable_metric_str """
25
            for value in self.values:
26
                if size_unit.upper() == 'INCH':
27
                    tokens = [x for x in value[5].split(',') if x and text.startswith(x)]
28
                    if text.startswidth(value[4]) or tokens: return value[4]
29
                elif size_unit.upper() == 'METRIC':
30
                    tokens = [x for x in value[7].split(',') if x and text.startswith(x)]
31
                    if text.startswidth(value[6]) or tokens: return value[6]
32
        else:
33
            for value in self.values:
34
                if text.startswith(value[1]):
35
                    return value[1], value[1]
36
                else:
37
                    matches = [x for x in value[3] if x and text.startswith(x)]
38
                    if matches: return value[1], matches[0]
23
        try:
24
            if self.name == "NOMINALDIAMETER":
25
                """ uid, code, metric, inch, inchstr, allowable_inch_str, metricstr, allowable_metric_str """
26
                for value in self.values:
27
                    if size_unit.upper() == 'INCH':
28
                        tokens = [x for x in value[5].split(',') if x and text.startswith(x)]
29
                        if text.startswidth(value[4]) or tokens: return value[4]
30
                    elif size_unit.upper() == 'METRIC':
31
                        tokens = [x for x in value[7].split(',') if x and text.startswith(x)]
32
                        if text.startswidth(value[6]) or tokens: return value[6]
33
            else:
34
                for value in self.values:
35
                    if text.startswith(value[1]):
36
                        return value[1], value[1]
37
                    else:
38
                        matches = [x for x in value[3] if x and text.startswith(x)]
39
                        if matches: return value[1], matches[0]
40

  
41
                return None, None
42
        except Exception as ex:
43
            import sys
44
            from App import App
45
            from AppDocData import MessageType
46

  
47
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
48
            App.mainWnd().addMessage.emit(MessageType.Error, message)
39 49

  
40 50
            return None, None
41 51

  
DTI_PID/DTI_PID/NominalPipeSize.py
22 22
        """ find given text starts with """
23 23

  
24 24
        for pipe_size in self.pipe_sizes:
25
            found = pipe_size.find_starts_with(text, size_unit)
26
            if found: return found
25
            found, origin = pipe_size.find_starts_with(text, size_unit)
26
            if found: return found, origin
27 27

  
28
        return None
28
        return None, None
29 29

  
30 30
    @property
31 31
    def pipe_sizes(self):
......
80 80

  
81 81
    def find_starts_with(self, value, size_unit='Inch'):
82 82
        """ find text start with """
83
        if size_unit.upper() == 'INCH':
84
            if value.startswith(self.inchStr):
85
                return self.inchStr, self.inchStr
83
        try:
84
            if size_unit.upper() == 'INCH':
85
                if value.startswith(self.inchStr):
86
                    return self.inchStr, self.inchStr
87
                else:
88
                    matches = [x for x in self.allowable_inch_str.split(',') if value.startswith(x)]
89
                    if matches: return self.inchStr, matches[0]
90
            elif size_unit.upper() == 'METRIC':
91
                if value.startswith(self.metricStr):
92
                    return self.metricStr, self.metricStr
93
                else:
94
                    matches = [x for x in self.allowable_metric_str.split(',') if value.startswith(x)]
95
                    if matches: return self.metricStr, matches[0]
86 96
            else:
87
                matches = [x for x in self.allowable_inch_str.split(',') if value.startswith(x)]
88
                if matches: return self.inchStr, matches[0]
89
        elif size_unit.upper() == 'METRIC':
90
            if value.startswith(self.metricStr):
91
                return self.metricStr, self.metricStr
92
            else:
93
                matches = [x for x in self.allowable_metric_str.split(',') if value.startswith(x)]
94
                if matches: return self.metricStr, matches[0]
95
        else:
96
            if value.startswith(self.inchStr):
97
                return self.inchStr, self.inchStr
98
            elif value.startswith(self.metricStr):
99
                return self.metricStr, self.metricStr
100
            else:
101
                matches = [x for x in self.allowable_inch_str.split(',') if value.startswith(x)]
102
                if matches: return self.inchStr, matches[0]
103

  
104
                matches = [x for x in self.allowable_metric_str.split(',') if value.startswith(x)]
105
                if matches: return self.metricStr, matches[0]
106

  
107
        return None, None
97
                if value.startswith(self.inchStr):
98
                    return self.inchStr, self.inchStr
99
                elif value.startswith(self.metricStr):
100
                    return self.metricStr, self.metricStr
101
                else:
102
                    matches = [x for x in self.allowable_inch_str.split(',') if value.startswith(x)]
103
                    if matches: return self.inchStr, matches[0]
104

  
105
                    matches = [x for x in self.allowable_metric_str.split(',') if value.startswith(x)]
106
                    if matches: return self.metricStr, matches[0]
107

  
108
            return None, None
109
        except Exception as ex:
110
            import sys
111
            from App import App
112
            from AppDocData import MessageType
113

  
114
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
115
            App.mainWnd().addMessage.emit(MessageType.Error, message)
116

  
117
            return None, None
108 118

  
109 119
    def toSql(self):
110 120
        """ generate sql string to insert database """
DTI_PID/DTI_PID/RecognitionDialog.py
24 24
from EngineeringTextItem import QEngineeringTextItem
25 25
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
26 26
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
27
from QEngineeringOPCItem import QEngineeringOPCItem
27 28
from LineDetector import LineDetector
28 29
from symbol import Symbol
29 30

  
......
513 514
                        worker.graphicsView.scene.removeItem(lineItem)
514 515

  
515 516
                # check opc validate
517
                '''
516 518
                try:
517
                    pass
519
                    invalid_opcs = []
520
                    for symbol in [item for item in app_doc_data.symbols if type(item) is QEngineeringOPCItem]:
521
                        invalid = True
522
                        for text in app_doc_data.texts:
523
                            if symbol.includes(text):
524
                                invalid = False
525
                                break
526
                        if invalid:
527
                            invalid_opcs.append(symbol)
528
                    
529
                    for index in reversed(range(len(app_doc_data.symbols))):
530
                        for invalid_opc in invalid_opcs:
531
                            if app_doc_data.symbols[index] is invalid_opc:
532
                                app_doc_data.symbols.pop(app_doc_data.symbols.index(invalid_opc))
533
                                app_doc_data.allItems.pop(app_doc_data.allItems.index(invalid_opc))
534
                                #invalid_opc.transfer.onRemoved.emit(invalid_opc)
535
                                break
536

  
518 537
                except Exception as ex:
519 538
                        message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[
520 539
                            -1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
521 540
                        worker.displayLog.emit(MessageType.Error, message)
541
                '''
522 542

  
523 543
                # connect symbol to symbol
524 544
                try:
DTI_PID/DTI_PID/Shapes/QEngineeringOPCItem.py
57 57
        """ return To value """
58 58
        return ''
59 59

  
60
    def includes(self, item):
61
        topLeft = [item.loc[0], item.loc[1]]
62
        bottomRight = [item.loc[0] + item.size[0], item.loc[1] + item.size[1]]
63
        if self.contains(topLeft) and self.contains(bottomRight):
64
            return True
65
        else:
66
            return False
67

  
68
    def contains(self, pt):
69
        minX = self.loc[0]
70
        minY = self.loc[1]
71
        maxX = minX + self.size[0]
72
        maxY = minY + self.size[1]
73

  
74
        if pt[0] < minX: return False
75
        if pt[0] > maxX: return False
76
        if pt[1] < maxY: return False
77
        if pt[1] > minY: return False
78

  
79
        return True
80

  
60 81
    '''
61 82
        @brief  connect attribute
62 83
        @author humkyung

내보내기 Unified diff

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