개정판 dee3eade
add text fixed size
Change-Id: I201fb0eaeeb5a49033515a96684a9c3b5326ec76
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
689 | 689 |
self.ui.label_47.hide() |
690 | 690 |
self.ui.radioButtonOCRLocal.hide() |
691 | 691 |
self.ui.radioButtonOCRServer.hide() |
692 |
self.ui.spinBoxFontSize.hide() |
|
692 | 693 |
# up to here |
693 | 694 |
except Exception as ex: |
694 | 695 |
from App import App |
DTI_PID/DTI_PID/ImportTextFromCADDialog.py | ||
---|---|---|
1320 | 1320 |
for node in nodes: |
1321 | 1321 |
line_infos.append(node) |
1322 | 1322 |
|
1323 |
configs = app_doc_data.getConfigs('Text Style', 'Font Size') |
|
1324 |
fontSize = int(configs[0].value) if configs else -1 |
|
1325 |
if fontSize != -1: |
|
1326 |
size = {} |
|
1327 |
for text in textInfo: |
|
1328 |
angle = float(text.find('ANGLE').text) if text.find('ANGLE') is not None else 0 |
|
1329 |
width = float(text.find('WIDTH').text) if text.find('WIDTH') is not None else 0 |
|
1330 |
height = float(text.find('HEIGHT').text) if text.find('HEIGHT') is not None else 0 |
|
1331 |
|
|
1332 |
if angle == 0: |
|
1333 |
if height in size: |
|
1334 |
size[height] += 1 |
|
1335 |
else: |
|
1336 |
size[height] = 1 |
|
1337 |
else: |
|
1338 |
if width in size: |
|
1339 |
size[width] += 1 |
|
1340 |
else: |
|
1341 |
size[width] = 1 |
|
1342 |
|
|
1343 |
targetSize, maxCount = 10, 0 |
|
1344 |
for key, value in size.items(): |
|
1345 |
if maxCount < value: |
|
1346 |
targetSize = key |
|
1347 |
|
|
1348 |
for text in textInfo: |
|
1349 |
_text = text.find('VALUE').text |
|
1350 |
angle = float(text.find('ANGLE').text) if text.find('ANGLE') is not None else 0 |
|
1351 |
width = float(text.find('WIDTH').text) if text.find('WIDTH') is not None else 0 |
|
1352 |
height = float(text.find('HEIGHT').text) if text.find('HEIGHT') is not None else 0 |
|
1353 |
|
|
1354 |
multiple = 1 if '\n' not in _text else _text.count('\n') + 1 |
|
1355 |
if angle == 0: |
|
1356 |
text.find('HEIGHT').text = str(targetSize * multiple) |
|
1357 |
else: |
|
1358 |
text.find('WIDTH').text = str(targetSize * multiple) |
|
1359 |
|
|
1323 | 1360 |
id2_xml.write(id2_xml_path, encoding="utf-8", xml_declaration=True) |
1324 | 1361 |
"""up to here""" |
1325 | 1362 |
|
... | ... | |
1570 | 1607 |
|
1571 | 1608 |
loc = self.convert_to_image_coords([float(text_node.attrib['X']), float(text_node.attrib['Y'])]) |
1572 | 1609 |
|
1573 |
text = text_node.text |
|
1610 |
text = text_node.text.strip()
|
|
1574 | 1611 |
if not text.replace(' ', '').replace('\n', ''): |
1575 | 1612 |
return |
1576 | 1613 |
#if text == '-': |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
458 | 458 |
return None |
459 | 459 |
width = text_info.getW() |
460 | 460 |
height = text_info.getH() |
461 |
|
|
462 |
configs = AppDocData.instance().getConfigs('Text Style', 'Font Size') |
|
463 |
fontSize = int(configs[0].value) if configs else -1 |
|
464 |
if fontSize != -1: |
|
465 |
textItems = [item for item in scene.items() if issubclass(type(item), QEngineeringTextItem)] |
|
466 |
if textItems: |
|
467 |
_height = textItems[0].size[1] if textItems[0].angle == 0 else textItems[0].size[0] |
|
468 |
if angle == 0: |
|
469 |
height = _height |
|
470 |
else: |
|
471 |
width = _height |
|
472 |
|
|
461 | 473 |
item = TextItemFactory.instance().createTextItem(text_info) |
462 | 474 |
if item is not None: |
463 | 475 |
item.loc = [x, y] |
DTI_PID/DTI_PID/TextInfo.py | ||
---|---|---|
88 | 88 |
staticmethod |
89 | 89 |
def text_filter(text): |
90 | 90 |
""" fix input text """ |
91 |
text = text.replace('—', '-').replace('--', '-').replace('”', '"').replace(r'%%C', 'Ø') |
|
91 |
text = text.replace('—', '-').replace('--', '-').replace('”', '"').replace(r'%%C', 'Ø').replace(r'%%%', '%')
|
|
92 | 92 |
return text |
내보내기 Unified diff