개정판 27b83026
issue #486: remain color
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
161 | 161 |
remainLineNos.append(lineno) |
162 | 162 |
|
163 | 163 |
## lineIndicator |
164 |
extendPixel = 10 |
|
164 | 165 |
for lineIndicator in self._lineIndicator: |
165 | 166 |
maxOverLap = 0 |
166 | 167 |
matchLineNo = None |
... | ... | |
176 | 177 |
if x1 - x2 is 0: |
177 | 178 |
xOverlap = True |
178 | 179 |
w += 1 |
180 |
if not xOverlap: |
|
181 |
continue |
|
179 | 182 |
for y1 in range(reNoRect[1], reNoRect[3] + 1): |
180 | 183 |
for y2 in range(liInRect[1], liInRect[3] + 1): |
181 | 184 |
if y1 - y2 is 0: |
... | ... | |
185 | 188 |
if not xOverlap or not yOverlap: |
186 | 189 |
continue |
187 | 190 |
overLapRate = (w / lineIndicator.boundingRect().width() * 100) if lineIndicator.boundingRect().width() > lineIndicator.boundingRect().height() else (h / lineIndicator.boundingRect().height() * 100) |
188 |
print(overLapRate) |
|
191 |
#print(overLapRate)
|
|
189 | 192 |
if maxOverLap < overLapRate: |
190 | 193 |
maxOverLap = overLapRate |
191 | 194 |
matchLineNo = remainLineNo |
192 |
lineIndicator.setBrush(QBrush(QColor(255, 0, 0, 127))) |
|
195 |
#lineIndicator.setBrush(QBrush(QColor(255, 0, 0, 127)))
|
|
193 | 196 |
|
194 | 197 |
if matchLineNo is not None: |
195 |
print(matchLineNo.text() + ' indicator : ' + str(lineIndicator.boundingRect().x()) + ', ' + str(lineIndicator.boundingRect().y())) |
|
198 |
#print(matchLineNo.text() + ' indicator : ' + str(lineIndicator.boundingRect().x()) + ', ' + str(lineIndicator.boundingRect().y()))
|
|
196 | 199 |
matchLine = None |
197 |
x1, y1, x2, y2 = lineIndicator.otherLine[0], lineIndicator.otherLine[1], lineIndicator.otherLine[2], lineIndicator.otherLine[3]
|
|
198 |
startXorY = (min(liInRect[0], liInRect[2]) - 4) if lineIndicator.isVH == 'V' else (min(liInRect[1], liInRect[3]) - 4)
|
|
199 |
endXorY = (max(liInRect[0], liInRect[2]) - 4) if lineIndicator.isVH == 'V' else (max(liInRect[1], liInRect[3]) - 4)
|
|
200 |
x1, y1, x2, y2 = round(lineIndicator.boundingRect().x() + lineIndicator.otherLine[0]), round(lineIndicator.boundingRect().y() + lineIndicator.otherLine[1]), round(lineIndicator.boundingRect().x() + lineIndicator.otherLine[2]), round(lineIndicator.boundingRect().y() + lineIndicator.otherLine[3])
|
|
201 |
startXorY = (min(liInRect[0], liInRect[2]) - extendPixel) if lineIndicator.isVH == 'V' else (min(liInRect[1], liInRect[3]) - extendPixel)
|
|
202 |
endXorY = (max(liInRect[0], liInRect[2]) + extendPixel) if lineIndicator.isVH == 'V' else (max(liInRect[1], liInRect[3]) + extendPixel)
|
|
200 | 203 |
fXorY = [] |
201 | 204 |
for dXOrdY in range(startXorY, endXorY + 1): # if horizontal -> Y, if vertical -> X |
202 | 205 |
if lineIndicator.isVH == 'V': |
203 |
fXorY.append(((y2-y1)/(x2-x1))*dXOrdY + y1 - ((y2-y1)/(x2-x1))*x1) # f(x)
|
|
206 |
fXorY.append(round(((y2-y1)/(x2-x1))*dXOrdY + y1 - ((y2-y1)/(x2-x1))*x1)) # f(x)
|
|
204 | 207 |
else: |
205 |
fXorY.append(((x2-x1)/(y2-y1))*dXOrdY + x1 - ((x2-x1)/(y2-y1))*x1) # f(y)
|
|
208 |
fXorY.append(round(((x2-x1)/(y2-y1))*dXOrdY + x1 - ((x2-x1)/(y2-y1))*y1)) # f(y)
|
|
206 | 209 |
|
207 | 210 |
for line in self._lines: |
208 | 211 |
axis1Overlap = False |
... | ... | |
211 | 214 |
|
212 | 215 |
if lineIndicator.isVH == 'V': |
213 | 216 |
range11 = range(startXorY, endXorY + 1) |
214 |
range12 = range(lX1, lX2 + 1)
|
|
217 |
range12 = range(min(lX1, lX2), max(lX1, lX2)+ 1)
|
|
215 | 218 |
range21 = fXorY |
216 |
range22 = range(lY1, lY2 + 1)
|
|
219 |
range22 = range(min(lY1, lY2), max(lY1, lY2) + 1)
|
|
217 | 220 |
else: |
218 | 221 |
range11 = range(startXorY, endXorY + 1) |
219 |
range12 = range(lY1, lY2 + 1)
|
|
222 |
range12 = range(min(lY1, lY2), max(lY1, lY2) + 1)
|
|
220 | 223 |
range21 = fXorY |
221 |
range22 = range(lX1, lX2 + 1)
|
|
224 |
range22 = range(min(lX1, lX2), max(lX1, lX2) + 1)
|
|
222 | 225 |
|
223 | 226 |
for axis11 in range11: |
224 | 227 |
for axis12 in range12: |
... | ... | |
226 | 229 |
axis1Overlap = True |
227 | 230 |
break |
228 | 231 |
if axis1Overlap: break |
232 |
if not axis1Overlap: |
|
233 |
continue |
|
229 | 234 |
for axis21 in range21: |
230 | 235 |
for axis22 in range22: |
231 | 236 |
if axis21 - axis22 is 0: |
... | ... | |
238 | 243 |
break |
239 | 244 |
if matchLine is not None: |
240 | 245 |
matchLineNo.conns.append(matchLine) |
241 |
print('connected ' + matchLineNo.text() + 'and ' + matchLine.uid) |
|
246 |
lineIndicator.lineIndicator = 'Match' |
|
247 |
lineIndicator.setBrush(QBrush(QColor(0, 0, 255, 127))) |
|
248 |
#print('connected ' + matchLineNo.text() + ' and ' + matchLine.uid) |
|
242 | 249 |
## up to here |
243 | 250 |
|
244 | 251 |
# set start line's owner |
내보내기 Unified diff