프로젝트

일반

사용자정보

개정판 23a1a458

ID23a1a4589f9a86774edcf0b92ef46590ed33377f
상위 fdac1a61
하위 cf21f3ce

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

issue #49: change nomdia determine allowable check first for inch text that has no "

Change-Id: Icf9c91b64eaa42abdf445f01ca0cc9eb11de22a8

차이점 보기:

DTI_PID/DTI_PID/ImportTextFromCADDialog.py
125 125
        height = round(float(textNode.find('Height').text))
126 126
        width = height * len(text) * 2 / 3#round( float(textNode.find('Width').text))
127 127

  
128
        allowed_error = 0.001
128
        allowed_error = 0.01
129 129
        if abs(angle - 1.57) < allowed_error:
130 130
            height, width = width, height
131 131
            loc[0], loc[1] = loc[0] - width, loc[1] - height + width
DTI_PID/DTI_PID/MainWindow.py
344 344
        app_doc_data = AppDocData.instance()
345 345
        project = app_doc_data.getCurrentProject()
346 346
        version = QCoreApplication.applicationVersion()
347
        #title = f"{App.NAME}({version}) - {project.name}:" \
348
        #        f"{app_doc_data.activeDrawing.name if app_doc_data.activeDrawing else ''}"
349
        title = f"{App.NAME} : ID2 " \
347
        title = f"{App.NAME}({version}) - {project.name}:" \
350 348
                f"{app_doc_data.activeDrawing.name if app_doc_data.activeDrawing else ''}"
349
        #title = f"{App.NAME} : ID2 " \
350
        #        f"{app_doc_data.activeDrawing.name if app_doc_data.activeDrawing else ''}"
351 351

  
352 352
        return title
353 353

  
DTI_PID/DTI_PID/NominalPipeSize.py
68 68
        import re
69 69

  
70 70
        if size_unit.upper() == 'INCH' or size_unit.upper() == 'IMPERIAL':
71
            '''
71 72
            # code
72 73
            if value == self.inchStr:
73 74
                return self.inchStr
......
85 86
                        match = re.search(self.allowable_inch_str.split(',')[0], value, re.DOTALL)
86 87
                        if match and match.start() is 0 and match.end() is len(value):
87 88
                            return self.inchStr
89
            '''
90
            # allowable
91
            matches = [x for x in self.allowable_inch_str.split(',') if x and value == x]
92
            if matches:
93
                return self.inchStr
94
            else:
95
                if self.allowable_inch_str.split(',')[0]:
96
                    match = re.search(self.allowable_inch_str.split(',')[0], value, re.DOTALL)
97
                    if match and match.start() is 0 and match.end() is len(value):
98
                        return self.inchStr
99
            
100
            # code
101
            if value == self.inchStr:
102
                return self.inchStr
103
            else:
104
                match = re.search(self.inchStr, value, re.DOTALL)
105
                if match and match.start() is 0 and match.end() is len(value):
106
                    return value
88 107

  
89 108
        elif size_unit.upper() == 'METRIC':
90 109
            # code
......
117 136
        import re
118 137
        try:
119 138
            if size_unit.upper() == 'INCH' or size_unit.upper() == 'IMPERIAL':
139
                '''
120 140
                # code
121 141
                if value.startswith(self.inchStr):
122 142
                    return self.inchStr, self.inchStr
......
134 154
                            match = re.search(self.allowable_inch_str.split(',')[0], value, re.DOTALL)
135 155
                            if match and match.start() is 0:
136 156
                                return self.inchStr, value[:match.end()]
157
                '''
158
                # allowable
159
                matches = [x for x in self.allowable_inch_str.split(',') if x and value.startswith(x)]
160
                if matches:
161
                    return self.inchStr, matches[0]
162
                else:
163
                    if self.allowable_inch_str.split(',')[0]:
164
                        match = re.search(self.allowable_inch_str.split(',')[0], value, re.DOTALL)
