개정판 d79cbac6
issue #1025:스트림 데이타 입력 - 저장 및 불러오기
Change-Id: I034d3e7f620206b7eebaecf9abfa8d1746be4318
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
97 | 97 |
self.texts = [] |
98 | 98 |
self.symbols = [] |
99 | 99 |
self.unknowns = [] |
100 |
self.allItems = [] |
|
101 | 100 |
self.tracerLineNos = [] |
102 | 101 |
self.lineIndicators = [] |
103 | 102 |
self._colors = None |
... | ... | |
105 | 104 |
self._lineTypes = None |
106 | 105 |
self._lineTypeConfigs = None |
107 | 106 |
self._activeDrawing = None |
108 |
self._hmbTable = None |
|
109 | 107 |
self._titleBlockProperties = None |
110 | 108 |
self.needReOpening = None |
111 | 109 |
|
... | ... | |
123 | 121 |
self.texts.clear() |
124 | 122 |
self.lines.clear() |
125 | 123 |
self.unknowns.clear() |
126 |
self.allItems.clear() |
|
127 | 124 |
self.lineIndicators.clear() |
128 | 125 |
if trim: |
129 | 126 |
self.tracerLineNos.clear() |
... | ... | |
146 | 143 |
self.texts.clear() |
147 | 144 |
self.symbols.clear() |
148 | 145 |
self.unknowns.clear() |
149 |
self.allItems.clear() |
|
150 | 146 |
self.tracerLineNos.clear() |
151 | 147 |
self.lineIndicators.clear() |
152 | 148 |
self._colors = None |
153 | 149 |
self._lineNoProperties = None |
154 | 150 |
self._lineTypeConfigs = None |
155 | 151 |
self._activeDrawing = None |
156 |
self._hmbTable = None |
|
157 | 152 |
self._titleBlockProperties = None |
158 | 153 |
|
159 | 154 |
''' |
... | ... | |
315 | 310 |
self._drain_size = value |
316 | 311 |
|
317 | 312 |
''' |
318 |
@brief getter of hmb table |
|
319 |
@author humkyung |
|
320 |
@date 2018.07.16 |
|
321 |
''' |
|
322 |
@property |
|
323 |
def hmbTable(self): |
|
324 |
from HMBTable import HMBTable |
|
325 |
|
|
326 |
if self._hmbTable is None: |
|
327 |
self._hmbTable = HMBTable() |
|
328 |
self._hmbTable.loadData() |
|
329 |
|
|
330 |
return self._hmbTable |
|
331 |
|
|
332 |
''' |
|
333 |
@brief setter of hmb table |
|
334 |
@author humkyung |
|
335 |
@date 2018.07.16 |
|
336 |
''' |
|
337 |
@hmbTable.setter |
|
338 |
def hmbTable(self, value): |
|
339 |
self._hmbTable = value |
|
340 |
|
|
341 |
''' |
|
342 | 313 |
@brief get line type config of given line type |
343 | 314 |
@author humkyung |
344 | 315 |
@date 2018.06.28 |
... | ... | |
1416 | 1387 |
# 0. Delete Points |
1417 | 1388 |
sql = "delete from Points where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
1418 | 1389 |
cursor.execute(sql) |
1419 |
# 1. Delete Components |
|
1390 |
|
|
1391 |
# 1. Delete HMB |
|
1392 |
sql = "delete from HMB where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
|
1393 |
cursor.execute(sql) |
|
1394 |
|
|
1395 |
# 2. Delete Components |
|
1420 | 1396 |
sql = "delete from Components where Drawings_UID='{}'".format(uid) |
1421 | 1397 |
cursor.execute(sql) |
1422 |
# 2. Delete DrawingsUnits
|
|
1398 |
# 3. Delete DrawingsUnits
|
|
1423 | 1399 |
sql = "delete from DrawingsUnits where Drawings_UID='{}'".format(uid) |
1424 | 1400 |
cursor.execute(sql) |
1425 |
# 3. Delete Drawings |
|
1401 |
|
|
1402 |
# 4. Delete Drawings |
|
1426 | 1403 |
sql = "delete from Drawings where UID='{}'".format(uid) |
1427 | 1404 |
cursor.execute(sql) |
1428 | 1405 |
|
... | ... | |
2857 | 2834 |
sql = "delete from Points where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
2858 | 2835 |
cursor.execute(sql) |
2859 | 2836 |
|
2837 |
# delete HMB |
|
2838 |
sql = "delete from HMB where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
|
2839 |
cursor.execute(sql) |
|
2840 |
|
|
2860 | 2841 |
# delete Components |
2861 | 2842 |
sql = "delete from Components where Drawings_UID = '{}'".format(uid) |
2862 | 2843 |
cursor.execute(sql) |
... | ... | |
3324 | 3305 |
|
3325 | 3306 |
return unitsList |
3326 | 3307 |
|
3327 |
def getColumnDisplayNames(self): |
|
3308 |
def getColumnDisplayNames(self, uid, table):
|
|
3328 | 3309 |
columnDisplayNameList = [] |
3329 | 3310 |
|
3330 | 3311 |
try: |
... | ... | |
3332 | 3313 |
|
3333 | 3314 |
conn = sqlite3.connect(dbPath) |
3334 | 3315 |
cursor = conn.cursor() |
3335 |
sql = 'SELECT * FROM Column_DisplayNames' |
|
3316 |
sql = """SELECT dn.DISPLAY_NAME |
|
3317 |
, u.UNIT |
|
3318 |
FROM DisplayNames dn |
|
3319 |
left join drawingsUnits du |
|
3320 |
on dn.TABLE_NAME = du.Table_Name and dn.COLUMN_NAME = du.Column_Name |
|
3321 |
left join Units u |
|
3322 |
on du.Units_UID = u.UID |
|
3323 |
where du.Drawings_UID = ? |
|
3324 |
and dn.Table_Name = ? |
|
3325 |
order by dn.[Order]""" |
|
3336 | 3326 |
try: |
3337 |
cursor.execute(sql) |
|
3327 |
param = (uid, table,) |
|
3328 |
cursor.execute(sql, param) |
|
3329 |
|
|
3338 | 3330 |
rows = cursor.fetchall() |
3339 | 3331 |
for row in rows: |
3340 |
columnDisplayNameList.append((row[0], row[1], row[2])) # UID, Name, Display_Name
|
|
3332 |
columnDisplayNameList.append((row[0], row[1])) # Display_Name
|
|
3341 | 3333 |
except Exception as ex: |
3342 | 3334 |
from App import App |
3343 | 3335 |
|
HYTOS/HYTOS/Commands/SaveWorkCommand.py | ||
---|---|---|
27 | 27 |
|
28 | 28 |
try: |
29 | 29 |
appDocData = AppDocData.instance() |
30 |
items = appDocData.allItems |
|
30 |
items = appDocData.activeDrawing.allItems
|
|
31 | 31 |
|
32 | 32 |
dbItems = [item for item in items if type(item) is SymbolSvgItem or type(item) is QEngineeringStreamlineItem] |
33 | 33 |
appDocData.saveToDatabase(dbItems) |
34 | 34 |
|
35 |
activeDrawing = appDocData.activeDrawing |
|
36 |
if activeDrawing is not None: |
|
37 |
activeDrawing.hmbTable.saveData() |
|
38 |
|
|
35 | 39 |
self.resultStr = SaveWorkCommand.save_to_database() |
36 | 40 |
|
37 | 41 |
""" update drawing's modified time """ |
... | ... | |
55 | 59 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
56 | 60 |
|
57 | 61 |
appDocData = AppDocData.instance() |
58 |
items = appDocData.allItems |
|
62 |
items = appDocData.activeDrawing.allItems
|
|
59 | 63 |
|
60 |
dbItems = [item for item in items if type(item) is SymbolSvgItem or type(item) is QEngineeringStreamlineItem] |
|
64 |
symbolCount = 0 |
|
65 |
streamCount = 0 |
|
66 |
|
|
67 |
for item in items: |
|
68 |
if type(item) is SymbolSvgItem: |
|
69 |
symbolCount += 1 |
|
70 |
elif type(item) is QEngineeringStreamlineItem: |
|
71 |
streamCount += 1 |
|
61 | 72 |
|
62 |
resultStr = " Save Count : " + str(len(dbItems))
|
|
73 |
resultStr = "Symbol(s) = {}, Stream Line(s) = {}".format(symbolCount, streamCount)
|
|
63 | 74 |
|
64 | 75 |
return resultStr |
65 | 76 |
|
... | ... | |
71 | 82 |
from AppDocData import MessageType |
72 | 83 |
from SymbolSvgItem import SymbolSvgItem |
73 | 84 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
85 |
from HMBTable import HMBData |
|
74 | 86 |
|
75 | 87 |
try: |
76 | 88 |
appDocData = AppDocData.instance() |
77 |
items = appDocData.allItems |
|
78 |
|
|
89 |
items = appDocData.activeDrawing.allItems
|
|
90 |
|
|
79 | 91 |
dbItems = [item for item in items if type(item) is SymbolSvgItem or type(item) is QEngineeringStreamlineItem] |
80 | 92 |
appDocData.saveToDatabase(dbItems) |
81 | 93 |
|
94 |
activeDrawing = appDocData.activeDrawing |
|
95 |
if activeDrawing is not None: |
|
96 |
activeDrawing.hmbTable.saveData() |
|
97 |
|
|
98 |
self.resultStr = SaveWorkCommand.save_to_database() |
|
99 |
|
|
82 | 100 |
except Exception as ex: |
83 | 101 |
from AppDocData import MessageType |
84 | 102 |
|
HYTOS/HYTOS/Drawing.py | ||
---|---|---|
21 | 21 |
self.UID = drawing[0][0] if drawing else uuid.uuid4() |
22 | 22 |
''' up to here ''' |
23 | 23 |
|
24 |
self.allItems = [] |
|
24 | 25 |
self._hmbTable = None |
25 |
|
|
26 |
|
|
27 |
def clearItemList(self): |
|
28 |
self.allItems.clear() |
|
29 |
|
|
26 | 30 |
''' |
27 | 31 |
@brief getter of attrs |
28 | 32 |
@author humkyung |
... | ... | |
66 | 70 |
|
67 | 71 |
if self._hmbTable is None: |
68 | 72 |
self._hmbTable = HMBTable() |
69 |
self._hmbTable.loadData()
|
|
73 |
self._hmbTable.loadDataByDrawingUID(self.UID)
|
|
70 | 74 |
|
71 | 75 |
return self._hmbTable |
72 | 76 |
|
HYTOS/HYTOS/HMBTable.py | ||
---|---|---|
11 | 11 |
class HMBData: |
12 | 12 |
def __init__(self, uid=None): |
13 | 13 |
self._uid = None |
14 |
self._drawing_uid = None
|
|
14 |
self._components_uid = None
|
|
15 | 15 |
self._stream_no = None |
16 |
self._tag_no = None |
|
17 | 16 |
self._phase_type = None |
18 | 17 |
self.isDeleted = False |
19 | 18 |
|
... | ... | |
39 | 38 |
@date 2018.07.12 |
40 | 39 |
''' |
41 | 40 |
@property |
42 |
def drawing_uid(self):
|
|
43 |
return self._drawing_uid
|
|
41 |
def components_uid(self):
|
|
42 |
return self._components_uid
|
|
44 | 43 |
|
45 | 44 |
''' |
46 | 45 |
@author humkyung |
47 | 46 |
@date 2018.07.12 |
48 | 47 |
''' |
49 |
@drawing_uid.setter
|
|
50 |
def drawing_uid(self, value):
|
|
51 |
self._drawing_uid = value
|
|
48 |
@components_uid.setter
|
|
49 |
def components_uid(self, value):
|
|
50 |
self._components_uid = value
|
|
52 | 51 |
|
53 | 52 |
''' |
54 | 53 |
@author humkyung |
... | ... | |
66 | 65 |
def stream_no(self, value): |
67 | 66 |
self._stream_no = value |
68 | 67 |
|
69 |
''' |
|
70 |
@author humkyung |
|
71 |
@date 2018.07.12 |
|
72 |
''' |
|
73 |
@property |
|
74 |
def tag_no(self): |
|
75 |
return self._tag_no |
|
76 |
|
|
77 |
''' |
|
78 |
@author humkyung |
|
79 |
@date 2018.07.12 |
|
80 |
''' |
|
81 |
@tag_no.setter |
|
82 |
def tag_no(self, value): |
|
83 |
self._tag_no = value |
|
84 |
|
|
85 |
|
|
86 | 68 |
@property |
87 | 69 |
def phase_type(self): |
88 | 70 |
return self._phase_type |
... | ... | |
90 | 72 |
@phase_type.setter |
91 | 73 |
def phase_type(self, value): |
92 | 74 |
self._phase_type = value |
75 |
|
|
93 | 76 |
|
77 |
def fromRow(row): |
|
78 |
hmb = HMBData() |
|
79 |
hmb._uid = row[0] |
|
80 |
hmb._components_uid = row[1] |
|
81 |
hmb._stream_no = row[2] |
|
82 |
|
|
83 |
|
|
84 |
return hmb |
|
94 | 85 |
class HMBTable: |
95 | 86 |
''' |
96 | 87 |
@brief constructor |
... | ... | |
102 | 93 |
|
103 | 94 |
@staticmethod |
104 | 95 |
def new_data(): |
105 |
import uuid |
|
96 |
|
|
106 | 97 |
|
107 | 98 |
# 새로운 HMB 데이타를 생성한다. |
108 | 99 |
hmb = HMBData() |
109 |
hmb.uid = uuid.uuid4() |
|
100 |
|
|
110 | 101 |
hmb.isDeleted = False |
111 | 102 |
return hmb |
112 | 103 |
|
... | ... | |
115 | 106 |
@author humkyung |
116 | 107 |
@date 2018.07.12 |
117 | 108 |
''' |
118 |
def loadData(self):
|
|
109 |
def loadDataByDrawingUID(self, uid):
|
|
119 | 110 |
from App import App |
120 | 111 |
from AppDocData import AppDocData |
121 | 112 |
|
... | ... | |
129 | 120 |
|
130 | 121 |
conn = sqlite3.connect(dbPath) |
131 | 122 |
cursor = conn.cursor() |
132 |
sql = """select UID |
|
133 |
, Components_UID |
|
134 |
, Stream_No |
|
135 |
from HMB |
|
136 |
order by Stream_No""" |
|
137 |
cursor.execute(sql) |
|
123 |
sql = """select h.UID |
|
124 |
, h.Components_UID |
|
125 |
, h.Stream_No |
|
126 |
from HMB h |
|
127 |
left join Components c |
|
128 |
on h.Components_UID = c.UID |
|
129 |
where c.Drawings_UID = ? |
|
130 |
order by h.Stream_No""" |
|
131 |
|
|
132 |
param = (uid, ) |
|
133 |
cursor.execute(sql, param) |
|
138 | 134 |
rows = cursor.fetchall() |
139 | 135 |
for row in rows: |
140 | 136 |
hmb = HMBData.fromRow(row) |
... | ... | |
159 | 155 |
from App import App |
160 | 156 |
from AppDocData import AppDocData |
161 | 157 |
|
162 |
try: |
|
163 |
if self._hmbs is not None: |
|
164 |
appDocData = AppDocData.instance() |
|
165 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
166 |
dbPath = os.path.join(appDocData.getCurrentProject().getDbFilePath(), App.NAME + '.db') |
|
167 |
conn = sqlite3.connect(dbPath) |
|
168 |
# Get a cursor object |
|
169 |
cursor = conn.cursor() |
|
158 |
if self._hmbs is None: |
|
159 |
return |
|
170 | 160 |
|
171 |
for data in self._hmbs: |
|
172 |
if data.isDeleted == False: |
|
173 |
if data.uid is None: |
|
174 |
sql = "insert or replace into HMB values(?,?,?,?,?)" |
|
175 |
param = (str(uuid.uuid4()), data.streamNo, data.name, data.unit, data.value) |
|
176 |
cursor.execute(sql, param) |
|
177 |
else: |
|
178 |
sql = "update HMB set STREAM_NO=?,NAME=?,UNIT=?,VALUE=? where UID=?" |
|
179 |
param = (data.streamNo, data.name, data.unit, data.value, data.uid) |
|
180 |
cursor.execute(sql, param) |
|
181 |
else: |
|
182 |
sql = "delete from HMB where uid=?" |
|
183 |
param = (data.uid,) |
|
184 |
cursor.execute(sql, param) |
|
185 |
|
|
186 |
conn.commit() |
|
161 |
try: |
|
162 |
appDocData = AppDocData.instance() |
|
163 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
164 |
dbPath = os.path.join(appDocData.getCurrentProject().getDbFilePath(), App.NAME + '.db') |
|
165 |
conn = sqlite3.connect(dbPath) |
|
166 |
# Get a cursor object |
|
167 |
cursor = conn.cursor() |
|
168 |
|
|
169 |
for data in self._hmbs: |
|
170 |
if data.isDeleted == False: |
|
171 |
cols = ['UID', 'Components_UID', 'Stream_No'] |
|
172 |
values = ['?', '?', '?'] |
|
173 |
param = (str(data.uid), str(data.components_uid), data.stream_no) |
|
174 |
|
|
175 |
sql = 'insert or replace into HMB({}) values({})'.format(','.join(cols), ','.join(values)) |
|
176 |
cursor.execute(sql, param) |
|
177 |
else: |
|
178 |
sql = "delete from HMB where uid=?" |
|
179 |
param = (data.uid,) |
|
180 |
cursor.execute(sql, param) |
|
181 |
|
|
182 |
conn.commit() |
|
187 | 183 |
# Catch the exception |
188 | 184 |
except Exception as ex: |
189 | 185 |
# Roll back any change if something goes wrong |
HYTOS/HYTOS/ItemPropertyTableWidget.py | ||
---|---|---|
162 | 162 |
noteContentsList = item.findNoteContents(item.text()) |
163 | 163 |
self.onNoteClicked(item.text(), noteContentsList) |
164 | 164 |
elif issubclass(type(item), QEngineeringTextItem): |
165 |
self.onTextClicked(item) |
|
166 |
elif type(item) is QEngineeringVendorItem: |
|
167 |
self.onVendorClicked(item) |
|
165 |
self.onTextClicked(item) |
|
168 | 166 |
elif item is None: |
169 | 167 |
self.setRowCount(0) |
170 | 168 |
except Exception as ex: |
... | ... | |
392 | 390 |
self._lineTypeComboBox.addItem(lineType.name) |
393 | 391 |
self.setCellWidget(2, 3, self._lineTypeComboBox) |
394 | 392 |
self._lineTypeComboBox.setCurrentText(item.lineType) |
395 |
self._lineTypeComboBox.currentIndexChanged.connect(self.onLineTypeChanged) |
|
396 |
elif type(item) is QEngineeringVendorItem: |
|
397 |
self.setRowCount(1) |
|
398 |
self.setItem(0, 1, QTableWidgetItem(self.tr("UID"))) |
|
393 |
self._lineTypeComboBox.currentIndexChanged.connect(self.onLineTypeChanged) |
|
399 | 394 |
#else: |
400 | 395 |
# self.setRowCount(4) |
401 | 396 |
# self.setItem(0, 1, QTableWidgetItem(self.tr("UID"))) |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
102 | 102 |
self.graphicsView.useDefaultCommand() |
103 | 103 |
self.graphicsView.setMouseTracking(True) |
104 | 104 |
self.graphicsView.viewport().installEventFilter(self) |
105 |
|
|
106 | 105 |
self.verticalLayout.addWidget(self.graphicsView) |
107 | 106 |
|
108 | 107 |
# Add Symbol TreeWidget |
109 | 108 |
self.symbolTreeWidget = SymbolTreeWidget.QSymbolTreeWidget() |
110 | 109 |
self.symbolTreeWidget.header().hide() |
111 | 110 |
self.verticalLayoutSymbolList.addWidget(self.symbolTreeWidget) |
112 |
|
|
113 |
self.treeWidgetDrawingList.setHeaderHidden(False) |
|
114 |
self.treeWidgetDrawingList.header().setStretchLastSection(True) |
|
115 |
self.treeWidgetDrawingList.header().setDefaultAlignment(Qt.AlignCenter) |
|
116 |
self.treeWidgetDrawingList.setHeaderLabels([self.tr('Name'), self.tr('DateTime'), self.tr('Uid')]) |
|
117 |
self.treeWidgetDrawingList.header().setSectionResizeMode(0, QHeaderView.ResizeToContents) |
|
118 |
self.treeWidgetDrawingList.header().setSectionResizeMode(1, QHeaderView.ResizeToContents) |
|
119 |
self.treeWidgetDrawingList.header().setSectionResizeMode(2, QHeaderView.ResizeToContents) |
|
120 |
self.treeWidgetDrawingList.hideColumn(2) |
|
121 |
|
|
122 |
self.treeWidgetDrawingList.itemDoubleClicked.connect(self.open_selected_drawing) |
|
123 |
|
|
111 |
|
|
124 | 112 |
# Initialize Action group |
125 | 113 |
self.actionGroup = QActionGroup(self) |
126 |
self.actionGroup.addAction(self.actionLine) |
|
127 |
|
|
114 |
self.actionGroup.addAction(self.actionLine) |
|
128 | 115 |
self.actionGroup.addAction(self.actionZoom) |
129 | 116 |
self.actionGroup.addAction(self.actionFitWindow) |
130 | 117 |
self.actionGroup.addAction(self.actionSave) |
131 | 118 |
|
132 |
self.actionGroup.triggered.connect(self.actionGroupTriggered) |
|
133 |
|
|
134 | 119 |
# connect signals and slots |
120 |
self.actionGroup.triggered.connect(self.actionGroupTriggered) |
|
135 | 121 |
self.actionClose.triggered.connect(self.close) |
136 | 122 |
self.actionNew.triggered.connect(self.new_drawing) |
137 | 123 |
self.actionSave.triggered.connect(self.actionSaveCliked) |
138 | 124 |
self.actionLine.triggered.connect(self.onPlaceLine) |
139 |
self.actionConfiguration.triggered.connect(self.configuration) |
|
140 |
|
|
141 |
self.actionImage_Drawing.triggered.connect(self.onViewImageDrawing) |
|
142 |
self.actionDrawing_Only.triggered.connect(self.onViewDrawingOnly) |
|
143 |
self.actionViewText.triggered.connect(self.onViewText) |
|
144 |
self.actionViewSymbol.triggered.connect(self.onViewSymbol) |
|
145 |
self.actionViewLine.triggered.connect(self.onViewLine) |
|
146 |
self.actionViewUnknown.triggered.connect(self.onViewUnknown) |
|
147 |
self.actionViewInconsistency.triggered.connect(self.onViewInconsistency) |
|
148 |
self.actionViewVendor_Area.triggered.connect(self.onViewVendorArea) |
|
149 |
self.actionRotate.triggered.connect(self.onRotate) |
|
125 |
self.actionConfiguration.triggered.connect(self.configuration) |
|
126 |
self.actionInitialize.triggered.connect(self.onInitializeScene) |
|
150 | 127 |
self.actionZoom.triggered.connect(self.onAreaZoom) |
151 |
|
|
152 |
self.actionFitWindow.triggered.connect(self.fitWindow) |
|
153 |
self.actionCreate_Symbol.triggered.connect(self.create_symbol) |
|
128 |
self.actionFitWindow.triggered.connect(self.fitWindow) |
|
154 | 129 |
self.graphicsView.scene.contents_changed.connect(self.onSceneChanged) |
155 |
self.graphicsView.scene.selectionChanged.connect(self.onSelectionChanged) |
|
156 |
self.actionInitialize.triggered.connect(self.onInitializeScene) |
|
130 |
self.graphicsView.scene.selectionChanged.connect(self.onSelectionChanged) |
|
157 | 131 |
self.addMessage.connect(self.onAddMessage) |
132 |
|
|
133 |
self.treeWidgetDrawingList.setContextMenuPolicy(Qt.CustomContextMenu) |
|
134 |
self.treeWidgetDrawingList.customContextMenuRequested.connect(self.openContextMenu) |
|
135 |
self.treeWidgetDrawingList.itemDoubleClicked.connect(self.open_selected_drawing) |
|
158 | 136 |
|
159 |
self.load_drawing_list()
|
|
137 |
self.initTreeWidgetDrawingList()
|
|
160 | 138 |
self.initTableWidgetHMB() |
161 |
|
|
139 |
self.load_drawing_list() |
|
140 |
|
|
141 |
self.load_stylesheet_file() |
|
142 |
self.load_language_file() |
|
143 |
|
|
144 |
def load_stylesheet_file(self): |
|
162 | 145 |
# load stylesheet file list |
163 | 146 |
stylesheet_name = QtWidgets.qApp.stylesheet_name |
164 | 147 |
files = [os.path.splitext(file)[0] for file in os.listdir(os.path.dirname(os.path.realpath(__file__))) if os.path.splitext(file)[1] == '.qss'] |
... | ... | |
169 | 152 |
action.triggered.connect(partial(self.load_stylesheet, file)) |
170 | 153 |
# up to here |
171 | 154 |
|
155 |
def load_language_file(self): |
|
172 | 156 |
# load language files |
173 | 157 |
language_name = QtWidgets.qApp.language_name |
174 | 158 |
files = ['en_us'] # englisgh is default language |
... | ... | |
180 | 164 |
action.triggered.connect(partial(self.load_language, file)) |
181 | 165 |
# up to here |
182 | 166 |
|
183 |
self.treeWidgetDrawingList.setContextMenuPolicy(Qt.CustomContextMenu) |
|
184 |
self.treeWidgetDrawingList.customContextMenuRequested.connect(self.openContextMenu) |
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 | 167 |
def openContextMenu(self, position): |
190 | 168 |
indexes = self.treeWidgetDrawingList.selectedIndexes() |
191 | 169 |
if len(indexes) > 0: |
... | ... | |
251 | 229 |
|
252 | 230 |
appDocData.deleteDrawingByUID(uid) |
253 | 231 |
|
254 |
self.clear_data() |
|
255 | 232 |
self.load_drawing_list() |
233 |
self.initTableWidgetHMB() |
|
256 | 234 |
|
257 | 235 |
except Exception as ex: |
258 | 236 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
289 | 267 |
#finally: |
290 | 268 |
# return QTableView.keyPressEvent(self.tableWidgetHMB, event) |
291 | 269 |
|
292 |
def makeInconsistencyTableRow(self, errorItem): |
|
293 |
''' |
|
294 |
@brief make row data for inconsistency widget |
|
295 |
@author euisung |
|
296 |
@date 2019.04.16 |
|
297 |
''' |
|
298 |
items = [] |
|
299 |
if type(errorItem.parent) is QEngineeringLineItem: |
|
300 |
item = QTableWidgetItem('line') |
|
301 |
#item.setFlags(Qt.ItemIsEnabled) |
|
302 |
elif issubclass(type(errorItem.parent), SymbolSvgItem): |
|
303 |
item = QTableWidgetItem('symbol') |
|
304 |
#item.setFlags(Qt.ItemIsEnabled) |
|
305 |
#elif |
|
306 |
item.tag = errorItem |
|
307 |
items.append(item) |
|
308 |
|
|
309 |
item = QTableWidgetItem(errorItem.msg) |
|
310 |
#item.setFlags(Qt.ItemIsEnabled) |
|
311 |
item.tag = errorItem |
|
312 |
items.append(item) |
|
313 |
|
|
314 |
return items |
|
315 |
|
|
316 |
def inconsistencyItemClickEvent(self, item): |
|
317 |
""" |
|
318 |
@brief inconsistency table item clicked |
|
319 |
@author euisung |
|
320 |
@date 2019.04.02 |
|
321 |
""" |
|
322 |
from HighlightCommand import HighlightCommand |
|
323 |
|
|
324 |
HighlightCommand(self.graphicsView).execute(item.tag) |
|
325 | 270 |
|
326 | 271 |
def load_stylesheet(self, file): |
327 | 272 |
""" |
... | ... | |
359 | 304 |
finally: |
360 | 305 |
self.retranslateUi(self) |
361 | 306 |
|
307 |
def initTreeWidgetDrawingList(self): |
|
308 |
|
|
309 |
self.treeWidgetDrawingList.setHeaderHidden(False) |
|
310 |
self.treeWidgetDrawingList.header().setStretchLastSection(True) |
|
311 |
self.treeWidgetDrawingList.header().setDefaultAlignment(Qt.AlignCenter) |
|
312 |
self.treeWidgetDrawingList.setHeaderLabels([self.tr('Name'), self.tr('DateTime'), self.tr('Uid')]) |
|
313 |
self.treeWidgetDrawingList.header().setSectionResizeMode(0, QHeaderView.ResizeToContents) |
|
314 |
self.treeWidgetDrawingList.header().setSectionResizeMode(1, QHeaderView.ResizeToContents) |
|
315 |
self.treeWidgetDrawingList.header().setSectionResizeMode(2, QHeaderView.ResizeToContents) |
|
316 |
self.treeWidgetDrawingList.hideColumn(2) |
|
362 | 317 |
|
363 | 318 |
def initTableWidgetHMB(self): |
364 |
if hasattr(self, '_headers'): del self._headers |
|
365 |
if not hasattr(self, '_headers'): self._headers = [] |
|
366 |
|
|
367 |
''' |
|
368 |
docData = AppDocData.instance() |
|
369 |
columnDisplayNameList = docData.getColumnDisplayNames() |
|
319 |
docData = AppDocData.instance() |
|
320 |
if docData.activeDrawing is None: |
|
321 |
drawingUid = '00000000-0000-0000-0000-000000000000' |
|
322 |
else: |
|
323 |
drawingUid = docData.activeDrawing.UID |
|
370 | 324 |
|
371 |
for columnDisplayName in columnDisplayNameList: |
|
372 |
self._headers.append(columnDisplayName[2]) |
|
373 |
''' |
|
374 |
|
|
375 |
self._headers.append('Uid') |
|
376 |
self._headers.append('Drawing_Uid') |
|
377 |
self._headers.append('Stream No.') |
|
378 |
self._headers.append('Tag No.') |
|
379 |
self._headers.append('Phase') |
|
380 |
self._headers.append('Flowrate (Mass)') |
|
381 |
self._headers.append('Flowrate (Volume)') |
|
382 |
self._headers.append('Density') |
|
383 |
self._headers.append('Viscosity') |
|
384 |
self._headers.append('Temperature') |
|
385 |
self._headers.append('Molecular Weight') |
|
386 |
self._headers.append('Specific Heat Ratio (Cp/Cv)') |
|
387 |
self._headers.append('Compress. Factor (Z)') |
|
388 |
self._headers.append('Pipe Nominal Diameter') |
|
389 |
self._headers.append('Pipe Inside Diameter') |
|
390 |
self._headers.append('Sch. No.') |
|
391 |
self._headers.append('Straight Length') |
|
392 |
self._headers.append('Equivalent Length') |
|
393 |
self._headers.append('Roughness') |
|
394 |
self._headers.append('Limitation of Velocity') |
|
395 |
self._headers.append('Limitation of Press. Drop') |
|
396 |
|
|
397 |
self.tableWidgetHMB.setColumnCount(len(self._headers)) |
|
398 |
self.tableWidgetHMB.setHorizontalHeaderLabels(self._headers) |
|
399 |
#self.tableWidgetHMB.horizontalHeaderItem(0).setSizeHint(QSize(0, 30)) |
|
400 |
self.tableWidgetHMB.horizontalHeaderItem(0).setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) # header 정렬 방식 |
|
325 |
columnDisplayNameList = docData.getColumnDisplayNames(drawingUid, 'HMB') |
|
326 |
|
|
327 |
count = len(columnDisplayNameList) |
|
328 |
self.tableWidgetHMB.setRowCount(count) |
|
329 |
self.tableWidgetHMB.setColumnCount(2) |
|
330 |
|
|
331 |
rowIndex = 0 |
|
332 |
for columnDisplayName in columnDisplayNameList: |
|
333 |
name = QTableWidgetItem(columnDisplayName[0]) |
|
334 |
name.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter) |
|
335 |
name.setBackground(QColor(230, 230, 230)) |
|
336 |
self.tableWidgetHMB.setItem(rowIndex, 0, name) |
|
337 |
|
|
338 |
unit = QTableWidgetItem(columnDisplayName[1]) |
|
339 |
unit.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
340 |
unit.setBackground(QColor(230, 230, 230)) |
|
341 |
self.tableWidgetHMB.setItem(rowIndex, 1, unit) |
|
342 |
|
|
343 |
rowIndex += 1 |
|
401 | 344 |
|
402 | 345 |
self.tableWidgetHMB.setEditTriggers(QAbstractItemView.NoEditTriggers) |
403 |
|
|
404 |
#self.tableWidgetHMB.setColumnHidden(0, True) |
|
405 |
#self.tableWidgetHMB.setColumnHidden(1, True) |
|
406 |
|
|
407 | 346 |
self.tableWidgetHMB.resizeColumnsToContents() |
408 |
self.tableWidgetHMB.resizeRowsToContents() |
|
409 |
#self.tableWidgetHMB.horizontalHeader().setStretchLastSection(True) |
|
410 |
|
|
347 |
self.tableWidgetHMB.resizeRowsToContents()
|
|
348 |
|
|
349 |
self.tableWidgetHMB.horizontalHeader().setVisible(False) |
|
411 | 350 |
self.tableWidgetHMB.verticalHeader().setVisible(False) |
351 |
|
|
412 | 352 |
|
353 |
|
|
413 | 354 |
|
414 | 355 |
''' |
415 | 356 |
@brief Clear TreeWidget and Set Current PID |
... | ... | |
473 | 414 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringErrorItem] |
474 | 415 |
self.labelSymbolStatus.setText("<font color='blue'>" + self.tr('Symbol') + " : {}</font>".format(len(items))) |
475 | 416 |
|
476 |
items = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem] |
|
477 |
self.labelLineStatus.setText("<font color='blue'>" + self.tr('Line') + " : {}</font>".format(len(items))) |
|
478 |
|
|
479 | 417 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
480 | 418 |
self.labelTextStatus.setText("<font color='blue'>" + self.tr('Text') + " : {}</font>".format(len(items))) |
481 | 419 |
|
... | ... | |
493 | 431 |
|
494 | 432 |
titleBlockProps = appDocData.getTitleBlockProperties() |
495 | 433 |
#items = self.graphicsView.scene.items() |
496 |
items = appDocData.allItems |
|
434 |
items = appDocData.activeDrawing.allItems
|
|
497 | 435 |
titleBlockItems = [] |
498 | 436 |
for item in items: |
499 | 437 |
#if type(item) is QEngineeringLineNoTextItem: |
... | ... | |
504 | 442 |
titleBlockItems.append(item) |
505 | 443 |
|
506 | 444 |
dbItems = [item for item in items if type(item) is QEngineeringInstrumentItem or type(item) is QEngineeringEquipmentItem or type(item) is QEngineeringReducerItem or\ |
507 |
type(item) is QEngineeringNoteItem or type(item) is SymbolSvgItem or type(item) is QEngineeringLineNoTextItem or type(item) is QEngineeringVendorItem] + titleBlockItems
|
|
445 |
type(item) is QEngineeringNoteItem or type(item) is SymbolSvgItem or type(item) is QEngineeringLineNoTextItem] + titleBlockItems |
|
508 | 446 |
appDocData.saveToDatabase(dbItems) |
509 | 447 |
except Exception as ex: |
510 | 448 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
532 | 470 |
self.showImageSelectionMessageBox() |
533 | 471 |
return |
534 | 472 |
|
535 |
appDocData.clearItemList(False)
|
|
473 |
appDocData.activeDrawing.clearItemList()
|
|
536 | 474 |
|
537 | 475 |
items = self.graphicsView.scene.items() |
538 | 476 |
for item in items: |
539 | 477 |
if issubclass(type(item), QEngineeringAbstractItem): |
540 |
appDocData.allItems.append(item) |
|
478 |
appDocData.activeDrawing.allItems.append(item)
|
|
541 | 479 |
if issubclass(type(item), QEngineeringTextItem): |
542 | 480 |
appDocData.texts.append(item) |
543 | 481 |
## |
... | ... | |
553 | 491 |
itemTypes.append(type(item)) |
554 | 492 |
## |
555 | 493 |
|
556 |
#SaveWorkCommand.save() |
|
557 |
|
|
494 |
#SaveWorkCommand.save() |
|
558 | 495 |
self._save_work_cmd = SaveWorkCommand() |
559 | 496 |
self._save_work_cmd.display_message.connect(self.onAddMessage) |
560 | 497 |
self._save_work_cmd.finished.connect(self.save_finished) |
... | ... | |
564 | 501 |
if not hasattr(self, '_movie'): |
565 | 502 |
self._movie = QMovie(':/newPrefix/spinner.gif') |
566 | 503 |
self.label_spinner.setMovie(self._movie) |
504 |
|
|
567 | 505 |
self.label_spinner.show() |
568 | 506 |
self._movie.start() |
569 | 507 |
|
570 | 508 |
self._save_work_cmd.start() |
571 |
|
|
572 |
|
|
573 | 509 |
except Exception as ex: |
574 | 510 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
575 | 511 |
self.addMessage.emit(MessageType.Error, message) |
... | ... | |
603 | 539 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
604 | 540 |
|
605 | 541 |
|
606 |
|
|
607 |
''' |
|
608 |
@brief rotate selected symbol |
|
609 |
@author humkyung |
|
610 |
@date 2018.08.15 |
|
611 |
''' |
|
612 |
def onRotate(self, action): |
|
613 |
selected = [item for item in self.graphicsView.scene.selectedItems() if issubclass(type(item), SymbolSvgItem)] |
|
614 |
if len(selected) == 1: |
|
615 |
selected[0].rotateSymbol() |
|
616 |
|
|
617 | 542 |
''' |
618 | 543 |
@brief Area Zoom |
619 | 544 |
@author Jeongwoo |
... | ... | |
691 | 616 |
if type(item) is not QGraphicsPixmapItem and item.scene() is not None: |
692 | 617 |
self.graphicsView.scene.removeItem(item) |
693 | 618 |
|
694 |
self.load_HMB()
|
|
619 |
self.initTableWidgetHMB()
|
|
695 | 620 |
|
696 | 621 |
except Exception as ex: |
697 | 622 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
833 | 758 |
|
834 | 759 |
self.path = os.path.join(project.getDrawingFilePath(), drawing + '.png') |
835 | 760 |
appDocData.setImgFilePath(self.path) |
836 |
appDocData.activeDrawing = Drawing(appDocData.imgName) |
|
837 |
|
|
761 |
appDocData.activeDrawing = Drawing(appDocData.imgName)
|
|
762 |
self.initTableWidgetHMB() |
|
838 | 763 |
## Load data on database |
839 | 764 |
|
840 | 765 |
components = appDocData.getComponentListByDrawingUID(appDocData.activeDrawing.UID) |
841 | 766 |
count = len(components) |
842 | 767 |
|
843 |
if count > 0: |
|
768 |
if count > 0:
|
|
844 | 769 |
try: |
845 | 770 |
self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) if not hasattr(self, 'progress') else self.progress |
846 | 771 |
self.progress.setWindowModality(Qt.WindowModal) |
... | ... | |
852 | 777 |
self.progress.show() |
853 | 778 |
|
854 | 779 |
self.load_components(components) |
780 |
|
|
855 | 781 |
self.load_HMB() |
856 | 782 |
finally: |
857 | 783 |
self.progress.setValue(self.progress.maximum()) |
858 | 784 |
self.progress.hide() |
859 | 785 |
|
860 |
self.changeViewCheckedState(True)
|
|
786 |
#self.changeViewCheckedState(False)
|
|
861 | 787 |
|
862 | 788 |
except Exception as ex: |
863 | 789 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
885 | 811 |
@author euisung |
886 | 812 |
@date 2019.03.06 |
887 | 813 |
''' |
888 |
#self.actionImage_Drawing.setChecked(checked) |
|
889 |
self.actionViewText.setChecked(checked) |
|
890 |
self.actionViewSymbol.setChecked(checked) |
|
891 |
self.actionViewLine.setChecked(checked) |
|
892 |
self.actionViewUnknown.setChecked(checked) |
|
893 |
self.actionViewInconsistency.setChecked(checked) |
|
894 |
self.actionViewVendor_Area.setChecked(not checked) |
|
895 |
self.actionDrawing_Only.setChecked(not checked) |
|
896 | 814 |
if clear: |
897 |
self.tableWidgetHMB.clearContents() |
|
898 | 815 |
self.initTableWidgetHMB() |
899 |
#self.tableWidgetHMB.setRowCount(0) |
|
900 |
|
|
901 |
def onViewDrawingOnly(self, isChecked): |
|
902 |
''' |
|
903 |
@brief visible/invisible except image drawing |
|
904 |
@author euisung |
|
905 |
@date 2019.04.22 |
|
906 |
''' |
|
907 |
self.changeViewCheckedState(not isChecked, False) |
|
908 |
for item in self.graphicsView.scene.items(): |
|
909 |
if type(item) is not QGraphicsPixmapItem: |
|
910 |
item.setVisible(not isChecked) |
|
911 |
|
|
912 |
''' |
|
913 |
@brief visible/invisible image drawing |
|
914 |
@author humkyung |
|
915 |
@date 2018.06.25 |
|
916 |
''' |
|
917 |
def onViewImageDrawing(self, isChecked): |
|
918 |
for item in self.graphicsView.scene.items(): |
|
919 |
if type(item) is QGraphicsPixmapItem: |
|
920 |
item.setVisible(isChecked) |
|
921 |
break |
|
922 |
|
|
923 |
''' |
|
924 |
@brief visible/invisible Text |
|
925 |
@author humkyung |
|
926 |
@date 2018.06.28 |
|
927 |
''' |
|
928 |
def onViewText(self, isChecked): |
|
929 |
selected = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
|
930 |
for item in selected: |
|
931 |
item.setVisible(isChecked) |
|
932 |
|
|
933 |
''' |
|
934 |
@brief visible/invisible Symbol |
|
935 |
@author humkyung |
|
936 |
@date 2018.06.28 |
|
937 |
''' |
|
938 |
def onViewSymbol(self, isChecked): |
|
939 |
selected = [item for item in self.graphicsView.scene.items() if (issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringErrorItem)] |
|
940 |
for item in selected: |
|
941 |
item.setVisible(isChecked) |
|
942 |
|
|
943 |
''' |
|
944 |
@brief visible/invisible Line |
|
945 |
@author humkyung |
|
946 |
@date 2018.06.28 |
|
947 |
''' |
|
948 |
def onViewLine(self, isChecked): |
|
949 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem] |
|
950 |
for item in selected: |
|
951 |
item.setVisible(isChecked) |
|
952 |
|
|
953 |
def onViewInconsistency(self, isChecked): |
|
954 |
''' |
|
955 |
@brief visible/invisible Inconsistency |
|
956 |
@author euisung |
|
957 |
@date 2019.04.03 |
|
958 |
''' |
|
959 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringErrorItem] |
|
960 |
for item in selected: |
|
961 |
item.setVisible(isChecked) |
|
962 |
|
|
963 |
''' |
|
964 |
@brief visible/invisible Unknown |
|
965 |
@author humkyung |
|
966 |
@date 2018.06.28 |
|
967 |
''' |
|
968 |
def onViewUnknown(self, isChecked): |
|
969 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringUnknownItem] |
|
970 |
for item in selected: |
|
971 |
item.setVisible(isChecked) |
|
972 |
|
|
973 |
def onViewVendorArea(self, isChecked): |
|
974 |
''' |
|
975 |
@brief visible/invisible Vendor Area |
|
976 |
@author euisung |
|
977 |
@date 2019.04.29 |
|
978 |
''' |
|
979 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringVendorItem] |
|
980 |
for item in selected: |
|
981 |
item.setVisible(isChecked) |
|
982 |
|
|
816 |
#self.clear_data() |
|
817 |
|
|
983 | 818 |
''' |
984 | 819 |
@brief create a line |
985 | 820 |
@author humkyung |
986 | 821 |
@history Jeongwoo 2018.05.10 Change method for Checkable action |
822 |
|
|
987 | 823 |
''' |
988 | 824 |
def onPlaceLine(self): |
989 | 825 |
self.actionLine.setChecked(True) |
... | ... | |
1000 | 836 |
@date 2018.07.23 |
1001 | 837 |
''' |
1002 | 838 |
def onLineCreated(self): |
1003 |
from HMBTable import HMBTable |
|
1004 |
|
|
1005 | 839 |
try: |
1006 | 840 |
count = len(self.actionLine.tag.streamline._vertices) |
1007 |
if count > 1: |
|
1008 |
drawing = AppDocData.instance().activeDrawing |
|
1009 |
|
|
1010 |
streamNos = sorted(list(drawing.hmbTable.streamNos())) |
|
1011 |
|
|
1012 |
hmb = HMBTable.new_data() |
|
1013 |
hmb.drawing_uid = drawing.UID |
|
1014 |
hmb.stream_no = len(streamNos) + 1 |
|
1015 |
hmb.tag_no = hmb.stream_no |
|
1016 |
|
|
1017 |
drawing.hmbTable.append(hmb) |
|
1018 |
|
|
841 |
if count > 1: |
|
842 |
self.insert_HMB() |
|
1019 | 843 |
self.load_HMB() |
1020 | 844 |
|
1021 | 845 |
finally: |
1022 | 846 |
self.actionLine.tag.reset() |
1023 | 847 |
|
848 |
def insert_HMB(self): |
|
849 |
from HMBTable import HMBTable |
|
850 |
import uuid |
|
851 |
|
|
852 |
drawing = AppDocData.instance().activeDrawing |
|
853 |
if drawing: |
|
854 |
hmb = HMBTable.new_data() |
|
855 |
hmb.uid = str(uuid.uuid4()) |
|
856 |
hmb.components_uid = self.actionLine.tag.streamline.uid |
|
857 |
hmb.stream_no = self.getNextStreamNo(drawing) |
|
858 |
|
|
859 |
drawing.hmbTable.append(hmb) |
|
860 |
|
|
861 |
def getNextStreamNo(self, drawing): |
|
862 |
|
|
863 |
if len(list(drawing.hmbTable.streamNos())) == 0: |
|
864 |
return 1 |
|
865 |
else: |
|
866 |
streamNos = sorted(list(drawing.hmbTable.streamNos())) |
|
867 |
lastStreamNo = streamNos[-1] |
|
868 |
return lastStreamNo + 1 |
|
869 |
|
|
1024 | 870 |
def clear_HMB(self): |
1025 | 871 |
self.tableWidgetHMB.clearContents() |
1026 |
self.tableWidgetHMB.setRowCount(0)
|
|
872 |
self.tableWidgetHMB.setColumnCount(0)
|
|
1027 | 873 |
|
1028 | 874 |
def load_HMB(self): |
1029 |
self.clear_HMB() |
|
1030 | 875 |
|
1031 | 876 |
drawing = AppDocData.instance().activeDrawing |
1032 | 877 |
if drawing is None: |
1033 | 878 |
return |
1034 | 879 |
|
1035 | 880 |
hmbs = drawing.hmbTable._hmbs |
1036 |
if hmbs is not None: |
|
1037 |
rowCount = len(hmbs) |
|
1038 |
self.tableWidgetHMB.setRowCount(rowCount) |
|
1039 |
|
|
1040 |
rowIndex = 0 |
|
1041 |
for hmb in hmbs: |
|
1042 |
uid = QTableWidgetItem(str(hmb.uid)) |
|
1043 |
uid.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
881 |
if hmbs is not None: |
|
882 |
self.tableWidgetHMB.setColumnCount(2) |
|
1044 | 883 |
|
1045 |
drawing_uid = QTableWidgetItem(str(hmb.drawing_uid)) |
|
1046 |
drawing_uid.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
884 |
for hmb in hmbs: |
|
885 |
if hmb.isDeleted == True: |
|
886 |
continue |
|
1047 | 887 |
|
888 |
columnCount = self.tableWidgetHMB.columnCount() |
|
889 |
self.tableWidgetHMB.setColumnCount(columnCount + 1) |
|
1048 | 890 |
stream_no = QTableWidgetItem(str(hmb.stream_no)) |
1049 | 891 |
stream_no.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
1050 |
|
|
1051 |
tag_no = QTableWidgetItem(str(hmb.tag_no)) |
|
1052 |
tag_no.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
1053 |
|
|
1054 |
phase_type = QTableWidgetItem(str(hmb.phase_type)) |
|
1055 |
phase_type.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
1056 |
|
|
1057 |
|
|
1058 |
|
|
1059 |
self.tableWidgetHMB.setItem(rowIndex, 0, uid) |
|
1060 |
self.tableWidgetHMB.setItem(rowIndex, 1, drawing_uid) |
|
1061 |
self.tableWidgetHMB.setItem(rowIndex, 2, stream_no) |
|
1062 |
self.tableWidgetHMB.setItem(rowIndex, 3, tag_no) |
|
1063 |
self.tableWidgetHMB.setItem(rowIndex, 4, phase_type) |
|
1064 |
|
|
1065 |
rowIndex += 1 |
|
1066 |
|
|
1067 |
|
|
1068 |
|
|
892 |
self.tableWidgetHMB.setItem(0, columnCount, stream_no) |
|
1069 | 893 |
|
1070 | 894 |
''' |
1071 | 895 |
@brief refresh scene |
... | ... | |
1108 | 932 |
#checked = self.actionGroup.checkedAction() |
1109 | 933 |
#if checked: |
1110 | 934 |
# checked.setChecked(False) |
1111 |
# self.graphicsView.useDefaultCommand() |
|
1112 |
elif event.key() == Qt.Key_1: |
|
1113 |
if self.actionImage_Drawing.isChecked(): |
|
1114 |
self.onViewImageDrawing(False) |
|
1115 |
self.actionImage_Drawing.setChecked(False) |
|
1116 |
else: |
|
1117 |
self.onViewImageDrawing(True) |
|
1118 |
self.actionImage_Drawing.setChecked(True) |
|
1119 |
elif event.key() == Qt.Key_2: |
|
1120 |
if self.actionViewText.isChecked(): |
|
1121 |
self.onViewText(False) |
|
1122 |
self.actionViewText.setChecked(False) |
|
1123 |
else: |
|
1124 |
self.onViewText(True) |
|
1125 |
self.actionViewText.setChecked(True) |
|
1126 |
elif event.key() == Qt.Key_3: |
|
1127 |
if self.actionViewSymbol.isChecked(): |
|
1128 |
self.onViewSymbol(False) |
|
1129 |
self.actionViewSymbol.setChecked(False) |
|
1130 |
else: |
|
1131 |
self.onViewSymbol(True) |
|
1132 |
self.actionViewSymbol.setChecked(True) |
|
1133 |
elif event.key() == Qt.Key_4: |
|
1134 |
if self.actionViewLine.isChecked(): |
|
1135 |
self.onViewLine(False) |
|
1136 |
self.actionViewLine.setChecked(False) |
|
1137 |
else: |
|
1138 |
self.onViewLine(True) |
|
1139 |
self.actionViewLine.setChecked(True) |
|
1140 |
elif event.key() == Qt.Key_5: |
|
1141 |
if self.actionViewUnknown.isChecked(): |
|
1142 |
self.onViewUnknown(False) |
|
1143 |
self.actionViewUnknown.setChecked(False) |
|
1144 |
else: |
|
1145 |
self.onViewUnknown(True) |
|
1146 |
self.actionViewUnknown.setChecked(True) |
|
1147 |
elif event.key() == Qt.Key_6: |
|
1148 |
if self.actionViewInconsistency.isChecked(): |
|
1149 |
self.onViewInconsistency(False) |
|
1150 |
self.actionViewInconsistency.setChecked(False) |
|
1151 |
else: |
|
1152 |
self.onViewInconsistency(True) |
|
1153 |
self.actionViewInconsistency.setChecked(True) |
|
1154 |
elif event.key() == Qt.Key_7: |
|
1155 |
if self.actionViewVendor_Area.isChecked(): |
|
1156 |
self.onViewVendorArea(False) |
|
1157 |
self.actionViewVendor_Area.setChecked(False) |
|
1158 |
else: |
|
1159 |
self.onViewVendorArea(True) |
|
1160 |
self.actionViewVendor_Area.setChecked(True) |
|
1161 |
elif event.key() == 96: # '`' key |
|
1162 |
if self.actionDrawing_Only.isChecked(): |
|
1163 |
self.onViewDrawingOnly(False) |
|
1164 |
self.actionDrawing_Only.setChecked(False) |
|
1165 |
else: |
|
1166 |
self.onViewDrawingOnly(True) |
|
1167 |
self.actionDrawing_Only.setChecked(True) |
|
1168 |
|
|
935 |
# self.graphicsView.useDefaultCommand() |
|
936 |
|
|
1169 | 937 |
QMainWindow.keyPressEvent(self, event) |
1170 | 938 |
except Exception as ex: |
1171 | 939 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
1370 | 1138 |
item.area = textInfo[0] |
1371 | 1139 |
#self.addTextItemToScene(item) |
1372 | 1140 |
#appDocData.texts.append(item) |
1373 |
appDocData.allItems.append(item) |
|
1141 |
appDocData.activeDrawing.allItems.append(item)
|
|
1374 | 1142 |
except Exception as ex: |
1375 | 1143 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
1376 | 1144 |
self.addMessage.emit(MessageType.Error, message) |
... | ... | |
1393 | 1161 |
processLine.area = 'Drawing' |
1394 | 1162 |
#self.graphicsView.scene.addItem(processLine) |
1395 | 1163 |
appDocData.lines.append(processLine) |
1396 |
appDocData.allItems.append(processLine) |
|
1164 |
appDocData.activeDrawing.allItems.append(processLine)
|
|
1397 | 1165 |
|
1398 | 1166 |
if processLine.length() > 100: # TODO: check critical length |
1399 | 1167 |
processLine.addFlowArrow() |
... | ... | |
1460 | 1228 |
svg.transfer.onRemoved.connect(self.itemRemoved) |
1461 | 1229 |
#self.addSvgItemToScene(svg) |
1462 | 1230 |
appDocData.symbols.append(svg) |
1463 |
appDocData.allItems.append(svg) |
|
1231 |
appDocData.activeDrawing.allItems.append(svg)
|
|
1464 | 1232 |
else: |
1465 | 1233 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
1466 | 1234 |
item.isSymbol = True |
... | ... | |
1468 | 1236 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
1469 | 1237 |
#self.graphicsView.scene.addItem(item) |
1470 | 1238 |
#appDocData.symbols.append(item) |
1471 |
appDocData.allItems.append(item) |
|
1239 |
appDocData.activeDrawing.allItems.append(item)
|
|
1472 | 1240 |
# up to here |
1473 | 1241 |
except Exception as ex: |
1474 | 1242 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
1507 | 1275 |
item.transfer.onRemoved.connect(self.itemRemoved) |
1508 | 1276 |
#self.addTextItemToScene(item) |
1509 | 1277 |
#appDocData.texts.append(item) |
1510 |
appDocData.allItems.append(item) |
|
1278 |
appDocData.activeDrawing.allItems.append(item)
|
|
1511 | 1279 |
except Exception as ex: |
1512 | 1280 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
1513 | 1281 |
self.addMessage.emit(MessageType.Error, message) |
... | ... | |
1544 | 1312 |
item.area = textInfoMap[0] |
1545 | 1313 |
item.transfer.onRemoved.connect(self.itemRemoved) |
1546 | 1314 |
#appDocData.texts.append(item) |
1547 |
appDocData.allItems.append(item) |
|
1315 |
appDocData.activeDrawing.allItems.append(item)
|
|
1548 | 1316 |
except Exception as ex: |
1549 | 1317 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
1550 | 1318 |
self.addMessage.emit(MessageType.Error, message) |
... | ... | |
1658 | 1426 |
|
1659 | 1427 |
return itemList |
1660 | 1428 |
|
1661 |
def create_symbol(self): |
|
1662 |
symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, None, AppDocData.instance().getCurrentProject()) |
|
1663 |
(isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog() |
|
1664 |
self.symbolTreeWidget.initSymbolTreeWidget() |
|
1665 |
|
|
1666 |
|
|
1667 | 1429 |
if __name__ == '__main__': |
1668 | 1430 |
import locale |
1669 | 1431 |
from PyQt5.QtCore import QTranslator |
HYTOS/HYTOS/QtImageViewer.py | ||
---|---|---|
363 | 363 |
@author Jeongwoo |
364 | 364 |
@date 2018.??.?? |
365 | 365 |
@history send escape key event to command |
366 |
''' |
|
366 |
|
|
367 | 367 |
def keyPressEvent(self, event): |
368 | 368 |
try: |
369 | 369 |
if event.key() == Qt.Key_Delete: |
... | ... | |
377 | 377 |
if self.command is not None: |
378 | 378 |
self.command.execute(['keyPressEvent', event, []]) |
379 | 379 |
if self.command.isTreated: return |
380 |
if type(self.mainWindow) is QTrainingEditorDialog: |
|
381 |
self.mainWindow.keyPressEvent(event) |
|
382 |
|
|
380 |
|
|
383 | 381 |
QGraphicsView.keyPressEvent(self, event) |
384 | 382 |
except Exception as ex: |
385 | 383 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
384 |
''' |
|
386 | 385 |
|
387 | 386 |
''' |
388 | 387 |
@brief key release event |
... | ... | |
584 | 583 |
if len(items) > 0 and type(items[0]) is QEngineeringConnectorItem: |
585 | 584 |
scenePos = QPointF(items[0].center()[0], items[0].center()[1]) |
586 | 585 |
|
587 |
matches = [item for item in self.scene.items() if (type(item) is QEngineeringLineItem) and (item.distanceTo((scenePos.x(), scenePos.y())) < 20)] |
|
588 |
if False:#len(matches) == 1: |
|
589 |
pass |
|
590 |
#matches[0].insertSymbol(svg, scenePos) |
|
591 |
else: |
|
592 |
transform = QTransform() |
|
593 |
transform.translate(scenePos.x() - svg.symbolOrigin[0], scenePos.y() - svg.symbolOrigin[1]) |
|
594 |
svg.setTransform(transform) |
|
595 |
svg.loc = [round(scenePos.x() - svg.symbolOrigin[0], 1), round(scenePos.y() - svg.symbolOrigin[1], 1)] |
|
596 |
svg.size = [svg.boundingRect().width(), svg.boundingRect().height()] |
|
597 |
svg.origin = [round(scenePos.x(), 1), round(scenePos.y(), 1)] |
|
598 |
self.scene.addItem(svg) |
|
586 |
transform = QTransform() |
|
587 |
transform.translate(scenePos.x() - svg.symbolOrigin[0], scenePos.y() - svg.symbolOrigin[1]) |
|
588 |
svg.setTransform(transform) |
|
589 |
svg.loc = [round(scenePos.x() - svg.symbolOrigin[0], 1), round(scenePos.y() - svg.symbolOrigin[1], 1)] |
|
590 |
svg.size = [svg.boundingRect().width(), svg.boundingRect().height()] |
|
591 |
svg.origin = [round(scenePos.x(), 1), round(scenePos.y(), 1)] |
|
592 |
self.scene.addItem(svg) |
|
599 | 593 |
|
600 | 594 |
svg.transfer.onRemoved.connect(self.mainWindow.itemRemoved) |
601 | 595 |
|
HYTOS/HYTOS/Shapes/EngineeringArrowItem.py | ||
---|---|---|
15 | 15 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
16 | 16 |
|
17 | 17 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
18 |
from EngineeringLineItem import QEngineeringLineItem |
|
19 | 18 |
|
20 | 19 |
""" |
21 | 20 |
A {ArrowItem} is the graphical representation of a {Symbol.Arrow}. |
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py | ||
---|---|---|
85 | 85 |
connector.setZValue(self.zValue() + 1) |
86 | 86 |
self.connectors.append(connector) |
87 | 87 |
if len(connected) > index: |
88 |
connector.connect(connected[index]) |
|
89 |
target = QEngineeringConnectorItem.find_connector(connected[index]) |
|
90 |
if target: |
|
91 |
target.connect(connector) |
|
92 |
targets.append(target) |
|
88 |
connectedItemUid = connected[index] |
|
89 |
if connectedItemUid: |
|
90 |
connector.connect(connectedItemUid) |
|
91 |
target = QEngineeringConnectorItem.find_connector(connectedItemUid) |
|
92 |
if target: |
|
93 |
target.connect(connector) |
|
94 |
targets.append(target) |
|
93 | 95 |
|
94 | 96 |
index = index + 1 |
95 | 97 |
|
... | ... | |
157 | 159 |
self._pt = None |
158 | 160 |
self.isCreated = False |
159 | 161 |
|
162 |
def buildItem(self): |
|
163 |
self.__buildItem() |
|
164 |
|
|
160 | 165 |
''' |
161 | 166 |
@build build path |
162 | 167 |
@author humkyung |
... | ... | |
366 | 371 |
if hmbs is not None: |
367 | 372 |
for hmb in hmbs: |
368 | 373 |
hmb.phase_type = selectedPhaseType |
369 |
|
|
370 |
|
|
374 |
|
|
375 |
def keyPressEvent(self, event): |
|
376 |
from App import App |
|
377 |
if not self.isSelected(): return |
|
378 |
|
|
379 |
if event.key() == Qt.Key_Delete: |
|
380 |
self.deleteHMBDataByUID() |
|
381 |
self.deleteStreamlineItemFromScene() |
|
382 |
App.mainWnd().load_HMB() |
|
383 |
|
|
384 |
def deleteHMBDataByUID(self): |
|
385 |
from AppDocData import AppDocData |
|
386 |
|
|
387 |
deleteUid = str(self.uid) |
|
388 |
|
|
389 |
appDocData = AppDocData.instance() |
|
390 |
activeDrawing = appDocData.activeDrawing |
|
391 |
if activeDrawing: |
|
392 |
hmbs = activeDrawing.hmbTable._hmbs |
|
393 |
if hmbs is not None: |
|
394 |
for hmb in hmbs: |
|
395 |
if str(hmb.components_uid) == str(deleteUid): |
|
396 |
hmb.isDeleted = True |
|
397 |
break |
|
398 |
|
|
399 |
def deleteStreamlineItemFromScene(self): |
|
400 |
""" remove self from scene """ |
|
401 |
try: |
|
402 |
for conn in self.connectors: |
|
403 |
if conn.connectedItem is not None: |
|
404 |
conn.connectedItem.connect(None) |
|
405 |
except Exception as ex: |
|
406 |
from App import App |
|
407 |
from AppDocData import MessageType |
|
408 |
|
|
409 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
410 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
411 |
|
|
412 |
self.transfer.onRemoved.emit(self) |
|
413 |
|
|
414 |
|
|
371 | 415 |
|
372 | 416 |
def toSql(self): |
373 | 417 |
""" convert valve data to sql query """ |
... | ... | |
427 | 471 |
pointsUids = [] |
428 | 472 |
for componentInfo in componentInfos: |
429 | 473 |
pointsUid = componentInfo[11] # uid@Points |
474 |
index = componentInfo[12] # Index@Points |
|
430 | 475 |
x = componentInfo[13] # X@Points |
431 | 476 |
y = componentInfo[14] # Y@Points |
432 | 477 |
ConnectedItem_UID = componentInfo[15] # ConnectedItem_UID@Points |
433 | 478 |
|
434 | 479 |
pointsUids.append(pointsUid) |
435 | 480 |
item._vertices.append((x, y)) |
436 |
if ConnectedItem_UID: |
|
437 |
connectorItems.append(ConnectedItem_UID) |
|
438 |
|
|
439 | 481 |
|
482 |
if index == 1 or index == 4: |
|
483 |
connectorItems.append(ConnectedItem_UID) |
|
440 | 484 |
|
441 | 485 |
item.setVisible(False) |
442 | 486 |
item.__buildItem() |
HYTOS/HYTOS/XmlGenerator.py | ||
---|---|---|
395 | 395 |
from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem |
396 | 396 |
from EngineeringReservedWordTextItem import QEngineeringReservedWordTextItem |
397 | 397 |
from SymbolSvgItem import SymbolSvgItem |
398 |
from EngineeringVendorItem import QEngineeringVendorItem |
|
399 | 398 |
from EngineeringErrorItem import QEngineeringErrorItem |
400 | 399 |
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
401 | 400 |
from EngineeringEndBreakItem import QEngineeringEndBreakItem |
402 | 401 |
|
403 | 402 |
appDocData = AppDocData.instance() |
404 | 403 |
items = [] |
405 |
items = appDocData.allItems |
|
404 |
items = appDocData.activeDrawing.allItems
|
|
406 | 405 |
path = os.path.join(AppDocData.instance().getCurrentProject().getTempPath(), pidName + '.xml') |
407 | 406 |
|
408 | 407 |
xml = Element(ROOT_NODE_NAME) # Root Node |
... | ... | |
419 | 418 |
node_dictionary = {SymbolSvgItem:symbolListNode, QEngineeringTextItem:textInfoListNode, QEngineeringNoteItem:noteTextInfoListNode, |
420 | 419 |
QEngineeringLineItem:lineListNode, QEngineeringLineNoTextItem:lineNoListNode, QEngineeringUnknownItem:unknownListNode, |
421 | 420 |
QEngineeringSizeTextItem:textInfoListNode, QEngineeringValveOperCodeTextItem:textInfoListNode, QEngineeringTagNoTextItem:textInfoListNode, |
422 |
QEngineeringReservedWordTextItem:textInfoListNode, QEngineeringVendorItem:vendorListNode}
|
|
421 |
QEngineeringReservedWordTextItem:textInfoListNode} |
|
423 | 422 |
|
424 | 423 |
# trim line 추가 |
425 | 424 |
trimLineNoListNode = Element(TRIM_LINE_NOS_NODE_NAME) |
내보내기 Unified diff