hytos / DTI_PID / DTI_PID / SymbolBase.py @ 25756413
이력 | 보기 | 이력해설 | 다운로드 (6.87 KB)
1 |
OCR_OPTION_NOT_EXEC = 0
|
---|---|
2 |
OCR_OPTION_ALL_FIND = 1
|
3 |
OCR_OPTION_HALF_AND_HALF = 2
|
4 |
|
5 |
from Area import Area |
6 |
|
7 |
|
8 |
class SymbolBase: |
9 |
def __init__(self, sName, sType, threshold = None, minMatchCount = 0 |
10 |
, isDetectOnOrigin = False, rotationCount = 4, ocrOption = OCR_OPTION_NOT_EXEC, isContainChild = 0 |
11 |
, originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None |
12 |
, isExceptDetect = 0, hasInstrumentLabel = 0, uid = None, width = None, height = None, iType = -2, detectFlip = None, text_area=None): |
13 |
self.uid = uid ## Auto increased Unique Id |
14 |
self.sName = sName
|
15 |
self.sType = sType
|
16 |
self.iType = iType
|
17 |
self.threshold = threshold
|
18 |
self.minMatchCount = minMatchCount
|
19 |
self.isDetectOnOrigin = isDetectOnOrigin
|
20 |
self.rotationCount = rotationCount
|
21 |
self.ocrOption = ocrOption
|
22 |
self.isContainChild = isContainChild
|
23 |
self.originalPoint = originalPoint
|
24 |
self.connectionPoint = connectionPoint
|
25 |
self.baseSymbol = baseSymbol
|
26 |
self.additionalSymbol = additionalSymbol
|
27 |
self.isExceptDetect = isExceptDetect
|
28 |
self.hasInstrumentLabel = hasInstrumentLabel
|
29 |
self.detectFlip = detectFlip
|
30 |
self._owner = None |
31 |
self.width = width
|
32 |
self.height = height
|
33 |
|
34 |
self.text_area = None |
35 |
if type(text_area) is str and text_area: |
36 |
text_area = text_area.split('/')
|
37 |
self.text_area = []
|
38 |
for area_str in text_area: |
39 |
area = Area('Text Area')
|
40 |
area.parse(area_str) |
41 |
self.text_area.append(area)
|
42 |
else:
|
43 |
self.text_area = text_area
|
44 |
|
45 |
self._pixmap = None |
46 |
|
47 |
@property
|
48 |
def pixmap(self): |
49 |
return self._pixmap |
50 |
|
51 |
@pixmap.setter
|
52 |
def pixmap(self, value): |
53 |
self._pixmap = value
|
54 |
|
55 |
def setUid(self, uid): |
56 |
self.uid = uid
|
57 |
|
58 |
def getUid(self): |
59 |
return self.uid |
60 |
|
61 |
def setName(self, sName): |
62 |
self.sName = sName
|
63 |
|
64 |
def getName(self): |
65 |
return self.sName |
66 |
|
67 |
def setType(self, type): |
68 |
self.sType = type |
69 |
|
70 |
def getType(self): |
71 |
return self.sType |
72 |
|
73 |
'''
|
74 |
@brief getter of owner
|
75 |
@author humkyung
|
76 |
@date 2018.07.20
|
77 |
'''
|
78 |
@property
|
79 |
def owner(self): |
80 |
return self._owner |
81 |
|
82 |
'''
|
83 |
@brief setter of owner
|
84 |
@author humkyung
|
85 |
@date 2018.07.20
|
86 |
'''
|
87 |
@owner.setter
|
88 |
def owner(self, value): |
89 |
self._owner = value
|
90 |
|
91 |
def getPath(self): |
92 |
import os |
93 |
from AppDocData import AppDocData |
94 |
|
95 |
return os.path.join(AppDocData.instance().getCurrentProject().getImageFilePath(), self.sType, self.sName + ".png") |
96 |
|
97 |
def setThreshold(self, threshold): |
98 |
self.threshold = threshold
|
99 |
|
100 |
def getThreshold(self): |
101 |
return self.threshold |
102 |
|
103 |
def setMinMatchCount(self, minMatchCount): |
104 |
self.minMatchCount = minMatchCount
|
105 |
|
106 |
def getMinMatchCount(self): |
107 |
return self.minMatchCount |
108 |
|
109 |
def setIsDetectOnOrigin(self, isDetectOnOrigin): |
110 |
self.isDetectOnOrigin = isDetectOnOrigin
|
111 |
|
112 |
def getIsDetectOnOrigin(self): |
113 |
return self.isDetectOnOrigin |
114 |
|
115 |
def setRotationCount(self, rotationCount): |
116 |
self.rotationCount = rotationCount
|
117 |
|
118 |
def getRotationCount(self): |
119 |
return self.rotationCount |
120 |
|
121 |
def setOcrOption(self, ocrOption): |
122 |
self.ocrOption = ocrOption
|
123 |
|
124 |
def getOcrOption(self): |
125 |
return self.ocrOption |
126 |
|
127 |
def setIsContainChild(self, isContainChild): |
128 |
self.isContainChild = isContainChild
|
129 |
|
130 |
def getIsContainChild(self): |
131 |
return self.isContainChild |
132 |
|
133 |
def setOriginalPoint(self, originalPoint): |
134 |
self.originalPoint = originalPoint
|
135 |
|
136 |
def getOriginalPoint(self): |
137 |
return self.originalPoint |
138 |
|
139 |
def parse_connection_pts(self, origin: list) -> list: |
140 |
"""
|
141 |
parse connection points and add origin point
|
142 |
:param origin:
|
143 |
:return: connector points which added by origin
|
144 |
"""
|
145 |
|
146 |
res = [] |
147 |
|
148 |
for param in self.connectionPoint.split('/'): |
149 |
if not param: |
150 |
continue
|
151 |
|
152 |
tokens = param.split(',')
|
153 |
res.append( |
154 |
('AUTO', origin[0] + float(tokens[0]), origin[1] + float(tokens[1]), '0') if len(tokens) == 2 else |
155 |
(tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), '0') if len(tokens) == 3 else |
156 |
(tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), tokens[3])) |
157 |
|
158 |
return res
|
159 |
|
160 |
def setConnectionPoint(self, connectionPoint): |
161 |
self.connectionPoint = connectionPoint
|
162 |
|
163 |
def getConnectionPoint(self): |
164 |
return self.connectionPoint |
165 |
|
166 |
def setBaseSymbol(self, baseSymbol): |
167 |
self.baseSymbol = baseSymbol
|
168 |
|
169 |
def getBaseSymbol(self): |
170 |
return self.baseSymbol |
171 |
|
172 |
def setAdditionalSymbol(self, additionalSymbol): |
173 |
self.additionalSymbol = additionalSymbol
|
174 |
|
175 |
def getAdditionalSymbol(self): |
176 |
return self.additionalSymbol |
177 |
|
178 |
def setIsExceptDetect(self, isExceptDetect): |
179 |
self.isExceptDetect = isExceptDetect
|
180 |
|
181 |
def getIsExceptDetect(self): |
182 |
return self.isExceptDetect |
183 |
|
184 |
def getDetectFlip(self): |
185 |
return self.detectFlip |
186 |
|
187 |
def getText_area(self): |
188 |
return self.text_area |
189 |
|
190 |
@property
|
191 |
def text_area_str(self): |
192 |
return '/'.join([area.toString() for area in self.text_area]) if self.text_area else '' |
193 |
|
194 |
'''
|
195 |
@Auther Yechecol
|
196 |
@Date 2018.07.03
|
197 |
@History hasInstrumentLabel add
|
198 |
'''
|
199 |
def setHasInstrumentLabel(self, hasInstrumentLabel): |
200 |
self.hasInstrumentLabel = hasInstrumentLabel
|
201 |
|
202 |
def getHasInstrumentLabel(self): |
203 |
return self.hasInstrumentLabel |
204 |
|
205 |
'''
|
206 |
@brief Get Image File Full Path
|
207 |
@author Jeongwoo
|
208 |
@date 2018.05.03
|
209 |
'''
|
210 |
def getImageFileFullPath(self): |
211 |
import os |
212 |
|
213 |
from AppDocData import AppDocData |
214 |
project = AppDocData.instance().getCurrentProject() |
215 |
if project is not None: |
216 |
return os.path.join(project.getImageFilePath(), self.getType(), self.getName() + ".png") |
217 |
|
218 |
return None |
219 |
|
220 |
'''
|
221 |
@brief Get Svg File Full Path
|
222 |
@author Jeongwoo
|
223 |
@date 2018.05.03
|
224 |
'''
|
225 |
def getSvgFileFullPath(self): |
226 |
from AppDocData import AppDocData |
227 |
project = AppDocData.instance().getCurrentProject() |
228 |
if project is not None: |
229 |
return project.getSvgFilePath() + "/" + self.getType() + "/" + self.getName() + ".svg" |
230 |
return None |
231 |
|
232 |
|
233 |
class imgLine(): |
234 |
def __init__(self, start, end): |
235 |
self.start = start
|
236 |
self.end = end
|
237 |
|
238 |
def tostring(self): |
239 |
return str(self.start.real) + ',' + str(self.start.imag) + ' ' + str(self.end.real) + ',' + str(self.end.imag) |
240 |
|
241 |
def getStart(self): |
242 |
return self.start |
243 |
|
244 |
def getEnd(self): |
245 |
return self.end |