165
                        if match and match.start() is 0:
166
                            return self.inchStr, value[:match.end()]
167
                
168
                # code
169
                if value.startswith(self.inchStr):
170
                    return self.inchStr, self.inchStr
171
                else:
172
                    match = re.search(self.inchStr, value, re.DOTALL)
173
                    if match and match.start() is 0:
174
                        return value[:match.end()], value[:match.end()]
137 175
                
138 176
            elif size_unit.upper() == 'METRIC':
139 177
                if value.startswith(self.metricStr):
DTI_PID/DTI_PID/OcrResultDialog.py
123 123
            self.textInfoList.append(text_info)
124 124
            self.display_text_rect()
125 125

  
126
            allowed_error = 0.001
126
            allowed_error = 0.01
127 127
            if abs(self._text_item.angle - 1.57) < allowed_error or abs(self._text_item.angle - 4.71) < allowed_error:
128 128
                self.rotateImage(False)
129 129

  
DTI_PID/DTI_PID/QtImageViewer.py
635 635

  
636 636
            matches = [item for item in scene.items() if
637 637
                    (type(item) is QEngineeringLineItem) and (item.distanceTo((scenePos.x(), scenePos.y())) < 20)]
638
            allowed_error = 0.00001
638
            allowed_error = 0.0001
639 639
            if False:  # len(matches) == 1:
640 640
                matches[0].insertSymbol(svg, scenePos)
641 641
            elif len(connectors) == 1 and len(svg.connectors) >= 2 and len(connectors[0].parentItem().connectors):
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
205 205

  
206 206
    def texts(self):
207 207
        """ return text type of associations """
208
        from EngineeringTextItem import QEngineeringTextItem
209

  
210 208
        res = []
211 209

  
212
        for text in sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)],
213
                           key=lambda attr: attr.loc[1]):
210
        for text in self.texts_order():
214 211
            consumed = False
215 212
            for key in list(self.attrs.keys()):
216 213
                if key.AssocItem and key.AssocItem is text:
......
220 217

  
221 218
        return res
222 219

  
220
    def texts_order(self):
221
        from EngineeringTextItem import QEngineeringTextItem
222
        
223
        return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)],
224
                           key=lambda attr: attr.loc[1])
225

  
223 226
    def symbols(self):
224 227
        """ return symbol type of associations """
225 228
        from SymbolSvgItem import SymbolSvgItem
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
482 482
            rect = None
483 483
            line_count = self.text().count('\n') if self.text().count('\n') is not 0 else 1
484 484

  
485
            allowed_error = 0.001
485
            allowed_error = 0.01
486 486
            if abs(self.angle - 1.57) < allowed_error:
487 487
                self.angle = 1.57
488 488
            elif abs(self.angle - 4.71) < allowed_error:
DTI_PID/DTI_PID/Shapes/QEngineeringOPCItem.py
144 144
                        attr[1].owner = self
145 145

  
146 146
            #self.associations() # to binding object from scene
147
            if 'Text Item' in self._associations and self._associations['Text Item']:
148
                if 0 == self.angle:
149
                    sorted(self._associations['Text Item'], key=lambda attr: attr.loc[0])                # sort by x coordinate
150
                elif 3.14 == self.angle:
151
                    sorted(self._associations['Text Item'], key=lambda attr: attr.loc[0], reverse=True)  # sort by x coordinate by descending
152
                elif 1.57 == self.angle:
153
                    sorted(self._associations['Text Item'], key=lambda attr: attr.loc[1], reverse=True)  # sort by y coordinate
154
                elif 4.71 == self.angle:
155
                    sorted(self._associations['Text Item'], key=lambda attr: attr.loc[1])                # sort by y coordinate
156 147

  
157 148
        except Exception as ex:
158 149
            from App import App
......
161 152
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
162 153
            App.mainWnd().addMessage.emit(MessageType.Error, message)
163 154

  
155
    def texts_order(self):
