개정판 aff7c828
issue #1061: 심볼 형상을 데이타베이스에 저장하는 기능 추가
Change-Id: I1cd8a90af3adfc158db39900153e50d8d3a54a75
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
32 | 32 |
18.05.30 Jeongwoo Add self variables (parentSymbol, childSymbol) |
33 | 33 |
''' |
34 | 34 |
|
35 |
def __init__(self, path, uid=None, flip=0): |
|
35 |
def __init__(self, path, uid=None, flip=0, symbol=None):
|
|
36 | 36 |
import uuid |
37 | 37 |
from SymbolAttr import SymbolProp |
38 | 38 |
|
... | ... | |
70 | 70 |
self.transfer = Transfer() |
71 | 71 |
|
72 | 72 |
try: |
73 |
f = QFile(path) |
|
74 |
f.open(QIODevice.ReadOnly) |
|
75 |
array = f.readAll() |
|
73 |
app_doc_data = AppDocData.instance() |
|
74 |
shape = None |
|
75 |
if symbol: |
|
76 |
shape = app_doc_data.read_symbol_shape(app_doc_data.activeDrawing.path, symbol) |
|
77 |
|
|
78 |
if not shape: |
|
79 |
f = QFile(path) |
|
80 |
if f.open(QIODevice.ReadOnly): |
|
81 |
shape = f.readAll() |
|
82 |
f.close() |
|
83 |
|
|
76 | 84 |
self._document = QDomDocument() |
77 |
self._document.setContent(array)
|
|
85 |
self._document.setContent(shape)
|
|
78 | 86 |
self._renderer = QSvgRenderer(self._document.toByteArray()) |
79 | 87 |
self.setSharedRenderer(self._renderer) |
80 | 88 |
|
... | ... | |
86 | 94 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
87 | 95 |
sys.exc_info()[-1].tb_lineno) |
88 | 96 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
89 |
finally: |
|
90 |
f.close() |
|
91 | 97 |
|
92 | 98 |
self.setZValue(SymbolSvgItem.ZVALUE) |
93 | 99 |
self._desc_label = QEngineeringEqpDescTextItem('eqp name<br>pressure drop<br>elevation', self) |
... | ... | |
1021 | 1027 |
svgFilePath = os.path.join(app_doc_data.symbol_file_path, category, _type, name + '.svg') |
1022 | 1028 |
|
1023 | 1029 |
if os.path.isfile(svgFilePath): |
1024 |
item = SymbolSvgItem.createItem(_type, svgFilePath, uid) |
|
1030 |
item = SymbolSvgItem.createItem(_type, svgFilePath, uid, None, 0, dbUid)
|
|
1025 | 1031 |
item.setVisible(False) |
1026 | 1032 |
item.buildItem(name, _type, float(angle), float(scale), pt, origin, connPts, dbUid, pointsUids) |
1027 | 1033 |
item.tag_no = tag_no |
... | ... | |
1043 | 1049 |
''' |
1044 | 1050 |
|
1045 | 1051 |
@staticmethod |
1046 |
def createItem(type, path, uid=None, owner=None, flip=0): |
|
1052 |
def createItem(type, path, uid=None, owner=None, flip=0, symbol=None):
|
|
1047 | 1053 |
import uuid |
1048 | 1054 |
|
1049 |
item = SymbolSvgItem(path, uid, flip=flip) |
|
1055 |
item = SymbolSvgItem(path, uid, flip=flip, symbol=symbol)
|
|
1050 | 1056 |
|
1051 | 1057 |
if owner is not None: |
1052 |
item.owner = uuid.UUID(owner, version=4)
|
|
1058 |
item.owner = uuid.UUID(owner) |
|
1053 | 1059 |
|
1054 | 1060 |
return item |
1055 | 1061 |
|
내보내기 Unified diff