프로젝트

일반

사용자정보

개정판 9c7075ef

ID9c7075ef83874afb895ead139a80d735b56cbc5a
상위 874d67dc
하위 0b31c830

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

fix branch size evaluation

Change-Id: I6412f41d2c67d43ceae1a281aa3553967071b3c1

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
361 361
                res.append(symbol)
362 362

  
363 363
        return res
364
    
365
    def find_connected_objects_size(self, start):
366
        from EngineeringLineItem import QEngineeringLineItem
367
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
368
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
369
        from SymbolSvgItem import SymbolSvgItem
370

  
371
        visited = [start]
372

  
373
        try:
374
            pool = []
375
            pool.append((0, start))
376

  
377
            while len(pool) > 0:
378
                sign, obj = pool.pop()
379

  
380
                match = False
381

  
382
                if issubclass(type(obj), QEngineeringEquipmentItem):
383
                    visited.pop(visited.index(obj))
384
                    continue
385
                elif match:
386
                    continue
387

  
388
                # nextmatches list always has one item
389
                if type(obj) is QEngineeringLineItem:
390
                    symbolMatches = [x.connectedItem for x in obj.connectors if x.connectedItem and issubclass(type(x.connectedItem), SymbolSvgItem) and \
391
                                        (x.connectedItem not in visited) and obj.is_connected(x.connectedItem)]
392
                    lineMatches = [x.connectedItem for x in obj.connectors if x.connectedItem and issubclass(type(x.connectedItem), QEngineeringLineItem) and \
393
                                        x.connectedItem.is_piping() and (x.connectedItem not in visited) and obj.is_connected(x.connectedItem)]
394
                    nextMatches = symbolMatches + lineMatches
395

  
396
                elif issubclass(type(obj), SymbolSvgItem):
397
                    # symbol can be connected with line and another symbol at the same time
398
                    lineMatches = [x.connectedItem for x in obj.connectors if x.connectedItem and issubclass(type(x.connectedItem), QEngineeringLineItem) and \
399
                                        x.connectedItem.is_piping() and (x.connectedItem not in visited) and obj.is_connected(x.connectedItem)]
400
                    symbolMatches = [x.connectedItem for x in obj.connectors if x.connectedItem and issubclass(type(x.connectedItem), SymbolSvgItem) and \
401
                                        (x.connectedItem not in visited) and obj.is_connected(x.connectedItem)]
402
                    nextMatches = symbolMatches + lineMatches
403

  
404
                    if len(visited) > 1: # symbol must pass straight, choose one if connected items are more than 2
405
                        matches = [x for x in visited if obj.is_connected(x)]
406
                        if matches:
407
                            next_connected = [x for x in nextMatches if obj.next_connected(x, matches[0])]
408

  
409
                            if next_connected:
410
                                nextMatches = next_connected
411
                            else:
412
                                nextMatches = []
413

  
414
                # order connected objects
415
                matches = []
416
                matches.extend(nextMatches)
417

  
418
                if sign == 0 and len(matches) > 1:
419
                    mid = int(len(matches) * 0.5)
420
                    lhs = matches[0:mid]
421
                    rhs = matches[mid:]
422
                elif sign == -1:
423
                    lhs = matches
424
                    rhs = []
425
                else:
426
                    lhs = []
427
                    rhs = matches
428

  
429
                for match in lhs:
430
                    pool.append((-1, match))
431
                    visited.insert(0, match)
432

  
433
                for match in rhs:
434
                    pool.append((1, match))
435
                    visited.append(match)
436
                # up to here
437

  
438
        except Exception as ex:
439
            from App import App
440
            from AppDocData import MessageType
441

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

  
446
        return visited
364 447

  
365 448
    @property
366 449
    def Size(self):
......
444 527

  
445 528
                if self.owner.runs and self in self.owner.runs[0].items:
446 529
                    self.sizeDepth = 0
447
                    return self.owner.Size 
530
                    return self.owner.Size
448 531
                elif self.sizeDepth < 2:
532
                    connected_items = self.find_connected_objects_size(self)
533
                    if connected_items:
534
                        res1 = None
535
                        res2 = None
536
                        if type(connected_items[0]) is QEngineeringLineItem:
537
                            connectedItems = [conn.connectedItem for conn in connected_items[0].connectors if conn.connectedItem and conn.connectedItem not in connected_items]
538
                            if connectedItems:
539
                                connectedItems[0].sizeDepth = self.sizeDepth + 1
540
                                res1  = connectedItems[0].EvaluatedSize
541
                        
542
                        if type(connected_items[-1]) is QEngineeringLineItem:
543
                            connectedItems = [conn.connectedItem for conn in connected_items[-1].connectors if conn.connectedItem and conn.connectedItem not in connected_items]
544
                            if connectedItems:
545
                                connectedItems[0].sizeDepth = self.sizeDepth + 1
546
                                res2  = connectedItems[0].EvaluatedSize
547
                                
548
                        if res1 and res2:
549
                            self.sizeDepth = 0
550
                            return res1 if self.inch_to_number(res1) <= self.inch_to_number(res2) else res2
551
                        elif res1:
552
                            self.sizeDepth = 0
553
                            return res1
554
                        elif res2:
555
                            self.sizeDepth = 0
556
                            return res2
557
                                
558
                if self.sizeDepth < 2:
449 559
                    matches = [run for run in self.owner.runs if self in run.items]
450 560
                    if matches:
451 561
                        if type(matches[0].items[0]) is QEngineeringLineItem:

내보내기 Unified diff

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