프로젝트

일반

사용자정보

개정판 776e52d3

ID776e52d3d043fd8703eb5b61f9234fe39a347c63
상위 2a6eb268
하위 59dac246

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

issue #1047: 객체 삭제

Change-Id: Iafd94789cfd17758802dc2fcb96793d80ca9331f

차이점 보기:

HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py
37 37
            QGraphicsPathItem.__init__(self, parent)
38 38
            QEngineeringAbstractItem.__init__(self)
39 39
            self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)
40
            self.setAcceptHoverEvents(True)
41
            self.setAcceptTouchEvents(True)
40 42

  
41 43
            self.uid = uuid.uuid4() if uid is None else uid
42 44
            self._vertices = []
......
45 47
            self.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) # set default pen
46 48

  
47 49
            self.transfer = Transfer()
50
            self.transfer.onRemoved.connect(self.on_item_removed)
48 51
            self.setZValue(QEngineeringStreamlineItem.ZVALUE)
49 52
        except Exception as ex:
50 53
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
......
227 230
        self.__buildItem()
228 231
        self.update()
229 232
        
233
    def hoverEnterEvent(self, event):
234
        """ hilight item and it's children """
235
        self.highlight(True)
236

  
237
    def hoverLeaveEvent(self, event):
238
        """ unhighlight item """
239
        self.highlight(False)
240

  
241
    def highlight(self, flag):
242
        self.hover = flag 
243
        self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else self.setZValue(QEngineeringStreamlineItem.ZVALUE)
244
        self.update()
245

  
246
    '''
247
        @brief      override paint method
248
        @history    humkyung 2018.08.30 draw flowmark only for Primary or Secondary
249
    '''
250
    def paint(self, painter, option, widget):
251
        if self.isSelected():
252
            hilightColor = QColor(255, 0, 0, 127)
253
            focuspen = QPen(Qt.DotLine)
254
            focuspen.setColor(hilightColor)
255
            focuspen.setWidthF(10)
256
            brush = QBrush(hilightColor, Qt.Dense7Pattern)
257
            painter.setBrush(brush)
258
            painter.setPen(focuspen)
259
        else:
260
            color = self.getColor()
261
            self.setColor(color)
262

  
263
        QGraphicsPathItem.paint(self, painter, option, widget)
264
        
265
    def on_item_removed(self, item): 
266
        """ remove item from scene and then delete it """
267
        if item is self:
268
            for conn in item.connectors:
269
                if conn.connectedItem is not None: conn.connectedItem.connect(None)                
270

  
271
            self.scene().removeItem(item)
272
            del item
273

  
230 274
    '''
231 275
        @brief      Return real item position
232 276
        @authro     Jeongwoo
......
255 299

  
256 300
    def on_symbol_pos_changed(self, symbol):
257 301
        """ rebuild stream line because symbol position is changed """
258
        self.connectors[0].setPos(self.connectors[0].connectedItem.center())
259
        self.connectors[-1].setPos(self.connectors[-1].connectedItem.center())
302
        if self.connectors[0].connectedItem is not None : self.connectors[0].setPos(self.connectors[0].connectedItem.center())
303
        if self.connectors[-1].connectedItem is not None : self.connectors[-1].setPos(self.connectors[-1].connectedItem.center())
260 304
        self.on_connector_pos_changed(None)
261 305

  
262 306
    def on_connector_pos_changed(self, connector):

내보내기 Unified diff

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