개정판 db9cf83a
pixel_to_mm 진행중
픽셀 * 2.54(inch) / DIP
DIP 는 96으로 가정 한다.
Change-Id: I16b856372087e60bd944944c3858742b82a38d13
DTI_PID/DTI_PID/DEXPI/ConvertToUnit.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" This is Extent module """ |
|
3 |
|
|
4 |
|
|
5 |
class ConvertToUnit: |
|
6 |
def __init__(self): |
|
7 |
pass |
|
8 |
|
|
9 |
def pixel_to_mm(p_pixel: int): |
|
10 |
"""https://mainia.tistory.com/4620""" |
|
11 |
DIP = 96 |
|
12 |
value = p_pixel * 2.54 / DIP |
|
13 |
|
|
14 |
str_value = "0" |
|
15 |
|
|
16 |
if value == 0: |
|
17 |
str_value = str(0) |
|
18 |
else: |
|
19 |
str_value = str(value) |
|
20 |
|
|
21 |
return str_value |
DTI_PID/DTI_PID/DEXPI/Extent.py | ||
---|---|---|
5 | 5 |
from PyQt5.QtWidgets import * |
6 | 6 |
from SymbolSvgItem import SymbolSvgItem |
7 | 7 |
|
8 |
from .ConvertToUnit import ConvertToUnit |
|
8 | 9 |
|
9 | 10 |
class Extent: |
10 | 11 |
def __init__(self): |
... | ... | |
22 | 23 |
rect = scene.itemsBoundingRect() |
23 | 24 |
|
24 | 25 |
_min = SubElement(_node, 'Min') |
25 |
_min.attrib['X'] = str(int(rect.left())) |
|
26 |
_min.attrib['Y'] = str(int(rect.top())) |
|
26 |
_min_X = int(rect.left()) |
|
27 |
_min_Y = int(rect.top()) |
|
28 |
_min.attrib['X'] = ConvertToUnit.pixel_to_mm(_min_X) |
|
29 |
_min.attrib['Y'] = ConvertToUnit.pixel_to_mm(_min_Y) |
|
27 | 30 |
_min.attrib['Z'] = '0' |
28 | 31 |
_max = SubElement(_node, 'Max') |
29 |
_max.attrib['X'] = str(int(rect.right())) |
|
30 |
_max.attrib['Y'] = str(int(rect.bottom())) |
|
32 |
_max_X = int(rect.right()) |
|
33 |
_max_Y = int(rect.bottom()) |
|
34 |
_max.attrib['X'] = ConvertToUnit.pixel_to_mm(_max_X) |
|
35 |
_max.attrib['Y'] = ConvertToUnit.pixel_to_mm(_max_Y) |
|
31 | 36 |
_max.attrib['Z'] = '0' |
32 | 37 |
|
33 | 38 |
return _node |
DTI_PID/DTI_PID/DEXPI/formatter.py | ||
---|---|---|
11 | 11 |
from .Extent import Extent |
12 | 12 |
from .ShapeCatalogue import ShapeCatalogue |
13 | 13 |
from .Equipment import Equipment |
14 |
from .ConvertToUnit import ConvertToUnit |
|
14 | 15 |
|
15 | 16 |
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..\\Shapes')) |
16 | 17 |
|
... | ... | |
43 | 44 |
node.attrib['Date'] = today.strftime("%Y-%m-%d") |
44 | 45 |
node.attrib['Time'] = datetime.now().strftime('%H:%M:%S') |
45 | 46 |
node.attrib['Is3D'] = 'no' |
46 |
node.attrib['Units'] = 'px'
|
|
47 |
node.attrib['Units'] = 'mm'
|
|
47 | 48 |
node.attrib['Discipline'] = 'PID' |
48 |
SubElement(node, 'UnitsOfMeasure').attrib['Distance'] = 'px'
|
|
49 |
SubElement(node, 'UnitsOfMeasure').attrib['Distance'] = 'Millimetre'
|
|
49 | 50 |
xml.append(node) |
50 | 51 |
extent = Extent.to_xml(xml, scene=scene) |
51 | 52 |
|
내보내기 Unified diff