개정판 b0034990
implementing issue #640:
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1189 | 1189 |
ret = [] |
1190 | 1190 |
|
1191 | 1191 |
try: |
1192 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
|
|
1192 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
|
|
1193 | 1193 |
conn = sqlite3.connect(dbPath) |
1194 | 1194 |
cursor = conn.cursor() |
1195 | 1195 |
if fieldName is not None and param is not None: |
... | ... | |
1521 | 1521 |
return result |
1522 | 1522 |
|
1523 | 1523 |
''' |
1524 |
@brief save symbol attributes |
|
1525 |
@author humkyung |
|
1526 |
@date 2018.08.14 |
|
1527 |
''' |
|
1528 |
def saveSymbolAttributes(self, type, attrs): |
|
1529 |
try: |
|
1530 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
1531 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
|
1532 |
conn = sqlite3.connect(dbPath) |
|
1533 |
# Get a cursor object |
|
1534 |
cursor = conn.cursor() |
|
1535 |
|
|
1536 |
sql = 'delete from SymbolAttribute where SymbolType = ?' |
|
1537 |
param = (type,) |
|
1538 |
cursor.execute(sql, param) |
|
1539 |
|
|
1540 |
for attr in attrs: |
|
1541 |
sql = 'insert into SymbolAttribute(SymbolType, Attribute) values(?,?)' |
|
1542 |
param = (type, attr) |
|
1543 |
cursor.execute(sql, param) |
|
1544 |
|
|
1545 |
conn.commit() |
|
1546 |
# Catch the exception |
|
1547 |
except Exception as ex: |
|
1548 |
# Roll back any change if something goes wrong |
|
1549 |
conn.rollback() |
|
1550 |
|
|
1551 |
from App import App |
|
1552 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1553 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
1554 |
finally: |
|
1555 |
# Close the db connection |
|
1556 |
conn.close() |
|
1557 |
|
|
1558 |
''' |
|
1524 | 1559 |
@brief get Code Table Data |
1525 | 1560 |
@author kyouho |
1526 | 1561 |
@date 2018.07.10 |
... | ... | |
1834 | 1869 |
symbolTypeList = [] |
1835 | 1870 |
|
1836 | 1871 |
try: |
1837 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
|
|
1872 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
|
|
1838 | 1873 |
|
1839 | 1874 |
conn = sqlite3.connect(dbPath) |
1840 | 1875 |
cursor = conn.cursor() |
... | ... | |
1843 | 1878 |
cursor.execute(sql) |
1844 | 1879 |
rows = cursor.fetchall() |
1845 | 1880 |
for row in rows: |
1846 |
symbolTypeList.append(row[2]) # Type String
|
|
1881 |
symbolTypeList.append((row[0], row[1], row[2])) # UID, category, type
|
|
1847 | 1882 |
except Exception as ex: |
1848 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1883 |
from App import App |
|
1884 |
|
|
1885 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1886 |
App.mainWin().addMessage(MessageType.Error, message) |
|
1849 | 1887 |
finally: |
1850 | 1888 |
conn.close() |
1851 | 1889 |
|
... | ... | |
1891 | 1929 |
''' |
1892 | 1930 |
def getSymbolTypeComboBoxItems(self): |
1893 | 1931 |
symbolTypeList = self.getSymbolTypeList() |
1894 |
symbolTypeList.insert(0, "None")
|
|
1932 |
symbolTypeList.insert(0, ('None', 'None', 'None'))
|
|
1895 | 1933 |
|
1896 | 1934 |
return symbolTypeList |
1897 | 1935 |
|
DTI_PID/DTI_PID/AttrEditorDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import os |
|
3 |
import sys |
|
4 |
from PyQt5.QtCore import * |
|
5 |
from PyQt5.QtGui import * |
|
6 |
from PyQt5.QtWidgets import * |
|
7 |
import sqlite3 |
|
8 |
from AppDocData import AppDocData |
|
9 |
from AppDocData import Config |
|
10 |
import AttrEditor_UI |
|
11 |
|
|
12 |
class QAttrEditorDialog(QDialog): |
|
13 |
def __init__(self, parent): |
|
14 |
QDialog.__init__(self, parent) |
|
15 |
|
|
16 |
self.ui = AttrEditor_UI.Ui_AttrEditorDialog() |
|
17 |
self.ui.setupUi(self) |
|
18 |
|
|
19 |
self.ui.pushButtonAddAttr.clicked.connect(self.onAddAttr) |
|
20 |
self.ui.pushButtonDelAttr.clicked.connect(self.onDelAttr) |
|
21 |
|
|
22 |
self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['Name', 'Type']) |
|
23 |
self.ui.tableWidgetAttr.horizontalHeaderItem(0).setSizeHint(QSize(25, 25)) |
|
24 |
|
|
25 |
''' |
|
26 |
@brief add a attribute |
|
27 |
@author humkyung |
|
28 |
@date 2018.08.13 |
|
29 |
''' |
|
30 |
def onAddAttr(self): |
|
31 |
rows = self.ui.tableWidgetAttr.rowCount() |
|
32 |
self.ui.tableWidgetAttr.setRowCount(rows + 1) |
|
33 |
|
|
34 |
attrTypeComboBox = QComboBox() |
|
35 |
attrTypeComboBox.addItem('Symbol Item') |
|
36 |
attrTypeComboBox.addItem('Text Item') |
|
37 |
attrTypeComboBox.addItem('Int') |
|
38 |
attrTypeComboBox.addItem('String') |
|
39 |
self.ui.tableWidgetAttr.setCellWidget(rows, 1, attrTypeComboBox) |
|
40 |
|
|
41 |
''' |
|
42 |
@brief delete selected attribute |
|
43 |
@author humkyung |
|
44 |
@date 2018.08.13 |
|
45 |
''' |
|
46 |
def onDelAttr(self): |
|
47 |
model = self.ui.tableWidgetAttr.model() |
|
48 |
|
|
49 |
row = self.ui.tableWidgetAttr.currentRow() |
|
50 |
if row != -1: |
|
51 |
model.removeRow(row) |
|
52 |
|
|
53 |
''' |
|
54 |
@brief save attributes |
|
55 |
@author humkyung |
|
56 |
@date 2018.08.13 |
|
57 |
''' |
|
58 |
def accept(self): |
|
59 |
QDialog.accept(self) |
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
62 | 62 |
elif type(item) is QEngineeringLineNoTextItem: |
63 | 63 |
self.onLineNoClicked(item) |
64 | 64 |
elif type(item) is QEngineeringNoteItem: |
65 |
self.onNoteClicked(item) |
|
65 |
noteContentsList = item.findNoteContents(item.text()) |
|
66 |
self.onNoteClicked(item.text(), noteContentsList) |
|
66 | 67 |
except Exception as ex: |
67 | 68 |
from App import App |
68 | 69 |
|
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
119 | 119 |
@history 18.05.14 Jeongwoo Change method to change color by changeTreeWidgetItemColorRecursively() |
120 | 120 |
''' |
121 | 121 |
def pickColorClickEvent(self, lineNoTreeWidgetItem): |
122 |
'''''' |
|
123 | 122 |
color = QColorDialog.getColor() # Dialog returns QColor |
124 | 123 |
|
125 | 124 |
if color is not None: |
DTI_PID/DTI_PID/Shapes/EngineeringUnknownItem.py | ||
---|---|---|
117 | 117 |
''' |
118 | 118 |
def paint(self, painter, options=None, widget=None): |
119 | 119 |
painter.setClipRect(options.exposedRect) |
120 |
QEngineeringPolylineItem.paint(self, painter, options, widget) |
|
121 |
|
|
120 | 122 |
if self.isSelected(): |
121 |
painter.setBrush(QBrush(QColor(255, 0, 0, 127))) |
|
122 |
QEngineeringPolylineItem.paint(self, painter, options, widget) |
|
123 |
else: |
|
124 |
QEngineeringPolylineItem.paint(self, painter, options, widget) |
|
123 |
painter.fillPath(self.path(), QBrush(QColor(255, 0, 0, 127))) |
|
125 | 124 |
|
126 | 125 |
''' |
127 | 126 |
@brief show symbol editor |
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import os |
|
3 |
import sys |
|
4 |
from PyQt5.QtCore import * |
|
5 |
from PyQt5.QtGui import * |
|
6 |
from PyQt5.QtWidgets import * |
|
7 |
import sqlite3 |
|
8 |
from AppDocData import AppDocData |
|
9 |
from AppDocData import Config |
|
10 |
import AttrEditor_UI |
|
11 |
|
|
12 |
class QSymbolAttrEditorDialog(QDialog): |
|
13 |
def __init__(self, parent, symbolType): |
|
14 |
QDialog.__init__(self, parent) |
|
15 |
|
|
16 |
self._symbolType = symbolType |
|
17 |
|
|
18 |
self.ui = AttrEditor_UI.Ui_AttrEditorDialog() |
|
19 |
self.ui.setupUi(self) |
|
20 |
|
|
21 |
self.ui.labelSelectedSymbolType.setText(symbolType[2]) |
|
22 |
|
|
23 |
self.ui.pushButtonAddAttr.clicked.connect(self.onAddAttr) |
|
24 |
self.ui.pushButtonDelAttr.clicked.connect(self.onDelAttr) |
|
25 |
|
|
26 |
self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['Name', 'Type']) |
|
27 |
self.ui.tableWidgetAttr.horizontalHeaderItem(0).setSizeHint(QSize(25, 25)) |
|
28 |
|
|
29 |
self.loadData() |
|
30 |
|
|
31 |
''' |
|
32 |
@brief load data |
|
33 |
@author humkyung |
|
34 |
@date 2018.08.14 |
|
35 |
''' |
|
36 |
def loadData(self): |
|
37 |
appDocData = AppDocData.instance() |
|
38 |
|
|
39 |
attrs = appDocData.getSymbolAttribute(self._symbolType[2]) |
|
40 |
self.ui.tableWidgetAttr.setRowCount(len(attrs)) |
|
41 |
|
|
42 |
row = 0 |
|
43 |
for attr in attrs: |
|
44 |
item = QTableWidgetItem(attr) |
|
45 |
self.ui.tableWidgetAttr.setItem(row, 0, item) |
|
46 |
|
|
47 |
attrTypeComboBox = QComboBox() |
|
48 |
attrTypeComboBox.addItem('Symbol Item') |
|
49 |
attrTypeComboBox.addItem('Text Item') |
|
50 |
attrTypeComboBox.addItem('Int') |
|
51 |
attrTypeComboBox.addItem('String') |
|
52 |
self.ui.tableWidgetAttr.setCellWidget(row, 1, attrTypeComboBox) |
|
53 |
|
|
54 |
row = row + 1 |
|
55 |
|
|
56 |
''' |
|
57 |
@brief save data |
|
58 |
@author humkyung |
|
59 |
@date 2018.08.14 |
|
60 |
''' |
|
61 |
def saveData(self): |
|
62 |
appDocData = AppDocData.instance() |
|
63 |
|
|
64 |
#appDocData.saveSymbolAttributes(self._symbolType[0], ) |
|
65 |
|
|
66 |
''' |
|
67 |
@brief add a attribute |
|
68 |
@author humkyung |
|
69 |
@date 2018.08.13 |
|
70 |
''' |
|
71 |
def onAddAttr(self): |
|
72 |
rows = self.ui.tableWidgetAttr.rowCount() |
|
73 |
self.ui.tableWidgetAttr.setRowCount(rows + 1) |
|
74 |
|
|
75 |
attrTypeComboBox = QComboBox() |
|
76 |
attrTypeComboBox.addItem('Symbol Item') |
|
77 |
attrTypeComboBox.addItem('Text Item') |
|
78 |
attrTypeComboBox.addItem('Int') |
|
79 |
attrTypeComboBox.addItem('String') |
|
80 |
self.ui.tableWidgetAttr.setCellWidget(rows, 1, attrTypeComboBox) |
|
81 |
|
|
82 |
''' |
|
83 |
@brief delete selected attribute |
|
84 |
@author humkyung |
|
85 |
@date 2018.08.13 |
|
86 |
''' |
|
87 |
def onDelAttr(self): |
|
88 |
model = self.ui.tableWidgetAttr.model() |
|
89 |
|
|
90 |
row = self.ui.tableWidgetAttr.currentRow() |
|
91 |
if row != -1: |
|
92 |
model.removeRow(row) |
|
93 |
|
|
94 |
''' |
|
95 |
@brief save attributes |
|
96 |
@author humkyung |
|
97 |
@date 2018.08.13 |
|
98 |
''' |
|
99 |
def accept(self): |
|
100 |
self.saveData() |
|
101 |
|
|
102 |
QDialog.accept(self) |
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
1 | 1 |
# coding: utf-8 |
2 |
|
|
2 | 3 |
from PyQt5 import QtCore, QtGui, QtWidgets |
3 | 4 |
from PyQt5.QtCore import pyqtSlot, QRectF |
4 | 5 |
from PyQt5.QtWidgets import * |
... | ... | |
13 | 14 |
import cv2 |
14 | 15 |
|
15 | 16 |
import SymbolEditor_UI |
16 |
from AppDocData import AppDocData
|
|
17 |
from AppDocData import *
|
|
17 | 18 |
|
18 | 19 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands') |
19 | 20 |
import CropCommand, HandCommand, ZoomCommand, PenCommand, EraserCommand, AreaEraserCommand, OriginalPointCommand, ConnectionPointCommand, AreaZoomCommand, FitImageCommand, RemoveTextCommand, RotateImageCommand, FlipImageCommand |
... | ... | |
48 | 49 |
|
49 | 50 |
self.setWindowTitle('심볼 편집기') |
50 | 51 |
except Exception as ex: |
51 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
52 |
from App import App |
|
53 |
|
|
54 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
55 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
52 | 56 |
|
53 | 57 |
def convertQImageToMat(self, incomingImage): |
54 | 58 |
''' Converts a QImage into an opencv MAT format ''' |
... | ... | |
64 | 68 |
arr = np.array(ptr).reshape(height, width, 4) # Copies the data |
65 | 69 |
return arr |
66 | 70 |
except Exception as ex: |
67 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
71 |
from App import App |
|
72 |
|
|
73 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
74 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
68 | 75 |
|
69 | 76 |
''' |
70 | 77 |
@brief Set up QtImageViewer and QImage |
... | ... | |
137 | 144 |
@brief Init Symbol Type ComboBox Items |
138 | 145 |
@author Jeongwoo |
139 | 146 |
@date 2018.04.06 |
140 |
@history . |
|
141 | 147 |
''' |
142 | 148 |
def initSymbolTypeComboBoxItems(self): |
143 | 149 |
for item in AppDocData.instance().getSymbolTypeComboBoxItems(): |
144 |
self.ui.typeComboBox.addItem(item) |
|
150 |
self.ui.typeComboBox.addItem(item[2])
|
|
145 | 151 |
self.ui.typeComboBox.currentTextChanged.connect(self.symbolTypeTextChagedEvent) |
146 | 152 |
|
147 | 153 |
def symbolTypeTextChagedEvent(self, value): |
DTI_PID/DTI_PID/SymbolPropertyTableWidget.py | ||
---|---|---|
51 | 51 |
|
52 | 52 |
### Symbol Type ComboBox Init |
53 | 53 |
symbolTypeComboBox = QComboBox() |
54 |
for name in AppDocData.instance().getSymbolTypeComboBoxItems():
|
|
55 |
symbolTypeComboBox.addItem(name)
|
|
54 |
for symbolType in AppDocData.instance().getSymbolTypeComboBoxItems():
|
|
55 |
symbolTypeComboBox.addItem(symbolType[2])
|
|
56 | 56 |
symbolTypeComboBox.setEnabled(False) |
57 | 57 |
self.setCellWidget(5, 1, symbolTypeComboBox) |
58 | 58 |
|
DTI_PID/DTI_PID/SymbolTreeWidget.py | ||
---|---|---|
43 | 43 |
itemPosition = self.mapTo(self, position) |
44 | 44 |
item = self.itemAt(itemPosition) |
45 | 45 |
data = item.data(0, self.TREE_DATA_ROLE) |
46 |
if data is not None: |
|
46 |
if data is not None and type(data) is symbol.SymbolBase:
|
|
47 | 47 |
sym = self.getSymbolByItemName(item, 0) |
48 | 48 |
text = item.text(0) |
49 | 49 |
if len(indexes) > 0: |
... | ... | |
80 | 80 |
@date 2018.08.13 |
81 | 81 |
''' |
82 | 82 |
def onEditAttrClicked(self, item, columnNo): |
83 |
from AttrEditorDialog import QAttrEditorDialog
|
|
83 |
from SymbolAttrEditorDialog import QSymbolAttrEditorDialog
|
|
84 | 84 |
|
85 | 85 |
try: |
86 |
dlg = QAttrEditorDialog(self) |
|
86 |
data = item.data(0, self.TREE_DATA_ROLE) |
|
87 |
|
|
88 |
dlg = QSymbolAttrEditorDialog(self, data) |
|
87 | 89 |
dlg.exec_() |
88 | 90 |
except Exception as ex: |
89 | 91 |
from App import App |
... | ... | |
146 | 148 |
humkyung 2018.07.30 sort child items |
147 | 149 |
''' |
148 | 150 |
def loadSymbolInfo(self): |
149 |
symbolTypeList = AppDocData.instance().getSymbolTypeList() |
|
150 |
for symbolType in symbolTypeList: |
|
151 |
parent = QTreeWidgetItem(self, [symbolType]) |
|
152 |
symbolList = AppDocData.instance().getSymbolListByQuery('type', symbolType) |
|
153 |
for symbol in symbolList: |
|
154 |
symbolItem = QTreeWidgetItem(parent, [symbol.getName()]) |
|
155 |
symbolItem.setData(0, self.TREE_DATA_ROLE, symbol) ## ADD DATA |
|
156 |
svgPath = symbol.getSvgFileFullPath() |
|
157 |
icon = QIcon(svgPath) |
|
158 |
symbolItem.setIcon(0, icon) |
|
159 |
symbolItem.svgFilePath = svgPath # save svg file path |
|
151 |
try: |
|
152 |
symbolTypeList = AppDocData.instance().getSymbolTypeList() |
|
153 |
for symbolType in symbolTypeList: |
|
154 |
parent = QTreeWidgetItem(self, [symbolType[2]]) |
|
155 |
parent.setData(0, self.TREE_DATA_ROLE, symbolType) |
|
156 |
symbolList = AppDocData.instance().getSymbolListByQuery('type', symbolType[2]) |
|
157 |
for symbol in symbolList: |
|
158 |
symbolItem = QTreeWidgetItem(parent, [symbol.getName()]) |
|
159 |
symbolItem.setData(0, self.TREE_DATA_ROLE, symbol) |
|
160 |
svgPath = symbol.getSvgFileFullPath() |
|
161 |
icon = QIcon(svgPath) |
|
162 |
symbolItem.setIcon(0, icon) |
|
163 |
symbolItem.svgFilePath = svgPath # save svg file path |
|
160 | 164 |
|
161 |
parent.sortChildren(0, Qt.AscendingOrder) |
|
165 |
parent.sortChildren(0, Qt.AscendingOrder) |
|
166 |
except Exception as ex: |
|
167 |
from App import App |
|
168 |
|
|
169 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
170 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
162 | 171 |
|
163 | 172 |
''' |
164 | 173 |
@brief Make Directory |
... | ... | |
196 | 205 |
else: |
197 | 206 |
QMessageBox.about(self, "알림", "심볼 데이터를 불러오는 중 에러가 발생했습니다.") |
198 | 207 |
except Exception as ex: |
199 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
|
|
208 |
from App import App
|
|
200 | 209 |
|
210 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
211 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
201 | 212 |
|
202 | 213 |
def itemDoubleClickEvent(self, item, columnNo): |
203 | 214 |
self.isDoubleClicked = True |
... | ... | |
228 | 239 |
item = self.currentItem() |
229 | 240 |
if item is not None: |
230 | 241 |
data = item.data(0, self.TREE_DATA_ROLE) |
231 |
if data is not None: |
|
242 |
if data is not None and type(data) is symbol.SymbolBase:
|
|
232 | 243 |
self.singleClicked.emit(data) |
233 | 244 |
|
234 | 245 |
''' |
... | ... | |
255 | 266 |
drag.setPixmap(pixmap) |
256 | 267 |
drag.exec(Qt.CopyAction) |
257 | 268 |
except Exception as ex: |
258 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
269 |
from App import App |
|
270 |
|
|
271 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
272 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
내보내기 Unified diff