hytos / DTI_PID / DTI_PID / Shapes / EngineeringNozzleItem.py @ 6a9a247d
이력 | 보기 | 이력해설 | 다운로드 (1.92 KB)
1 | 25e0cacb | Gyusu | # 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 | ae297667 | humkyung | def __init__(self, path, uid=None, flip=0): |
16 | 4d9163f7 | humkyung | SymbolSvgItem.__init__(self, None, path, uid, flip=flip) |
17 | 25e0cacb | Gyusu | |
18 | 17e67b4f | esham21 | #self._props = [['Name', None], ['Size', None]]
|
19 | 25e0cacb | Gyusu | |
20 | '''
|
||
21 | @brief getter of property
|
||
22 | @author humkyung
|
||
23 | @date 2018.07.29
|
||
24 | '''
|
||
25 | 17e67b4f | esham21 | '''
|
26 | 25e0cacb | Gyusu | @property
|
27 | def props(self):
|
||
28 | return self._props
|
||
29 | 17e67b4f | esham21 | '''
|
30 | 25e0cacb | Gyusu | |
31 | '''
|
||
32 | @brief connect attribute
|
||
33 | @author humkyung
|
||
34 | @date 2018.07.19
|
||
35 | '''
|
||
36 | 17e67b4f | esham21 | '''
|
37 | 72edf08b | humkyung | def connectAttribute(self, attributes, clear=True):
|
38 | 25e0cacb | Gyusu | from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
|
39 |
|
||
40 | 72edf08b | humkyung | super(QEngineeringNozzleItem, self).connectAttribute(attributes, clear)
|
41 | 25e0cacb | Gyusu |
|
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 | 0819fd28 | esham21 | if selected is not None:
|
64 | self.attrs.append(selected)
|
||
65 | 17e67b4f | esham21 | selected.onwer = self
|
66 | ''' |