프로젝트

일반

사용자정보

개정판 72edf08b

ID72edf08b6ba4c7e33610e759fd25bfa0488afeca
상위 9a5aef6e
하위 55cd1b8b, 083a0460

백흠경이(가) 약 6년 전에 추가함

issue #563: link valve and label

Change-Id: I726e3e19a446571d2bcdd2bed94c4355ddedfd4e

차이점 보기:

DTI_PID/DTI_PID/ConnectAttrDialog.py
36 36
        @author humkyung
37 37
        @date   2018.06.17
38 38
    '''
39
    #pyqtSlot()
40 39
    def procCounter(self): # A slot takes no params
41 40
        from LineNoTracer import connectAttrImpl
42 41

  
DTI_PID/DTI_PID/LineNoTracer.py
407 407
    from LineNoTracer import LineNoTracer
408 408
    from AppDocData import AppDocData
409 409
    from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
410
    from EngineeringInstrumentItem import QEngineeringInstrumentItem
411
    from EngineeringReducerItem import QEngineeringReducerItem
412
    from EngineeringEquipmentItem import QEngineeringEquipmentItem
413
    from QEngineeringOPCItem import QEngineeringOPCItem
414
    from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
410 415

  
411 416
    try:
412 417
        symbols = []
......
438 443
        tracer.execute(worker.displayMessage, worker.updateProgress)
439 444
        # up to here
440 445

  
441
        # connect attribut
446
        # connect attribute
442 447
        texts = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)]
443 448
        for symbol in symbols:
444 449
            try:
......
448 453
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
449 454
                App.mainWnd().addMessage.emit(MessageType.Error, message)
450 455

  
456
        """ try to connect label to valve """
457
        labels = [symbol for symbol in symbols if type(symbol) is QEngineeringInstrumentItem and not symbol.is_connected]
458
        valves = [symbol for symbol in symbols if type(symbol) is not QEngineeringInstrumentItem and type(symbol) is not QEngineeringReducerItem and type(symbol) is not QEngineeringEquipmentItem \
459
            and type(symbol) is not QEngineeringOPCItem and type(symbol) is not QEngineeringSpecBreakItem]
460
        for valve in valves:
461
            valve.connectAttribute(labels, clear=False)
462

  
451 463
        # up to here
452 464
    except Exception as ex:
453
        print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
465
        from App import App 
466
        message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
467
        App.mainWnd().addMessage.emit(MessageType.Error, message)
454 468
    finally:
455
        worker.finished.emit()
469
        worker.finished.emit()
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
74 74
    def owner(self, value):
75 75
        self._owner = value
76 76

  
77
    @property
78
    def is_connected(self):
79
        """ check this is connected to other """
80
        for connector in self.connectors:
81
            if connector.connectedItem: return True
82
        
83
        return False
84

  
77 85
    def validate(self):
78 86
        """
79 87
        validate this
......
165 173
                self._associations[_type].append(item)
166 174
            else:
167 175
                self._associations[_type][at] = item
168
            item.owner = self
176
            #item.owner = self
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py
50 50
        @author humkyung
51 51
        @date   2018.05.03
52 52
    '''
53
    def connectAttribute(self, attributes):
53
    def connectAttribute(self, attributes, clear=True):
54 54
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
55 55

  
56
        self._associations.clear()
56
        if clear:
57
            self.attrs.clear()
58
            self._associations.clear()
57 59

  
58 60
        try:
59 61
            rect = self.sceneBoundingRect()
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py
161 161
        @author humkyung
162 162
        @date   2018.05.06
163 163
    '''
164
    def connectAttribute(self, attributes):
165
        self._associations.clear()
164
    def connectAttribute(self, attributes, clear=True):
165
        if clear:
166
            self.attrs.clear()
167
            self._associations.clear()
166 168

  
167 169
        try:
168 170
            rect = self.sceneBoundingRect()
DTI_PID/DTI_PID/Shapes/EngineeringNozzleItem.py
37 37
        @author humkyung
38 38
        @date   2018.07.19
39 39
    '''
40
    def connectAttribute(self, attributes):
40
    def connectAttribute(self, attributes, clear=True):
41 41
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
42 42

  
43
        self.attrs.clear()
44

  
45
        super(QEngineeringNozzleItem, self).connectAttribute(attributes)
43
        super(QEngineeringNozzleItem, self).connectAttribute(attributes, clear)
46 44

  
47 45
        rect = self.sceneBoundingRect()
48 46
        attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem]
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py
26 26

  
27 27
        self.setZValue(QEngineeringReducerItem.ZVALUE)
28 28

  
29
    def connectAttribute(self, attributes):
30
        """ 
31
        connect attribute of reducer
32
        """
29
    def connectAttribute(self, attributes, clear=True):
30
        """ connect attribute of reducer """
33 31

  
34 32
        super(QEngineeringReducerItem, self).connectAttribute(attributes)
35 33
        
......
52 50
            for attr in symbolAttrs:
53 51
                if attr.AttributeType == 'Size Text Item' or attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
54 52
                    at = int(attr.AttrAt)
55
                    items = [text for text in _texts if QEngineeringAbsractItem.assoc_type(text) == attr.AttributeType]
53
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
56 54
                    if len(items) > at:
57 55
                        item = items[at]
58 56
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
DTI_PID/DTI_PID/Shapes/QEngineeringOPCItem.py
61 61
        @author humkyung
62 62
        @date   2018.05.02
63 63
    '''
64
    def connectAttribute(self, attributes):
64
    def connectAttribute(self, attributes, clear=True):
65 65
        from AppDocData import AppDocData, MessageType
66 66

  
67
        self.attrs.clear()
68
        self._associations.clear()
67
        if clear:
68
            self.attrs.clear()
69
            self._associations.clear()
69 70

  
70 71
        try:
71 72
            rect = self.sceneBoundingRect()
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
611 611
        @date       2018.05.02
612 612
        @history    humkyung 2018.05.09 append only nearest size attribute
613 613
    '''
614
    def connectAttribute(self, attributes):
614
    def connectAttribute(self, attributes, clear=True):
615 615
        import math
616 616
        from EngineeringTextItem import QEngineeringTextItem
617 617
        from QEngineeringSizeTextItem import QEngineeringSizeTextItem
618 618
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
619 619
        from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem
620 620

  
621
        self.attrs.clear()
622
        self._associations.clear()
621
        if clear:
622
            self.attrs.clear()
623
            self._associations.clear()
623 624

  
624 625
        try:
625 626
            dist = max(self.sceneBoundingRect().height(), self.sceneBoundingRect().width())
......
636 637
                        minDist = length
637 638
                        selected = attr
638 639
                elif type(attr) is QEngineeringInstrumentItem:
639
                    isConnected = False
640
                    for connector in attr.connectors:
641
                        if connector.connectedItem is not None:
642
                            isConnected = True
643
                            break
644
                            
645
                    if isConnected == False:
646
                        dx = attr.origin[0] - self.origin[0]
647
                        dy = attr.origin[1] - self.origin[1]
648
                        if math.sqrt(dx*dx + dy*dy) < 200:
649
                            self.add_assoc_item(symbol)
640
                    if not attr.is_connected:
641
                        dx = attr.center().x() - center.x()
642
                        dy = attr.center().y() - center.y()
643
                        if math.sqrt(dx*dx + dy*dy) < dist*2:
644
                            self.add_assoc_item(attr)
650 645

  
651 646
            if selected is not None:
652 647
                self.add_assoc_item(selected)

내보내기 Unified diff

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