프로젝트

일반

사용자정보

개정판 ee195020

IDee1950206c2b754291894fb27ad4d286253d108c
상위 7298f494
하위 e2194a0c, d2179741

백흠경이(가) 5년 이상 전에 추가함

issue #481: apply instrument color

Change-Id: I4f0a257be8b27da189e87eb3c418ceb7ea807093

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringRunItem.py
118 118
        from SymbolSvgItem import SymbolSvgItem
119 119

  
120 120
        try:
121
            # Line 가로, 세로 기준으로 아이템을 묶음 (라인별로)
122
            isVertical = None
123
            lineType = None
124
            itemLists = []
125
            itemList = []
126
            for index in range(len(self.items)):
127
                last = False
128

  
129
                if type(self.items[index]) is QEngineeringLineItem:
130
                    lineVertical = self.items[index].isVertical()
131
                    # Line의 처음 상태 확인 후 저장
132
                    if isVertical == None:
133
                        itemList.append(self.items[index])
134
                        isVertical = lineVertical
135
                        lineType = self.items[index].lineType
136
                    # 속성 확인 다르면 초기화
137
                    elif lineType is not None and lineType != self.items[index].lineType:
138
                        itemLists.append((itemList, isVertical, lineType))
139
                        itemList = []
140
                        isVertical = lineVertical
141
                        lineType = self.items[index].lineType
142
                        itemList.append(self.items[index])
143
                    # Line이 같은 방향이면 저장
144
                    elif isVertical == lineVertical:
145
                        itemList.append(self.items[index])
146
                    # Line이 다른 방향이면 초기화
147
                    else:
148
                        itemLists.append((itemList, isVertical, lineType))
149
                        itemList = []
150
                        isVertical = lineVertical
151
                        lineType = self.items[index].lineType
152
                        itemList.append(self.items[index])
153
                else:
154
                    itemList.append(self.items[index])
155

  
156
                if index == len(self.items) - 1:
157
                    itemLists.append((itemList, isVertical, lineType))
158

  
159
            # Line 별로 라인을 합친 라인을 저장
160
            mergedLines = []
161
            for list in itemLists:
162
                startPoint = []
163
                endPoint = []
164
                # direction의 0 = 낮은 값 -> 높은 값 (좌표 값 기준)
165
                direction = 0
166
                for line in list[0]:
167
                    # 통합 Line의 시작점과 끝점을 구함
168
                    if type(line) is QEngineeringLineItem:
169
                        pt1 = line.startPoint()
170
                        pt2 = line.endPoint()
171
                        if len(startPoint) == 0:
172
                            # vertical 경우
173
                            if list[1]:
174
                                # startPoint가 더 큼
175
                                if pt1[1] > pt2[1]:
176
                                    direction = 1
177
                                # endPoint가 더 큼
178
                                else:
179
                                    direction = 0
180
                            # horizontal 경우
181
                            else:
182
                                if pt1[0] > pt2[0]:
183
                                    direction = 1
184
                                else:
185
                                    direction = 0
186
                        
187
                        # start가 end로 낮은 값에서 높은 값으로
188
                        if direction == 0:
189
                            if list[1]:
190
                                if len(startPoint) == 0:
191
                                    startPoint = pt1 if pt1[1] < pt2[1] else pt2
192
                                    endPoint = pt1 if pt1[1] > pt2[1] else pt2
193
                                else:
194
                                    startPoint = startPoint if startPoint[1] < pt1[1] else pt1
195
                                    startPoint = startPoint if startPoint[1] < pt2[1] else pt2
196
                                    endPoint = endPoint if endPoint[1] > pt1[1] else pt1
197
                                    endPoint = endPoint if endPoint[1] > pt2[1] else pt2
198
                            else:
199
                                if len(startPoint) == 0:
200
                                    startPoint = pt1 if pt1[0] < pt2[0] else pt2
201
                                    endPoint = pt1 if pt1[0] > pt2[0] else pt2
202
                                else:
203
                                    startPoint = startPoint if startPoint[0] < pt1[0] else pt1
204
                                    startPoint = startPoint if startPoint[0] < pt2[0] else pt2
205
                                    endPoint = endPoint if endPoint[0] > pt1[0] else pt1