156
        from EngineeringTextItem import QEngineeringTextItem
157

  
158
        allowed_error = 0.01
159
        if abs(0 - self.angle) < allowed_error:
160
            return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)], key=lambda attr: attr.loc[1])                # sort by y coordinate
161
        elif abs(3.14 - self.angle) < allowed_error:
162
            return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)], key=lambda attr: attr.loc[1], reverse=True)  # sort by y coordinate by descending
163
        elif abs(1.57 - self.angle) < allowed_error:
164
            return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)], key=lambda attr: attr.loc[0], reverse=True)  # sort by x coordinate by descending
165
        elif abs(4.71 - self.angle) < allowed_error:
166
            return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)], key=lambda attr: attr.loc[0])                # sort by x coordinate
167

  
164 168
    '''
165 169
        @brief  generate xml code for attribute
166 170
        @author humkyung
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
428 428

  
429 429
    def includes(self, pt, margin=0):
430 430
        """return True if symbol contains given point else return False"""
431
        rect = self.sceneBoundingRect()
432
        allowed_error = 0.1
433

  
434
        if abs(rect.x() - 0) <= allowed_error and abs(rect.y() - 0) <= allowed_error:
435
            # when first recognition step, symbols are not in scene(not yet added) therefore cannot use scenebounding rect
436
            minX = self.loc[0] - margin
437
            minY = self.loc[1] - margin
438
            maxX = minX + self.size[0] + margin
439
            maxY = minY + self.size[1] + margin
431
        if hasattr(item, 'sceneBoundingRect'):
432
            rect = item.sceneBoundingRect()
433
            topLeft = QPoint(rect.x(), rect.y())
434
            bottomRight = QPoint(rect.x() + rect.width(), rect.y() + rect.height())
435
            margin_rect = QRect(self.sceneBoundingRect().x() - margin, self.sceneBoundingRect().y() - margin, \
436
                            self.sceneBoundingRect().width() + 2 * margin, self.sceneBoundingRect().height() + 2 * margin)
437
            if margin_rect.contains(topLeft) and margin_rect.contains(bottomRight):
438
                return True
439
            else:
440
                return False
441

  
440 442
        else:
441
            minX = rect.x() - margin
442
            minY = rect.y() - margin
443
            maxX = minX + rect.width() + margin
444
            maxY = minY + rect.height() + margin
443
            pt = item
444
            rect = self.sceneBoundingRect()
445
            allowed_error = 0.1
446

  
447
            if abs(rect.x() - 0) <= allowed_error and abs(rect.y() - 0) <= allowed_error:
448
                # when first recognition step, symbols are not in scene(not yet added) therefore cannot use scenebounding rect
449
                minX = self.loc[0] - margin
450
                minY = self.loc[1] - margin
451
                maxX = minX + self.size[0] + margin
452
                maxY = minY + self.size[1] + margin
453
            else:
454
                minX = rect.x() - margin
455
                minY = rect.y() - margin
456
                maxX = minX + rect.width() + margin
457
                maxY = minY + rect.height() + margin
445 458

  
446
        return True if (pt[0] >= minX and pt[0] <= maxX and pt[1] >= minY and pt[1] <= maxY) else False
459
            return True if (pt[0] >= minX and pt[0] <= maxX and pt[1] >= minY and pt[1] <= maxY) else False
447 460

  
448 461
    '''
449 462
    def associations(self):
DTI_PID/DTI_PID/TextDataListDialog.py
50 50
        self.ui.tableWidget.keyPressEvent = self.keyPressEvent
51 51

  
52 52
        row = 0
53
        allowed_error = 0.001
53
        allowed_error = 0.01
54 54
        for textItem in self.textItems:
55 55
            imageWidget = QTableWidgetItem()
56 56
            textImage = self.graphicsView.image().copy(textItem.loc[0] - 3, textItem.loc[1] - 3, textItem.size[0] + 6,

내보내기 Unified diff

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