개정판 eca61950
Add EngineeringTagNoTextItem
DTI_PID/DTI_PID/Shapes/QEngineeringEquipmentItem.py | ||
---|---|---|
35 | 35 |
|
36 | 36 |
rect = self.sceneBoundingRect() |
37 | 37 |
attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem] |
38 |
# check if text locates inside equipment |
|
38 | 39 |
for attr in attrs: |
39 | 40 |
if rect.contains(attr.center()): |
40 | 41 |
self.attrs.append(attr) |
... | ... | |
44 | 45 |
if not self.attrs: |
45 | 46 |
minDist = None |
46 | 47 |
selected = None |
48 |
# get nearest text from equipment |
|
47 | 49 |
for attr in attrs: |
48 | 50 |
dx = attr.center().x() - rect.center().x() |
49 | 51 |
dy = attr.center().y() - rect.center().y() |
DTI_PID/DTI_PID/Shapes/QEngineeringTagNoTextItem.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import os.path |
|
3 |
import sys |
|
4 |
import copy |
|
5 |
try: |
|
6 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
7 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
|
8 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
|
9 |
except ImportError: |
|
10 |
try: |
|
11 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
12 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont |
|
13 |
except ImportError: |
|
14 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
|
15 |
|
|
16 |
from QGraphicsPolylineItem import QGraphicsPolylineItem |
|
17 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
18 |
import QOcrResultDialog |
|
19 |
from AppDocData import AppDocData |
|
20 |
from QEngineeringTextItem import QEngineeringTextItem |
|
21 |
|
|
22 |
class QEngineeringTagNoTextItem(QEngineeringTextItem): |
|
23 |
#removed = pyqtSignal(QGraphicsItem) |
|
24 |
|
|
25 |
def __init__(self, parent=None): |
|
26 |
import uuid |
|
27 |
|
|
28 |
QEngineeringTextItem.__init__(self, parent) |
|
29 |
|
|
30 |
''' |
|
31 |
@brief generate xml code |
|
32 |
@author humkyung |
|
33 |
@date 2018.05.02 |
|
34 |
''' |
|
35 |
def toXml(self, owner, name='TAG NO'): |
|
36 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
37 |
from QEngineeringLineItem import QEngineeringLineItem |
|
38 |
from SymbolSvgItem import SymbolSvgItem |
|
39 |
|
|
40 |
try: |
|
41 |
node = Element('ATTRIBUTE') |
|
42 |
uidNode = Element('UID') |
|
43 |
uidNode.text = str(owner.uid) |
|
44 |
node.append(uidNode) |
|
45 |
|
|
46 |
textNode = Element('NAME') |
|
47 |
textNode.text = 'TAG NO' |
|
48 |
node.append(textNode) |
|
49 |
|
|
50 |
valueNode = Element('VALUE') |
|
51 |
valueNode.text = self.text() |
|
52 |
node.append(valueNode) |
|
53 |
|
|
54 |
anlgeNode = Element('ANGLE') |
|
55 |
anlgeNode.text = str(self.angle) |
|
56 |
node.append(anlgeNode) |
|
57 |
|
|
58 |
rect = self.sceneBoundingRect() |
|
59 |
widthNode = Element('WIDTH') |
|
60 |
widthNode.text = str(rect.width()) |
|
61 |
node.append(widthNode) |
|
62 |
|
|
63 |
heightNode = Element('HEIGHT') |
|
64 |
heightNode.text = str(rect.height()) |
|
65 |
node.append(heightNode) |
|
66 |
except Exception as ex: |
|
67 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
68 |
|
|
69 |
return node |
|
70 |
|
|
71 |
def hoverEnterEvent(self, event): |
|
72 |
pass |
|
73 |
|
|
74 |
def hoverLeaveEvent(self, event): |
|
75 |
pass |
|
76 |
|
|
77 |
def hoverMoveEvent(self, event): |
|
78 |
pass |
DTI_PID/DTI_PID/TextItemFactory.py | ||
---|---|---|
16 | 16 |
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem |
17 | 17 |
from QEngineeringNoteItem import QEngineeringNoteItem |
18 | 18 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
19 |
from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem |
|
19 | 20 |
|
20 | 21 |
class TextItemFactory(SingletonInstane): |
21 | 22 |
def __init__(self): |
... | ... | |
40 | 41 |
item = QEngineeringLineNoTextItem() |
41 | 42 |
elif self.isSizeText(text, sizeDelimiter): |
42 | 43 |
item = QEngineeringSizeTextItem() |
44 |
elif self.isTagNoText(text): |
|
45 |
item = QEngineeringTagNoTextItem() |
|
43 | 46 |
else: |
44 | 47 |
item = QEngineeringTextItem() |
45 | 48 |
except Exception as ex: |
... | ... | |
107 | 110 |
if not matches: return False |
108 | 111 |
|
109 | 112 |
return True |
113 |
|
|
114 |
''' |
|
115 |
@brief check if given text is tag no |
|
116 |
@author humkyung |
|
117 |
@date 2018.05.03 |
|
118 |
''' |
|
119 |
def isTagNoText(self, text): |
|
120 |
docData = AppDocData.instance() |
|
121 |
dataList = docData.getEquipmentDataList() |
|
122 |
matches = [data for data in dataList if data.tagNo == text] |
|
123 |
return (len(matches) > 0) |
|
124 |
|
내보내기 Unified diff