개정판 269a15c8
dev issue #640: edit lineProperty
DTI_PID/DTI_PID/App.py | ||
---|---|---|
74 | 74 |
except Exception as ex: |
75 | 75 |
print('에러가 발생했습니다.\n', ex) |
76 | 76 |
|
77 |
sys.exit(app.exec_()) |
|
77 |
sys.exit(app.exec_()) |
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
715 | 715 |
# Get a cursor object |
716 | 716 |
cursor = db.cursor() |
717 | 717 |
|
718 |
sql = "select Name from LineProperties order by Name"
|
|
718 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]"
|
|
719 | 719 |
cursor.execute(sql) |
720 | 720 |
rows = cursor.fetchall() |
721 | 721 |
for row in rows: |
722 |
res.append(row[0]) |
|
722 |
res.append((row[0], row[1], row[2], row[3], row[4], row[5])) |
|
723 |
# Catch the exception |
|
724 |
except Exception as ex: |
|
725 |
# Roll back any change if something goes wrong |
|
726 |
db.rollback() |
|
727 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
728 |
finally: |
|
729 |
# Close the db connection |
|
730 |
db.close() |
|
731 |
|
|
732 |
return res |
|
733 |
|
|
734 |
''' |
|
735 |
@brief return line properties |
|
736 |
@author humkyung |
|
737 |
@date 2018.04.09 |
|
738 |
''' |
|
739 |
def getLinePropertiesByUID(self, UID): |
|
740 |
res = [] |
|
741 |
try: |
|
742 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
743 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
|
744 |
db = sqlite3.connect(dbPath) |
|
745 |
# Get a cursor object |
|
746 |
cursor = db.cursor() |
|
747 |
|
|
748 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties where uid = '{}'".format(UID) |
|
749 |
cursor.execute(sql) |
|
750 |
rows = cursor.fetchall() |
|
751 |
for row in rows: |
|
752 |
res.append((row[0], row[1], row[2], row[3], row[4], row[5])) |
|
723 | 753 |
# Catch the exception |
724 | 754 |
except Exception as ex: |
725 | 755 |
# Roll back any change if something goes wrong |
... | ... | |
1599 | 1629 |
conn.close() |
1600 | 1630 |
|
1601 | 1631 |
''' |
1632 |
@brief save symbol attributes |
|
1633 |
@author humkyung |
|
1634 |
@date 2018.08.14 |
|
1635 |
''' |
|
1636 |
def saveLineAttributes(self, attrs): |
|
1637 |
try: |
|
1638 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
1639 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
|
1640 |
conn = sqlite3.connect(dbPath) |
|
1641 |
# Get a cursor object |
|
1642 |
cursor = conn.cursor() |
|
1643 |
|
|
1644 |
sql = 'delete from LineProperties' |
|
1645 |
cursor.execute(sql) |
|
1646 |
|
|
1647 |
for attr in attrs: |
|
1648 |
sql = 'insert into LineProperties(UID, Name, DisplayName, Type, LimitNumber, [index]) values(?, ?, ?, ?, ?, ?)' |
|
1649 |
param = tuple(attr) |
|
1650 |
cursor.execute(sql, param) |
|
1651 |
|
|
1652 |
conn.commit() |
|
1653 |
# Catch the exception |
|
1654 |
except Exception as ex: |
|
1655 |
# Roll back any change if something goes wrong |
|
1656 |
conn.rollback() |
|
1657 |
|
|
1658 |
from App import App |
|
1659 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1660 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
1661 |
finally: |
|
1662 |
# Close the db connection |
|
1663 |
conn.close() |
|
1664 |
|
|
1665 |
''' |
|
1602 | 1666 |
@brief get symbol type id |
1603 | 1667 |
@author kyouho |
1604 | 1668 |
@date 2018.08.17 |
... | ... | |
1668 | 1732 |
return result |
1669 | 1733 |
|
1670 | 1734 |
''' |
1735 |
@brief get Code Table Data |
|
1736 |
@author kyouho |
|
1737 |
@date 2018.07.10 |
|
1738 |
''' |
|
1739 |
def getCodeTable(self, property, forCheckLineNumber = False): |
|
1740 |
result = [] |
|
1741 |
try: |
|
1742 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
1743 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
|
1744 |
conn = sqlite3.connect(dbPath) |
|
1745 |
# Get a cursor object |
|
1746 |
cursor = conn.cursor() |
|
1747 |
|
|
1748 |
if property == "NominalDiameter" and forCheckLineNumber: |
|
1749 |
sql = 'select InchStr, MetricStr from [{}] order by length(code) DESC'.format(property) |
|
1750 |
cursor.execute(sql) |
|
1751 |
rows = cursor.fetchall() |
|
1752 |
for index in range(2): |
|
1753 |
for row in rows: |
|
1754 |
if row[index] != '': |
|
1755 |
result.append(row[index]) |
|
1756 |
else: |
|
1757 |
sql = 'select uid, code, description from [{}] order by length(code) DESC'.format(property) |
|
1758 |
cursor.execute(sql) |
|
1759 |
rows = cursor.fetchall() |
|
1760 |
for row in rows: |
|
1761 |
if forCheckLineNumber: |
|
1762 |
data = row[1] |
|
1763 |
else: |
|
1764 |
data = (row[0], row[1], row[2]) |
|
1765 |
result.append(data) |
|
1766 |
# Catch the exception |
|
1767 |
except Exception as ex: |
|
1768 |
# Roll back any change if something goes wrong |
|
1769 |
conn.rollback() |
|
1770 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1771 |
finally: |
|
1772 |
# Close the db connection |
|
1773 |
conn.close() |
|
1774 |
|
|
1775 |
return result |
|
1776 |
|
|
1777 |
''' |
|
1671 | 1778 |
@brief Set Common Code Data |
1672 | 1779 |
@author kyouho |
1673 | 1780 |
@date 2018.07.12 |
DTI_PID/DTI_PID/AttrEditor_UI.py | ||
---|---|---|
11 | 11 |
class Ui_AttrEditorDialog(object): |
12 | 12 |
def setupUi(self, AttrEditorDialog): |
13 | 13 |
AttrEditorDialog.setObjectName("AttrEditorDialog") |
14 |
AttrEditorDialog.resize(769, 300)
|
|
14 |
AttrEditorDialog.resize(825, 446)
|
|
15 | 15 |
font = QtGui.QFont() |
16 | 16 |
font.setFamily("맑은 고딕") |
17 | 17 |
font.setBold(True) |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
13 | 13 |
class ListView(QListView): |
14 | 14 |
def __init__(self, *args, **kwargs): |
15 | 15 |
super(ListView, self).__init__(*args, **kwargs) |
16 |
|
|
17 |
''' |
|
18 |
@brief deleted selected item |
|
19 |
@author humkyung |
|
20 |
@date 2018.04.09 |
|
21 |
''' |
|
22 |
def removeSelectedItem(self): |
|
23 |
selectedIndexes = self.selectedIndexes() |
|
24 |
selectedRows = [item.row() for item in selectedIndexes] |
|
25 |
model = self.model() |
|
26 |
# iterates each selected row in descending order |
|
27 |
for row in sorted(selectedRows, reverse=True): |
|
28 |
# remove the row from the model |
|
29 |
model.removeRow(row) |
|
30 |
|
|
31 |
''' |
|
32 |
@brief key press event |
|
33 |
@author humkyung |
|
34 |
@date 2018.04.09 |
|
35 |
''' |
|
36 |
def keyPressEvent(self, event): |
|
37 |
if event.key() == Qt.Key_Delete: |
|
38 |
self.removeSelectedItem() |
|
39 |
return |
|
40 |
|
|
41 |
super(ListView, self).keyPressEvent(event) |
|
42 | 16 |
|
43 | 17 |
class QConfigurationDialog(QDialog): |
44 | 18 |
''' |
... | ... | |
64 | 38 |
self.delimiter = '"' |
65 | 39 |
self.defaultColor = Color(0, 0, 0, 255) |
66 | 40 |
self.currentIndex = 0 |
41 |
self.lineNoAttributeUID = [] |
|
42 |
self.tempLineNoAttributeUID = [] |
|
43 |
self.tempLineColorUID = [] |
|
44 |
|
|
67 | 45 |
|
68 | 46 |
docData = AppDocData.instance() |
69 | 47 |
configs = docData.getConfigs('Text Area', 'Text Area') |
... | ... | |
122 | 100 |
|
123 | 101 |
properties = docData.getLineProperties() |
124 | 102 |
for prop in properties: |
125 |
self.ui.comboBoxProperties.addItem(prop) |
|
126 |
if prop != "Tag Seq No": |
|
127 |
self.ui.comboBoxColorOption.addItem(prop) |
|
103 |
self.lineNoAttributeUID.append(prop[0]) |
|
104 |
self.ui.comboBoxProperties.addItem(prop[2]) |
|
105 |
if prop[3] == "Code Table": |
|
106 |
self.tempLineColorUID.append(prop[0]) |
|
107 |
self.ui.comboBoxColorOption.addItem(prop[2]) |
|
128 | 108 |
|
129 | 109 |
configs = docData.getConfigs('Line No', 'Configuration') |
130 | 110 |
if len(configs) == 1 and configs[0].value is not None: |
131 | 111 |
for value in configs[0].value.split(self.delimiter): |
132 | 112 |
#for value in configs[0].value.split(self.ui.lineEdit.text()): |
133 |
self.itemModel.appendRow(QStandardItem(value)) |
|
113 |
lineProp = docData.getLinePropertiesByUID(value) |
|
114 |
if lineProp: |
|
115 |
self.itemModel.appendRow(QStandardItem(lineProp[0][2])) |
|
116 |
else: |
|
117 |
self.itemModel.appendRow(QStandardItem(value)) |
|
118 |
self.tempLineNoAttributeUID.append(value) |
|
134 | 119 |
self.ui.listViewProperties.setModel(self.itemModel) |
135 | 120 |
|
136 | 121 |
configs = docData.getConfigs('Line No Tag Rule', 'Tag Seq No') |
... | ... | |
210 | 195 |
# Color Property 선택값 가져옴 |
211 | 196 |
table = self.ui.tableWidgetColorProperty |
212 | 197 |
configs = docData.getConfigs('Color Property', 'State') |
213 |
selectedOption = configs[0].value if configs and self.ui.comboBoxColorOption.findText(configs[0].value) >= 0 else 'Nominal Diameter' |
|
198 |
uid = configs[0].value |
|
199 |
lineProp = docData.getLinePropertiesByUID(uid) |
|
200 |
selectedOption = lineProp[0][2] if lineProp and self.ui.comboBoxColorOption.findText(lineProp[0][2]) >= 0 else '' |
|
214 | 201 |
self.ui.tableWidgetColorProperty.setHorizontalHeaderLabels(['Value', 'Color', 'ref', 'colorStr']) |
215 | 202 |
|
216 | 203 |
index = self.ui.comboBoxColorOption.findText(selectedOption) |
... | ... | |
268 | 255 |
|
269 | 256 |
dic = {} |
270 | 257 |
|
271 |
if property == "Nominal Diameter": |
|
258 |
lineProp = docData.getLinePropertiesByUID(property) |
|
259 |
if lineProp: |
|
260 |
tableName = lineProp[0][1] |
|
261 |
else: |
|
262 |
return |
|
263 |
|
|
264 |
if tableName.replace(' ','') == "NominalDiameter": |
|
272 | 265 |
#중복 체크 배열 |
273 | 266 |
checkRepeat = [] |
274 | 267 |
# Size 표기 가져옴 |
... | ... | |
291 | 284 |
else: |
292 | 285 |
dic[pipeSize.metricStr] = pipeSize.metricStr |
293 | 286 |
|
294 |
elif property != "Tag Seq No":
|
|
295 |
result = docData.getCodeTable(property.replace(' ','').replace('&', 'n'), True)
|
|
287 |
elif tableName != "Tag Seq No":
|
|
288 |
result = docData.getCodeTable(tableName, True)
|
|
296 | 289 |
for fluidCode in result: |
297 | 290 |
dic[fluidCode] = fluidCode |
298 | 291 |
|
... | ... | |
356 | 349 |
def currentIndexChanged(self, index): |
357 | 350 |
if self.currentIndex != index: |
358 | 351 |
self.currentIndex = index |
359 |
selectedOption = self.ui.comboBoxColorOption.currentText() |
|
352 |
|
|
353 |
selectedIndex = self.ui.comboBoxColorOption.currentIndex() |
|
354 |
uid = self.tempLineColorUID[selectedIndex] |
|
355 |
|
|
356 |
docData = AppDocData.instance() |
|
357 |
lineProp = docData.getLinePropertiesByUID(uid) |
|
358 |
|
|
360 | 359 |
# 기본 테이블 셋팅 |
361 |
self.settingDefaultColorTable(selectedOption)
|
|
360 |
self.settingDefaultColorTable(lineProp[0][0])
|
|
362 | 361 |
# 설정된 색상 가져옴 |
363 |
self.settingColorStringCell(selectedOption)
|
|
362 |
self.settingColorStringCell(lineProp[0][0])
|
|
364 | 363 |
#Table Color Setting |
365 | 364 |
self.settingColorCell() |
366 | 365 |
|
... | ... | |
387 | 386 |
text = self.ui.lineEdit.text() |
388 | 387 |
if text != self.delimiter: |
389 | 388 |
self.itemModel.appendRow(QStandardItem(text)) |
389 |
self.tempLineNoAttributeUID.append(text) |
|
390 | 390 |
else: |
391 | 391 |
pass |
392 | 392 |
|
... | ... | |
399 | 399 |
index = self.ui.comboBoxProperties.currentIndex() |
400 | 400 |
prop = self.ui.comboBoxProperties.itemText(index) |
401 | 401 |
self.itemModel.appendRow(QStandardItem(prop)) |
402 |
self.tempLineNoAttributeUID.append(self.lineNoAttributeUID[index]) |
|
402 | 403 |
|
403 | 404 |
''' |
404 | 405 |
@brief enable/disable font size spinbox |
... | ... | |
422 | 423 |
''' |
423 | 424 |
def setPropertyToggle(self, enable): |
424 | 425 |
if enable: |
425 |
selectedOption = self.ui.comboBoxColorOption.currentText() |
|
426 |
selectedIndex = self.ui.comboBoxColorOption.currentIndex() |
|
427 |
uid = self.tempLineColorUID[selectedIndex] |
|
428 |
|
|
429 |
docData = AppDocData.instance() |
|
430 |
lineProp = docData.getLinePropertiesByUID(uid) |
|
431 |
|
|
426 | 432 |
# 기본 테이블 셋팅 |
427 |
self.settingDefaultColorTable(selectedOption)
|
|
433 |
self.settingDefaultColorTable(lineProp[0][0])
|
|
428 | 434 |
# 설정된 색상 가져옴 |
429 |
self.settingColorStringCell(selectedOption)
|
|
435 |
self.settingColorStringCell(lineProp[0][0])
|
|
430 | 436 |
#Table Color Setting |
431 | 437 |
self.settingColorCell() |
432 | 438 |
else: |
... | ... | |
484 | 490 |
|
485 | 491 |
# Add Line Color Option - 2018.07.06 by kyouho |
486 | 492 |
rbRandomValue = self.ui.radioButtonRandom.isChecked() |
487 |
cbColorOptionValue = self.ui.comboBoxColorOption.currentText() |
|
493 |
|
|
494 |
selectedIndex = self.ui.comboBoxColorOption.currentIndex() |
|
495 |
uid = self.tempLineColorUID[selectedIndex] |
|
496 |
|
|
497 |
docData = AppDocData.instance() |
|
498 |
lineProp = docData.getLinePropertiesByUID(uid) |
|
499 |
|
|
488 | 500 |
configs.append(Config('Line Color', 'Visible Option', 'Random' if rbRandomValue else 'Property')) |
489 |
configs.append(Config('Color Property', 'State', cbColorOptionValue))
|
|
501 |
configs.append(Config('Color Property', 'State', lineProp[0][0]))
|
|
490 | 502 |
|
491 | 503 |
for row in range(self.ui.tableWidgetLineTypes.rowCount()): |
492 | 504 |
lineType = self.ui.tableWidgetLineTypes.item(row, 0).text() |
... | ... | |
501 | 513 |
refStr = table.item(i, 2).text() |
502 | 514 |
colorStr = table.item(i, 3).text() |
503 | 515 |
if colorStr: |
504 |
configs.append(Config(cbColorOptionValue, refStr, colorStr))
|
|
516 |
configs.append(Config(lineProp[0][0], refStr, colorStr))
|
|
505 | 517 |
|
506 | 518 |
#Configuration |
507 | 519 |
configuration = None |
508 |
self.ui.listViewProperties.model() |
|
509 |
for i in range(self.itemModel.rowCount()): |
|
510 |
item = self.ui.listViewProperties.model().item(i).text() |
|
520 |
for i in range(len(self.tempLineNoAttributeUID)): |
|
521 |
item = self.tempLineNoAttributeUID[i] |
|
511 | 522 |
if configuration is None: |
512 | 523 |
configuration = item |
513 | 524 |
else: |
514 | 525 |
configuration += self.delimiter + item |
515 |
#configuration += self.ui.lineEdit.text() + item |
|
516 | 526 |
configs.append(Config('Line No', 'Configuration', configuration)) |
517 | 527 |
|
518 | 528 |
font = self.ui.fontComboBox.currentFont() |
... | ... | |
525 | 535 |
except Exception as ex: |
526 | 536 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
527 | 537 |
|
528 |
QDialog.accept(self) |
|
538 |
QDialog.accept(self) |
|
539 |
|
|
540 |
|
|
541 |
''' |
|
542 |
@brief deleted selected item |
|
543 |
@author humkyung |
|
544 |
@date 2018.04.09 |
|
545 |
''' |
|
546 |
def removeSelectedItem(self): |
|
547 |
selectedIndexes = self.ui.listViewProperties.selectedIndexes() |
|
548 |
selectedRows = [item.row() for item in selectedIndexes] |
|
549 |
model = self.ui.listViewProperties.model() |
|
550 |
# iterates each selected row in descending order |
|
551 |
for row in sorted(selectedRows, reverse=True): |
|
552 |
# remove the row from the model |
|
553 |
model.removeRow(row) |
|
554 |
del self.tempLineNoAttributeUID[row] |
|
555 |
''' |
|
556 |
@brief key press event |
|
557 |
@author humkyung |
|
558 |
@date 2018.04.09 |
|
559 |
''' |
|
560 |
def keyPressEvent(self, event): |
|
561 |
if event.key() == Qt.Key_Delete: |
|
562 |
self.removeSelectedItem() |
|
563 |
return |
DTI_PID/DTI_PID/ItemDataExportDialog.py | ||
---|---|---|
197 | 197 |
lineNo.append(lineTable.item(row, 3).text()) |
198 | 198 |
|
199 | 199 |
for line in self.sceneLineData.keys(): |
200 |
lineData = self.sceneLineData[line] |
|
200 | 201 |
# 중복 (어떻게 할지) |
201 | 202 |
if lineNo.count(line) >= 1: |
202 | 203 |
rowIndex = lineNo.index(line) |
203 |
continue |
|
204 |
|
|
205 |
for index in range(len(lineData)): |
|
206 |
if str(lineData[index]): |
|
207 |
oldData = lineTable.item(rowIndex, index).text() |
|
208 |
if oldData != lineData[index]: |
|
209 |
lineTable.item(rowIndex, index).setText(lineData[index]) |
|
210 |
lineTable.item(rowIndex, index).setBackground(QColor(int(134), int(229), int(127))) |
|
211 |
|
|
212 |
|
|
204 | 213 |
# 신규 |
205 | 214 |
else: |
206 | 215 |
rowCount += 1 |
207 | 216 |
lineTable.setRowCount(rowCount) |
208 |
lineData = self.sceneLineData[line] |
|
209 | 217 |
lineData[0] = '' |
210 | 218 |
|
211 | 219 |
for index in range(len(lineData)): |
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
366 | 366 |
@history humkyung 2018.07.20 display combobox when key is 'Stream No' |
367 | 367 |
''' |
368 | 368 |
def initLineNoCell(self, lineNoItem): |
369 |
appDocData = AppDocData.instance() |
|
370 |
|
|
371 |
self.attrValueList = [] |
|
372 |
self.stringCell = [] |
|
373 |
|
|
369 | 374 |
self.setRowCount(1 + len(lineNoItem.getLineNoAttributes())) |
370 | 375 |
|
371 | 376 |
lineNoTitleItem = QTableWidgetItem("Line No.") |
... | ... | |
377 | 382 |
attrItems = lineNoItem.getLineNoAttributes() |
378 | 383 |
if attrItems is not None: |
379 | 384 |
for index in range(len(attrItems)): |
380 |
key = attrItems[index][0] |
|
381 |
value = attrItems[index][1] |
|
385 |
attr = attrItems[index] |
|
386 |
|
|
387 |
if type(attr) is UserInputAttribute: |
|
388 |
key = attr.attribute |
|
389 |
value = attr.text |
|
390 |
valueCell = QTableWidgetItem(value) |
|
391 |
self.attrValueList.append((valueCell, key)) |
|
392 |
self.stringCell.append(valueCell) |
|
393 |
key = appDocData.getLinePropertiesByUID(key)[0][2] |
|
394 |
else: |
|
395 |
key = attrItems[index][0] |
|
396 |
value = attrItems[index][1] |
|
397 |
valueCell = QTableWidgetItem(value) |
|
398 |
|
|
382 | 399 |
item = QTableWidgetItem(key) |
383 | 400 |
item.setFlags(Qt.ItemIsEnabled) |
384 | 401 |
item.setBackground(QColor(220, 220, 220)) |
... | ... | |
387 | 404 |
self.streamNoComboBox = QComboBox() |
388 | 405 |
self.streamNoComboBox.tag = lineNoItem |
389 | 406 |
self.streamNoComboBox.currentIndexChanged.connect(self.onStreamNoChanged) |
390 |
|
|
391 |
appDocData = AppDocData.instance() |
|
407 |
|
|
392 | 408 |
streamNos = sorted(list(appDocData.hmbTable.streamNos())) |
393 | 409 |
for streamNo in streamNos: |
394 | 410 |
self.streamNoComboBox.addItem(streamNo) |
395 | 411 |
self.setCellWidget(1 + index, 1, self.streamNoComboBox) |
396 | 412 |
self.streamNoComboBox.setCurrentText(value) |
397 | 413 |
else: |
398 |
self.setItem(1 + index, 1, QTableWidgetItem(value))
|
|
414 |
self.setItem(1 + index, 1, valueCell)
|
|
399 | 415 |
|
400 | 416 |
''' |
401 | 417 |
@brief change selected lines' stream no by selected stream no |
... | ... | |
444 | 460 |
cell = self.item(row, column) |
445 | 461 |
for valueCell in self.attrValueList: |
446 | 462 |
if valueCell[0] == cell and (self.intCell.count(cell) or self.stringCell.count(cell)): |
447 |
typeUID = valueCell[1] |
|
448 |
str = '' |
|
449 |
if self.intCell.count(cell): |
|
450 |
str = cell.text() |
|
451 |
if not self.isNumber(str): |
|
452 |
str = '' |
|
453 |
cell.setText(str) |
|
454 |
elif self.stringCell.count(cell): |
|
455 |
str = cell.text() |
|
456 |
|
|
457 | 463 |
items = self.mainWindow.graphicsView.scene.selectedItems() |
458 | 464 |
if items is not None and len(items) == 1: |
459 |
find = False |
|
460 |
for attr in items[0].attrs: |
|
461 |
if attr.attribute == typeUID: |
|
462 |
find = True |
|
463 |
attr.setText(str) |
|
464 |
break |
|
465 |
|
|
466 |
if not find: |
|
467 |
newAttr = UserInputAttribute(typeUID, str) |
|
468 |
items[0].attrs.append(newAttr) |
|
469 |
|
|
465 |
typeUID = valueCell[1] |
|
466 |
|
|
467 |
str = '' |
|
468 |
if self.intCell.count(cell): |
|
469 |
str = cell.text() |
|
470 |
if not self.isNumber(str): |
|
471 |
str = '' |
|
472 |
cell.setText(str) |
|
473 |
elif self.stringCell.count(cell): |
|
474 |
str = cell.text() |
|
475 |
|
|
476 |
if issubclass(type(items[0]), SymbolSvgItem): |
|
477 |
find = False |
|
478 |
for attr in items[0].attrs: |
|
479 |
if attr.attribute == typeUID: |
|
480 |
find = True |
|
481 |
attr.setText(str) |
|
482 |
break |
|
483 |
|
|
484 |
if not find: |
|
485 |
newAttr = UserInputAttribute(typeUID, str) |
|
486 |
items[0].attrs.append(newAttr) |
|
487 |
# line no 경우 |
|
488 |
else: |
|
489 |
for attr in items[0]._attrs: |
|
490 |
if type(attr) is UserInputAttribute and attr.attribute == typeUID: |
|
491 |
attr.text = str |
|
492 |
|
|
470 | 493 |
''' |
471 | 494 |
@brief Check Number |
472 | 495 |
@author kyouho |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
169 | 169 |
self.removedItems['EQUIP'] = [] |
170 | 170 |
self.removedItems['INST'] = [] |
171 | 171 |
|
172 |
self.delimiter = '"' |
|
173 |
|
|
172 | 174 |
''' |
173 | 175 |
@brief action save click event |
174 | 176 |
@author kyouho |
... | ... | |
245 | 247 |
break |
246 | 248 |
|
247 | 249 |
if uid is not None: |
248 |
docData = AppDocData.instance() |
|
249 |
attrType = docData.getSymbolAttributeByUID(uid) |
|
250 |
if attrType[2] == 'Text Item' or attrType[2] == 'Symbol Item': |
|
251 |
items = self.graphicsView.scene.selectedItems() |
|
252 |
if items is not None and len(items) == 1: |
|
253 |
self.graphicsView.command = SelectAttributeCommand.SelectAttributeCommand(self.graphicsView) |
|
254 |
self.graphicsView.command.setType(attrType[2]) |
|
255 |
cursor = QCursor(Qt.PointingHandCursor) |
|
256 |
QApplication.instance().setOverrideCursor(cursor) |
|
257 |
self.graphicsView.currentAttribute = uid |
|
258 |
|
|
259 |
# 기존 cellText를 가진 attrs 삭제 |
|
260 |
items[0].removeSelfAttr(uid) |
|
261 |
|
|
262 |
from PyQt5 import QtGui |
|
263 |
cellItem = QTableWidgetItem('') |
|
264 |
icon = QtGui.QIcon() |
|
265 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
266 |
cellItem.setIcon(icon) |
|
267 |
self.resultPropertyTableWidget.setItem(row, 1, cellItem) |
|
250 |
items = self.graphicsView.scene.selectedItems() |
|
251 |
if items is not None and len(items) == 1: |
|
252 |
if issubclass(type(items[0]), SymbolSvgItem): |
|
253 |
docData = AppDocData.instance() |
|
254 |
attrType = docData.getSymbolAttributeByUID(uid) |
|
255 |
if attrType[2] == 'Text Item' or attrType[2] == 'Symbol Item': |
|
256 |
self.graphicsView.command = SelectAttributeCommand.SelectAttributeCommand(self.graphicsView) |
|
257 |
self.graphicsView.command.setType(attrType[2]) |
|
258 |
cursor = QCursor(Qt.PointingHandCursor) |
|
259 |
QApplication.instance().setOverrideCursor(cursor) |
|
260 |
self.graphicsView.currentAttribute = uid |
|
261 |
|
|
262 |
# 기존 cellText를 가진 attrs 삭제 |
|
263 |
items[0].removeSelfAttr(uid) |
|
264 |
|
|
265 |
from PyQt5 import QtGui |
|
266 |
cellItem = QTableWidgetItem('') |
|
267 |
icon = QtGui.QIcon() |
|
268 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
269 |
cellItem.setIcon(icon) |
|
270 |
self.resultPropertyTableWidget.setItem(row, 1, cellItem) |
|
268 | 271 |
|
269 |
else: |
|
270 |
self.resultPropertyTableWidget.editItem(cell) |
|
272 |
else: |
|
273 |
self.resultPropertyTableWidget.editItem(cell) |
|
274 |
else: |
|
275 |
self.resultPropertyTableWidget.editItem(cell) |
|
271 | 276 |
|
272 | 277 |
|
273 | 278 |
#cell = self.resultPropertyTableWidget.item(row, 0) |
... | ... | |
509 | 514 |
text = textInfo.getText() |
510 | 515 |
width = textInfo.getW() |
511 | 516 |
height = textInfo.getH() |
512 |
item = TextItemFactory.instance().createTextItem(text, delimiter, lineNoconfigs)
|
|
517 |
item = TextItemFactory.instance().createTextItem(text) |
|
513 | 518 |
if item is not None: |
514 | 519 |
item.loc = (x, y) |
515 | 520 |
item.size = (width, height) |
... | ... | |
1010 | 1015 |
from TextItemFactory import TextItemFactory |
1011 | 1016 |
import math |
1012 | 1017 |
try: |
1013 |
docData = AppDocData.instance() |
|
1014 |
configs = docData.getConfigs('Line No', 'Delimiter') |
|
1015 |
delimiter = configs[0].value if 1 == len(configs) else '-' |
|
1016 |
lineNoconfigs = docData.getConfigs('Line No', 'Configuration') |
|
1017 |
# |
|
1018 |
linePropertyData = {} |
|
1019 |
linePropertyData['NominalDiameter'] = docData.getNomialPipeSizeData(True) |
|
1020 |
linePropertyData['FluidCode'] = docData.getCodeTable('FluidCode', True) |
|
1021 |
linePropertyData['UnitNumber'] = docData.getCodeTable('UnitNumber', True) |
|
1022 |
linePropertyData['PnIDNumber'] = docData.getCodeTable('PnIDNumber', True) |
|
1023 |
linePropertyData['PipingMaterialsClass'] = docData.getCodeTable('PipingMaterialsClass', True) |
|
1024 |
linePropertyData['InsulationPurpose'] = docData.getCodeTable('InsulationPurpose', True) |
|
1025 |
# |
|
1026 |
configs = docData.getConfigs('Line No Tag Rule', 'Tag Seq No') |
|
1027 |
tagSeqNoPattern = configs[0].value if 1 == len(configs) else None |
|
1028 |
|
|
1029 | 1018 |
# parse texts |
1030 | 1019 |
for textInfo in textInfoList: |
1031 | 1020 |
x = textInfo.getX() |
... | ... | |
1034 | 1023 |
height = textInfo.getH() |
1035 | 1024 |
angle = round(math.radians(textInfo.getAngle()), 2) |
1036 | 1025 |
text = textInfo.getText() |
1037 |
item = TextItemFactory.instance().createTextItem(text, delimiter, lineNoconfigs, linePropertyData, tagSeqNoPattern)
|
|
1026 |
item = TextItemFactory.instance().createTextItem(text) |
|
1038 | 1027 |
|
1039 | 1028 |
if item is not None: |
1040 | 1029 |
item.loc = (x, y) |
... | ... | |
1185 | 1174 |
for item in symbols: |
1186 | 1175 |
self.addSvgItemToScene(item[0]) |
1187 | 1176 |
|
1188 |
docData = AppDocData.instance() |
|
1189 |
configs = docData.getConfigs('Line No', 'Delimiter') |
|
1190 |
delimiter = configs[0].value if 1 == len(configs) else '-' |
|
1191 |
lineNoconfigs = docData.getConfigs('Line No', 'Configuration') |
|
1192 |
# |
|
1193 |
linePropertyData = {} |
|
1194 |
linePropertyData['NominalDiameter'] = docData.getNomialPipeSizeData(True) |
|
1195 |
linePropertyData['FluidCode'] = docData.getCodeTable('FluidCode', True) |
|
1196 |
linePropertyData['UnitNumber'] = docData.getCodeTable('UnitNumber', True) |
|
1197 |
linePropertyData['PnIDNumber'] = docData.getCodeTable('PnIDNumber', True) |
|
1198 |
linePropertyData['PipingMaterialsClass'] = docData.getCodeTable('PipingMaterialsClass', True) |
|
1199 |
linePropertyData['InsulationPurpose'] = docData.getCodeTable('InsulationPurpose', True) |
|
1200 |
# |
|
1201 |
configs = docData.getConfigs('Line No Tag Rule', 'Tag Seq No') |
|
1202 |
tagSeqNoPattern = configs[0].value if 1 == len(configs) else None |
|
1203 |
|
|
1204 | 1177 |
# parse texts |
1205 | 1178 |
for text in root.iter('ATTRIBUTE'): |
1206 | 1179 |
location = text.find('LOCATION').text if text.find('LOCATION') is not None else '0,0' |
... | ... | |
1214 | 1187 |
attributeValue = text.find('ATTRIBUTEVALUE') |
1215 | 1188 |
name = text.find('NAME').text |
1216 | 1189 |
if name == 'TEXT': |
1217 |
item = TextItemFactory.instance().createTextItem(value, delimiter, lineNoconfigs, linePropertyData, tagSeqNoPattern)
|
|
1190 |
item = TextItemFactory.instance().createTextItem(value) |
|
1218 | 1191 |
if item is not None: |
1219 | 1192 |
item.loc = (x, y) |
1220 | 1193 |
item.size = (width, height) |
... | ... | |
1246 | 1219 |
angle = float(lineNo.find('ANGLE').text) if lineNo.find('ANGLE') is not None else 0 |
1247 | 1220 |
text = lineNo.find('TEXT').text |
1248 | 1221 |
|
1249 |
item = TextItemFactory.instance().createTextItem(text, delimiter, lineNoconfigs, linePropertyData, tagSeqNoPattern)
|
|
1222 |
item = TextItemFactory.instance().createTextItem(text) |
|
1250 | 1223 |
if item is not None: |
1251 | 1224 |
item.loc = (x, y) |
1252 | 1225 |
item.size = (width, height) |
... | ... | |
1255 | 1228 |
item.transfer.onRemoved.connect(self.itemRemoved) |
1256 | 1229 |
self.addTextItemToScene(item) |
1257 | 1230 |
|
1231 |
if type(item) is UserInputAttribute: |
|
1232 |
for attr in lineNo.iter('USERINPUTATTRIBUTE'): |
|
1233 |
newAttr = UserInputAttribute(attr.find('TYPEUID').text, attr.find('TYPEVALUE').text) |
|
1234 |
item._attrs.append(newAttr) |
|
1235 |
|
|
1258 | 1236 |
for line in root.iter('LINE'): |
1259 | 1237 |
item = QEngineeringLineItem.fromXml(line) |
1260 | 1238 |
item.transfer.onRemoved.connect(self.itemRemoved) |
... | ... | |
1419 | 1397 |
if not self.graphicsView.hasImage(): |
1420 | 1398 |
return |
1421 | 1399 |
|
1400 |
# symbol 경우 |
|
1422 | 1401 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)] |
1423 |
|
|
1424 | 1402 |
for item in items: |
1425 | 1403 |
attrs = item.attrs |
1426 |
|
|
1404 |
|
|
1427 | 1405 |
removeAttrList = [] |
1428 | 1406 |
for attr in attrs: |
1429 | 1407 |
attrInfo = docData.getSymbolAttributeByUID(attr.attribute) |
... | ... | |
1449 | 1427 |
for attr in removeAttrList: |
1450 | 1428 |
attrs.remove(attr) |
1451 | 1429 |
|
1430 |
# Line No Text Item의 경우 |
|
1431 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringLineNoTextItem)] |
|
1432 |
for item in items: |
|
1433 |
attrs = item._attrs |
|
1434 |
|
|
1435 |
removeAttrList = [] |
|
1436 |
for attr in attrs: |
|
1437 |
if type(attr) is UserInputAttribute: |
|
1438 |
attrInfo = docData.getLinePropertiesByUID(attr.attribute) |
|
1439 |
if attrInfo is None: |
|
1440 |
removeAttrList.append(attr) |
|
1441 |
|
|
1442 |
for attr in removeAttrList: |
|
1443 |
attrs.remove(attr) |
|
1452 | 1444 |
|
1453 | 1445 |
''' |
1454 | 1446 |
@brief Check Number |
DTI_PID/DTI_PID/Shapes/QEngineeringLineNoTextItem.py | ||
---|---|---|
15 | 15 |
|
16 | 16 |
from EngineeringPolylineItem import QEngineeringPolylineItem |
17 | 17 |
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
18 |
from UserInputAttribute import UserInputAttribute |
|
18 | 19 |
from OcrResultDialog import QOcrResultDialog |
19 | 20 |
from AppDocData import AppDocData |
20 | 21 |
from EngineeringTextItem import QEngineeringTextItem |
... | ... | |
93 | 94 |
|
94 | 95 |
try: |
95 | 96 |
docData = AppDocData.instance() |
96 |
configs = docData.getConfigs('Line No', 'Delimiter') |
|
97 |
delimiter = configs[0].value if 1 == len(configs) else '-' |
|
98 | 97 |
lineNoconfigs = docData.getConfigs('Line No', 'Configuration') |
99 |
# |
|
100 |
linePropertyData = {} |
|
101 |
linePropertyData['NominalDiameter'] = docData.getNomialPipeSizeData(True) |
|
102 |
linePropertyData['FluidCode'] = docData.getCodeTable('FluidCode', True) |
|
103 |
linePropertyData['UnitNumber'] = docData.getCodeTable('UnitNumber', True) |
|
104 |
linePropertyData['PnIDNumber'] = docData.getCodeTable('PnIDNumber', True) |
|
105 |
linePropertyData['PipingMaterialsClass'] = docData.getCodeTable('PipingMaterialsClass', True) |
|
106 |
linePropertyData['InsulationPurpose'] = docData.getCodeTable('InsulationPurpose', True) |
|
107 |
# |
|
108 |
configs = docData.getConfigs('Line No Tag Rule', 'Tag Seq No') |
|
109 |
tagSeqNoPattern = configs[0].value if 1 == len(configs) else None |
|
110 | 98 |
|
111 | 99 |
from TextItemFactory import TextItemFactory |
112 |
item = TextItemFactory.instance().isLineNo(self.text(), delimiter, lineNoconfigs, linePropertyData, tagSeqNoPattern)
|
|
113 |
|
|
100 |
item = TextItemFactory.instance().isLineNo(self.text()) |
|
101 |
# Line No 부분 |
|
114 | 102 |
if item[0]: |
115 | 103 |
result = item[1] |
116 | 104 |
configs = lineNoconfigs[0].value.split(self.delimiter) |
117 |
for i in range(len(configs)): |
|
118 |
if configs[i] == delimiter: |
|
119 |
continue |
|
120 |
res.append((configs[i], result[i])) |
|
105 |
lineAttrs = docData.getLineProperties() |
|
106 |
for lineAttr in lineAttrs: |
|
107 |
if lineAttr[3] == 'String': |
|
108 |
find = False |
|
109 |
for attr in self._attrs: |
|
110 |
if type(attr) is UserInputAttribute and attr.attribute == lineAttr[0]: |
|
111 |
find = True |
|
112 |
res.append(attr) |
|
113 |
break; |
|
114 |
if not find: |
|
115 |
newAttr = UserInputAttribute(lineAttr[0], '') |
|
116 |
self._attrs.append(newAttr) |
|
117 |
res.append(newAttr) |
|
118 |
else: |
|
119 |
for i in range(len(configs)): |
|
120 |
if lineAttr[0] == configs[i]: |
|
121 |
res.append((lineAttr[2], result[i])) |
|
122 |
break |
|
121 | 123 |
|
122 |
res.extend(self._attrs) |
|
123 | 124 |
if getLineNo: |
124 | 125 |
res.append(('Line No', self.uid)) |
125 | 126 |
except Exception as ex: |
... | ... | |
175 | 176 |
node.append(run.toXml()) |
176 | 177 |
|
177 | 178 |
attrs = self.getLineNoAttributes() |
178 |
for key,value in attrs: |
|
179 |
attrNode = Element('ATTRIBUTE') |
|
179 |
for attr in attrs: |
|
180 |
if type(attr) is not UserInputAttribute: |
|
181 |
attrNode = Element('ATTRIBUTE') |
|
180 | 182 |
|
181 |
uidNode = Element('UID') |
|
182 |
uidNode.text = str(self.uid) |
|
183 |
attrNode.append(uidNode) |
|
183 |
uidNode = Element('UID')
|
|
184 |
uidNode.text = str(self.uid)
|
|
185 |
attrNode.append(uidNode)
|
|
184 | 186 |
|
185 |
nameNode = Element('NAME') |
|
186 |
nameNode.text = str(key)
|
|
187 |
attrNode.append(nameNode) |
|
187 |
nameNode = Element('NAME')
|
|
188 |
nameNode.text = str(attr[0])
|
|
189 |
attrNode.append(nameNode)
|
|
188 | 190 |
|
189 |
valueNode = Element('VALUE') |
|
190 |
valueNode.text = str(value)
|
|
191 |
attrNode.append(valueNode) |
|
191 |
valueNode = Element('VALUE')
|
|
192 |
valueNode.text = str(attr[1])
|
|
193 |
attrNode.append(valueNode)
|
|
192 | 194 |
|
193 |
node.append(attrNode) |
|
195 |
node.append(attrNode) |
|
196 |
else: |
|
197 |
node.append(attr.toXml()) |
|
194 | 198 |
except Exception as ex: |
195 | 199 |
return str(self.uid) |
196 | 200 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
... | ... | |
254 | 258 |
for index in range(len(lineColumnList)): |
255 | 259 |
dataList.append('') |
256 | 260 |
|
257 |
dataList[0] = str(uuid.uuid4()) |
|
258 | 261 |
dataList[20] = docData.imgName |
259 | 262 |
|
260 | 263 |
for attr in attrs: |
261 |
attrName = attr[0].upper().replace(' ', '') |
|
262 |
data = attr[1] if attr[1] is not None else '' |
|
263 |
if attrName == 'NOMINALDIAMETER': |
|
264 |
dataList[1] = data |
|
265 |
elif attrName == 'FLUIDCODE': |
|
266 |
dataList[2] = data |
|
267 |
dataList[7] = data |
|
268 |
elif attrName == 'TAGSEQNO': |
|
269 |
pass |
|
270 |
elif attrName == 'INSULATIONPURPOSE': |
|
271 |
dataList[16] = data |
|
272 |
elif attrName == 'STREAMNO': |
|
273 |
pass |
|
274 |
elif attrName == 'LINENO': |
|
275 |
dataList[3] = data |
|
276 |
elif attrName == 'PNIDNUMBER': |
|
277 |
pass |
|
278 |
elif attrName == 'PIPINGMATERIALSCLASS': |
|
279 |
dataList[4] = data |
|
280 |
elif attrName == '': |
|
281 |
pass |
|
264 |
if type(attr) is not UserInputAttribute: |
|
265 |
attrName = attr[0].upper().replace(' ', '') |
|
266 |
data = attr[1] if attr[1] is not None else '' |
|
267 |
if attrName == 'NOMINALDIAMETER': |
|
268 |
dataList[1] = data |
|
269 |
elif attrName == 'FLUIDCODE': |
|
270 |
dataList[2] = data |
|
271 |
dataList[7] = data |
|
272 |
elif attrName == 'TAGSEQNO': |
|
273 |
pass |
|
274 |
elif attrName == 'INSULATIONPURPOSE': |
|
275 |
dataList[16] = data |
|
276 |
elif attrName == 'STREAMNO': |
|
277 |
pass |
|
278 |
elif attrName == 'LINENO': |
|
279 |
dataList[3] = data |
|
280 |
elif attrName == 'PNIDNUMBER': |
|
281 |
pass |
|
282 |
elif attrName == 'PIPINGMATERIALSCLASS': |
|
283 |
dataList[4] = data |
|
284 |
elif attrName == '': |
|
285 |
pass |
|
286 |
else: |
|
287 |
typeUID = attr.attribute |
|
288 |
value = attr.text |
|
289 |
lineAttr = docData.getLinePropertiesByUID(typeUID) |
|
290 |
|
|
291 |
for index in range(len(lineColumnList)): |
|
292 |
if lineColumnList[index] == lineAttr[0][1]: |
|
293 |
dataList[index] = value |
|
294 |
|
|
282 | 295 |
|
283 | 296 |
except Exception as ex: |
284 | 297 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py | ||
---|---|---|
1 | 1 |
# coding: utf-8 |
2 | 2 |
import os |
3 | 3 |
import sys |
4 |
import re |
|
4 | 5 |
from PyQt5.QtCore import * |
5 | 6 |
from PyQt5.QtGui import * |
6 | 7 |
from PyQt5.QtWidgets import * |
... | ... | |
53 | 54 |
self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Limit Number']) |
54 | 55 |
self.ui.tableWidgetAttr.horizontalHeaderItem(1).setSizeHint(QSize(25, 25)) |
55 | 56 |
|
57 |
self.settingLineNoAttributeTable() |
|
58 |
|
|
59 |
self.ui.pushButtonAddAttr.clicked.connect(self.onAddLineNoAttr) |
|
60 |
self.ui.pushButtonDelAttr.clicked.connect(self.onDelLineNoAttr) |
|
61 |
|
|
56 | 62 |
|
57 | 63 |
|
58 | 64 |
''' |
... | ... | |
176 | 182 |
@date 2018.08.13 |
177 | 183 |
''' |
178 | 184 |
def accept(self): |
179 |
if self._symbolType is None: |
|
185 |
if self._symbolType is not None:
|
|
180 | 186 |
self.saveData() |
181 |
self.reSettingSceneAttribute() |
|
182 | 187 |
else: |
183 |
pass |
|
184 |
|
|
188 |
self.saveLineAttrData() |
|
189 |
|
|
190 |
self.reSettingSceneAttribute() |
|
185 | 191 |
QDialog.accept(self) |
186 | 192 |
|
187 | 193 |
''' |
... | ... | |
194 | 200 |
App.mainWnd().checkAttribute() |
195 | 201 |
|
196 | 202 |
''' |
203 |
@brief setting attribute table line no |
|
204 |
@author kyoyho |
|
205 |
@date 2018.08.21 |
|
197 | 206 |
''' |
198 | 207 |
def settingLineNoAttributeTable(self): |
199 | 208 |
table = self.ui.tableWidgetAttr |
200 |
appDocData = AppDocData.instance() |
|
209 |
docData = AppDocData.instance() |
|
210 |
attrs = docData.getLineProperties() |
|
201 | 211 |
|
212 |
table.setRowCount(len(attrs)) |
|
202 | 213 |
|
214 |
row = 0 |
|
215 |
for attr in attrs: |
|
216 |
item = QTableWidgetItem(attr[0] if attr[0] is not None else '') |
|
217 |
self.ui.tableWidgetAttr.setItem(row, 0, item) |
|
218 |
item = QTableWidgetItem(attr[1] if attr[1] is not None else '') |
|
219 |
self.ui.tableWidgetAttr.setItem(row, 1, item) |
|
220 |
item = QTableWidgetItem(attr[2] if attr[2] is not None else '') |
|
221 |
self.ui.tableWidgetAttr.setItem(row, 2, item) |
|
222 |
|
|
223 |
attrTypeComboBox = QComboBox() |
|
224 |
attrTypeComboBox.addItem('Code Table') |
|
225 |
attrTypeComboBox.addItem('Int') |
|
226 |
attrTypeComboBox.addItem('String') |
|
227 |
self.ui.tableWidgetAttr.setCellWidget(row, 3, attrTypeComboBox) |
|
228 |
result = attrTypeComboBox.findText(attr[3] if attr[2] is not None else '') |
|
229 |
attrTypeComboBox.setCurrentIndex(result) |
|
230 |
|
|
231 |
|
|
232 |
item = QTableWidgetItem(str(attr[4]) if attr[4] is not None else '') |
|
233 |
self.ui.tableWidgetAttr.setItem(row, 4, item) |
|
234 |
|
|
235 |
row = row + 1 |
|
236 |
|
|
237 |
''' |
|
238 |
@brief add attribute |
|
239 |
@author kyoyho |
|
240 |
@date 2018.08.21 |
|
241 |
''' |
|
242 |
def onAddLineNoAttr(self): |
|
243 |
rows = self.ui.tableWidgetAttr.rowCount() |
|
244 |
self.ui.tableWidgetAttr.setRowCount(rows + 1) |
|
245 |
|
|
246 |
attrTypeComboBox = QComboBox() |
|
247 |
attrTypeComboBox.addItem('Code Table') |
|
248 |
attrTypeComboBox.addItem('Int') |
|
249 |
attrTypeComboBox.addItem('String') |
|
250 |
self.ui.tableWidgetAttr.setCellWidget(rows, 3, attrTypeComboBox) |
|
251 |
|
|
252 |
import uuid |
|
253 |
self.ui.tableWidgetAttr.setItem(rows, 0, QTableWidgetItem(str(uuid.uuid4()))) |
|
254 |
|
|
255 |
''' |
|
256 |
@brief delete selected attribute |
|
257 |
@author kyoyho |
|
258 |
@date 2018.08.21 |
|
259 |
''' |
|
260 |
def onDelLineNoAttr(self): |
|
261 |
model = self.ui.tableWidgetAttr.model() |
|
262 |
row = self.ui.tableWidgetAttr.currentRow() |
|
263 |
|
|
264 |
if row != -1: |
|
265 |
model.removeRow(row) |
|
266 |
|
|
267 |
''' |
|
268 |
@brief Check Number |
|
269 |
@author kyouho |
|
270 |
@date 2018.08.20 |
|
271 |
''' |
|
272 |
def isNumber(self, num): |
|
273 |
p = re.compile('(^[0-9]+$)') |
|
274 |
result = p.match(num) |
|
275 |
|
|
276 |
if result: |
|
277 |
return True |
|
278 |
else: |
|
279 |
return False |
|
280 |
|
|
281 |
''' |
|
282 |
@brief save data |
|
283 |
@author kyouho |
|
284 |
@date 2018.08.21 |
|
285 |
''' |
|
286 |
def saveLineAttrData(self): |
|
287 |
appDocData = AppDocData.instance() |
|
288 |
|
|
289 |
attrs = [] |
|
290 |
table = self.ui.tableWidgetAttr |
|
291 |
|
|
292 |
for index in range(table.rowCount()): |
|
293 |
attr = [] |
|
294 |
attr.append(table.item(index, 0).text() if table.item(index, 0) is not None else '') |
|
295 |
attr.append(table.item(index, 1).text() if table.item(index, 1) is not None else '') |
|
296 |
attr.append(table.item(index, 2).text() if table.item(index, 2) is not None else '') |
|
297 |
attr.append(table.cellWidget(index, 3).currentText() if table.cellWidget(index, 3).currentIndex() >= 0 else '') |
|
298 |
attr.append(int(table.item(index, 4).text()) if table.item(index, 4) is not None and self.isNumber(table.item(index, 4).text()) else None) |
|
299 |
attr.append(index) |
|
300 |
attrs.append(attr) |
|
203 | 301 |
|
302 |
appDocData.saveLineAttributes(attrs) |
DTI_PID/DTI_PID/TextItemFactory.py | ||
---|---|---|
30 | 30 |
kyouho 2018.07.04 edit for isLineNo method (add parameter) |
31 | 31 |
humkyung 2018.08.08 fill linePropertyData and tagSeqNoPattern if given data is None |
32 | 32 |
''' |
33 |
def createTextItem(self, text, delimiter = '', lineNoConfig = '', linePropertyData = None, tagSeqNoPattern = None):
|
|
33 |
def createTextItem(self, text): |
|
34 | 34 |
import random |
35 | 35 |
|
36 | 36 |
item = None |
... | ... | |
40 | 40 |
configs = docData.getConfigs('Size', 'Delimiter') |
41 | 41 |
sizeDelimiter = configs[0].value.upper() if 1 == len(configs) else None |
42 | 42 |
|
43 |
if linePropertyData is None: |
|
44 |
linePropertyData = {} |
|
45 |
linePropertyData['NominalDiameter'] = docData.getNomialPipeSizeData(True) |
|
46 |
linePropertyData['FluidCode'] = docData.getCodeTable('FluidCode', True) |
|
47 |
linePropertyData['UnitNumber'] = docData.getCodeTable('UnitNumber', True) |
|
48 |
linePropertyData['PnIDNumber'] = docData.getCodeTable('PnIDNumber', True) |
|
49 |
linePropertyData['PipingMaterialsClass'] = docData.getCodeTable('PipingMaterialsClass', True) |
|
50 |
linePropertyData['InsulationPurpose'] = docData.getCodeTable('InsulationPurpose', True) |
|
51 |
|
|
52 |
if tagSeqNoPattern is None: |
|
53 |
configs = docData.getConfigs('Line No Tag Rule', 'Tag Seq No') |
|
54 |
tagSeqNoPattern = configs[0].value if 1 == len(configs) else None |
|
55 |
|
|
56 | 43 |
result = (False,) |
57 |
if (delimiter != '' and lineNoConfig != ''): |
|
58 |
result = self.isLineNo(text, delimiter, lineNoConfig, linePropertyData, tagSeqNoPattern) |
|
44 |
result = self.isLineNo(text) |
|
59 | 45 |
|
60 | 46 |
if self.isNoteNoText(text): |
61 | 47 |
item = QEngineeringNoteItem() |
62 | 48 |
item.setToolTip(text) |
63 |
elif (delimiter != '' and lineNoConfig != '') and result[0]:
|
|
49 |
elif result[0]: |
|
64 | 50 |
item = QEngineeringLineNoTextItem(text) |
65 | 51 |
item.setToolTip(text) |
66 | 52 |
|
... | ... | |
85 | 71 |
item.setColor(QColor(rgb.red, rgb.green, rgb.blue).name()) |
86 | 72 |
|
87 | 73 |
else: |
88 |
configs = lineNoConfig[0].value.split(self.delimiter) |
|
74 |
configs = docData.getConfigs('Line No', 'Configuration') |
|
75 |
configs = configs[0].value.split(self.delimiter) |
|
76 |
|
|
89 | 77 |
values = result[1] |
90 | 78 |
index = configs.index(colorProperty) |
91 | 79 |
if index >= 0: |
92 | 80 |
value = values[index] |
93 |
if colorProperty == 'Nominal Diameter':
|
|
81 |
if colorProperty.replace(' ','') == 'NominalDiameter':
|
|
94 | 82 |
configs = docData.getConfigs('Line No', 'Size Unit') |
95 | 83 |
if configs and configs[0].value == "Inch": |
96 | 84 |
value = docData.convertInchToMetric(value) |
... | ... | |
128 | 116 |
2018.04.30 Jeongwoo lineNoConfig None Check |
129 | 117 |
kyouho 2018.07.04 edit logic |
130 | 118 |
''' |
131 |
def isLineNo(self, text, delimiter, lineNoConfig, linePropertyData, tagSeqNoPattern):
|
|
119 |
def isLineNo(self, text): |
|
132 | 120 |
try: |
121 |
docData = AppDocData.instance() |
|
122 |
# delimiter |
|
123 |
configs = docData.getConfigs('Line No', 'Delimiter') |
|
124 |
delimiter = configs[0].value if 1 == len(configs) else '-' |
|
125 |
# line config |
|
126 |
configs = docData.getConfigs('Line No', 'Configuration') |
|
127 |
lineNoConfig = configs[0].value.split(self.delimiter) |
|
128 |
|
|
133 | 129 |
res = [] |
134 | 130 |
|
135 | 131 |
if lineNoConfig is None or len(lineNoConfig) == 0: |
136 | 132 |
return (False,) |
137 | 133 |
|
138 | 134 |
tokens = text.split(delimiter) |
139 |
patternText = lineNoConfig[0].value.replace(self.delimiter, '').split(self.delimiter)
|
|
135 |
patternText = configs[0].value.replace(self.delimiter, '').split(self.delimiter)
|
|
140 | 136 |
#Line Number에 Delimiter가 있을 수 있음 |
141 |
if lineNoConfig[0].value != 'None' and len(tokens) >= len(patternText): |
|
142 |
configs = lineNoConfig[0].value.split(self.delimiter) |
|
143 |
|
|
137 |
if configs[0].value != 'None' and len(tokens) >= len(patternText): |
|
144 | 138 |
loopText = text.replace(' ','') |
145 | 139 |
|
146 |
for propertyName in configs: |
|
147 |
isTable = True |
|
148 |
|
|
140 |
for propertyName in lineNoConfig: |
|
141 |
isStartWord = False |
|
149 | 142 |
loopList = [] |
150 | 143 |
|
151 |
if propertyName == 'Tag Seq No': |
|
152 |
isTable = False |
|
153 |
elif propertyName == delimiter: |
|
154 |
loopList.append(delimiter) |
|
155 |
else: |
|
156 |
loopList = linePropertyData[propertyName.replace(' ','').replace('&','n')] |
|
144 |
lineProp = docData.getLinePropertiesByUID(propertyName) |
|
145 |
# Line property인 경우 |
|
146 |
if lineProp: |
|
147 |
lineType = lineProp[0][3] |
|
148 |
if lineType == 'Code Table': |
|
149 |
tableName = lineProp[0][1] |
|
150 |
loopList = docData.getCodeTable(tableName, True) |
|
151 |
isStartWord = True |
|
157 | 152 |
|
158 |
if isTable: |
|
159 |
find = False |
|
160 |
for loop in loopList: |
|
161 |
result = self.isStartWithWord(loopText, loop) |
|
162 |
if result[0]: |
|
163 |
loopText = result[1] |
|
164 |
res.append(result[2]) |
|
165 |
find = True |
|
166 |
break |
|
167 |
if not find: |
|
168 |
return (False,) |
|
153 |
elif lineType == 'Int': |
|
154 |
length = lineProp[0][4] |
|
155 |
loopList.append((length, True)) |
|
156 |
|
|
157 |
elif lineType == 'String': |
|
158 |
length = lineProp[0][4] |
|
159 |
loopList.append((length, False)) |
|
160 |
|
|
161 |
# 못찾은 경우 (ex. delimiter) |
|
169 | 162 |
else: |
170 |
result = self.isTagSeqNo(loopText, tagSeqNoPattern) |
|
163 |
if propertyName == delimiter: |
|
164 |
loopList.append(delimiter) |
|
165 |
isStartWord = True |
|
166 |
else: |
|
167 |
return (False,) |
|
168 |
|
|
169 |
find = False |
|
170 |
for loop in loopList: |
|
171 |
if isStartWord: |
|
172 |
result = self.isStartWithWord(loopText, loop) |
|
173 |
else: |
|
174 |
result = self.isLimitWord(loopText, loop) |
|
171 | 175 |
if result[0]: |
172 | 176 |
loopText = result[1] |
173 | 177 |
res.append(result[2]) |
174 |
else: |
|
175 |
return (False,) |
|
178 |
find = True |
|
179 |
break |
|
180 |
if not find: |
|
181 |
return (False,) |
|
176 | 182 |
|
177 | 183 |
if loopText == '': |
178 | 184 |
return (True, res) |
... | ... | |
254 | 260 |
else: |
255 | 261 |
return (False,) |
256 | 262 |
except Exception as ex: |
257 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
263 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
264 |
|
|
265 |
''' |
|
266 |
@brief Check Number |
|
267 |
@author kyouho |
|
268 |
@date 2018.07.05 |
|
269 |
''' |
|
270 |
def isLimitWord(self, text, pattern): |
|
271 |
try: |
|
272 |
if pattern is not None: |
|
273 |
attr = text |
|
274 |
length = pattern[0] |
|
275 |
isNumber = pattern[1] |
|
276 |
result = eval('attr[:' + str(length) + ']') |
|
277 |
|
|
278 |
if int(length) != len(result): |
|
279 |
return(False,) |
|
280 |
|
|
281 |
if isNumber: |
|
282 |
if self.isNumber(result): |
|
283 |
sliceText = text[0:len(result)] |
|
284 |
return (True, text[len(sliceText):len(text)], sliceText) |
|
285 |
else: |
|
286 |
return (False,) |
|
287 |
else: |
|
288 |
sliceText = text[0:len(result)] |
|
289 |
return (True, text[len(sliceText):len(text)], sliceText) |
|
290 |
else: |
|
291 |
return (False,) |
|
292 |
except Exception as ex: |
|
293 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
258 | 294 |
|
259 | 295 |
''' |
260 | 296 |
@brief Check if given text is Note No Text (ex : NOTE 1, NOTE 2, ...) |
DTI_PID/DTI_PID/UI/AttrEditor.ui | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>769</width>
|
|
10 |
<height>300</height>
|
|
9 |
<width>825</width>
|
|
10 |
<height>446</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="font"> |
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 | 9 |
<width>553</width> |
10 |
<height>622</height>
|
|
10 |
<height>626</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="font"> |
내보내기 Unified diff