개정판 d52b3462
작업 중
DTI_PID/DTI_PID/App.py | ||
---|---|---|
21 | 21 |
from QEngineeringLineItem import QEngineeringLineItem |
22 | 22 |
from SymbolSvg import SymbolSvg |
23 | 23 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
24 |
from AppDocData import AppDocData |
|
25 |
import QDirTreeWidget |
|
24 | 26 |
|
25 | 27 |
class Worker(QObject): |
26 | 28 |
from PyQt5.QtCore import QThread |
... | ... | |
68 | 70 |
self.graphicsView.setParent(self.centralwidget) |
69 | 71 |
self.verticalLayout.addWidget(self.graphicsView) |
70 | 72 |
|
73 |
# Add Custom TreeWidget |
|
74 |
dirTreeWidget = QDirTreeWidget.QDirTreeWidget() |
|
75 |
dirTreeWidget.header().hide() |
|
76 |
self.symbolTabVerticalLayout.addWidget(dirTreeWidget) |
|
77 |
|
|
78 |
# Add Custom Property ??? Widget |
|
79 |
# TEMP |
|
80 |
tempWidget = QTreeWidget() |
|
81 |
self.symbolTabVerticalLayout.addWidget(tempWidget) |
|
82 |
|
|
71 | 83 |
# connect signals and slots |
72 | 84 |
self.actionClose.triggered.connect(self.close) |
73 | 85 |
self.actionOpen.triggered.connect(self.openImageDrawing) |
... | ... | |
261 | 273 |
dlg.show() |
262 | 274 |
dlg.exec_() |
263 | 275 |
if dlg.selectedProject is not None: |
276 |
AppDocData.instance().setCurrentProject(dlg.selectedProject) |
|
264 | 277 |
form = ExampleApp.instance() |
265 | 278 |
form.show() |
266 | 279 |
except Exception as ex: |
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
4 | 4 |
import os |
5 | 5 |
import sqlite3 |
6 | 6 |
from SingletonInstance import SingletonInstane |
7 |
import Project |
|
7 | 8 |
|
8 | 9 |
DB_NAME = os.path.dirname(os.path.realpath(__file__)) + "\\db\\DTI_PID.db" |
9 | 10 |
|
10 | 11 |
class AppDocData(SingletonInstane): |
11 | 12 |
''' |
13 |
@brief Set current Project |
|
14 |
''' |
|
15 |
def setCurrentProject(self, project): |
|
16 |
self.project = project |
|
17 |
|
|
18 |
''' |
|
19 |
@brief Get current Project |
|
20 |
''' |
|
21 |
def getCurrentProject(self): |
|
22 |
return self.project |
|
23 |
|
|
24 |
''' |
|
12 | 25 |
@brief return project database path |
13 | 26 |
''' |
14 | 27 |
def getPrjDatabasePath(self): |
... | ... | |
93 | 106 |
''' |
94 | 107 |
@brief delete added symbol data |
95 | 108 |
''' |
96 |
def deleteSymbol(self, dbPath, imagePath):
|
|
109 |
def deleteSymbol(self, imagePath): |
|
97 | 110 |
ret = False |
98 | 111 |
try: |
112 |
dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db" |
|
99 | 113 |
conn = sqlite3.connect(dbPath) |
100 | 114 |
cursor = conn.cursor() |
101 | 115 |
sql = "DELETE FROM Symbol WHERE path = ?" |
... | ... | |
110 | 124 |
conn.close() |
111 | 125 |
return (ret, imagePath) |
112 | 126 |
|
127 |
''' |
|
128 |
@brief get symbol name list |
|
129 |
''' |
|
130 |
def getSymbolByQuery(self, fieldName, param): |
|
131 |
symbol = None |
|
132 |
|
|
133 |
try: |
|
134 |
dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db" |
|
135 |
conn = sqlite3.connect(dbPath) |
|
136 |
cursor = conn.cursor() |
|
137 |
sql = 'SELECT * FROM Symbol WHERE ' + fieldName + ' = "' + param + '"' |
|
138 |
try: |
|
139 |
cursor.execute(sql) |
|
140 |
rows = cursor.fetchall() |
|
141 |
if rows is not None and len(rows) > 0: |
|
142 |
symbol = rows[0] |
|
143 |
except Exception as ex: |
|
144 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
145 |
finally: |
|
146 |
conn.close() |
|
147 |
|
|
148 |
return symbol |
|
149 |
|
|
113 | 150 |
pass |
DTI_PID/DTI_PID/DTI_PID_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file 'ui/DTI__PID.ui'
|
|
3 |
# Form implementation generated from reading ui file 'DTI__PID.ui' |
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.10.1
|
|
5 |
# Created by: PyQt5 UI code generator 5.6
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
... | ... | |
49 | 49 |
self.dockWidgetContents = QtWidgets.QWidget() |
50 | 50 |
self.dockWidgetContents.setObjectName("dockWidgetContents") |
51 | 51 |
self.gridLayout_2 = QtWidgets.QGridLayout(self.dockWidgetContents) |
52 |
self.gridLayout_2.setContentsMargins(0, 0, 0, 0) |
|
52 | 53 |
self.gridLayout_2.setObjectName("gridLayout_2") |
53 | 54 |
self.tabWidget = QtWidgets.QTabWidget(self.dockWidgetContents) |
54 | 55 |
self.tabWidget.setObjectName("tabWidget") |
55 | 56 |
self.Symbol = QtWidgets.QWidget() |
56 | 57 |
self.Symbol.setObjectName("Symbol") |
57 | 58 |
self.gridLayout_3 = QtWidgets.QGridLayout(self.Symbol) |
59 |
self.gridLayout_3.setContentsMargins(0, 0, 0, 0) |
|
58 | 60 |
self.gridLayout_3.setObjectName("gridLayout_3") |
59 |
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
|
|
60 |
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
|
61 |
self.symbolTabVerticalLayout = QtWidgets.QVBoxLayout()
|
|
62 |
self.symbolTabVerticalLayout.setObjectName("symbolTabVerticalLayout")
|
|
61 | 63 |
self.pushButtonCreateSymbol = QtWidgets.QPushButton(self.Symbol) |
62 | 64 |
self.pushButtonCreateSymbol.setMaximumSize(QtCore.QSize(32, 16777215)) |
63 | 65 |
self.pushButtonCreateSymbol.setLayoutDirection(QtCore.Qt.LeftToRight) |
64 | 66 |
self.pushButtonCreateSymbol.setObjectName("pushButtonCreateSymbol") |
65 |
self.verticalLayout_2.addWidget(self.pushButtonCreateSymbol) |
|
66 |
self.listView_2 = QtWidgets.QListView(self.Symbol) |
|
67 |
self.listView_2.setObjectName("listView_2") |
|
68 |
self.verticalLayout_2.addWidget(self.listView_2) |
|
69 |
self.listView = QtWidgets.QListView(self.Symbol) |
|
70 |
self.listView.setObjectName("listView") |
|
71 |
self.verticalLayout_2.addWidget(self.listView) |
|
72 |
self.gridLayout_3.addLayout(self.verticalLayout_2, 0, 0, 1, 1) |
|
67 |
self.symbolTabVerticalLayout.addWidget(self.pushButtonCreateSymbol) |
|
68 |
self.gridLayout_3.addLayout(self.symbolTabVerticalLayout, 0, 0, 1, 1) |
|
73 | 69 |
self.tabWidget.addTab(self.Symbol, "") |
74 | 70 |
self.gridLayout_2.addWidget(self.tabWidget, 0, 0, 1, 1) |
75 | 71 |
self.dockWidget.setWidget(self.dockWidgetContents) |
... | ... | |
79 | 75 |
self.dockWidgetContents_2 = QtWidgets.QWidget() |
80 | 76 |
self.dockWidgetContents_2.setObjectName("dockWidgetContents_2") |
81 | 77 |
self.gridLayout_4 = QtWidgets.QGridLayout(self.dockWidgetContents_2) |
78 |
self.gridLayout_4.setContentsMargins(0, 0, 0, 0) |
|
82 | 79 |
self.gridLayout_4.setObjectName("gridLayout_4") |
83 | 80 |
self.verticalLayout_3 = QtWidgets.QVBoxLayout() |
84 | 81 |
self.verticalLayout_3.setObjectName("verticalLayout_3") |
... | ... | |
165 | 162 |
self.actionConfiguration.setText(_translate("MainWindow", "환경 설정")) |
166 | 163 |
self.actionArea.setText(_translate("MainWindow", "영역 설정")) |
167 | 164 |
|
168 |
import DTI_PID_rc |
|
169 | 165 |
|
170 | 166 |
if __name__ == "__main__": |
171 | 167 |
import sys |
DTI_PID/DTI_PID/QDirTreeWidget.py | ||
---|---|---|
1 |
try: |
|
2 |
from PyQt5.QtCore import * |
|
3 |
from PyQt5.QtGui import * |
|
4 |
from PyQt5.QtWidgets import * |
|
5 |
except ImportError: |
|
6 |
try: |
|
7 |
from PyQt4.QtCore import * |
|
8 |
from PyQt4.QtGui import * |
|
9 |
except ImportError: |
|
10 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
|
11 |
from AppDocData import AppDocData |
|
12 |
import os |
|
13 |
|
|
14 |
class QDirTreeWidget(QTreeWidget): |
|
15 |
def __init__(self): |
|
16 |
QTreeWidget.__init__(self) |
|
17 |
self.project = AppDocData.instance().getCurrentProject() |
|
18 |
self.initDirTreeWidget() |
|
19 |
|
|
20 |
def initDirTreeWidget(self): |
|
21 |
self.itemDoubleClicked.connect(self.itemDoubleClickEvent) |
|
22 |
self.itemClicked.connect(self.itemClickEvent) |
|
23 |
if self.project is not None: |
|
24 |
self.clear() |
|
25 |
print("Project : " + self.project.getName()) |
|
26 |
projectPath = self.project.getPath().replace("\\", "/") |
|
27 |
self.makeChildDir(projectPath) |
|
28 |
self.loadDirectoryInfo(projectPath, self) |
|
29 |
|
|
30 |
def makeChildDir(self, startPath): |
|
31 |
dbDir = startPath+"/db" |
|
32 |
if not os.path.exists(dbDir): |
|
33 |
os.makedirs(dbDir) |
|
34 |
imgDir = startPath+"/image" |
|
35 |
if not os.path.exists(imgDir): |
|
36 |
os.makedirs(imgDir) |
|
37 |
svgDir = startPath+"/svg" |
|
38 |
if not os.path.exists(svgDir): |
|
39 |
os.makedirs(svgDir) |
|
40 |
|
|
41 |
def loadDirectoryInfo(self, startPath, tree): |
|
42 |
for element in os.listdir(startPath): |
|
43 |
pathInfo = startPath + "/" + element |
|
44 |
parentItem = QTreeWidgetItem(tree, [os.path.basename(element)]) |
|
45 |
if os.path.isdir(pathInfo): |
|
46 |
self.loadDirectoryInfo(pathInfo, parentItem) |
|
47 |
|
|
48 |
def itemDoubleClickEvent(self, item, columnNo): |
|
49 |
print(item.text(columnNo) + " : Double Clicked") |
|
50 |
name = item.text(columnNo) |
|
51 |
if name.lower().endswith(".png"): |
|
52 |
print("Image [" + name + "] Double Clicked") |
|
53 |
|
|
54 |
def itemClickEvent(self, item, columnNo): |
|
55 |
print(item.text(columnNo) + " : Single Clicked") |
|
56 |
tmpItem = item |
|
57 |
itemName = item.text(columnNo) |
|
58 |
path = itemName |
|
59 |
while tmpItem.parent() is not None: |
|
60 |
path = tmpItem.parent().text(columnNo) + "/" + path |
|
61 |
tmpItem = tmpItem.parent() |
|
62 |
fullPath = self.project.getPath() + "/" + path |
|
63 |
print(fullPath) |
|
64 |
|
|
65 |
symbol = AppDocData.instance().getSymbolByQuery("path", fullPath) |
|
66 |
print(symbol.getPath()) |
DTI_PID/DTI_PID/QSymbolEditorDialog.py | ||
---|---|---|
297 | 297 |
if os.path.exists(svgPath): |
298 | 298 |
os.remove(svgPath) |
299 | 299 |
|
300 |
dbPath = self.project.getPath()+"/db/ITI_PID.db" |
|
301 |
AppDocData.instance().deleteSymbol(dbPath, imagePath) |
|
300 |
AppDocData.instance().deleteSymbol(imagePath) |
|
302 | 301 |
|
303 | 302 |
def keyPressEvent(self, event): |
304 | 303 |
if event.key() == QtCore.Qt.Key_Delete: |
DTI_PID/DTI_PID/UI/DTI__PID.ui | ||
---|---|---|
103 | 103 |
</attribute> |
104 | 104 |
<layout class="QGridLayout" name="gridLayout_3"> |
105 | 105 |
<item row="0" column="0"> |
106 |
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
106 |
<layout class="QVBoxLayout" name="symbolTabVerticalLayout">
|
|
107 | 107 |
<item> |
108 | 108 |
<widget class="QPushButton" name="pushButtonCreateSymbol"> |
109 | 109 |
<property name="maximumSize"> |
... | ... | |
120 | 120 |
</property> |
121 | 121 |
</widget> |
122 | 122 |
</item> |
123 |
<item> |
|
124 |
<widget class="QListView" name="listView_2"/> |
|
125 |
</item> |
|
126 |
<item> |
|
127 |
<widget class="QListView" name="listView"/> |
|
128 |
</item> |
|
129 | 123 |
</layout> |
130 | 124 |
</item> |
131 | 125 |
</layout> |
... | ... | |
165 | 159 |
</widget> |
166 | 160 |
<action name="actionOpen"> |
167 | 161 |
<property name="icon"> |
168 |
<iconset resource="../res/DTI_PID.qrc">
|
|
162 |
<iconset> |
|
169 | 163 |
<normaloff>:/appPrefix/open-file-icon.png</normaloff>:/appPrefix/open-file-icon.png</iconset> |
170 | 164 |
</property> |
171 | 165 |
<property name="text"> |
... | ... | |
189 | 183 |
</action> |
190 | 184 |
<action name="actionRecognition"> |
191 | 185 |
<property name="icon"> |
192 |
<iconset resource="../res/DTI_PID.qrc">
|
|
186 |
<iconset> |
|
193 | 187 |
<normaloff>:/appPrefix/recognition-file.png</normaloff>:/appPrefix/recognition-file.png</iconset> |
194 | 188 |
</property> |
195 | 189 |
<property name="text"> |
... | ... | |
201 | 195 |
</action> |
202 | 196 |
<action name="actionLine"> |
203 | 197 |
<property name="icon"> |
204 |
<iconset resource="../res/DTI_PID.qrc">
|
|
198 |
<iconset> |
|
205 | 199 |
<normaloff>:/appPrefix/draw-line-icon.png</normaloff>:/appPrefix/draw-line-icon.png</iconset> |
206 | 200 |
</property> |
207 | 201 |
<property name="text"> |
... | ... | |
221 | 215 |
</action> |
222 | 216 |
<action name="actionValidate"> |
223 | 217 |
<property name="icon"> |
224 |
<iconset resource="../res/DTI_PID.qrc">
|
|
218 |
<iconset> |
|
225 | 219 |
<normaloff>:/appPrefix/validation-icon.png</normaloff>:/appPrefix/validation-icon.png</iconset> |
226 | 220 |
</property> |
227 | 221 |
<property name="text"> |
... | ... | |
242 | 236 |
</property> |
243 | 237 |
</action> |
244 | 238 |
</widget> |
245 |
<resources> |
|
246 |
<include location="../res/DTI_PID.qrc"/> |
|
247 |
</resources> |
|
239 |
<resources/> |
|
248 | 240 |
<connections/> |
249 | 241 |
</ui> |
내보내기 Unified diff