프로젝트

일반

사용자정보

개정판 adec0e4c

IDadec0e4c4eac34be2419bf57f8b89502eb326fcb
상위 6d101ba5
하위 aa9f1081

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

issue #610: 라인의 flow direction을 바꿀때 연결된 아이템의 flow direction도 함께 바꾸도록 개선(revised)

Change-Id: I0039d8fbd58054b52700e860f431de236c4dac69

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringArrowItem.py
3 3

  
4 4
import os.path
5 5
import copy, sys
6

  
6 7
try:
7 8
    from PyQt5.QtCore import *
8 9
    from PyQt5.QtGui import *
......
20 21
"""
21 22
    A {ArrowItem} is the graphical representation of a {Symbol.Arrow}.
22 23
"""
24

  
25

  
23 26
class QEngineeringArrowItem(QGraphicsPolygonItem):
24 27
    """ This is engineering arrow item class """
25 28
    SMALL_SIZE = 10
......
30 33
        """ initialize arrow """
31 34

  
32 35
        QGraphicsPolygonItem.__init__(self, polygon, parent)
33
        #QEngineeringAbstractItem.__init__(self)
36
        # QEngineeringAbstractItem.__init__(self)
34 37

  
35
        self.setFlag(QGraphicsItem.ItemIsSelectable, False) 
36
        self.setFlag(QGraphicsItem.ItemIsFocusable, False) 
37
        self.setFlag(QGraphicsItem.ItemStacksBehindParent, True)
38
        self.setFlag(QGraphicsItem.ItemIsSelectable, False)
39
        self.setFlag(QGraphicsItem.ItemIsFocusable, False)
40
        self.setFlag(QGraphicsItem.ItemStacksBehindParent, True)
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
55 55
            self._flowMark = None
56 56
            configs = AppDocData.instance().getConfigs('Line', 'Default Type')
57 57
            self._lineType = None
58
            self.lineType = configs[0].value if 1 == len(configs) else 'Secondary'  # defulat line type is 'Secondary'
58
            self.lineType = configs[0].value if 1 == len(configs) else 'Secondary'  # default line type is 'Secondary'
59 59

  
60
            self._properties = \
61
                { \
62
                    SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'): None
63
                }
60
            self._properties = {SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'): None}
64 61

  
65 62
            self.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
66 63

  
......
114 111

  
115 112
        return tooltip
116 113

  
117
    '''
118
    @property
119
    def properties(self):
120
        """ getter of flow mark """
121
        import uuid
122

  
123
        for prop, value in self._properties.items():
124
            if prop.is_selectable and type(value) is uuid.UUID and self.scene():
125
                matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)]
126
                if matches: self._properties[prop] = matches[0]
127

  
128
            if prop.Expression: self._properties[prop] = eval(prop.Expression)
129

  
130
        return self._properties
131

  
132
    def set_property(self, property, value):
133
        """ set property with given value """
134
        if issubclass(type(value), QEngineeringAbstractItem): self.add_assoc_item(value, 0)
135
        matches = [prop for prop, _ in self._properties.items() if prop.Attribute == property]
136
        if matches: self._properties[matches[0]] = value
137

  
138
    def prop(self, name):
139
        """ return the value of given property with name """
140
        matches = [(prop, value) for prop, value in self.properties.items() if prop.Attribute == name]
141
        if matches: return matches[0][1]
142

  
143
        return None
144
    '''
145

  
146 114
    @property
147 115
    def Size(self):
148 116
        """ always return None """
......
760 728
        """find all connected items except equipment and instrument"""
761 729
        from EngineeringLineItem import QEngineeringLineItem
762 730
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
763
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
764 731
        from SymbolSvgItem import SymbolSvgItem
765 732

  
766 733
        left_visited, right_visited = [self], [self]
......
772 739
            while left_pool:
773 740
                obj = left_pool.pop()
774 741

  
775
                if issubclass(type(obj), QEngineeringEquipmentItem) or (len(obj.connectors) > 2):
742
                if issubclass(type(obj), QEngineeringEquipmentItem) or (len(obj.connectors) > 2) or \
743
                        not obj.is_connected(left_visited[-1]):
776 744
                    continue
777 745

  
778 746
                left_visited.append(obj)
......
789 757
            while right_pool:
790 758
                obj = right_pool.pop()
791 759

  
792
                if issubclass(type(obj), QEngineeringEquipmentItem) or (len(obj.connectors) > 3):
760
                if issubclass(type(obj), QEngineeringEquipmentItem) or (len(obj.connectors) > 2) or \
761
                        not obj.is_connected(right_visited[-1]):
793 762
                    continue
794 763

  
795 764
                right_visited.append(obj)
......
1820 1789
            self._arrow.setBrush(Qt.blue)
1821 1790
        self._arrow.update()
1822 1791

  
1823
        '''
1824
        if self._flowMark:
1825
            flowMark = self._flowMark[0]
1826
            flowMark.angle = math.atan2(_dir[0], _dir[1]) - math.pi / 2
1827
            flowMark.loc = [self.connectors[1].center()[0] - flowMark.symbolOrigin[0] - _dir[0] * 20, self.connectors[1].center()[1] - flowMark.symbolOrigin[1] - _dir[1] * 20]
1828
            flowMark.origin = [self.connectors[1].center()[0] - _dir[0] * 20, self.connectors[1].center()[1] - _dir[1] * 20]
1829
            scene = flowMark.scene()
1830
            scene.removeItem(flowMark)
1831
            flowMark.addSvgItemToScene(scene)
1832
        '''
1833

  
1834 1792
    def onConnectorPosChaned(self, connector):
1835 1793
        """update line shape when connector is moved"""
1836 1794

  

내보내기 Unified diff

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