개정판 763f6ba0
issue #622:
- change the logic to save line no's attribute to xml
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1499 | 1499 |
self.addSvgItemToScene(item[0]) |
1500 | 1500 | |
1501 | 1501 |
# parse texts |
1502 |
for text in root.iter('ATTRIBUTE'): |
|
1502 |
for text in root.find('TEXTINFOS').iter('ATTRIBUTE'):
|
|
1503 | 1503 |
item = QEngineeringTextItem.fromXml(text) |
1504 | 1504 |
if item is not None: |
1505 | 1505 |
uid = text.find('UID') |
... | ... | |
1540 | 1540 |
|
1541 | 1541 |
QApplication.processEvents() |
1542 | 1542 | |
1543 |
for lineNo in root.iter('LINE_NO'): |
|
1544 |
location = lineNo.find('LOCATION').text if lineNo.find('LOCATION') is not None else '0,0' |
|
1545 |
x = float(location.split(',')[0]) |
|
1546 |
y = float(location.split(',')[1]) |
|
1547 |
width = float(lineNo.find('WIDTH').text) if lineNo.find('WIDTH') is not None else 0 |
|
1548 |
height = float(lineNo.find('HEIGHT').text) if lineNo.find('HEIGHT') is not None else 0 |
|
1549 |
angle = float(lineNo.find('ANGLE').text) if lineNo.find('ANGLE') is not None else 0 |
|
1550 |
text = lineNo.find('TEXT').text |
|
1551 | ||
1552 |
item = TextItemFactory.instance().createTextItem(text) |
|
1543 |
for line_no in root.find('LINENOS').iter('LINE_NO'): |
|
1544 |
item = QEngineeringLineNoTextItem.fromXml(line_no) |
|
1553 | 1545 |
if item is not None: |
1554 |
item.loc = (x, y) |
|
1555 |
item.size = (width, height) |
|
1556 |
item.angle = angle |
|
1557 |
item.setPlainText(text) |
|
1558 | 1546 |
item.transfer.onRemoved.connect(self.itemRemoved) |
1559 | 1547 |
self.addTextItemToScene(item) |
1560 | 1548 | |
1561 |
# attr |
|
1562 |
""" |
|
1563 |
for userInputAttr in lineNo.iter('USERINPUTATTRIBUTE'): |
|
1564 |
newAttr = UserInputAttribute(userInputAttr.find('TYPEUID').text, userInputAttr.find('TYPEVALUE').text) |
|
1565 |
item.attrs.append(newAttr) |
|
1566 |
for attr in lineNo.iter('ATTRIBUTE'): |
|
1567 |
item.attrs[docData.getLinePropertiesByUID(attr.find('UID').text)[0]] = attr.find('VALUE').text |
|
1568 |
""" |
|
1569 |
connLine = lineNo.find('CONNLINE') |
|
1549 |
connLine = line_no.find('CONNLINE') |
|
1570 | 1550 |
if connLine is not None: |
1571 | 1551 |
lineUID = connLine.text |
1572 | 1552 |
connLine = self.graphicsView.findItemByUid(lineUID) |
1573 | 1553 |
if connLine is not None: |
1574 | 1554 |
item.conns.append(connLine) |
1575 | 1555 | |
1576 |
run = lineNo.find('RUN')
|
|
1556 |
run = line_no.find('RUN')
|
|
1577 | 1557 |
if run is not None: |
1578 | 1558 |
lineRunItem = QEngineeringRunItem() |
1579 | 1559 |
for child in run: |
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py | ||
---|---|---|
13 | 13 |
from EngineeringTextItem import QEngineeringTextItem |
14 | 14 |
from UserInputAttribute import UserInputAttribute |
15 | 15 | |
16 |
equipColumnList = ['UID', 'ITEM_NO', 'SERVICE', 'NO_REQ', 'FLUID', 'DESC_OF_PART', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'MATERIAL', 'WEIGHT', 'POWER', 'INSULATION', 'PNID_NO', 'REV'] |
|
17 | ||
18 | 16 |
class QEngineeringEquipmentItem(SymbolSvgItem): |
19 | 17 |
clicked = pyqtSignal(QGraphicsSvgItem) |
20 | 18 |
ZVALUE = 10 |
19 |
EQUIP_COLUMN_LIST = None #['UID', 'ITEM_NO', 'SERVICE', 'NO_REQ', 'FLUID', 'DESC_OF_PART', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'MATERIAL', 'WEIGHT', 'POWER', 'INSULATION', 'PNID_NO', 'REV'] |
|
21 | 20 | |
22 | 21 |
''' |
23 | 22 |
''' |
... | ... | |
25 | 24 |
SymbolSvgItem.__init__(self, path, uid) |
26 | 25 |
self.setZValue(QEngineeringEquipmentItem.ZVALUE) |
27 | 26 | |
27 |
if QEngineeringEquipmentItem.EQUIP_COLUMN_LIST is None: |
|
28 |
from AppDocData import AppDocData |
|
29 | ||
30 |
appDocData = AppDocData.instance() |
|
31 |
QEngineeringEquipmentItem.EQUIP_COLUMN_LIST = appDocData.getColNames('EQUIPMENT_DATA_LIST') |
|
32 | ||
28 | 33 |
''' |
29 | 34 |
@brief connect attribute |
30 | 35 |
@author humkyung |
... | ... | |
184 | 189 |
try: |
185 | 190 |
from AppDocData import AppDocData |
186 | 191 | |
187 |
global equipColumnList |
|
188 | ||
189 | 192 |
docData = AppDocData.instance() |
190 | 193 |
attrs = self.attrs |
191 | 194 | |
192 |
for index in range(len(equipColumnList)):
|
|
195 |
for index in range(len(QEngineeringEquipmentItem.EQUIP_COLUMN_LIST)):
|
|
193 | 196 |
dataList.append('') |
194 | 197 | |
195 | 198 |
dataList[0] = str(self.uid) |
... | ... | |
198 | 201 |
for attr in attrs: |
199 | 202 |
attrInfo = docData.getSymbolAttributeByUID(attr.attribute) |
200 | 203 |
attrName = attrInfo[0] |
201 |
if equipColumnList.count(attrName):
|
|
202 |
colIndex = equipColumnList.index(attrName)
|
|
204 |
if QEngineeringEquipmentItem.EQUIP_COLUMN_LIST.count(attrName):
|
|
205 |
colIndex = QEngineeringEquipmentItem.EQUIP_COLUMN_LIST.index(attrName)
|
|
203 | 206 |
|
204 | 207 |
if type(attr) is UserInputAttribute: |
205 | 208 |
dataList[colIndex] = attr.text if attr.text is not None else '' |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
127 | 127 |
|
128 | 128 |
return _attrs |
129 | 129 | |
130 |
@staticmethod |
|
131 |
def fromXml(node): |
|
132 |
""" |
|
133 |
generate EngineeringLineNoTextItem from xml node |
|
134 |
""" |
|
135 |
from TextItemFactory import TextItemFactory |
|
136 |
from SymbolAttr import SymbolAttr |
|
137 | ||
138 |
item = None |
|
139 | ||
140 |
location = node.find('LOCATION').text if node.find('LOCATION') is not None else '0,0' |
|
141 |
x = float(location.split(',')[0]) |
|
142 |
y = float(location.split(',')[1]) |
|
143 |
width = float(node.find('WIDTH').text) if node.find('WIDTH') is not None else 0 |
|
144 |
height = float(node.find('HEIGHT').text) if node.find('HEIGHT') is not None else 0 |
|
145 |
angle = float(node.find('ANGLE').text) if node.find('ANGLE') is not None else 0 |
|
146 |
text = node.find('TEXT').text |
|
147 | ||
148 |
item = TextItemFactory.instance().createTextItem(text) |
|
149 |
if item is not None: |
|
150 |
for attr_node in node.iter('ATTRIBUTE'): |
|
151 |
attr = SymbolAttr.fromXml(attr_node) |
|
152 |
item.attrs[attr] = attr_node.text |
|
153 | ||
154 |
item.loc = (x, y) |
|
155 |
item.size = (width, height) |
|
156 |
item.angle = angle |
|
157 |
item.setPlainText(text) |
|
158 | ||
159 |
return item |
|
160 | ||
130 | 161 |
''' |
131 | 162 |
@brief generate xml code |
132 | 163 |
@author humkyung |
... | ... | |
179 | 210 |
node.append(run.toXml()) |
180 | 211 | |
181 | 212 |
for key in self.attrs.keys(): |
182 |
attrNode = key.toXml() |
|
183 |
attrNode.text = str(self.attrs[key]) |
|
184 |
node.append(attrNode) |
|
213 |
if key.UID is not None: |
|
214 |
attrNode = key.toXml() |
|
215 |
attrNode.text = str(self.attrs[key]) |
|
216 |
node.append(attrNode) |
|
185 | 217 |
|
186 | 218 |
if self.conns: |
187 | 219 |
connNode = Element('CONNLINE') |
DTI_PID/DTI_PID/SymbolAttr.py | ||
---|---|---|
16 | 16 |
self.Expression = None |
17 | 17 |
self.Length = None |
18 | 18 | |
19 |
@staticmethod |
|
20 |
def fromXml(node): |
|
21 |
""" |
|
22 |
generate SymbolAttr instance from xml node |
|
23 |
""" |
|
24 | ||
25 |
attr = SymbolAttr() |
|
26 |
attr.UID = node.attrib['UID'] |
|
27 |
attr.Attribute = node.attrib['Attribute'] |
|
28 |
attr.DisplayAttribute = node.attrib['DisplayAttribute'] |
|
29 |
attr.AttributeType = node.attrib['AttributeType'] |
|
30 |
attr.AttrAt = node.attrib['AttrAt'] |
|
31 |
attr.Expression = node.attrib['Expression'] |
|
32 |
attr.Length = node.attrib['Length'] |
|
33 | ||
34 |
return attr |
|
35 | ||
19 | 36 |
def toXml(self): |
20 | 37 |
""" |
21 | 38 |
generate xml code for symbol attribute |
... | ... | |
23 | 40 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
24 | 41 | |
25 | 42 |
node = Element('ATTRIBUTE') |
26 |
node.attrib['UID'] = str(self.UID) |
|
27 |
node.attrib['Attribute'] = self.Attribute |
|
28 |
node.attrib['DisplayAttribute'] = self.DisplayAttribute |
|
29 |
node.attrib['AttributeType'] = self.AttributeType |
|
30 |
node.attrib['AttrAt'] = str(self.AttrAt) |
|
31 |
node.attrib['Expression'] = self.Expression |
|
32 |
node.attrib['Length'] = str(self.Length) |
|
43 |
node.attrib['UID'] = str(self.UID) if self.UID is not None else ''
|
|
44 |
node.attrib['Attribute'] = self.Attribute if self.Attribute is not None else ''
|
|
45 |
node.attrib['DisplayAttribute'] = self.DisplayAttribute if self.DisplayAttribute is not None else ''
|
|
46 |
node.attrib['AttributeType'] = self.AttributeType if self.AttributeType is not None else ''
|
|
47 |
node.attrib['AttrAt'] = str(self.AttrAt) if self.AttrAt is not None else ''
|
|
48 |
node.attrib['Expression'] = self.Expression if self.Expression is not None else ''
|
|
49 |
node.attrib['Length'] = str(self.Length) if self.Length is not None else ''
|
|
33 | 50 | |
34 | 51 |
return node |
내보내기 Unified diff