프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / DTI_PID / Shapes / EngineeringNozzleItem.py @ 17e67b4f

이력 | 보기 | 이력해설 | 다운로드 (1.92 KB)

1
# coding: utf-8
2

    
3
import sys
4
import os
5
import math
6
from PyQt5.QtGui import *
7
from PyQt5.QtCore import *
8
from PyQt5.QtSvg import *
9
from PyQt5.QtWidgets import (QApplication, QGraphicsItem)
10

    
11
from SymbolSvgItem import SymbolSvgItem
12
from EngineeringConnectorItem import QEngineeringConnectorItem
13

    
14
class QEngineeringNozzleItem(SymbolSvgItem):
15
    def __init__(self, path, uid=None, flip=0):
16
        SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
17

    
18
        #self._props = [['Name', None], ['Size', None]]
19

    
20
    '''
21
        @brief      getter of property
22
        @author     humkyung
23
        @date       2018.07.29
24
    '''
25
    '''
26
    @property
27
    def props(self):
28
        return self._props
29
    '''
30

    
31
    '''
32
        @brief  connect attribute
33
        @author humkyung
34
        @date   2018.07.19
35
    '''
36
    '''
37
    def connectAttribute(self, attributes, clear=True):
38
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
39

40
        super(QEngineeringNozzleItem, self).connectAttribute(attributes, clear)
41

42
        rect = self.sceneBoundingRect()
43
        attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem]
44
        # check if text locates inside equipment
45
        for attr in attrs:
46
            if rect.contains(attr.center()):
47
                self.attrs.append(attr)
48
                attrs.remove(attr)
49
                break
50
        
51
        if not self.attrs:
52
            minDist = None
53
            selected = None
54
            # get nearest text from nozzle 
55
            for attr in attrs:
56
                dx = attr.center().x() - rect.center().x()
57
                dy = attr.center().y() - rect.center().y()
58
                dist = math.sqrt(dx*dx + dy*dy)
59
                if (minDist is None) or (dist < minDist):
60
                    minDist = dist
61
                    selected = attr
62
            
63
            if selected is not None:
64
                self.attrs.append(selected)
65
                selected.onwer = self
66
    '''
클립보드 이미지 추가 (최대 크기: 500 MB)