206
                                    endPoint = endPoint if endPoint[0] > pt2[0] else pt2
207
                        # start가 end로 높은 값에서 낮은 값으로
208
                        else:
209
                            if list[1]:
210
                                if len(startPoint) == 0:
211
                                    startPoint = pt1 if pt1[1] > pt2[1] else pt2
212
                                    endPoint = pt1 if pt1[1] < pt2[1] else pt2
213
                                else:
214
                                    startPoint = startPoint if startPoint[1] > pt1[1] else pt1
215
                                    startPoint = startPoint if startPoint[1] > pt2[1] else pt2
216
                                    endPoint = endPoint if endPoint[1] < pt1[1] else pt1
217
                                    endPoint = endPoint if endPoint[1] < pt2[1] else pt2
218
                            else:
219
                                if len(startPoint) == 0:
220
                                    startPoint = pt1 if pt1[0] > pt2[0] else pt2
221
                                    endPoint = pt1 if pt1[0] < pt2[0] else pt2
222
                                else:
223
                                    startPoint = startPoint if startPoint[0] > pt1[0] else pt1
224
                                    startPoint = startPoint if startPoint[0] > pt2[0] else pt2
225
                                    endPoint = endPoint if endPoint[0] < pt1[0] else pt1
226
                                    endPoint = endPoint if endPoint[0] < pt2[0] else pt2
227

  
228
                # 통합 Line을 추가
229
                if len(startPoint) == 2 and len(endPoint) == 2:
230
                    allLine = QEngineeringLineItem([startPoint, endPoint])
231
                    allLine.lineType = list[2]
232

  
233
                    for line in list[0]:
234
                        if type(line) is QEngineeringLineItem:
235
                            if startPoint[0] == line.startPoint()[0] and startPoint[1] == line.startPoint()[1]:
236
                                if line.connectors[0].connectedItem is None:
237
                                    allLine.connectors[0].connectedItem = None
238
                                elif issubclass(type(line.connectors[0].connectedItem), SymbolSvgItem):
239
                                    allLine.connectors[0].connectedItem = line.connectors[0].connectedItem
240

  
241
                            elif startPoint[0] == line.endPoint()[0] and startPoint[1] == line.endPoint()[1]:
242
                                if line.connectors[1].connectedItem is None:
243
                                    allLine.connectors[0].connectedItem = None
244
                                elif issubclass(type(line.connectors[1].connectedItem), SymbolSvgItem):
245
                                    allLine.connectors[0].connectedItem = line.connectors[1].connectedItem
246
                                
247
                            elif endPoint[0] == line.startPoint()[0] and endPoint[1] == line.startPoint()[1]:
248
                                if line.connectors[0].connectedItem is None:
249
                                    allLine.connectors[1].connectedItem = None
250
                                elif issubclass(type(line.connectors[0].connectedItem), SymbolSvgItem):
251
                                    allLine.connectors[1].connectedItem = line.connectors[0].connectedItem
252

  
253
                            elif endPoint[0] == line.endPoint()[0] and endPoint[1] == line.endPoint()[1]:
254
                                if line.connectors[1].connectedItem is None:
255
                                    allLine.connectors[1].connectedItem = None
256
                                elif issubclass(type(line.connectors[1].connectedItem), SymbolSvgItem):
257
                                    allLine.connectors[1].connectedItem = line.connectors[1].connectedItem
258
                    allLine.uid = '-'
259
                    mergedLines.append(allLine)
260

  
261 121
            node = Element('RUN')
262
            # append merged Line 
263
            mergeNode = Element('MERGEDLINE')
264
            for line in mergedLines:
265
                mergeNode.append(line.toXml())
266
            node.append(mergeNode)
267

  
268 122
            for item in self.items:
269 123
                # skip line item which's connected items are same
270 124
                if (type(item) is QEngineeringLineItem) and (item.connectors[0].connectedItem is item.connectors[1].connectedItem):
......
273 127

  
274 128
                node.append(item.toXml())
275 129

  
276

  
277

  
278 130
        except Exception as ex: 
279
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
131
            from App import App 
132
            from AppDocData import MessageType
133

  
134
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
135
            App.mainWnd().addMessage.emit(MessageType.Error, message)
280 136

  
281 137
        return node

내보내기 Unified diff

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