개정판 206eb105
issue #1052: 스트림 라인 태그 형상을 기존 HYTOS와 유사하게 수정
Change-Id: I9dd2972bb8a9ee5a1e9ab20e6e6de7e27673170d
HYTOS/HYTOS/Shapes/EngineeringStreamNoTextItem.py | ||
---|---|---|
6 | 6 |
import copy |
7 | 7 |
try: |
8 | 8 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
9 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
|
9 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QPainter, QPolygonF, QBrush, QPen, QTransform, QFont
|
|
10 | 10 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
11 | 11 |
except ImportError: |
12 | 12 |
try: |
... | ... | |
31 | 31 |
self.type = 'STREAM NO' |
32 | 32 |
|
33 | 33 |
font = QFont('Arial', 15) |
34 |
font.setPointSizeF(5)
|
|
34 |
font.setPointSizeF(4)
|
|
35 | 35 |
self.setFont(font) |
36 |
|
|
37 |
def paint(self, painter, option, widget): |
|
38 |
""" override paint method """ |
|
39 |
|
|
40 |
painter.setPen(QPen(Qt.black, 1)) |
|
41 |
painter.drawPolygon(self.create_poly(4, 7, 0)) |
|
42 |
QGraphicsTextItem.paint(self, painter, option, widget) |
|
43 |
|
|
44 |
def create_poly(self, n, r, s): |
|
45 |
import math |
|
46 |
|
|
47 |
rect = self.boundingRect() |
|
48 |
polygon = QPolygonF() |
|
49 |
w = 360 / n # angle per step |
|
50 |
for i in range(n): # add the points of polygon |
|
51 |
t = w * i + s |
|
52 |
x = r * math.cos(math.radians(t)) |
|
53 |
y = r * math.sin(math.radians(t)) |
|
54 |
polygon.append(QPointF(rect.width()*0.5 + x, rect.height()*0.5 + y)) |
|
55 |
|
|
56 |
return polygon |
내보내기 Unified diff