개정판 0df8e0bc
issue #641: 도면 열기 수정(use scene() instead of scene in graphicsView) - revised
Change-Id: I62fb7b1269b610c9321ebffa9f528d3d60dd9ac9
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
21 | 21 |
from SingletonInstance import SingletonInstance |
22 | 22 |
import symbol |
23 | 23 |
from NominalPipeSize import NominalPipeSize |
24 |
from QtImageViewerScene import QtImageViewerScene |
|
24 | 25 |
|
25 | 26 |
|
26 | 27 |
class Config: |
... | ... | |
107 | 108 |
self._associationss = {} |
108 | 109 |
self._attributess = {} |
109 | 110 |
|
111 |
self._scene = QtImageViewerScene(None) |
|
112 |
|
|
113 |
@property |
|
114 |
def scene(self): |
|
115 |
"""getter scene""" |
|
116 |
return self._scene |
|
117 |
|
|
110 | 118 |
def clearTempDBData(self): |
111 | 119 |
self._connecterss = {} |
112 | 120 |
self._associationss = {} |
DTI_PID/DTI_PID/Commands/ConnectionPointCommand.py | ||
---|---|---|
1 | 1 |
import os.path |
2 | 2 |
import AbstractCommand |
3 |
|
|
3 | 4 |
try: |
4 | 5 |
from PyQt5.QtCore import * |
5 | 6 |
from PyQt5.QtGui import * |
... | ... | |
7 | 8 |
except ImportError: |
8 | 9 |
try: |
9 | 10 |
from PyQt4.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QMimeData |
10 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QColor, QPen, QBrush, QCursor |
|
11 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QColor, QPen, \ |
|
12 |
QBrush, QCursor |
|
11 | 13 |
except ImportError: |
12 | 14 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
13 | 15 |
|
16 |
|
|
14 | 17 |
class ConnectionPointCommand(AbstractCommand.AbstractCommand): |
15 | 18 |
""" |
16 | 19 |
ConnectionPointCommand class |
... | ... | |
20 | 23 |
|
21 | 24 |
def __init__(self, imageViewer, connectionPointLineEdit, index=-1): |
22 | 25 |
super(ConnectionPointCommand, self).__init__(imageViewer) |
23 |
self.name = 'ConnectionPoint'
|
|
26 |
self.name = 'ConnectionPoint' |
|
24 | 27 |
self.connectionPointLineEdit = connectionPointLineEdit |
25 | 28 |
self.imageViewer.setCursor(QCursor(Qt.CrossCursor)) |
26 | 29 |
self.imageWidth = self.imageViewer.image().width() |
... | ... | |
28 | 31 |
self.initMinPoint = QPointF(self.imageWidth * -1, self.imageHeight * -1) |
29 | 32 |
self.connectionPointLineEdit.setText("") |
30 | 33 |
self.index = index |
31 |
|
|
34 |
|
|
32 | 35 |
''' |
33 | 36 |
@brief pan image by left click and drag |
34 | 37 |
@history 2016.06.12 Jeongwoo Make new point (newScenePos) |
35 | 38 |
''' |
39 |
|
|
36 | 40 |
def execute(self, param): |
37 | 41 |
from EngineeringOriginItem import QEngineeringOriginItem |
38 | 42 |
from EngineeringGuidelineItem import QEngineeringGuidelineItem |
... | ... | |
41 | 45 |
scenePos = param[2] |
42 | 46 |
|
43 | 47 |
newScenePos = QPointF(round(scenePos.x()), round(scenePos.y())) |
44 |
items = [item for item in self.imageViewer.scene.items(scenePos) \ |
|
45 |
if type(item) is QEngineeringOriginItem or type(item) is QEngineeringGuidelineItem] |
|
48 |
items = [item for item in self.imageViewer.scene().items(scenePos) \
|
|
49 |
if type(item) is QEngineeringOriginItem or type(item) is QEngineeringGuidelineItem]
|
|
46 | 50 |
|
47 | 51 |
originItem = None |
48 | 52 |
if items and type(items[0]) is QEngineeringGuidelineItem: |
... | ... | |
51 | 55 |
originItem = items[0] |
52 | 56 |
|
53 | 57 |
if originItem is not None: |
54 |
center = originItem.rect().center()
|
|
58 |
center = originItem.rect().center() |
|
55 | 59 |
dx = scenePos.x() - center.x() |
56 | 60 |
dy = scenePos.y() - center.y() |
57 | 61 |
if abs(dx) < 1: |
... | ... | |
63 | 67 |
if event.button() == Qt.LeftButton: |
64 | 68 |
if self.isOnImage(newScenePos.x(), newScenePos.y()): |
65 | 69 |
## drawCircle Method is static |
66 |
conn = ConnectionPointCommand.drawCircle(self.imageViewer, newScenePos.x(), newScenePos.y(), self.index) |
|
70 |
conn = ConnectionPointCommand.drawCircle(self.imageViewer, newScenePos.x(), newScenePos.y(), |
|
71 |
self.index) |
|
67 | 72 |
text = "{},{}".format(newScenePos.x(), newScenePos.y()) |
68 | 73 |
self.connectionPointLineEdit.setText(text) |
69 | 74 |
self.index += 1 |
70 | 75 |
self.onSuccess.emit(conn) |
71 | 76 |
else: |
72 |
QMessageBox.about(self.imageViewer, self.tr('Notice'), self.tr('Please select inside of the symbol.')) |
|
77 |
QMessageBox.about(self.imageViewer, self.tr('Notice'), |
|
78 |
self.tr('Please select inside of the symbol.')) |
|
73 | 79 |
|
74 | 80 |
QGraphicsView.mousePressEvent(self.imageViewer, event) |
75 | 81 |
elif 'mouseMoveEvent' == param[0]: |
... | ... | |
79 | 85 |
self.connectionPointLineEdit.setText("") |
80 | 86 |
pass |
81 | 87 |
self.isTreated = False |
82 |
|
|
88 |
|
|
83 | 89 |
''' |
84 | 90 |
@history 2018.06.11 Jeongwoo Shorten method to add Ellipse |
85 | 91 |
2018.06.12 Jeongwoo Modify RectF's coords |
86 | 92 |
humkyung 2018.08.28 add connector item instead of QGraphicsEllipse |
87 | 93 |
''' |
94 |
|
|
88 | 95 |
@staticmethod |
89 | 96 |
def drawCircle(imageViewer, x, y, index=-1): |
90 | 97 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
91 | 98 |
|
92 | 99 |
connector = QEngineeringConnectorItem(index=index) |
93 | 100 |
connector.setPos((float(x), float(y))) |
94 |
imageViewer.scene.addItem(connector) |
|
101 |
imageViewer.scene().addItem(connector)
|
|
95 | 102 |
|
96 | 103 |
return connector |
97 | 104 |
|
... | ... | |
99 | 106 |
@history 2018.06.11 Jeongwoo Make area bigger (width/height 1px) |
100 | 107 |
2018.06.12 Jeongwoo Make area smaller (width/height 1px) |
101 | 108 |
''' |
109 |
|
|
102 | 110 |
def isOnImage(self, x, y): |
103 | 111 |
if (x >= 0 and x <= self.imageWidth) and (y >= 0 and y <= self.imageHeight): |
104 | 112 |
return True |
105 | 113 |
else: |
106 | 114 |
return False |
107 |
|
|
115 |
|
|
108 | 116 |
def undo(self): |
109 | 117 |
pass |
110 | 118 |
|
111 | 119 |
def redo(self): |
112 |
pass |
|
120 |
pass |
DTI_PID/DTI_PID/Commands/OriginalPointCommand.py | ||
---|---|---|
93 | 93 |
origin.setPos((float(x), float(y))) |
94 | 94 |
|
95 | 95 |
startPoint = (float(x), 0) |
96 |
endPoint = (float(x), imageViewer.scene.sceneRect().height()) |
|
96 |
endPoint = (float(x), imageViewer.scene().sceneRect().height())
|
|
97 | 97 |
vertical = QEngineeringGuidelineItem([startPoint, endPoint], origin) |
98 | 98 |
vertical.setParentItem(origin) |
99 | 99 |
vertical.setZValue(origin.zValue() + 1) |
100 | 100 |
startPoint = (0, float(y)) |
101 |
endPoint = (imageViewer.scene.sceneRect().width(), float(y)) |
|
101 |
endPoint = (imageViewer.scene().sceneRect().width(), float(y))
|
|
102 | 102 |
horizontal = QEngineeringGuidelineItem([startPoint, endPoint], origin) |
103 | 103 |
horizontal.setParentItem(origin) |
104 | 104 |
horizontal.setZValue(origin.zValue() + 1) |
105 | 105 |
|
106 |
imageViewer.scene.addItem(origin) |
|
106 |
imageViewer.scene().addItem(origin)
|
|
107 | 107 |
|
108 | 108 |
return origin |
109 | 109 |
|
... | ... | |
115 | 115 |
from EngineeringOriginItem import QEngineeringOriginItem |
116 | 116 |
|
117 | 117 |
scenePos = QPointF(x, y) |
118 |
items = [item for item in imageViewer.scene.items(QRectF(float(scenePos.x())-0.5, float(scenePos.y())-0.5, 1, 1)) \ |
|
118 |
items = [item for item in imageViewer.scene().items(QRectF(float(scenePos.x())-0.5, float(scenePos.y())-0.5, 1, 1)) \
|
|
119 | 119 |
if type(item) is QEngineeringOriginItem] |
120 | 120 |
for item in items: |
121 |
imageViewer.scene.removeItem(item) |
|
121 |
imageViewer.scene().removeItem(item)
|
|
122 | 122 |
|
123 | 123 |
''' |
124 | 124 |
@history 2018.06.11 Jeongwoo Make area bigger (width/height 1px) |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
428 | 428 |
self.ui.listWidgetTagNo.itemDoubleClicked.connect(self.tagNoItemDoubleCliced) |
429 | 429 |
self.ui.pushButtonClearAccessInfo.clicked.connect(self.clear_drawing_access_info_clicked) |
430 | 430 |
|
431 |
# close when user press escape key |
|
432 |
shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self) |
|
433 |
shortcut.activated.connect(self.reject) |
|
434 |
# up to here |
|
435 |
|
|
431 | 436 |
def set_page_segmentation_modes(self): |
432 | 437 |
"""show page segmentation modes""" |
433 | 438 |
try: |
DTI_PID/DTI_PID/ItemDataExportDialog.py | ||
---|---|---|
405 | 405 |
self.viewTables[key].setColumnWidth(col, len(self.columnListAll[key][col]) * 8 + 10) |
406 | 406 |
# UID column hide |
407 | 407 |
self.viewTables[key].hideColumn(0) |
408 |
self.viewTables[key].setSortingEnabled(True) |
|
408 | 409 |
|
409 | 410 |
self.sortListOrder() |
410 | 411 |
except Exception as ex: |
DTI_PID/DTI_PID/ItemDataFormatDialog.py | ||
---|---|---|
9 | 9 |
from AppDocData import AppDocData, Config |
10 | 10 |
import ItemDataFormat_UI |
11 | 11 |
|
12 |
dbListOrderName = ['LINE_DATA_LIST_EXPORT_ORDER', 'EQUIPMENT_DATA_LIST_EXPORT_ORDER', 'VALVE_DATA_LIST_EXPORT_ORDER', 'INSTRUMENT_DATA_LIST_EXPORT_ORDER', 'NOTE_DATA_LIST_EXPORT_ORDER'] |
|
12 |
dbListOrderName = ['LINE_DATA_LIST_EXPORT_ORDER', 'EQUIPMENT_DATA_LIST_EXPORT_ORDER', 'VALVE_DATA_LIST_EXPORT_ORDER', |
|
13 |
'INSTRUMENT_DATA_LIST_EXPORT_ORDER', 'NOTE_DATA_LIST_EXPORT_ORDER'] |
|
13 | 14 |
dbListName = ['LINE_DATA_LIST', 'EQUIPMENT_DATA_LIST', 'VALVE_DATA_LIST', 'INSTRUMENT_DATA_LIST', 'NOTE_DATA_LIST'] |
14 | 15 |
|
16 |
|
|
15 | 17 |
class QItemDataFormatDialog(QDialog): |
16 | 18 |
""" This is QItemDataFormatDialog class """ |
17 | 19 |
|
... | ... | |
33 | 35 |
self.emptyCol = 'Empty Column' |
34 | 36 |
self.selectedCol = None |
35 | 37 |
|
36 |
self.lineHistory =[] |
|
38 |
self.lineHistory = []
|
|
37 | 39 |
self.equipmentHistory = [] |
38 | 40 |
self.valveHistory = [] |
39 | 41 |
self.instrumentHistory = [] |
40 | 42 |
self.noteHistory = [] |
41 | 43 |
self.colHistory = \ |
42 |
{ |
|
43 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineHistory,
|
|
44 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentHistory,
|
|
45 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveHistory,
|
|
46 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentHistory,
|
|
47 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteHistory
|
|
48 |
} |
|
44 |
{
|
|
45 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineHistory,
|
|
46 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentHistory,
|
|
47 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveHistory,
|
|
48 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentHistory,
|
|
49 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteHistory
|
|
50 |
}
|
|
49 | 51 |
|
50 | 52 |
self.listWidgets = \ |
51 |
{ |
|
52 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.listWidgetLine,
|
|
53 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.listWidgetEquipment,
|
|
54 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.listWidgetValve,
|
|
55 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.listWidgetInstrument,
|
|
56 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.listWidgetNote
|
|
57 |
} |
|
53 |
{
|
|
54 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.listWidgetLine,
|
|
55 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.listWidgetEquipment,
|
|
56 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.listWidgetValve,
|
|
57 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.listWidgetInstrument,
|
|
58 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.listWidgetNote
|
|
59 |
}
|
|
58 | 60 |
|
59 | 61 |
self.tableWidgets = \ |
60 |
{ |
|
61 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.tableWidgetLine,
|
|
62 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.tableWidgetEquipment,
|
|
63 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.tableWidgetValve,
|
|
64 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.tableWidgetInstrument,
|
|
65 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.tableWidgetNote
|
|
66 |
} |
|
62 |
{
|
|
63 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.tableWidgetLine,
|
|
64 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.tableWidgetEquipment,
|
|
65 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.tableWidgetValve,
|
|
66 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.tableWidgetInstrument,
|
|
67 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.tableWidgetNote
|
|
68 |
}
|
|
67 | 69 |
|
68 | 70 |
self.sections = \ |
69 |
{ |
|
70 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineSectionClicked,
|
|
71 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentSectionClicked,
|
|
72 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveSectionClicked,
|
|
73 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentSectionClicked,
|
|
74 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteSectionClicked
|
|
75 |
} |
|
71 |
{
|
|
72 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineSectionClicked,
|
|
73 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentSectionClicked,
|
|
74 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveSectionClicked,
|
|
75 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentSectionClicked,
|
|
76 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteSectionClicked
|
|
77 |
}
|
|
76 | 78 |
|
77 | 79 |
self.items = \ |
78 |
{ |
|
79 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineItemDoubleCliked,
|
|
80 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentItemDoubleCliked,
|
|
81 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveItemDoubleCliked,
|
|
82 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentItemDoubleCliked,
|
|
83 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteItemDoubleCliked
|
|
84 |
} |
|
80 |
{
|
|
81 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineItemDoubleCliked,
|
|
82 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentItemDoubleCliked,
|
|
83 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveItemDoubleCliked,
|
|
84 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentItemDoubleCliked,
|
|
85 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteItemDoubleCliked
|
|
86 |
}
|
|
85 | 87 |
|
86 | 88 |
self.drops = \ |
87 |
{ |
|
88 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineDropEvent,
|
|
89 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentDropEvent,
|
|
90 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveDropEvent,
|
|
91 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentDropEvent,
|
|
92 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteDropEvent
|
|
93 |
} |
|
89 |
{
|
|
90 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineDropEvent,
|
|
91 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentDropEvent,
|
|
92 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveDropEvent,
|
|
93 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentDropEvent,
|
|
94 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteDropEvent
|
|
95 |
}
|
|
94 | 96 |
|
95 | 97 |
self.deleteButtons = \ |
96 |
{ |
|
97 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineDelete,
|
|
98 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEquipmentDelete,
|
|
99 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveDelete,
|
|
100 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstrumentDelete,
|
|
101 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteDelete
|
|
102 |
} |
|
98 |
{
|
|
99 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.pushButtonLineDelete,
|
|
100 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.pushButtonEquipmentDelete,
|
|
101 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.pushButtonValveDelete,
|
|
102 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.pushButtonInstrumentDelete,
|
|
103 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.pushButtonNoteDelete
|
|
104 |
}
|
|
103 | 105 |
|
104 | 106 |
self.deletes = \ |
105 |
{ |
|
106 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineDeleteClicked,
|
|
107 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentDeleteClicked,
|
|
108 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveDeleteClicked,
|
|
109 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentDeleteClicked,
|
|
110 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteDeleteClicked
|
|
111 |
} |
|
107 |
{
|
|
108 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineDeleteClicked,
|
|
109 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentDeleteClicked,
|
|
110 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveDeleteClicked,
|
|
111 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentDeleteClicked,
|
|
112 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteDeleteClicked
|
|
113 |
}
|
|
112 | 114 |
|
113 | 115 |
self.addButtons = \ |
114 |
{ |
|
115 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineAdd,
|
|
116 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEquipmentAdd,
|
|
117 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveAdd,
|
|
118 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstrumentAdd,
|
|
119 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteAdd
|
|
120 |
} |
|
116 |
{
|
|
117 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.pushButtonLineAdd,
|
|
118 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.pushButtonEquipmentAdd,
|
|
119 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.pushButtonValveAdd,
|
|
120 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.pushButtonInstrumentAdd,
|
|
121 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.pushButtonNoteAdd
|
|
122 |
}
|
|
121 | 123 |
|
122 | 124 |
self.adds = \ |
123 |
{ |
|
124 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineAddClicked,
|
|
125 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentAddClicked,
|
|
126 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveAddClicked,
|
|
127 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentAddClicked,
|
|
128 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteAddClicked
|
|
129 |
} |
|
125 |
{
|
|
126 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineAddClicked,
|
|
127 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentAddClicked,
|
|
128 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveAddClicked,
|
|
129 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentAddClicked,
|
|
130 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteAddClicked
|
|
131 |
}
|
|
130 | 132 |
|
131 | 133 |
self.emptyButtons = \ |
132 |
{ |
|
133 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineEmptyColumn,
|
|
134 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEquipmentEmptyColumn,
|
|
135 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveEmptyColumn,
|
|
136 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstrumentEmptyColumn,
|
|
137 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteEmptyColumn
|
|
138 |
} |
|
134 |
{
|
|
135 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.pushButtonLineEmptyColumn,
|
|
136 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.pushButtonEquipmentEmptyColumn,
|
|
137 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.pushButtonValveEmptyColumn,
|
|
138 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.pushButtonInstrumentEmptyColumn,
|
|
139 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.pushButtonNoteEmptyColumn
|
|
140 |
}
|
|
139 | 141 |
|
140 | 142 |
self.emptys = \ |
141 |
{ |
|
142 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineEmptyClicked,
|
|
143 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentEmptyClicked,
|
|
144 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveEmptyClicked,
|
|
145 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentEmptyClicked,
|
|
146 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteEmptyClicked
|
|
147 |
} |
|
143 |
{
|
|
144 |
QItemDataFormatDialog.DATA_LIST[0]: self.lineEmptyClicked,
|
|
145 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipmentEmptyClicked,
|
|
146 |
QItemDataFormatDialog.DATA_LIST[2]: self.valveEmptyClicked,
|
|
147 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrumentEmptyClicked,
|
|
148 |
QItemDataFormatDialog.DATA_LIST[4]: self.noteEmptyClicked
|
|
149 |
}
|
|
148 | 150 |
|
149 | 151 |
self.colAddButtons = \ |
150 |
{ |
|
151 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineColAdd,
|
|
152 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEqpColAdd,
|
|
153 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveColAdd,
|
|
154 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstColAdd,
|
|
155 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteColAdd
|
|
156 |
} |
|
152 |
{
|
|
153 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.pushButtonLineColAdd,
|
|
154 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.pushButtonEqpColAdd,
|
|
155 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.pushButtonValveColAdd,
|
|
156 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.pushButtonInstColAdd,
|
|
157 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.pushButtonNoteColAdd
|
|
158 |
}
|
|
157 | 159 |
|
158 | 160 |
self.colAdds = \ |
159 |
{ |
|
160 |
QItemDataFormatDialog.DATA_LIST[0]:self.line_add_clicked,
|
|
161 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipment_add_clicked,
|
|
162 |
QItemDataFormatDialog.DATA_LIST[2]:self.valve_add_clicked,
|
|
163 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrument_add_clicked,
|
|
164 |
QItemDataFormatDialog.DATA_LIST[4]:self.note_add_clicked
|
|
165 |
} |
|
161 |
{
|
|
162 |
QItemDataFormatDialog.DATA_LIST[0]: self.line_add_clicked,
|
|
163 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipment_add_clicked,
|
|
164 |
QItemDataFormatDialog.DATA_LIST[2]: self.valve_add_clicked,
|
|
165 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrument_add_clicked,
|
|
166 |
QItemDataFormatDialog.DATA_LIST[4]: self.note_add_clicked
|
|
167 |
}
|
|
166 | 168 |
|
167 | 169 |
self.colEditButtons = \ |
168 |
{ |
|
169 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineColEdit,
|
|
170 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEqpColEdit,
|
|
171 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveColEdit,
|
|
172 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstColEdit,
|
|
173 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteColEdit
|
|
174 |
} |
|
170 |
{
|
|
171 |
QItemDataFormatDialog.DATA_LIST[0]: self.ui.pushButtonLineColEdit,
|
|
172 |
QItemDataFormatDialog.DATA_LIST[1]: self.ui.pushButtonEqpColEdit,
|
|
173 |
QItemDataFormatDialog.DATA_LIST[2]: self.ui.pushButtonValveColEdit,
|
|
174 |
QItemDataFormatDialog.DATA_LIST[3]: self.ui.pushButtonInstColEdit,
|
|
175 |
QItemDataFormatDialog.DATA_LIST[4]: self.ui.pushButtonNoteColEdit
|
|
176 |
}
|
|
175 | 177 |
|
176 | 178 |
self.colEdits = \ |
177 |
{ |
|
178 |
QItemDataFormatDialog.DATA_LIST[0]:self.line_edit_clicked,
|
|
179 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipment_edit_clicked,
|
|
180 |
QItemDataFormatDialog.DATA_LIST[2]:self.valve_edit_clicked,
|
|
181 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrument_edit_clicked,
|
|
182 |
QItemDataFormatDialog.DATA_LIST[4]:self.note_edit_clicked
|
|
183 |
} |
|
179 |
{
|
|
180 |
QItemDataFormatDialog.DATA_LIST[0]: self.line_edit_clicked,
|
|
181 |
QItemDataFormatDialog.DATA_LIST[1]: self.equipment_edit_clicked,
|
|
182 |
QItemDataFormatDialog.DATA_LIST[2]: self.valve_edit_clicked,
|
|
183 |
QItemDataFormatDialog.DATA_LIST[3]: self.instrument_edit_clicked,
|
|
184 |
QItemDataFormatDialog.DATA_LIST[4]: self.note_edit_clicked
|
|
185 |
}
|
|
184 | 186 |
|
185 | 187 |
# button en/disable setting |
186 | 188 |
self.ui.pushButtonLineColAdd.setDisabled(True) |
... | ... | |
213 | 215 |
for col in range(len(headers)): |
214 | 216 |
self.tableWidgets[key].setItem(0, col, QTableWidgetItem(headers[col][1])) |
215 | 217 |
self.tableWidgets[key].horizontalHeaderItem(col).setSizeHint(QSize(25, 25)) |
216 |
#self.tableWidgets[key].setColumnWidth(col, len(headers[col]) * 8 + 10) |
|
218 |
# self.tableWidgets[key].setColumnWidth(col, len(headers[col]) * 8 + 10)
|
|
217 | 219 |
|
218 | 220 |
self.tableWidgets[key].horizontalHeader().sectionClicked.connect(self.sections[key]) |
219 | 221 |
self.tableWidgets[key].cellClicked.connect(self.sections[key]) |
... | ... | |
236 | 238 |
self.listWidgets[key].addItem(item) |
237 | 239 |
for logical in range(self.tableWidgets[key].columnCount()): |
238 | 240 |
if item.text() == self.tableWidgets[key].horizontalHeaderItem(logical).text(): |
239 |
#item.setBackground(self.selectionBackground) |
|
241 |
# item.setBackground(self.selectionBackground)
|
|
240 | 242 |
self.listWidgets[key].takeItem(self.listWidgets[key].count() - 1) |
241 | 243 |
break |
242 | 244 |
|
... | ... | |
252 | 254 |
@author euisung |
253 | 255 |
@date 2018.10.31 |
254 | 256 |
''' |
257 |
|
|
255 | 258 |
def tabchanged(self, event): |
256 | 259 |
if self.selectedCol is not None: |
257 | 260 |
self.selectedCol[0].setCurrentCell(0, 0) |
... | ... | |
262 | 265 |
@author euisung |
263 | 266 |
@date 2018.10.30 |
264 | 267 |
''' |
268 |
|
|
265 | 269 |
def dragEnterEvent(self, event): |
266 | 270 |
try: |
267 | 271 |
self.dragItem = self.focusWidget().item(self.focusWidget().indexAt(event.pos()).row()).text() |
268 | 272 |
except: |
269 | 273 |
self.dragItem = None |
270 |
#self.clearFocus() |
|
274 |
# self.clearFocus()
|
|
271 | 275 |
|
272 | 276 |
def dropEvent(self, event, table, alist): |
273 | 277 |
if self.dragItem is None: |
... | ... | |
278 | 282 |
logicalIndex = table.horizontalHeader().logicalIndex(visualIndex) |
279 | 283 |
table.setCurrentCell(0, logicalIndex) |
280 | 284 |
self.selectedCol = [table, logicalIndex, alist] |
281 |
#self.update() |
|
282 |
|
|
285 |
# self.update()
|
|
286 |
|
|
283 | 287 |
def lineDropEvent(self, event): |
284 | 288 |
self.dropEvent(event, self.tableWidgets[0], self.listWidgets[0]) |
285 |
|
|
289 |
|
|
286 | 290 |
def equipmentDropEvent(self, event): |
287 | 291 |
self.dropEvent(event, self.tableWidgets[1], self.listWidgets[1]) |
288 |
|
|
292 |
|
|
289 | 293 |
def valveDropEvent(self, event): |
290 | 294 |
self.dropEvent(event, self.tableWidgets[2], self.listWidgets[2]) |
291 |
|
|
295 |
|
|
292 | 296 |
def instrumentDropEvent(self, event): |
293 | 297 |
self.dropEvent(event, self.tableWidgets[3], self.listWidgets[3]) |
294 |
|
|
298 |
|
|
295 | 299 |
def noteDropEvent(self, event): |
296 | 300 |
self.dropEvent(event, self.tableWidgets[4], self.listWidgets[4]) |
297 | 301 |
|
... | ... | |
320 | 324 |
|
321 | 325 |
def line_edit_clicked(self): |
322 | 326 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
323 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
327 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
328 |
self.colHistory[data_list]) |
|
324 | 329 |
|
325 | 330 |
def equipment_edit_clicked(self): |
326 | 331 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
327 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
332 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
333 |
self.colHistory[data_list]) |
|
328 | 334 |
|
329 | 335 |
def valve_edit_clicked(self): |
330 | 336 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
331 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
337 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
338 |
self.colHistory[data_list]) |
|
332 | 339 |
|
333 | 340 |
def instrument_edit_clicked(self): |
334 | 341 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
335 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
342 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
343 |
self.colHistory[data_list]) |
|
336 | 344 |
|
337 | 345 |
def note_edit_clicked(self): |
338 | 346 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
339 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
347 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
348 |
self.colHistory[data_list]) |
|
340 | 349 |
|
341 | 350 |
def add_column_clicked(self, tableName, alist, colList, history): |
342 | 351 |
''' |
... | ... | |
349 | 358 |
item_data_format_dialog = QItemDataAddEditDialog(self, True, tableName, colList, history) |
350 | 359 |
isAccepted, newHistory = item_data_format_dialog.showDialog() |
351 | 360 |
if isAccepted: |
352 |
#print('added') |
|
361 |
# print('added')
|
|
353 | 362 |
history.append(newHistory) |
354 | 363 |
item = QListWidgetItem(newHistory[1]) |
355 | 364 |
item.setSizeHint(QSize(25, 25)) |
... | ... | |
357 | 366 |
|
358 | 367 |
def line_add_clicked(self): |
359 | 368 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
360 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
369 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
370 |
self.colHistory[data_list]) |
|
361 | 371 |
|
362 | 372 |
def equipment_add_clicked(self): |
363 | 373 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
364 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
374 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
375 |
self.colHistory[data_list]) |
|
365 | 376 |
|
366 | 377 |
def valve_add_clicked(self): |
367 | 378 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
368 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
379 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
380 |
self.colHistory[data_list]) |
|
369 | 381 |
|
370 | 382 |
def instrument_add_clicked(self): |
371 | 383 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
372 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
384 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
385 |
self.colHistory[data_list]) |
|
373 | 386 |
|
374 | 387 |
def note_add_clicked(self): |
375 | 388 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
376 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
389 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], |
|
390 |
self.colHistory[data_list]) |
|
377 | 391 |
|
378 | 392 |
''' |
379 | 393 |
@brief add empty column |
380 | 394 |
@author euisung |
381 | 395 |
@date 2018.10.29 |
382 | 396 |
''' |
397 |
|
|
383 | 398 |
def emptyColumnClicked(self, table, alist): |
384 | 399 |
table.setColumnCount(table.columnCount() + 1) |
385 | 400 |
table.setHorizontalHeaderItem(table.columnCount() - 1, QTableWidgetItem(self.emptyCol)) |
386 | 401 |
table.setItem(0, table.columnCount() - 1, QTableWidgetItem('add header')) |
387 | 402 |
if self.selectedCol is not None: |
388 |
table.horizontalHeader().moveSection(table.columnCount() - 1, table.horizontalHeader().visualIndex(self.selectedCol[0].currentColumn()) + 1) |
|
403 |
table.horizontalHeader().moveSection(table.columnCount() - 1, table.horizontalHeader().visualIndex( |
|
404 |
self.selectedCol[0].currentColumn()) + 1) |
|
389 | 405 |
else: |
390 | 406 |
table.horizontalHeader().moveSection(table.columnCount() - 1, 1) |
391 | 407 |
table.setCurrentCell(0, table.columnCount() - 1) |
... | ... | |
416 | 432 |
@author euisung |
417 | 433 |
@date 2018.10.25 |
418 | 434 |
''' |
435 |
|
|
419 | 436 |
def pushButtonApplyClicked(self): |
420 | 437 |
docData = AppDocData.instance() |
421 | 438 |
configs = [] |
... | ... | |
424 | 441 |
addedCol = [] |
425 | 442 |
editedCol = [] |
426 | 443 |
for history in self.colHistory[key]: |
427 |
if history[0] is not None: # edit |
|
444 |
if history[0] is not None: # edit
|
|
428 | 445 |
isNewAddedCol = False |
429 | 446 |
for index in range(len(addedCol)): |
430 | 447 |
if addedCol[index] == history[0]: |
... | ... | |
433 | 450 |
break |
434 | 451 |
if not isNewAddedCol: |
435 | 452 |
editedCol.append(history) |
436 |
else: # add |
|
453 |
else: # add
|
|
437 | 454 |
addedCol.append(history[1]) |
438 | 455 |
|
439 | 456 |
# save column order |
... | ... | |
448 | 465 |
|
449 | 466 |
value = value[:-len(self.delimiter)] |
450 | 467 |
configs.append(Config('Order', key, value)) |
451 |
|
|
468 |
|
|
452 | 469 |
docData.saveConfigs(configs) |
453 | 470 |
|
454 |
reply = QMessageBox.information(self, self.tr('Information'), self.tr('Save Success!'), QMessageBox.Ok, QMessageBox.Cancel) |
|
471 |
reply = QMessageBox.information(self, self.tr('Information'), self.tr('Save Success!'), QMessageBox.Ok, |
|
472 |
QMessageBox.Cancel) |
|
455 | 473 |
if reply == QMessageBox.Ok: |
456 | 474 |
QDialog.accept(self) |
457 | 475 |
|
... | ... | |
460 | 478 |
@author euisung |
461 | 479 |
@date 2018.10.25 |
462 | 480 |
''' |
463 |
def listItemDoubleClicked(self, table, item, alist, loc = None): |
|
481 |
|
|
482 |
def listItemDoubleClicked(self, table, item, alist, loc=None): |
|
464 | 483 |
if item == None: |
465 | 484 |
return |
466 | 485 |
for index in range(table.columnCount()): |
467 | 486 |
if item.text() == table.horizontalHeaderItem(index).text(): |
468 |
#QMessageBox.about(self, "알림", '이미 추가된 항목입니다.') |
|
487 |
# QMessageBox.about(self, "알림", '이미 추가된 항목입니다.')
|
|
469 | 488 |
return |
470 | 489 |
table.setColumnCount(table.columnCount() + 1) |
471 | 490 |
table.setHorizontalHeaderItem(table.columnCount() - 1, QTableWidgetItem(item.text())) |
... | ... | |
476 | 495 |
if self.selectedCol is None: |
477 | 496 |
table.horizontalHeader().moveSection(table.columnCount() - 1, 1) |
478 | 497 |
else: |
479 |
table.horizontalHeader().moveSection(table.columnCount() - 1, table.horizontalHeader().visualIndex(self.selectedCol[0].currentColumn()) + 1) |
|
498 |
table.horizontalHeader().moveSection(table.columnCount() - 1, table.horizontalHeader().visualIndex( |
|
499 |
self.selectedCol[0].currentColumn()) + 1) |
|
480 | 500 |
else: |
481 | 501 |
table.horizontalHeader().moveSection(table.columnCount() - 1, loc) |
482 | 502 |
table.setCurrentCell(0, table.columnCount() - 1) |
... | ... | |
484 | 504 |
if item.text() == alist.item(logical).text(): |
485 | 505 |
alist.takeItem(logical) |
486 | 506 |
break |
487 |
|
|
507 |
|
|
488 | 508 |
def lineItemDoubleCliked(self, item): |
489 | 509 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
490 | 510 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
... | ... | |
492 | 512 |
def equipmentItemDoubleCliked(self, item): |
493 | 513 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
494 | 514 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
495 |
|
|
515 |
|
|
496 | 516 |
def valveItemDoubleCliked(self, item): |
497 | 517 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
498 | 518 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
499 |
|
|
519 |
|
|
500 | 520 |
def instrumentItemDoubleCliked(self, item): |
501 | 521 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
502 | 522 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
503 |
|
|
523 |
|
|
504 | 524 |
def noteItemDoubleCliked(self, item): |
505 | 525 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
506 | 526 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
... | ... | |
510 | 530 |
@author euisung |
511 | 531 |
@date 2018.10.25 |
512 | 532 |
''' |
533 |
|
|
513 | 534 |
def pushButtonCloseClicked(self): |
514 | 535 |
QDialog.reject(self) |
515 | 536 |
|
... | ... | |
518 | 539 |
@author euisung |
519 | 540 |
@date 2018.10.25 |
520 | 541 |
''' |
542 |
|
|
521 | 543 |
def keyPressEvent(self, event): |
522 | 544 |
try: |
523 |
if event.key() == Qt.Key_Delete and self.selectedCol is not None and self.selectedCol[0].columnCount() is not 1 and self.selectedCol[0].currentColumn() is not 0: |
|
545 |
if event.key() == Qt.Key_Delete and self.selectedCol is not None and self.selectedCol[ |
|
546 |
0].columnCount() is not 1 and self.selectedCol[0].currentColumn() is not 0: |
|
524 | 547 |
visualIndex = self.selectedCol[0].horizontalHeader().visualIndex(self.selectedCol[0].currentColumn()) |
525 |
if self.selectedCol[0].horizontalHeaderItem(self.selectedCol[0].currentColumn()).text() != self.emptyCol: |
|
526 |
item = QListWidgetItem(self.selectedCol[0].horizontalHeaderItem(self.selectedCol[0].currentColumn()).text()) |
|
548 |
if self.selectedCol[0].horizontalHeaderItem( |
|
549 |
self.selectedCol[0].currentColumn()).text() != self.emptyCol: |
|
550 |
item = QListWidgetItem( |
|
551 |
self.selectedCol[0].horizontalHeaderItem(self.selectedCol[0].currentColumn()).text()) |
|
527 | 552 |
item.setSizeHint(QSize(25, 25)) |
528 | 553 |
self.selectedCol[2].addItem(item) |
529 |
#for logical in range(self.selectedCol[2].count()): |
|
554 |
# for logical in range(self.selectedCol[2].count()):
|
|
530 | 555 |
# if self.selectedCol[0].horizontalHeaderItem(self.selectedCol[1]).text() == self.selectedCol[2].item(logical).text(): |
531 | 556 |
# self.selectedCol[2].item(logical).setBackground(self.originBackground) |
532 | 557 |
# break |
... | ... | |
541 | 566 |
logicalIndex = self.selectedCol[0].horizontalHeader().logicalIndex(visualIndex) |
542 | 567 |
self.selectedCol[1] = logicalIndex |
543 | 568 |
self.selectedCol[0].setCurrentCell(0, logicalIndex) |
544 |
|
|
569 |
|
|
545 | 570 |
QDialog.keyPressEvent(self, event) |
546 | 571 |
except Exception as ex: |
547 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
572 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
573 |
sys.exc_info()[-1].tb_lineno)) |
|
548 | 574 |
from App import App |
549 | 575 |
from AppDocData import MessageType |
550 | 576 |
|
551 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
577 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
578 |
sys.exc_info()[-1].tb_lineno) |
|
552 | 579 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
553 | 580 |
return None |
554 | 581 |
|
... | ... | |
557 | 584 |
@author euisung |
558 | 585 |
@date 2018.10.25 |
559 | 586 |
''' |
587 |
|
|
560 | 588 |
def addClicked(self, table, alist): |
561 | 589 |
item = alist.currentItem() |
562 | 590 |
self.listItemDoubleClicked(table, item, alist) |
... | ... | |
586 | 614 |
@author euisung |
587 | 615 |
@date 2018.10.25 |
588 | 616 |
''' |
617 |
|
|
589 | 618 |
def deleteClicked(self, table, alist): |
590 | 619 |
if self.selectedCol is None: |
591 | 620 |
return |
... | ... | |
593 | 622 |
item = QListWidgetItem(table.horizontalHeaderItem(table.currentColumn()).text()) |
594 | 623 |
item.setSizeHint(QSize(25, 25)) |
595 | 624 |
alist.addItem(item) |
596 |
#for logical in range(self.selectedCol[2].count()): |
|
625 |
# for logical in range(self.selectedCol[2].count()):
|
|
597 | 626 |
# if self.selectedCol[0].horizontalHeaderItem(self.selectedCol[1]).text() == self.selectedCol[2].item(logical).text(): |
598 | 627 |
# self.selectedCol[2].item(logical).setBackground(self.originBackground) |
599 | 628 |
# break |
... | ... | |
625 | 654 |
@author euisung |
626 | 655 |
@date 2018.10.25 |
627 | 656 |
''' |
657 |
|
|
628 | 658 |
def sectionClicked(self, table, logicalIndex, alist): |
629 | 659 |
if logicalIndex is not 0: |
630 | 660 |
table.setCurrentCell(0, logicalIndex) |
631 |
|
|
661 |
|
|
632 | 662 |
self.selectedCol = [table, None, alist] |
633 | 663 |
|
634 | 664 |
def lineSectionClicked(self, logicalIndex): |
... | ... | |
649 | 679 |
|
650 | 680 |
def noteSectionClicked(self, logicalIndex): |
651 | 681 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
652 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
|
682 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
121 | 121 |
self.statusbar.addPermanentWidget(self.labelTextStatus) |
122 | 122 |
self.statusbar.addPermanentWidget(self.labelStatus) |
123 | 123 |
|
124 |
docData = AppDocData.instance()
|
|
125 |
docData.clear()
|
|
126 |
project = docData.getCurrentProject()
|
|
124 |
app_doc_data = AppDocData.instance()
|
|
125 |
app_doc_data.clear()
|
|
126 |
project = app_doc_data.getCurrentProject()
|
|
127 | 127 |
_translate = QCoreApplication.translate |
128 | 128 |
version = QCoreApplication.applicationVersion() |
129 | 129 |
# set title |
... | ... | |
133 | 133 |
for condition in LineTypeConditions.items(): |
134 | 134 |
self.lineComboBox.addItem(condition.name) |
135 | 135 |
|
136 |
configs = docData.getConfigs('Line', 'Default Type')
|
|
136 |
configs = app_doc_data.getConfigs('Line', 'Default Type')
|
|
137 | 137 |
value = configs[0].value if 1 == len(configs) else '' |
138 | 138 |
if value: |
139 | 139 |
at = self.lineComboBox.findText(value) |
... | ... | |
154 | 154 |
self.graphicsView.useDefaultCommand() # USE DEFAULT COMMAND |
155 | 155 |
self.graphicsView.setMouseTracking(True) |
156 | 156 |
self.graphicsView.viewport().installEventFilter(self) |
157 |
self.graphicsView.setScene(app_doc_data.scene) |
|
157 | 158 |
|
158 | 159 |
self._display_widget = QDisplayWidget() |
159 | 160 |
self._display_widget.radioButtonByGroup.toggled.connect(self.display_colors) |
... | ... | |
267 | 268 |
self.pushButtonDetectSymbol.clicked.connect(self.show_detect_symbol_dialog) |
268 | 269 |
# self.graphicsView.scene().contents_changed.connect(self.scene_changed) |
269 | 270 |
|
270 |
configs = docData.getAppConfigs('app', 'mode')
|
|
271 |
configs = app_doc_data.getAppConfigs('app', 'mode')
|
|
271 | 272 |
if configs and 1 == len(configs) and 'advanced' == configs[0].value: |
272 | 273 |
self.actionOCR_Training.triggered.connect(self.oCRTrainingClicked) |
273 | 274 |
self.actionSymbol_Training.triggered.connect(self.symbolTrainingClicked) |
... | ... | |
3235 | 3236 |
|
3236 | 3237 |
self.progress.setValue(self.progress.value() + 1) |
3237 | 3238 |
|
3239 |
for line in root.find('LINEINFOS').iter('GRAPHICS_LINE'): |
|
3240 |
item = QEngineeringGraphicsLineItem.fromXml(line) |
|
3241 |
if item: |
|
3242 |
item.transfer.onRemoved.connect(self.itemRemoved) |
|
3243 |
self.graphicsView.scene().addItem(item) |
|
3244 |
|
|
3245 |
self.progress.setValue(self.progress.value() + 1) |
|
3246 |
|
|
3238 | 3247 |
QApplication.processEvents() |
3239 | 3248 |
|
3240 | 3249 |
for unknown in root.iter('UNKNOWN'): |
... | ... | |
3334 | 3343 |
# up to here |
3335 | 3344 |
|
3336 | 3345 |
""" update scene """ |
3337 |
self.addMessage.emit(MessageType.Normal, 'update scene') |
|
3338 | 3346 |
_items = [_item for _item in self.graphicsView.scene().items() if hasattr(_item, 'owner') or hasattr(_item, 'connectors')] |
3339 | 3347 |
items = divide_chunks(_items, App.THREAD_MAX_WORKER if len(_items) > App.THREAD_MAX_WORKER else len(_items)) |
3340 | 3348 |
with futures.ThreadPoolExecutor(max_workers=App.THREAD_MAX_WORKER) as pool: |
... | ... | |
3354 | 3362 |
self.progress.setValue(self.progress.value() + 1) |
3355 | 3363 |
""" |
3356 | 3364 |
|
3357 |
self.addMessage.emit(MessageType.Normal, 'set visible') |
|
3358 | 3365 |
for item in self.graphicsView.scene().items(): |
3359 | 3366 |
item.setVisible(True) |
3360 | 3367 |
|
... | ... | |
3420 | 3427 |
|
3421 | 3428 |
# collect items |
3422 | 3429 |
appDocData.lines.clear() |
3423 |
appDocData.lines = [item for item in self.graphicsView().scene.items() if
|
|
3430 |
appDocData.lines = [item for item in self.graphicsView.scene().items() if
|
|
3424 | 3431 |
type(item) is QEngineeringLineItem and item.owner is None] |
3425 | 3432 |
|
3426 | 3433 |
appDocData.symbols.clear() |
DTI_PID/DTI_PID/OcrResultDialog.py | ||
---|---|---|
17 | 17 |
from App import App |
18 | 18 |
from AppDocData import * |
19 | 19 |
from TextInfo import TextInfo |
20 |
from QtImageViewerScene import QtImageViewerScene |
|
20 | 21 |
|
21 | 22 |
|
22 | 23 |
class SpellTextEdit(QTextEdit): |
... | ... | |
78 | 79 |
self.ui.pushButtonMakeTrainingImage.setVisible(False) |
79 | 80 |
|
80 | 81 |
self.graphicsView = QtImageViewer.QtImageViewer(App.mainWnd()) |
82 |
self.graphicsView.setScene(QtImageViewerScene(self.graphicsView)) |
|
81 | 83 |
self.graphicsView.useDefaultCommand() # USE DEFAULT COMMAND |
82 | 84 |
self.graphicsView.setImage(self.image) |
83 | 85 |
self.ui.horizontalLayoutGraphicsView.addWidget(self.graphicsView) |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
57 | 57 |
''' |
58 | 58 |
|
59 | 59 |
def __init__(self, mainWindow=None): |
60 |
from QtImageViewerScene import QtImageViewerScene |
|
61 |
|
|
62 | 60 |
QGraphicsView.__init__(self) |
63 | 61 |
|
64 | 62 |
self.mainWindow = mainWindow |
65 | 63 |
# Image is displayed as a QPixmap in a QGraphicsScene attached to this QGraphicsView. |
66 | 64 |
self.command = None |
67 |
self._scene = QtImageViewerScene(self) |
|
68 |
self.setScene(self._scene) |
|
69 | 65 |
|
70 | 66 |
self.scaleFactor = 1.0 |
71 | 67 |
self.numScheduledScalings = 0 |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
353 | 353 |
|
354 | 354 |
item = None |
355 | 355 |
try: |
356 |
dialog = QOcrResultDialog(None, self.scene().parent().image().copy(self.loc[0], self.loc[1],
|
|
356 |
dialog = QOcrResultDialog(None, self.scene().views()[0].image().copy(self.loc[0], self.loc[1],
|
|
357 | 357 |
self.size[0], self.size[1]), |
358 | 358 |
QRect(self.loc[0], self.loc[1], self.size[0], self.size[1]), text_item=self) |
359 | 359 |
(res, textInfoList) = dialog.showDialog() |
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
133 | 133 |
boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged) |
134 | 134 |
boundingBox.transfer.onRemoved.connect(self.itemRemoved) |
135 | 135 |
boundingBox.setPen(QPen(Qt.darkGray, THICKNESS, Qt.SolidLine)) |
136 |
self.ui.imageView.scene.addItem(boundingBox) |
|
136 |
self.ui.imageView.scene().addItem(boundingBox)
|
|
137 | 137 |
|
138 | 138 |
strArea = '({},{}),({},{})'.format(x, y, width, height) |
139 | 139 |
self.ui.textAreaLineEdit.setText(strArea) |
... | ... | |
192 | 192 |
|
193 | 193 |
def removeArea(self, box): |
194 | 194 |
try: |
195 |
self.ui.imageView.scene.removeItem(box) |
|
195 |
self.ui.imageView.scene().removeItem(box)
|
|
196 | 196 |
except Exception as ex: |
197 | 197 |
from App import App |
198 | 198 |
from AppDocData import MessageType |
... | ... | |
264 | 264 |
''' |
265 | 265 |
|
266 | 266 |
def setupImageViewer(self): |
267 |
from MainWindow import MainWindow
|
|
267 |
from QtImageViewerScene import QtImageViewerScene
|
|
268 | 268 |
|
269 | 269 |
x = self.ui.imageViewContainer.x() |
270 | 270 |
y = self.ui.imageViewContainer.y() |
271 | 271 |
width = self.ui.imageViewContainer.frameGeometry().width() |
272 | 272 |
height = self.ui.imageViewContainer.frameGeometry().height() |
273 |
self.ui.imageView = QtImageViewer(MainWindow.instance()) |
|
274 |
self.ui.imageView.scene.guidesEnabled = True |
|
273 |
self.ui.imageView = QtImageViewer(self) |
|
274 |
self.ui.imageView.setScene(QtImageViewerScene(self)) |
|
275 |
self.ui.imageView.scene().guidesEnabled = True |
|
275 | 276 |
self.ui.imageView.setGeometry(QtCore.QRect(0, y, height, height)) |
276 | 277 |
self.ui.imageView.aspectRatioMode = QtCore.Qt.KeepAspectRatio |
277 | 278 |
self.ui.imageView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) |
... | ... | |
585 | 586 |
imageWidth = self.ui.imageView.image().width() |
586 | 587 |
imageHeight = self.ui.imageView.image().height() |
587 | 588 |
items = [item for item in |
588 |
self.ui.imageView.scene.items(QRectF(float(circlePoint.x()) - 0.5, float(circlePoint.y()) - 0.5, 1, 1)) \ |
|
589 |
self.ui.imageView.scene().items(QRectF(float(circlePoint.x()) - 0.5, float(circlePoint.y()) - 0.5, 1, 1)) \
|
|
589 | 590 |
if type(item) is QEngineeringConnectorItem] |
590 | 591 |
for item in items: |
591 |
self.ui.imageView.scene.removeItem(item) |
|
592 |
self.ui.imageView.scene().removeItem(item)
|
|
592 | 593 |
|
593 | 594 |
'''^ |
594 | 595 |
@brief Display this QDialog |
... | ... | |
881 | 882 |
item = self.ui.tableWidgetConnList.item(item.row(), 0) |
882 | 883 |
data = item.data(Qt.UserRole) |
883 | 884 |
if data is not None: |
884 |
self.ui.imageView.scene.removeItem(data) |
|
885 |
self.ui.imageView.scene().removeItem(data)
|
|
885 | 886 |
model.removeRow(item.row()) |
886 | 887 |
self.conn_index -= 1 |
887 | 888 |
|
... | ... | |
1045 | 1046 |
def onCommandSuccess(self, pt): |
1046 | 1047 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
1047 | 1048 |
|
1048 |
self.ui.imageView.scene.invalidate() |
|
1049 |
self.ui.imageView.scene().invalidate()
|
|
1049 | 1050 |
if type(pt) is QEngineeringConnectorItem: |
1050 | 1051 |
rows = self.ui.tableWidgetConnList.rowCount() |
1051 | 1052 |
self.ui.tableWidgetConnList.setRowCount(rows + 1) |
... | ... | |
1125 | 1126 |
item = self.ui.tableWidgetConnList.item(item.row(), 0) |
1126 | 1127 |
data = item.data(Qt.UserRole) |
1127 | 1128 |
if data is not None: |
1128 |
self.ui.imageView.scene.removeItem(data) |
|
1129 |
self.ui.imageView.scene().removeItem(data)
|
|
1129 | 1130 |
model.removeRow(item.row()) |
1130 | 1131 |
self.conn_index -= 1 |
1131 | 1132 |
|
내보내기 Unified diff