프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / DTI_PID / TextInfo.py @ 30a35908

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

1
# coding: utf-8
2
from PyQt5.QtCore import *
3

    
4

    
5
class TextInfo:
6
    def __init__(self, text, x, y, w, h, angle):
7
        self._text = text
8
        self.text_area = QRect(x, y, w, h)
9
        """
10
        self.x = x
11
        self.y = y
12
        self.w = w
13
        self.h = h
14
        """
15
        self.angle = angle
16

    
17
    @property
18
    def area(self):
19
        """ return area of area """
20
        return self.text_area.width() * self.text_area.height()
21

    
22
    def contains(self, pt):
23
        if len(pt) == 2:
24
            """
25
            if pt[0] < self.x: return False
26
            if pt[0] > self.x + self.w: return False
27
            if pt[1] < self.y: return False
28
            if pt[1] > self.y + self.h: return False
29
            """
30
            return self.text_area.contains(pt[0], pt[1])
31
        elif len(pt) == 4:
32
            """
33
            minx = pt[0]
34
            miny = pt[1]
35
            maxx = pt[2]
36
            maxy = pt[3]
37

38
            if minx < self.x: return False
39
            if maxx > self.x + self.w: return False
40
            if miny < self.y: return False
41
            if maxy > self.y + self.h: return False
42
            """
43
            return self.text_area.contains(QRect(pt[0], pt[1], pt[2] - pt[0], pt[3] - pt[1]))
44

    
45
        return False
46

    
47
    @property
48
    def center(self):
49
        """ return center of text """
50
        return self.text_area.center().x(), self.text_area.center().y()
51

    
52
    def setText(self, text):
53
        self._text = text
54

    
55
    def getText(self):
56
        return self._text
57

    
58
    def setX(self, x):
59
        self.text_area.moveLeft(x)
60

    
61
    def getX(self):
62
        return int(self.text_area.x())
63

    
64
    def setY(self, y):
65
        self.text_area.moveTop(y)
66

    
67
    def getY(self):
68
        return int(self.text_area.y())
69

    
70
    def setW(self, w):
71
        self.text_area.setWidth(w)
72

    
73
    def getW(self):
74
        return int(self.text_area.width())
75

    
76
    def setH(self, h):
77
        self.text_area.setHeight(h)
78

    
79
    def getH(self):
80
        return int(self.text_area.height())
81

    
82
    def setAngle(self, angle):
83
        self.angle = angle
84

    
85
    def getAngle(self):
86
        return self.angle
클립보드 이미지 추가 (최대 크기: 500 MB)