개정판 b4c3e73a
issue #563: symbol attribute code table done, testing
Change-Id: Icc679d26fa75dd045faf18799be184004f204dc6
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
2170 | 2170 |
# Get a cursor object |
2171 | 2171 |
cursor = conn.cursor() |
2172 | 2172 |
|
2173 |
# delete symbol attribute code table data for deleted symbol attribute, and backup not edited attribute code table data
|
|
2173 |
# delete symbol attribute code table data |
|
2174 | 2174 |
origin_attrs = self.getSymbolAttribute(type_str) |
2175 | 2175 |
for origin_attr in origin_attrs: |
2176 |
''' |
|
2177 |
# delete symbol attribute code table data for deleted symbol attribute, and backup not edited attribute code table data |
|
2176 | 2178 |
remain = False |
2177 | 2179 |
for attr in attrs: |
2178 | 2180 |
if str(origin_attr.UID) == attr[0]: |
2179 | 2181 |
remain = True |
2180 | 2182 |
break |
2181 |
if remain and not attr[-1]:
|
|
2183 |
if remain and attr[-1] and type(attr[-1][0][3]) is list: # this means not edited and need backup
|
|
2182 | 2184 |
attr[-1] = self.getCodeTable('SymbolAttributeCodeTable', forCheckLineNumber=False, symbol_attribute_uid=origin_attr.UID) |
2185 |
''' |
|
2183 | 2186 |
|
2184 | 2187 |
sql = "delete from SymbolAttributeCodeTable where SymbolAttribute_UID = '{}'".format(origin_attr.UID) |
2185 | 2188 |
cursor.execute(sql) |
... | ... | |
2204 | 2207 |
for code in attr[-1]: |
2205 | 2208 |
sql = self.project.database.to_sql( \ |
2206 | 2209 |
"insert into SymbolAttributeCodeTable(UID, Code, Description, Allowables, SymbolAttribute_UID) VALUES(?,?,?,?,?)") |
2207 |
param = (code[0], code[1], code[2], code[3], attr[0])
|
|
2210 |
param = (code[0], code[1], code[2], ','.join(code[3]), attr[0])
|
|
2208 | 2211 |
cursor.execute(sql, param) |
2209 | 2212 |
# up to here |
2210 | 2213 |
|
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
217 | 217 |
@date 2018.07.10 |
218 | 218 |
''' |
219 | 219 |
|
220 |
def settingTable(self, tableName, symbol_attribute_uid=None): |
|
220 |
def settingTable(self, tableName, symbol_attribute_uid=None, tableDatas=None):
|
|
221 | 221 |
try: |
222 | 222 |
tableName = self.replaceText(tableName) |
223 | 223 |
docData = AppDocData.instance() |
... | ... | |
226 | 226 |
if tableName == "NominalDiameter": |
227 | 227 |
tableDatas = docData.getNomialPipeSizeData() |
228 | 228 |
elif tableName == "SymbolAttributeCodeTable": |
229 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, symbol_attribute_uid=symbol_attribute_uid) |
|
229 |
if tableDatas is None: |
|
230 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, symbol_attribute_uid=symbol_attribute_uid) |
|
231 |
else: |
|
232 |
pass |
|
230 | 233 |
else: |
231 | 234 |
tableDatas = docData.getCodeTable(tableName) |
232 | 235 |
|
... | ... | |
305 | 308 |
table.setItem(row, 0, QTableWidgetItem(tableData[0])) # UID |
306 | 309 |
table.setItem(row, 1, QTableWidgetItem(tableData[1])) # Name |
307 | 310 |
table.setItem(row, 2, QTableWidgetItem(tableData[2])) # Description |
308 |
table.setItem(row, 3, QTableWidgetItem(tableData[3])) # Allowables |
|
311 |
table.setItem(row, 3, QTableWidgetItem(tableData[3] if type(tableData[3]) is str else ','.join(tableData[3]))) # Allowables
|
|
309 | 312 |
row += 1 |
310 | 313 |
except Exception as ex: |
311 | 314 |
from App import App |
DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py | ||
---|---|---|
98 | 98 |
if QEngineeringAbstractItem.assoc_type(item) not in self._item._associations: |
99 | 99 |
self._item._associations[QEngineeringAbstractItem.assoc_type(item)] = [] |
100 | 100 |
|
101 |
while len(self._item._associations[QEngineeringAbstractItem.assoc_type(item)]) <= self._attr.AttrAt: |
|
102 |
self._item._associations[QEngineeringAbstractItem.assoc_type(item)].append(None) |
|
103 |
self._item.add_assoc_item(item, self._attr.AttrAt, force=True) |
|
104 | 101 |
for key in self._item.attrs.keys(): |
105 | 102 |
if key.Attribute == self._attr.Attribute: |
106 |
key.AssocItem = item |
|
107 |
# auto freeze when manually attribute setting |
|
108 |
self._item.getAttributes() # attr rebinding so old key is not valid |
|
109 |
for neyKey in self._item.attrs.keys(): |
|
110 |
if neyKey.Attribute == self._attr.Attribute: |
|
111 |
neyKey.Freeze = True |
|
112 |
break |
|
113 |
break |
|
114 |
if issubclass(type(item), QEngineeringTextItem): item.owner = self._item |
|
115 |
self.onSuccess.emit() |
|
103 |
if not key.Codes.values or (key.Codes.values and key.Codes.find_match_exactly(item.text())): |
|
104 |
key.AssocItem = item |
|
105 |
self._item.add_assoc_item(item, self._attr.AttrAt, force=True) |
|
106 |
|
|
107 |
# auto freeze when manually attribute setting |
|
108 |
self._item.getAttributes() # attr rebinding so old key is not valid |
|
109 |
for neyKey in self._item.attrs.keys(): |
|
110 |
if neyKey.Attribute == self._attr.Attribute: |
|
111 |
neyKey.Freeze = True |
|
112 |
break |
|
113 |
|
|
114 |
if issubclass(type(item), QEngineeringTextItem): item.owner = self._item |
|
115 |
self.onSuccess.emit() |
|
116 |
break |
|
116 | 117 |
elif self._attr is not None and type(self._attr) is SymbolProp: |
117 | 118 |
item = self.imageViewer.scene.itemAt(scenePos, QTransform()) |
118 | 119 |
if item is not None and self._attr.match_type(item): |
DTI_PID/DTI_PID/ConnectAttrDialog.py | ||
---|---|---|
38 | 38 |
self._update_line_type = update_line_type |
39 | 39 |
self._update_flow_mark = update_flow_mark |
40 | 40 |
self._update_spec = update_spec |
41 |
self.need_update_texts = [] |
|
41 | 42 |
|
42 | 43 |
''' |
43 | 44 |
@brief execute connecting attributes |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
554 | 554 |
type(text) is QEngineeringTagNoTextItem or type(text) is QEngineeringTextItem): |
555 | 555 |
targetText.append(text) |
556 | 556 |
|
557 |
worker.need_update_texts = [] |
|
557 | 558 |
for text in targetText: |
558 |
text.findOwner(symbols) |
|
559 |
ret = text.findOwner(symbols) |
|
560 |
if ret: |
|
561 |
worker.need_update_texts.append([text, ret]) |
|
559 | 562 |
|
560 | 563 |
""" update line type """ |
561 | 564 |
if update_line_type: |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1992 | 1992 |
self.itemTreeWidget.addTreeItem(item, connectedItem) |
1993 | 1993 |
# up to here |
1994 | 1994 |
|
1995 |
if self.dlgConnectAttr.obj.need_update_texts: |
|
1996 |
for text, _text in self.dlgConnectAttr.obj.need_update_texts: |
|
1997 |
text.setPlainText(_text) |
|
1998 |
|
|
1995 | 1999 |
self.tableWidgetInconsistency.clearContents() |
1996 | 2000 |
if self.dlgConnectAttr.ui.checkBoxValidation.isChecked(): |
1997 | 2001 |
self.onValidation() |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
256 | 256 |
else: |
257 | 257 |
items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType] |
258 | 258 |
|
259 |
if not attr.AssocItem and len(items) > at: |
|
259 |
if not attr.AssocItem and len(items) > at and not attr.Codes.values:
|
|
260 | 260 |
attr.AssocItem = items[at] |
261 | 261 |
item = attr.AssocItem |
262 | 262 |
_attrs[attr] = eval(attr.Expression) if attr.Expression else '' |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
21 | 21 |
from AppDocData import * |
22 | 22 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
23 | 23 |
from TextInfo import TextInfo |
24 |
|
|
24 |
from SymbolSvgItem import SymbolSvgItem |
|
25 | 25 |
|
26 | 26 |
class QEngineeringTextItem(QGraphicsTextItem, QEngineeringAbstractItem): |
27 | 27 |
HIGHLIGHT = '#BC4438' |
... | ... | |
712 | 712 |
break |
713 | 713 |
|
714 | 714 |
for symbol in target_symbols: |
715 |
if type(symbol) is SymbolSvgItem or type(symbol) is QEngineeringInstrumentItem:
|
|
715 |
if issubclass(type(symbol), SymbolSvgItem):
|
|
716 | 716 |
dx = symbol.center().x() - center.x() |
717 | 717 |
dy = symbol.center().y() - center.y() |
718 | 718 |
|
... | ... | |
729 | 729 |
for attr in attrs: |
730 | 730 |
ret = attr.Codes.find_match_exactly(self.text()) |
731 | 731 |
if ret: |
732 |
self.setPlainText(ret) |
|
733 | 732 |
target_attr = attr |
734 | 733 |
break |
735 | 734 |
if selected.add_assoc_item(self, at=int(target_attr.AttrAt)): |
735 |
target_attr.AssocItem = self |
|
736 | 736 |
self.owner = selected |
737 |
return ret |
|
737 | 738 |
except Exception as ex: |
738 | 739 |
from App import App |
739 | 740 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
DTI_PID/DTI_PID/Shapes/EngineeringValveOperCodeTextItem.py | ||
---|---|---|
21 | 21 |
import OcrResultDialog |
22 | 22 |
from AppDocData import AppDocData, MessageType |
23 | 23 |
from EngineeringTextItem import QEngineeringTextItem |
24 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
|
24 | 25 |
from SymbolSvgItem import SymbolSvgItem |
25 | 26 |
|
26 | 27 |
class QEngineeringValveOperCodeTextItem(QEngineeringTextItem): |
DTI_PID/DTI_PID/SymbolAttrCodeTableDialog.py | ||
---|---|---|
14 | 14 |
import SymbolAttrCodeTable_UI |
15 | 15 |
|
16 | 16 |
class SymbolAttrCodeTableDialog(QCodeTableDialog): |
17 |
def __init__(self, parent, symbol_attribute_uid): |
|
17 |
def __init__(self, parent, symbol_attribute_uid, tableDatas=None):
|
|
18 | 18 |
QCodeTableDialog.__init__(self, parent, 'SymbolAttributeCodeTable') |
19 | 19 |
|
20 | 20 |
self.ui = SymbolAttrCodeTable_UI.Ui_AttributeCodeTable() |
... | ... | |
30 | 30 |
self.ui.buttonBox.accepted.connect(self.accept) |
31 | 31 |
self.ui.buttonBox.rejected.connect(self.reject) |
32 | 32 |
|
33 |
self.settingTable('SymbolAttributeCodeTable', symbol_attribute_uid=symbol_attribute_uid) |
|
33 |
self.settingTable('SymbolAttributeCodeTable', symbol_attribute_uid=symbol_attribute_uid, tableDatas=tableDatas)
|
|
34 | 34 |
''' |
35 | 35 |
@brief accept dialog |
36 | 36 |
''' |
... | ... | |
51 | 51 |
uid = table.item(row, 0).text() if table.item(row, 0).text() else str(uuid.uuid4()) |
52 | 52 |
code = table.item(row, 1).text() |
53 | 53 |
description = table.item(row, 2).text() if table.item(row, 2) is not None else '' |
54 |
allowables = table.item(row, 3).text() if table.item(row, 3) is not None else ''
|
|
54 |
allowables = table.item(row, 3).text().split(',') if table.item(row, 3) is not None else []
|
|
55 | 55 |
|
56 | 56 |
if code: |
57 | 57 |
self.code_data.append((uid, code, description, allowables)) |
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py | ||
---|---|---|
87 | 87 |
if column == 7: |
88 | 88 |
symbolType = self.ui.comboBoxSymbolType.currentText() |
89 | 89 |
|
90 |
dialog = SymbolAttrCodeTableDialog(self, str(self.ui.tableWidgetAttr.item(row, 0).tag.UID)) |
|
90 |
dialog = SymbolAttrCodeTableDialog(self, str(self.ui.tableWidgetAttr.item(row, 0).tag.UID), self.ui.tableWidgetAttr.item(row, 7).tag)
|
|
91 | 91 |
(isAccept, code_data) = dialog.showDialog() |
92 | 92 |
|
93 | 93 |
if isAccept: |
... | ... | |
212 | 212 |
self.ui.tableWidgetAttr.setItem(row, 6, item) |
213 | 213 |
|
214 | 214 |
item = QTableWidgetItem('...') |
215 |
item.tag = []
|
|
215 |
item.tag = attr.Codes.values
|
|
216 | 216 |
item.setTextAlignment(Qt.AlignHCenter) |
217 | 217 |
item.setFlags(Qt.ItemIsEnabled) |
218 | 218 |
self.ui.tableWidgetAttr.setItem(row, 7, item) |
내보내기 Unified diff