프로젝트

일반

사용자정보

개정판 d6819cb8

IDd6819cb897c759c8f6a3f1a66ca7b10615054867
상위 e5ba176a
하위 36d003ae

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

issue #000: attr selection add exception

Change-Id: I67e1a3ab8cb242256f19ca9dfb7892954506b401

차이점 보기:

DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py
63 63

  
64 64
                if self._attr is not None and type(self._attr) is SymbolAttr:
65 65
                    item = self.imageViewer.scene().itemAt(scenePos, QTransform())
66
                    if False:#item is not None and self._attr.AttributeType == 'Line Item' and issubclass(type(item), QEngineeringLineItem):
67
                        # unused code
68
                        self._item.conns.clear()
69
                        self._item.conns.append(item)
70
                        self.onSuccess.emit()
71
                    elif item is not None and self._attr.AttributeType == 'CONN' and (issubclass(type(item), QEngineeringLineItem) or issubclass(type(item), SymbolSvgItem) or type(item) is QEngineeringVendorItem or type(item) is QEngineeringReservedWordTextItem):
72
                        self._item.connectors[self._attr.AttrAt - 1].connect(item, QEngineeringAbstractItem.CONNECTED_AT_BODY)
73
                        if type(item) is QEngineeringReservedWordTextItem:
74
                            item.owner = self._item
75
                        self.onSuccess.emit()
76
                    elif item is not None and self._attr.AttributeType == 'CONN' and (type(item) is QEngineeringConnectorItem):
77
                        self._item.connectors[self._attr.AttrAt - 1].connect(item.parent, QEngineeringAbstractItem.CONNECTED_AT_PT)
78
                        self.onSuccess.emit()
79
                    #elif item is not None and issubclass(type(self._item), QEngineeringSpecBreakItem) and self._attr.AttributeType == 'Comp Item' and type(item) is not QGraphicsPixmapItem:
80
                    #    self._item.attrs[self._attr] = str(item.uid)
81
                    #    self.onSuccess.emit()
82
                    elif item is not None and (type(self._item) is not QEngineeringEndBreakItem) and (type(item) is QEngineeringLineNoTextItem) and self._attr.AttributeType == 'OWNER':
83
                        inserted = False
84
                        if item.runs:
85
                            for run in item.runs:
86
                                for index in range(len(run.items)):
87
                                    if run.items[index].is_connected(self._item):
88
                                        if index + 1 != len(run.items) and index != 0 and run.items[index + 1].is_connected(self._item):
89
                                            run.items.insert(index + 1, self._item)
90
                                            inserted = True
91
                                            break
92
                                        elif index + 1 == len(run.items):
93
                                            run.items.append(self._item)
94
                                            inserted = True
95
                                            break
96
                                        elif index == 0:
97
                                            run.items.insert(0, self._item)
98
                                            inserted = True
99
                                            break
100

  
101
                                if inserted:
102
                                    break
103
                            if not inserted:
66
                    if self._item is not item:
67
                        if False:#item is not None and self._attr.AttributeType == 'Line Item' and issubclass(type(item), QEngineeringLineItem):
68
                            # unused code
69
                            self._item.conns.clear()
70
                            self._item.conns.append(item)
71
                            self.onSuccess.emit()
72
                        elif item is not None and self._attr.AttributeType == 'CONN' and (issubclass(type(item), QEngineeringLineItem) or issubclass(type(item), SymbolSvgItem) or type(item) is QEngineeringVendorItem or type(item) is QEngineeringReservedWordTextItem):
73
                            self._item.connectors[self._attr.AttrAt - 1].connect(item, QEngineeringAbstractItem.CONNECTED_AT_BODY)
74
                            if type(item) is QEngineeringReservedWordTextItem:
75
                                item.owner = self._item
76
                            self.onSuccess.emit()
77
                        elif item is not None and self._attr.AttributeType == 'CONN' and (type(item) is QEngineeringConnectorItem):
78
                            self._item.connectors[self._attr.AttrAt - 1].connect(item.parent, QEngineeringAbstractItem.CONNECTED_AT_PT)
79
                            self.onSuccess.emit()
80
                        #elif item is not None and issubclass(type(self._item), QEngineeringSpecBreakItem) and self._attr.AttributeType == 'Comp Item' and type(item) is not QGraphicsPixmapItem:
81
                        #    self._item.attrs[self._attr] = str(item.uid)
82
                        #    self.onSuccess.emit()
83
                        elif item is not None and (type(self._item) is not QEngineeringEndBreakItem) and (type(item) is QEngineeringLineNoTextItem) and self._attr.AttributeType == 'OWNER':
84
                            inserted = False
85
                            if item.runs:
86
                                for run in item.runs:
87
                                    for index in range(len(run.items)):
88
                                        if run.items[index].is_connected(self._item):
89
                                            if index + 1 != len(run.items) and index != 0 and run.items[index + 1].is_connected(self._item):
90
                                                run.items.insert(index + 1, self._item)
91
                                                inserted = True
92
                                                break
93
                                            elif index + 1 == len(run.items):
94
                                                run.items.append(self._item)
95
                                                inserted = True
96
                                                break
97
                                            elif index == 0:
98
                                                run.items.insert(0, self._item)
99
                                                inserted = True
100
                                                break
101

  
102
                                    if inserted:
103
                                        break
104
                                if not inserted:
105
                                    item.runs.append(QEngineeringRunItem())
106
                                    item.runs[-1].items.append(self._item)
107
                                    inserted = True
108
                            else:
104 109
                                item.runs.append(QEngineeringRunItem())
105
                                item.runs[-1].items.append(self._item)
110
                                item.runs[0].items.append(self._item)
106 111
                                inserted = True
107
                        else:
108
                            item.runs.append(QEngineeringRunItem())
109
                            item.runs[0].items.append(self._item)
110
                            inserted = True
111

  
112
                        if inserted:
113
                            if not item.conns and type(self._item) is QEngineeringLineItem:
114
                                item.conns.append(self._item)
112

  
113
                            if inserted:
114
                                if not item.conns and type(self._item) is QEngineeringLineItem:
115
                                    item.conns.append(self._item)
116
                                self._item.owner = item
117
                            self.onSuccess.emit()
118
                        elif item is not None and (type(self._item) is QEngineeringEndBreakItem or issubclass(type(self._item), QEngineeringTextItem)) and (type(item) is QEngineeringLineItem or issubclass(type(item), SymbolSvgItem)) and self._attr.AttributeType == 'OWNER':
115 119
                            self._item.owner = item
116
                        self.onSuccess.emit()
117
                    elif item is not None and (type(self._item) is QEngineeringEndBreakItem or issubclass(type(self._item), QEngineeringTextItem)) and (type(item) is QEngineeringLineItem or issubclass(type(item), SymbolSvgItem)) and self._attr.AttributeType == 'OWNER':
118
                        self._item.owner = item
119
                        self.onSuccess.emit()
120
                    elif item is not None and (self._attr.AttributeType == QEngineeringAbstractItem.assoc_type(item) or \
121
                                                (self._attr.AttributeType == 'Comp Item' and (QEngineeringAbstractItem.assoc_type(item) == 'Symbol Item' or QEngineeringAbstractItem.assoc_type(item) == 'Line Item')) or \
122
                                                (self._attr.AttributeType == 'EQ Item' and QEngineeringAbstractItem.assoc_type(item) == 'EQ Item')):
123
                        if self._attr.Freeze:
124 120
                            self.onSuccess.emit()
125
                            return
126
                            
127
                        if QEngineeringAbstractItem.assoc_type(item) not in self._item._associations:
128
                            self._item._associations[QEngineeringAbstractItem.assoc_type(item)] = []
129

  
130
                        for key in self._item.attrs.keys():
131
                            if key.Attribute == self._attr.Attribute:
132
                                if not key.Codes.values or (key.Codes.values and key.Codes.find_match_exactly(item.text())):
133
                                    key.AssocItem = item
134
                                    self._item.add_assoc_item(item, self._attr.AttrAt, force=True)
135

  
136
                                    # auto freeze when manually attribute setting
137
                                    self._item.getAttributes()  # attr rebinding so old key is not valid
138
                                    for neyKey in self._item.attrs.keys():
139
                                        if neyKey.Attribute == self._attr.Attribute:
140
                                            neyKey.Freeze = True
141
                                            break
142

  
143
                                    if issubclass(type(item), QEngineeringTextItem): item.owner = self._item
144
                                    self.onSuccess.emit()
145
                                    break
121
                        elif item is not None and (self._attr.AttributeType == QEngineeringAbstractItem.assoc_type(item) or \
122
                                                    (self._attr.AttributeType == 'Comp Item' and (QEngineeringAbstractItem.assoc_type(item) == 'Symbol Item' or QEngineeringAbstractItem.assoc_type(item) == 'Line Item')) or \
123
                                                    (self._attr.AttributeType == 'EQ Item' and QEngineeringAbstractItem.assoc_type(item) == 'EQ Item')):
124
                            if self._attr.Freeze:
125
                                self.onSuccess.emit()
126
                                return
127
                                
128
                            if QEngineeringAbstractItem.assoc_type(item) not in self._item._associations:
129
                                self._item._associations[QEngineeringAbstractItem.assoc_type(item)] = []
130

  
131
                            for key in self._item.attrs.keys():
132
                                if key.Attribute == self._attr.Attribute:
133
                                    if not key.Codes.values or (key.Codes.values and key.Codes.find_match_exactly(item.text())):
134
                                        key.AssocItem = item
135
                                        self._item.add_assoc_item(item, self._attr.AttrAt, force=True)
136

  
137
                                        # auto freeze when manually attribute setting
138
                                        self._item.getAttributes()  # attr rebinding so old key is not valid
139
                                        for neyKey in self._item.attrs.keys():
140
                                            if neyKey.Attribute == self._attr.Attribute:
141
                                                neyKey.Freeze = True
142
                                                break
143

  
144
                                        if issubclass(type(item), QEngineeringTextItem): item.owner = self._item
145
                                        self.onSuccess.emit()
146
                                        break
146 147
                elif self._attr is not None and type(self._attr) is SymbolProp:
147 148
                    item = self.imageViewer.scene().itemAt(scenePos, QTransform())
148
                    if item is not None and self._attr.match_type(item):
149
                    if self._item is not item and item is not None and self._attr.match_type(item):
149 150
                        self._item.set_property(self._attr.Attribute, item)
150 151
                        if issubclass(type(item), QEngineeringTextItem): item.owner = self._item
151 152
                        self.onSuccess.emit()

내보내기 Unified diff

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