프로젝트

일반

사용자정보

개정판 9ea6785d

ID9ea6785d736d3dce93efb3e623d0b42586ce67ef
상위 fa332baf
하위 2a6eb268

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

issue #1061: update stream line while equipment is moving

Change-Id: I32caea886fd0f7841f9b45d81faa18289b7990e9

차이점 보기:

HYTOS/HYTOS/Shapes/SymbolSvgItem.py
37 37
        QGraphicsSvgItem.__init__(self)
38 38
        QEngineeringAbstractItem.__init__(self)
39 39

  
40
        self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable|QGraphicsItem.ItemIsMovable)
40
        self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable|QGraphicsItem.ItemIsMovable|QGraphicsItem.ItemSendsGeometryChanges)
41 41

  
42 42
        self.dbUid = None
43 43
        self.uid = uuid.uuid4() if uid is None else uuid.UUID(uid, version=4)
......
312 312

  
313 313
        return True if (pt[0] >= minX and pt[0] <= maxX and pt[1] >= minY and pt[1] <= maxY) else False
314 314

  
315
    '''
316
    def associations(self):
317
        """ return associated instance """
318
        # move to abstractitem
319
        import uuid
320

  
321
        res = []
322
        for key in self._associations.keys():
323
            index = 0
324
            for assoc in self._associations[key]:
325
                # find owner with uid
326
                if assoc and type(assoc) is uuid.UUID:
327
                    matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(assoc)]
328
                    if matches:
329
                        res.append(matches[0]) # TODO: need to update association with instance
330
                        self._associations[key][index] = matches[0]
331
                    index += 1
332
                # up to here
333
                elif assoc:
334
                    res.append(assoc)
335

  
336
        for key in self.attrs.keys():
337
            if type(key.AssocItem) is uuid.UUID:
338
                for assoc in res:
339
                    if str(key.AssocItem) == str(assoc.uid):
340
                        key.AssocItem = assoc
341

  
342
        return res
343

  
344
    def texts(self):
345
        """ return text type of associations """
346
        from EngineeringTextItem import QEngineeringTextItem
347

  
348
        res = []
349
        for text in [x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)]:
350
            consumed = False
351
            for key in list(self.attrs.keys()):
352
                if key.AssocItem and key.AssocItem is text:
353
                    consumed = True
354
            if not consumed:
355
                res.append(text)
356

  
357
        return res
358

  
359
    def symbols(self):
360
        """ return symbol type of associations """
361
        res = []
362
        for symbol in [x for x in self.associations() if issubclass(type(x), SymbolSvgItem)]:
363
            consumed = False
364
            for key in list(self.attrs.keys()):
365
                if key.AssocItem and key.AssocItem is symbol:
366
                    consumed = True
367
            if not consumed:
368
                res.append(symbol)
369

  
370
        return res
371
    '''
372

  
373 315
    def toSql(self):
374 316
        """ convert valve data to sql query """
375 317
        import uuid
......
708 650
    '''
709 651
    def mouseReleaseEvent(self, event):
710 652
        super().mouseReleaseEvent(event)
711
        self.transfer.on_pos_changed.emit(self)
653

  
654
    def itemChange(self, change, value):
655
        """ call signals when item's position is changed """
656
        if change == QGraphicsItem.ItemPositionChange:
657
            self.transfer.on_pos_changed.emit(self)
658
            return value
659
        
660
        return super().itemChange(change, value)
712 661

  
713 662
    def removeSelfAttr(self, attributeName):
714 663
        target = None
......
847 796
            self.reSettingConnetors()
848 797

  
849 798
    '''
850
        @brief      get attribute
851
        @author     humkyung
852
        @date       2018.06.14
853
        @history    kyouho  2018.07.18  Add only attr QEngineeringTextItem
854
    '''
855
    '''
856
    def getAttributes(self):
857
        _attrs = {}
858
        try:
859
            from AppDocData import AppDocData
860
            from EngineeringAbstractItem import QEngineeringAbstractItem
861
            from EngineeringTextItem import QEngineeringTextItem
862
            from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem
863

  
864
            """ get attributes of item from database """
865
            docData = AppDocData.instance()
866
            symbolAttrs = docData.getSymbolAttribute(self.type)
867

  
868
            _texts = self.texts()
869
            _symbols = self.symbols()
870
            for attr in symbolAttrs:
871
                matches = [_attr for _attr,_ in self.attrs.items() if _attr.UID == attr.UID]
872
                if matches:
873
                    attr.Freeze = matches[0].Freeze         ### update freeze value
874
                    attr.AssocItem = matches[0].AssocItem
875
                    _attrs[attr] = self.attrs[matches[0]]   ### copy attribute value
876
                else:
877
                    _attrs[attr] = ''
878
 
879
                if attr.Freeze: continue    ### do not evalulate value if attribute is frozen
880
                if attr.AttributeType == 'Size Text Item' or attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
881
                    at = int(attr.AttrAt)
882
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
883
                    if not attr.AssocItem and len(items) > at:
884
                        attr.AssocItem = items[at]
885
                        item = attr.AssocItem
886
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
887
                    elif attr.AssocItem:
888
                        item = attr.AssocItem
889
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
890
                    else:
891
                        _attrs[attr] = ''
892
                elif attr.AttributeType == 'Symbol Item':
893
                    at = int(attr.AttrAt)
894
                    if not attr.AssocItem and len(_symbols) > at:
895
                        attr.AssocItem = _symbols[at]
896
                        item = attr.AssocItem
897
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
898
                    elif attr.AssocItem:
899
                        item = attr.AssocItem
900
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
901
                    else:
902
                        _attrs[attr] = ''
903
            
904
            self.attrs = _attrs ### assign self.attrs
905
        except Exception as ex:
906
            from App import App 
907
            from AppDocData import MessageType
908

  
909
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
910
            App.mainWnd().addMessage.emit(MessageType.Error, message)
911
        
912
        return self.attrs
913
    '''
914

  
915
    '''
916 799
        @brief      generate xml code
917 800
        @author     humkyung
918 801
        @date       2018.04.23

내보내기 Unified diff

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