개정판 2885ca96
dev issue #587: 심볼 드래그를 통하여 속성과 연계기능 추가
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1402 | 1402 |
return result |
1403 | 1403 |
|
1404 | 1404 |
''' |
1405 |
@brief get Symbol Attribute |
|
1406 |
@author kyouho |
|
1407 |
@date 2018.07.18 |
|
1408 |
''' |
|
1409 |
def getSymbolAttribute(self, _type): |
|
1410 |
result = [] |
|
1411 |
|
|
1412 |
try: |
|
1413 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
1414 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
|
1415 |
conn = sqlite3.connect(dbPath) |
|
1416 |
# Get a cursor object |
|
1417 |
cursor = conn.cursor() |
|
1418 |
|
|
1419 |
sql = 'select attribute from SymbolAttribute where SymbolType = ?' |
|
1420 |
param = (_type,) |
|
1421 |
cursor.execute(sql, param) |
|
1422 |
rows = cursor.fetchall() |
|
1423 |
for row in rows: |
|
1424 |
result.append(row[0]) |
|
1425 |
# Catch the exception |
|
1426 |
except Exception as ex: |
|
1427 |
# Roll back any change if something goes wrong |
|
1428 |
conn.rollback() |
|
1429 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1430 |
finally: |
|
1431 |
# Close the db connection |
|
1432 |
conn.close() |
|
1433 |
|
|
1434 |
return result |
|
1435 |
|
|
1436 |
''' |
|
1405 | 1437 |
@brief get Code Table Data |
1406 | 1438 |
@author kyouho |
1407 | 1439 |
@date 2018.07.10 |
DTI_PID/DTI_PID/DTI_PID.pyproj | ||
---|---|---|
39 | 39 |
<Compile Include="azure_ocr_module.py"> |
40 | 40 |
<SubType>Code</SubType> |
41 | 41 |
</Compile> |
42 |
<Compile Include="SelectAttributeDialog.py" /> |
|
42 | 43 |
<Compile Include="CodeTableDialog.py" /> |
43 | 44 |
<Compile Include="CodeTable_UI.py" /> |
44 | 45 |
<Compile Include="ConfigurationAreaDialog.py" /> |
DTI_PID/DTI_PID/Scripts/SymbolAttribute.sql | ||
---|---|---|
1 |
CREATE TABLE IF NOT EXISTS [SymbolAttribute]( |
|
2 |
[SymbolType] TEXT, |
|
3 |
[Attribute] TEXT, |
|
4 |
PRIMARY KEY([SymbolType], [Attribute])); |
DTI_PID/DTI_PID/SelectAttributeDialog.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 SelectAttribute_UI |
|
11 |
|
|
12 |
class QSelectAttributeDialog(QDialog): |
|
13 |
def __init__(self, parent, symbolType): |
|
14 |
QDialog.__init__(self, parent) |
|
15 |
|
|
16 |
self.removeUID = {} |
|
17 |
self.currentCode = {} |
|
18 |
|
|
19 |
self.ui = SelectAttribute_UI.Ui_SelectAttributeDialog() |
|
20 |
self.ui.setupUi(self) |
|
21 |
|
|
22 |
self.dialogResult = False |
|
23 |
self.selectedAttribute = '' |
|
24 |
|
|
25 |
self.settingComboBoxAttribute(symbolType) |
|
26 |
|
|
27 |
|
|
28 |
def settingComboBoxAttribute(self, symbolType): |
|
29 |
docData = AppDocData.instance() |
|
30 |
symbolAttrs = docData.getSymbolAttribute(symbolType) |
|
31 |
for attr in symbolAttrs: |
|
32 |
self.ui.comboBoxAttribute.addItem(attr) |
|
33 |
|
|
34 |
|
|
35 |
def accept(self): |
|
36 |
self.dialogResult = True |
|
37 |
index = self.ui.comboBoxAttribute.currentIndex() |
|
38 |
self.selectedAttribute = self.ui.comboBoxAttribute.itemText(index) |
|
39 |
QDialog.accept(self) |
DTI_PID/DTI_PID/SelectAttribute_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file './UI/SelectAttribute.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.9.2 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
10 |
|
|
11 |
class Ui_SelectAttributeDialog(object): |
|
12 |
def setupUi(self, SelectAttributeDialog): |
|
13 |
SelectAttributeDialog.setObjectName("SelectAttributeDialog") |
|
14 |
SelectAttributeDialog.resize(277, 67) |
|
15 |
self.gridLayout = QtWidgets.QGridLayout(SelectAttributeDialog) |
|
16 |
self.gridLayout.setObjectName("gridLayout") |
|
17 |
self.buttonBox = QtWidgets.QDialogButtonBox(SelectAttributeDialog) |
|
18 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
19 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
20 |
self.buttonBox.setObjectName("buttonBox") |
|
21 |
self.gridLayout.addWidget(self.buttonBox, 1, 1, 1, 1) |
|
22 |
self.comboBoxAttribute = QtWidgets.QComboBox(SelectAttributeDialog) |
|
23 |
self.comboBoxAttribute.setObjectName("comboBoxAttribute") |
|
24 |
self.gridLayout.addWidget(self.comboBoxAttribute, 0, 1, 1, 1) |
|
25 |
self.label = QtWidgets.QLabel(SelectAttributeDialog) |
|
26 |
self.label.setObjectName("label") |
|
27 |
self.gridLayout.addWidget(self.label, 0, 0, 1, 1) |
|
28 |
|
|
29 |
self.retranslateUi(SelectAttributeDialog) |
|
30 |
self.buttonBox.accepted.connect(SelectAttributeDialog.accept) |
|
31 |
self.buttonBox.rejected.connect(SelectAttributeDialog.reject) |
|
32 |
QtCore.QMetaObject.connectSlotsByName(SelectAttributeDialog) |
|
33 |
|
|
34 |
def retranslateUi(self, SelectAttributeDialog): |
|
35 |
_translate = QtCore.QCoreApplication.translate |
|
36 |
SelectAttributeDialog.setWindowTitle(_translate("SelectAttributeDialog", "Dialog")) |
|
37 |
self.label.setText(_translate("SelectAttributeDialog", "Attribute")) |
|
38 |
|
|
39 |
|
|
40 |
if __name__ == "__main__": |
|
41 |
import sys |
|
42 |
app = QtWidgets.QApplication(sys.argv) |
|
43 |
SelectAttributeDialog = QtWidgets.QDialog() |
|
44 |
ui = Ui_SelectAttributeDialog() |
|
45 |
ui.setupUi(SelectAttributeDialog) |
|
46 |
SelectAttributeDialog.show() |
|
47 |
sys.exit(app.exec_()) |
|
48 |
|
DTI_PID/DTI_PID/Shapes/QEngineeringTextItem.py | ||
---|---|---|
44 | 44 |
self.setColor(self._color) |
45 | 45 |
|
46 | 46 |
self.delimiter = '"' |
47 |
|
|
48 |
self.attribute = '' |
|
47 | 49 |
''' |
48 | 50 |
@brief Get owner |
49 | 51 |
@author Jeongwoo |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
13 | 13 |
from QEngineeringConnectorItem import QEngineeringConnectorItem |
14 | 14 |
from QEngineeringAbstractItem import QEngineeringAbstractItem |
15 | 15 |
|
16 |
import SelectAttributeDialog |
|
17 |
|
|
16 | 18 |
class SymbolSvgItem(QGraphicsSvgItem, QEngineeringAbstractItem): |
17 | 19 |
clicked = pyqtSignal(QGraphicsSvgItem) |
18 | 20 |
removed = pyqtSignal(QGraphicsItem) |
... | ... | |
51 | 53 |
self.setAcceptedMouseButtons(Qt.LeftButton) |
52 | 54 |
self.setAcceptTouchEvents(True) |
53 | 55 |
|
56 |
self.isClick = False |
|
57 |
self.currentCursor = 0 |
|
58 |
|
|
54 | 59 |
try: |
55 | 60 |
f = QFile(path) |
56 | 61 |
f.open(QIODevice.ReadOnly) |
... | ... | |
237 | 242 |
@date 2018.05.02 |
238 | 243 |
''' |
239 | 244 |
def hoverEnterEvent(self, event): |
245 |
self.currentCursor = int(Qt.OpenHandCursor) |
|
240 | 246 |
cursor = QCursor(Qt.OpenHandCursor) |
241 | 247 |
QApplication.instance().setOverrideCursor(cursor) |
242 | 248 |
self.update() |
... | ... | |
251 | 257 |
for attr in self.attrs: |
252 | 258 |
attr.setDefaultTextColor(Qt.red) |
253 | 259 |
attr.update() |
254 |
|
|
260 |
#kyouho Edit Start |
|
255 | 261 |
''' |
256 | 262 |
@brief unhighlight connector and attribute |
257 | 263 |
@author humkyung |
258 | 264 |
@date 2018.05.02 |
265 |
@history kyouho 2018.07.18 edit ArrowCursor |
|
259 | 266 |
''' |
260 | 267 |
def hoverLeaveEvent(self, event): |
261 |
QApplication.instance().restoreOverrideCursor() |
|
268 |
self.currentCursor = int(Qt.ArrowCursor) |
|
269 |
cursor = QCursor(Qt.ArrowCursor) |
|
270 |
QApplication.instance().setOverrideCursor(cursor) |
|
262 | 271 |
self.update() |
263 | 272 |
|
264 | 273 |
''' |
... | ... | |
295 | 304 |
@brief Mouse Press Event |
296 | 305 |
@author Jeongwoo |
297 | 306 |
@date 18.04.11 |
298 |
@history .
|
|
307 |
@history kyouho 2018.07.18 add isClick logic
|
|
299 | 308 |
''' |
300 | 309 |
def mousePressEvent(self, event): |
301 | 310 |
if event.buttons() == Qt.LeftButton: |
302 | 311 |
self.clicked.emit(self) |
312 |
#Type에 따라서 isClick 조절 설정 가능 |
|
313 |
self.isClick = True |
|
314 |
|
|
315 |
''' |
|
316 |
@brief Mouse Release Event |
|
317 |
@author kyouho |
|
318 |
@date 18.07.17 |
|
319 |
''' |
|
320 |
def mouseReleaseEvent(self, event): |
|
321 |
super().mouseReleaseEvent(event) |
|
322 |
if self.isClick: |
|
323 |
self.isClick = False |
|
324 |
self.currentCursor = int(Qt.ArrowCursor) |
|
325 |
cursor = QCursor(Qt.ArrowCursor) |
|
326 |
QApplication.instance().setOverrideCursor(cursor) |
|
327 |
self.update() |
|
328 |
|
|
329 |
scenePos = self.mapToScene(event.pos()) |
|
330 |
result = self.findTextItemInPoint(scenePos) |
|
331 |
if result[0]: |
|
332 |
item = result[1] |
|
333 |
|
|
334 |
dialog = SelectAttributeDialog.QSelectAttributeDialog(None, self.type) |
|
335 |
dialog.exec_() |
|
336 |
|
|
337 |
if dialog.dialogResult and dialog.selectedAttribute: |
|
338 |
attrStr = dialog.selectedAttribute |
|
339 |
item.attribute = attrStr |
|
340 |
|
|
341 |
#기존 연결되있는 Attr 제거 |
|
342 |
self.removeAttr(item) |
|
343 |
|
|
344 |
self.attrs.append(item) |
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
''' |
|
353 |
@brief Mouse Move Event |
|
354 |
@author kyouho |
|
355 |
@date 18.07.17 |
|
356 |
''' |
|
357 |
def mouseMoveEvent(self, event): |
|
358 |
if self.isClick and self.currentCursor != int(Qt.ClosedHandCursor): |
|
359 |
self.currentCursor = int(Qt.ClosedHandCursor) |
|
360 |
cursor = QCursor(Qt.ClosedHandCursor) |
|
361 |
QApplication.instance().setOverrideCursor(cursor) |
|
362 |
self.update() |
|
363 |
|
|
364 |
''' |
|
365 |
@brief Mouse Move Event |
|
366 |
@author kyouho |
|
367 |
@date 18.07.17 |
|
368 |
''' |
|
369 |
def findTextItemInPoint(self, point): |
|
370 |
from QEngineeringTextItem import QEngineeringTextItem |
|
371 |
|
|
372 |
scene = self.scene() |
|
373 |
|
|
374 |
for item in scene.items(): |
|
375 |
if type(item) is QEngineeringTextItem: |
|
376 |
if self.isOverlapItemAndPoint(item, point): |
|
377 |
return (True, item) |
|
378 |
|
|
379 |
return (False,) |
|
380 |
''' |
|
381 |
@brief Mouse Move Event |
|
382 |
@author kyouho |
|
383 |
@date 18.07.17 |
|
384 |
''' |
|
385 |
def isOverlapItemAndPoint(self, item, point): |
|
386 |
x = point.x() |
|
387 |
y = point.y() |
|
388 |
loc = item.loc |
|
389 |
size = item.size |
|
390 |
|
|
391 |
if loc[0] <= x and loc[0] + size[0] >= x and loc[1] <= y and loc[1] + size[1] >= y: |
|
392 |
return True |
|
393 |
else: |
|
394 |
return False |
|
395 |
|
|
396 |
''' |
|
397 |
@brief Remove Attr |
|
398 |
@author kyouho |
|
399 |
@date 18.07.17 |
|
400 |
''' |
|
401 |
def removeAttr(self, item): |
|
402 |
scene = self.scene() |
|
403 |
for symbol in scene.items(): |
|
404 |
if type(symbol) is SymbolSvgItem: |
|
405 |
for attr in symbol.attrs: |
|
406 |
if attr == item: |
|
407 |
symbol.attrs.remove(item) |
|
408 |
#kyouho Edit End |
|
303 | 409 |
|
304 | 410 |
''' |
305 | 411 |
@brief remove item when user press delete key |
... | ... | |
373 | 479 |
@brief get attribute |
374 | 480 |
@author humkyung |
375 | 481 |
@date 2018.06.14 |
482 |
@history kyouho 2018.07.18 Add only attr QEngineeringTextItem |
|
376 | 483 |
''' |
377 | 484 |
def getAttributes(self): |
485 |
from QEngineeringTextItem import QEngineeringTextItem |
|
486 |
|
|
378 | 487 |
attrs = {} |
488 |
for attr in self.attrs: |
|
489 |
if type(attr) is QEngineeringTextItem: |
|
490 |
attrs[attr.attribute] = attr.text() |
|
491 |
|
|
379 | 492 |
return attrs |
380 | 493 |
|
381 | 494 |
''' |
DTI_PID/DTI_PID/UI/SelectAttribute.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>SelectAttributeDialog</class> |
|
4 |
<widget class="QDialog" name="SelectAttributeDialog"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>277</width> |
|
10 |
<height>67</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>Dialog</string> |
|
15 |
</property> |
|
16 |
<layout class="QGridLayout" name="gridLayout"> |
|
17 |
<item row="1" column="1"> |
|
18 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
19 |
<property name="orientation"> |
|
20 |
<enum>Qt::Horizontal</enum> |
|
21 |
</property> |
|
22 |
<property name="standardButtons"> |
|
23 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
24 |
</property> |
|
25 |
</widget> |
|
26 |
</item> |
|
27 |
<item row="0" column="1"> |
|
28 |
<widget class="QComboBox" name="comboBoxAttribute"/> |
|
29 |
</item> |
|
30 |
<item row="0" column="0"> |
|
31 |
<widget class="QLabel" name="label"> |
|
32 |
<property name="text"> |
|
33 |
<string>Attribute</string> |
|
34 |
</property> |
|
35 |
</widget> |
|
36 |
</item> |
|
37 |
</layout> |
|
38 |
</widget> |
|
39 |
<resources/> |
|
40 |
<connections> |
|
41 |
<connection> |
|
42 |
<sender>buttonBox</sender> |
|
43 |
<signal>accepted()</signal> |
|
44 |
<receiver>SelectAttributeDialog</receiver> |
|
45 |
<slot>accept()</slot> |
|
46 |
<hints> |
|
47 |
<hint type="sourcelabel"> |
|
48 |
<x>248</x> |
|
49 |
<y>254</y> |
|
50 |
</hint> |
|
51 |
<hint type="destinationlabel"> |
|
52 |
<x>157</x> |
|
53 |
<y>274</y> |
|
54 |
</hint> |
|
55 |
</hints> |
|
56 |
</connection> |
|
57 |
<connection> |
|
58 |
<sender>buttonBox</sender> |
|
59 |
<signal>rejected()</signal> |
|
60 |
<receiver>SelectAttributeDialog</receiver> |
|
61 |
<slot>reject()</slot> |
|
62 |
<hints> |
|
63 |
<hint type="sourcelabel"> |
|
64 |
<x>316</x> |
|
65 |
<y>260</y> |
|
66 |
</hint> |
|
67 |
<hint type="destinationlabel"> |
|
68 |
<x>286</x> |
|
69 |
<y>274</y> |
|
70 |
</hint> |
|
71 |
</hints> |
|
72 |
</connection> |
|
73 |
</connections> |
|
74 |
</ui> |
내보내기 Unified diff