프로젝트

일반

사용자정보

개정판 280e3095

ID280e3095a9b733c1b7d5e3c9e02636084cb53562
상위 a2763748
하위 20da2100

김연진이(가) 5년 이상 전에 추가함

issue #1048: 화면/메뉴/툴바 개발 - 불필요한 코드 삭제

Change-Id: Iac7ba841e64fb927447e706920d70e54fceef3ef

차이점 보기:

HYTOS/HYTOS/Shapes/EngineeringOriginItem.py
13 13
    except ImportError:
14 14
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
15 15

  
16
from EngineeringLineItem import QEngineeringLineItem
17

  
18 16
class QEngineeringOriginItem(QGraphicsEllipseItem):
19 17
    SMALL_SIZE = 10
20 18
    BIG_SIZE = 16
......
37 35

  
38 36
        self.setAcceptHoverEvents(True)
39 37

  
40
        if type(parent) is QEngineeringLineItem:
41
            self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)
42
            self.setAcceptTouchEvents(True)
43

  
44 38
        if self.parent is not None: 
45 39
            self.transfer = Transfer()
46 40
            self.transfer.onPosChanged.connect(parent.onConnectorPosChaned)
......
124 118
        @date       2018.08.28
125 119
    '''
126 120
    def mousePressEvent(self, event):
127
        if type(self.parent) is QEngineeringLineItem:
128
            if event.buttons() == Qt.LeftButton:
129
                self._savedPos = self._loc
130
                self._savedConnectedItem = self.connectedItem
131
                self.grabKeyboard()
132
                
121
    
133 122
        QGraphicsEllipseItem.mousePressEvent(self, event)
134 123

  
135 124
    '''
......
141 130
        import shapely
142 131

  
143 132
        try:
144
            if type(self.parent) is QEngineeringLineItem and self._savedPos is not None:
133
            if self._savedPos is not None:
145 134
                items = [item for item in self.scene().items(event.scenePos()) if item is not self and item is not self.parent and type(item) is not QGraphicsPixmapItem]
146 135

  
147
                if items and type(items[0]) is QEngineeringLineItem:
148
                    length = items[0].length()*0.5
149
                    dir = items[0].perpendicular()
150
                    if self.parent.isHorizontal():
151
                        start = [event.scenePos().x() - dir[0]*length, self.parent.startPoint()[1] - dir[1]*length]
152
                        end = [event.scenePos().x() + dir[0]*length, self.parent.startPoint()[1] + dir[1]*length]
153
                    else:
154
                        start = [self.parent.startPoint()[0] - dir[0]*length, event.scenePos().y() - dir[1]*length]
155
                        end = [self.parent.startPoint()[0] + dir[0]*length, event.scenePos().y() + dir[1]*length]
156

  
157
                    pt = items[0].intersection([start, end])
158
                    if (pt is not None) and (type(pt) == shapely.geometry.point.Point):
159
                        self.setPos((pt.x, pt.y))
160
                        self.connectedItem = items[0]
161
                elif items and type(items[0]) is QEngineeringConnectorItem:
136
                if items and type(items[0]) is QEngineeringConnectorItem:
162 137
                    self.setPos(items[0].center())
163 138
                    
164 139
                    if self.connectedItem is not None:
......
192 167
                    self._underItem.hoverLeaveEvent(event)
193 168
                ## up to here
194 169

  
195
            if type(self.parent) is QEngineeringLineItem:
196
                self._savedPos = None 
197
                self._savedConnectedItem = None
198
                self.transfer.onPosChanged.emit(self)
199 170
        finally:
200 171
            self.ungrabKeyboard()
201 172

  
......
209 180
    def mouseMoveEvent(self, event):
210 181
        import shapely
211 182

  
212
        if type(self.parent) is QEngineeringLineItem and self._savedPos is not None:
183
        if self._savedPos is not None:
213 184
            if event.buttons() == Qt.LeftButton:
214 185
                items = [item for item in self.scene().items(event.scenePos()) if item is not self and item is not self.parent and type(item) is not QGraphicsPixmapItem]
215 186
                ## highlight underitem
......
225 196
                    self._underItem = None
226 197
                ## up to here
227 198

  
228
                if items and self.parent not in items and type(items[0]) is QEngineeringLineItem:
199
                if items and self.parent not in items:
229 200
                    length = items[0].length()*0.5
230 201
                    dir = items[0].perpendicular()
231 202
                    if self.parent.isHorizontal():

내보내기 Unified diff

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