개정판 cc4ddc30
issue #563: inst new column test
Change-Id: I16a08c6323aca99c2d97e6f957649281264fb8fc
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
2588 | 2588 |
|
2589 | 2589 |
for code in table[3]: |
2590 | 2590 |
sql = self.project.database.to_sql( \ |
2591 |
"insert into InstCodes(UID, Code, Symbols, NewCode, Table_UID) VALUES(?,?,?,?,?)")
|
|
2592 |
param = (code[0], ','.join(code[1]), ','.join(code[2]), code[3], table[0])
|
|
2591 |
"insert into InstCodes(UID, Code, Symbols, Attribute, NewCode, Expression, Priority, Table_UID) VALUES(?,?,?,?,?,?,?,?)")
|
|
2592 |
param = (code[0], ','.join(code[1]), ','.join(code[2]), ','.join(code[3]), code[4], code[5], code[6], table[0])
|
|
2593 | 2593 |
cursor.execute(sql, param) |
2594 | 2594 |
# up to here |
2595 | 2595 |
|
... | ... | |
2709 | 2709 |
sql = "select uid, code, description, Allowables from [{}] where Table_UID='{}' " \ |
2710 | 2710 |
"order by code DESC".format(property, custom_table_uid) |
2711 | 2711 |
elif not symbol_attribute_uid and not custom_table_uid and inst_table_uid: |
2712 |
sql = "select uid, code, symbols, newcode from [{}] where Table_UID='{}' " \
|
|
2712 |
sql = "select uid, code, symbols, attribute, newcode, expression, priority from [{}] where Table_UID='{}' " \
|
|
2713 | 2713 |
"order by code DESC".format(property, inst_table_uid) |
2714 | 2714 |
elif custom: |
2715 | 2715 |
sql = "select uid, code, description, Allowables from CustomCodes \ |
2716 | 2716 |
where table_uid = (select uid from CustomTables where upper(name) like upper('{}'))".format(property) |
2717 | 2717 |
elif inst: |
2718 |
sql = "select uid, code, symbols, newcode from InstCodes \
|
|
2718 |
sql = "select uid, code, symbols, attribute, newcode, expression, priority from InstCodes \
|
|
2719 | 2719 |
where table_uid = (select uid from InstTables where upper(name) like upper('{}'))".format(property) |
2720 | 2720 |
cursor.execute(sql) |
2721 | 2721 |
rows = cursor.fetchall() |
... | ... | |
2730 | 2730 |
# result = None |
2731 | 2731 |
else: |
2732 | 2732 |
for row in rows: |
2733 |
data = (row['uid'], row['code'], row['symbols'], row['newcode'])
|
|
2733 |
data = (row['uid'], row['code'], row['symbols'], row['attribute'], row['newcode'], row['expression'], row['priority'])
|
|
2734 | 2734 |
result.append(data) |
2735 | 2735 |
# Catch the exception |
2736 | 2736 |
except Exception as ex: |
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
358 | 358 |
table.setItem(row, 0, QTableWidgetItem(tableData[0])) # UID |
359 | 359 |
table.setItem(row, 1, QTableWidgetItem(','.join(tableData[1]))) # Code |
360 | 360 |
table.setItem(row, 2, QTableWidgetItem(','.join(tableData[2]))) # Symbols |
361 |
table.setItem(row, 3, QTableWidgetItem(tableData[3])) # New Code |
|
361 |
table.setItem(row, 3, QTableWidgetItem(','.join(tableData[3]))) # Attribute |
|
362 |
table.setItem(row, 4, QTableWidgetItem(tableData[4])) # New Code |
|
363 |
table.setItem(row, 5, QTableWidgetItem(tableData[5])) # Expression |
|
364 |
table.setItem(row, 6, QTableWidgetItem(tableData[6])) # Priority |
|
362 | 365 |
|
363 | 366 |
row += 1 |
364 | 367 |
except Exception as ex: |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
2019 | 2019 |
line_types = [condition.name for condition in LineTypeConditions.items()] |
2020 | 2020 |
|
2021 | 2021 |
new_codes = [] |
2022 |
for value in table.values: |
|
2022 |
for value in table.values: # uid, old code, symbol, attribute, new code, expression, priority
|
|
2023 | 2023 |
# symbol, line type |
2024 |
if not [attr for attr in value[2] if 'attr(' in attr]:
|
|
2024 |
if len(value[3]) == 1 and not value[3][0]:
|
|
2025 | 2025 |
# symbol |
2026 | 2026 |
if not [line_type for line_type in line_types if line_type in value[2]]: |
2027 | 2027 |
for item in items: |
... | ... | |
2031 | 2031 |
dx = item.origin[0] - self.origin[0] |
2032 | 2032 |
dy = item.origin[1] - self.origin[1] |
2033 | 2033 |
length = math.sqrt(dx*dx + dy*dy) |
2034 |
new_codes.append([length, value[3]]) |
|
2034 |
if not value[5]: |
|
2035 |
new_codes.append([length if not value[6] else value[6], value[4]]) |
|
2036 |
else: |
|
2037 |
new_codes.append([length if not value[6] else value[6], eval(value[5])]) |
|
2035 | 2038 |
# line |
2036 | 2039 |
else: |
2037 | 2040 |
types = [conn.connectedItem.lineType for conn in self.connectors if conn.connectedItem and type(conn.connectedItem) is QEngineeringLineItem] |
2038 | 2041 |
if [line_type for line_type in value[2] if line_type in types]: |
2039 |
new_codes.append([0, value[3]]) |
|
2042 |
if not value[5]: |
|
2043 |
new_codes.append([0 if not value[6] else value[6], value[4]]) |
|
2044 |
else: |
|
2045 |
new_codes.append([0 if not value[6] else value[6], eval(value[5])]) |
|
2040 | 2046 |
|
2041 | 2047 |
# self attribute |
2042 |
elif len(value[2]) == 1: |
|
2043 |
attr_value = [attr for attr in value[2] if 'attr(' in attr][0].replace('attr(', '')[:-1] |
|
2048 |
elif len(value[2]) == 1 and not value[2][0] and value[3][0]: |
|
2044 | 2049 |
for key, _value in self.attrs.items(): |
2045 |
if _value == attr_value: |
|
2046 |
new_codes.append([0, value[3]]) |
|
2050 |
if _value in value[3]: |
|
2051 |
if not value[5]: |
|
2052 |
new_codes.append([0 if not value[6] else value[6], value[4]]) |
|
2053 |
else: |
|
2054 |
new_codes.append([0 if not value[6] else value[6], eval(value[5])]) |
|
2047 | 2055 |
|
2048 | 2056 |
# symbol + attribute |
2049 |
elif len(value[2]) == 2:
|
|
2057 |
elif value[2][0] and value[3][0]:
|
|
2050 | 2058 |
for item in items: |
2051 | 2059 |
match = re.search(value[1][0], old_code, re.DOTALL) |
2052 | 2060 |
if (old_code in value[1] or (match and match.start() is 0 and match.end() is len(old_code))) \ |
... | ... | |
2055 | 2063 |
dy = item.origin[1] - self.origin[1] |
2056 | 2064 |
length = math.sqrt(dx*dx + dy*dy) |
2057 | 2065 |
|
2058 |
attr_value = [attr for attr in value[2] if 'attr(' in attr][0].replace('attr(', '')[:-1] |
|
2059 | 2066 |
for key, _value in item.attrs.items(): |
2060 |
if _value == attr_value: |
|
2061 |
new_codes.append([length, value[3]]) |
|
2067 |
if _value in value[3]: |
|
2068 |
if not value[5]: |
|
2069 |
new_codes.append([length if not value[6] else value[6], value[4]]) |
|
2070 |
else: |
|
2071 |
new_codes.append([length if not value[6] else value[6], eval(value[5])]) |
|
2062 | 2072 |
|
2063 | 2073 |
# default |
2064 | 2074 |
for value in table.values: |
2065 |
if old_code in value[1] and len(value[2]) == 1 and value[2][0] == '': |
|
2066 |
new_codes.append([sys.maxsize, value[3]]) |
|
2075 |
if old_code in value[1] and len(value[2]) == 1 and len(value[3]) == 1 and value[2][0] == '' and value[3][0] == '': |
|
2076 |
if not value[5]: |
|
2077 |
new_codes.append([sys.maxsize if not value[6] else value[6], value[4]]) |
|
2078 |
else: |
|
2079 |
new_codes.append([sys.maxsize if not value[6] else value[6], eval(value[5])]) |
|
2067 | 2080 |
|
2068 | 2081 |
if new_codes: |
2069 | 2082 |
return sorted(new_codes, key=lambda param: param[0])[0][1] |
내보내기 Unified diff