개정판 ffecb5ba
issue #563: add symbol attribute reference type
Change-Id: I8474493ba03f937fd5d61a4c777f5e0495198fd0
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1036 | 1036 |
attr.AttributeType = row['Type'] |
1037 | 1037 |
attr.Length = row['LimitNumber'] |
1038 | 1038 |
attr.IsProp = 5 |
1039 |
attr.Index = -1 |
|
1039 | 1040 |
self._lineNoProperties.append(attr) |
1040 | 1041 |
|
1041 | 1042 |
res = self._lineNoProperties |
... | ... | |
1112 | 1113 |
attr.AttributeType = row['Type'] |
1113 | 1114 |
attr.Length = row['LimitNumber'] |
1114 | 1115 |
attr.IsProp = 5 |
1116 |
attr.Index = -1 |
|
1115 | 1117 |
res.append(attr) |
1116 | 1118 |
self._lineNoPropertiesUID[UID] = res |
1117 | 1119 |
# Catch the exception |
... | ... | |
2255 | 2257 |
attr.Target = attr_old.Target |
2256 | 2258 |
attr.IsProp = attr_old.IsProp |
2257 | 2259 |
attr.Codes = attr_old.Codes |
2260 |
attr.Index = attr_old.Index |
|
2258 | 2261 |
new_attr_without_any_binding_data.append(attr) |
2259 | 2262 |
self._attributeByType[_type] = new_attr_without_any_binding_data |
2260 | 2263 |
|
... | ... | |
2267 | 2270 |
|
2268 | 2271 |
sql = self.project.database.to_sql( |
2269 | 2272 |
'select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], ' |
2270 |
'a.[index], a.[Target], a.[Property] from SymbolAttribute a inner join SymbolType t ' |
|
2273 |
'a.[index], a.[Target], a.[Property], a.[index] from SymbolAttribute a inner join SymbolType t '
|
|
2271 | 2274 |
'on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]') |
2272 | 2275 |
param = (_type,) |
2273 | 2276 |
cursor.execute(sql, param) |
... | ... | |
2282 | 2285 |
attr.Expression = row['Expression'] |
2283 | 2286 |
attr.Target = row['Target'] |
2284 | 2287 |
attr.IsProp = row['Property'] |
2288 |
attr.Index = row['index'] |
|
2285 | 2289 |
attr.Codes = CodeTable.instance('SymbolAttributeCodeTable', symbol_attribute_uid=row['UID']) |
2286 | 2290 |
result.append(attr) |
2287 | 2291 |
# Catch the exception |
... | ... | |
2311 | 2315 |
# Get a cursor object |
2312 | 2316 |
cursor = conn.cursor() |
2313 | 2317 |
|
2314 |
sql = f"select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, Property from " \ |
|
2318 |
sql = f"select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, Property, [index] from " \
|
|
2315 | 2319 |
f"SymbolAttribute where uid = '{UID}'" |
2316 | 2320 |
cursor.execute(sql) |
2317 | 2321 |
rows = cursor.fetchall() |
... | ... | |
2325 | 2329 |
res.Expression = rows[0]['Expression'] |
2326 | 2330 |
res.Target = rows[0]['Target'] |
2327 | 2331 |
res.IsProp = rows[0]['Property'] |
2332 |
res.Index = row[0]['index'] |
|
2328 | 2333 |
# Catch the exception |
2329 | 2334 |
except Exception as ex: |
2330 | 2335 |
from App import App |
... | ... | |
2440 | 2445 |
attr.Expression = row['Expression'] |
2441 | 2446 |
attr.Target = row['Target'] |
2442 | 2447 |
attr.IsProp = row['Property'] |
2448 |
attr.Index = row['index'] |
|
2443 | 2449 |
|
2444 | 2450 |
attrs.append(attr) |
2445 | 2451 |
|
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
570 | 570 |
if attrs is not None: |
571 | 571 |
self.setRowCount(row + len(attrs)) |
572 | 572 |
|
573 |
for key, value in attrs.items():
|
|
573 |
for key, value in sorted(attrs.items(), key=lambda param:int(param[0].Index)):
|
|
574 | 574 |
try: |
575 | 575 |
""" show freeze state """ |
576 | 576 |
checkbox = QCustomCheckBox(self, row, 0) |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
408 | 408 |
|
409 | 409 |
_texts = self.texts() |
410 | 410 |
_symbols = self.symbols() |
411 |
for attr in [_attr for _attr in targetAttrs if _attr.AttributeType != 'Combined']: |
|
411 |
for attr in [_attr for _attr in targetAttrs if _attr.AttributeType != 'Combined' and _attr.AttributeType != 'Reference']:
|
|
412 | 412 |
matches = [_attr for _attr, _ in self.attrs.items() if _attr.UID == attr.UID] |
413 | 413 |
if matches: |
414 | 414 |
if matches[0].AttributeType == 'Spec' and not self.attrs[matches[0]]: |
... | ... | |
476 | 476 |
for match in matches: |
477 | 477 |
attr_name = attr.Expression[(match.start() + 1):(match.end() - 1)] |
478 | 478 |
values = [value for key, value in _attrs.items() if key.Attribute == attr_name] |
479 |
value += attr.Expression[pos:match.start()] + values[0] if values and values[0] else '' |
|
479 |
if not values or not values[0]: |
|
480 |
values = ['\'\''] |
|
481 |
value += attr.Expression[pos:match.start()] + values[0] |
|
480 | 482 |
pos = match.end() |
481 | 483 |
|
482 | 484 |
value += attr.Expression[pos:len(attr.Expression)] |
483 | 485 |
_attrs[attr] = value |
484 | 486 |
"""up to here""" |
485 | 487 |
|
488 |
"""calculate attribute value for Reference type""" |
|
489 |
for attr in [_attr for _attr in targetAttrs if _attr.AttributeType == 'Reference']: |
|
490 |
value, pos = '', 0 |
|
491 |
|
|
492 |
matches = p.finditer(attr.Expression) |
|
493 |
for match in matches: |
|
494 |
attr_name = attr.Expression[(match.start() + 1):(match.end() - 1)] |
|
495 |
values = [value for key, value in _attrs.items() if key.Attribute == attr_name] |
|
496 |
if not values: |
|
497 |
values = [] |
|
498 |
value += attr.Expression[pos:match.start()] + '\'' + values[0] + '\'' |
|
499 |
pos = match.end() |
|
500 |
|
|
501 |
value += attr.Expression[pos:len(attr.Expression)] |
|
502 |
_attrs[attr] = eval(value) if attr.Expression else '' |
|
503 |
"""up to here""" |
|
504 |
|
|
486 | 505 |
for _attr, _value in _attrs.items(): |
487 | 506 |
if _value is None or _value == '': |
488 | 507 |
_attr.AssocItem = None |
DTI_PID/DTI_PID/SymbolAttr.py | ||
---|---|---|
137 | 137 |
self.Length = None |
138 | 138 |
self.AssocItem = None |
139 | 139 |
self.IsProp = 0 # default value is 0, 1 : provided ediable, 2 : provided not ediable, 3 : provided not ediable, 5 : for line no props not in database |
140 |
self.Index = None |
|
140 | 141 |
self.Codes = None |
141 | 142 |
|
142 | 143 |
@staticmethod |
DTI_PID/DTI_PID/SymbolAttrCodeTableDialog.py | ||
---|---|---|
79 | 79 |
symbols = table.item(row, 2).text().split(',') if table.item(row, 3) is not None else [] |
80 | 80 |
newCode = table.item(row, 3).text() if table.item(row, 1) else '' |
81 | 81 |
|
82 |
if symbols: |
|
82 |
texts = [table.item(row, 1).text(), table.item(row, 2).text(), table.item(row, 3).text()] |
|
83 |
if False if len([text for text in texts if text == '']) >= 2 else True: |
|
83 | 84 |
self.code_data.append((uid, code, symbols, newCode)) |
84 | 85 |
|
85 | 86 |
self.isAccepted = True |
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py | ||
---|---|---|
45 | 45 |
|
46 | 46 |
SYMBOL_ATTR_DATA_TYPES = {'Symbol Item': -1, 'Size Text Item': -1, 'Text Item': -1, 'Tag No': -1, |
47 | 47 |
'Valve Oper Code': -1, 'Line Item': -1, 'Comp Item': -1, 'EQ Item': -1, 'Int': 1, |
48 |
'String': 1, 'Combined': 1, 'HMB': -1} |
|
48 |
'String': 1, 'Combined': 1, 'HMB': -1, 'Reference': 1}
|
|
49 | 49 |
LINE_NO_ATTR_TYPES = ['Code Table', 'Int', 'String', 'Symbol'] |
50 | 50 |
|
51 | 51 |
def __init__(self, parent, symbolType = None): |
내보내기 Unified diff