개정판 e534f39d
issue #1053 : 생성한 장치의 데이터 입력 => 폼의 Unit 를 Drawing의 Attrs 에서 읽어 오도록 변경
Change-Id: Ie8edffc92576006b3da35c7a9ff7531f6831504a
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
310 | 310 |
self.tableWidgetHMB.setRowCount(count) |
311 | 311 |
self.tableWidgetHMB.setColumnCount(2) |
312 | 312 |
self.tableWidgetHMB.hideRow(0) |
313 |
self.tableWidgetHMB.hideRow(1) |
|
314 |
|
|
315 |
rowIndex = 0 |
|
316 |
for columnInfo in columnInfos: |
|
317 |
displayName = columnInfo[0] |
|
318 |
unitsExpres = columnInfo[1] |
|
319 |
|
|
320 |
name = QTableWidgetItem(displayName) |
|
321 |
name.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter) |
|
322 |
name.setBackground(QColor(230, 230, 230)) |
|
323 |
self.tableWidgetHMB.setItem(rowIndex, 0, name) |
|
324 |
|
|
325 |
if docData.activeDrawing: |
|
326 |
if unitsExpres: |
|
327 |
units = self.convertToUnits(unitsExpres) |
|
328 |
else: |
|
329 |
units = None |
|
330 |
else: |
|
331 |
units = None |
|
332 |
|
|
333 |
unit = QTableWidgetItem(units) |
|
334 |
unit.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
335 |
unit.setBackground(QColor(230, 230, 230)) |
|
336 |
self.tableWidgetHMB.setItem(rowIndex, 1, unit) |
|
337 |
|
|
338 |
rowIndex += 1 |
|
339 |
|
|
313 |
self.tableWidgetHMB.hideRow(1) |
|
340 | 314 |
self.tableWidgetHMB.setEditTriggers(QAbstractItemView.NoEditTriggers) |
341 |
self.tableWidgetHMB.resizeColumnsToContents() |
|
342 |
self.tableWidgetHMB.resizeRowsToContents() |
|
343 |
|
|
344 | 315 |
self.tableWidgetHMB.horizontalHeader().setVisible(False) |
345 | 316 |
self.tableWidgetHMB.verticalHeader().setVisible(False) |
346 | 317 |
|
347 |
|
|
348 |
return |
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
docData = AppDocData.instance() |
|
353 |
if docData.activeDrawing is None: |
|
354 |
|
|
355 |
drawingUid = '00000000-0000-0000-0000-000000000000' |
|
356 |
else: |
|
357 |
drawingUid = docData.activeDrawing.UID |
|
358 |
|
|
359 |
columnDisplayNameList = docData.getColumnDisplayNames(drawingUid, 'HMB') |
|
360 |
count = len(columnDisplayNameList) |
|
361 |
self.tableWidgetHMB.setRowCount(count) |
|
362 |
self.tableWidgetHMB.setColumnCount(2) |
|
363 |
self.tableWidgetHMB.hideRow(0) |
|
364 |
self.tableWidgetHMB.hideRow(1) |
|
365 |
|
|
366 | 318 |
rowIndex = 0 |
367 |
for columnDisplayName in columnDisplayNameList: |
|
368 |
name = QTableWidgetItem(columnDisplayName[0]) |
|
369 |
name.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter) |
|
370 |
name.setBackground(QColor(230, 230, 230)) |
|
371 |
self.tableWidgetHMB.setItem(rowIndex, 0, name) |
|
372 |
|
|
373 |
unit = QTableWidgetItem(columnDisplayName[1]) |
|
374 |
unit.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
375 |
unit.setBackground(QColor(230, 230, 230)) |
|
376 |
self.tableWidgetHMB.setItem(rowIndex, 1, unit) |
|
319 |
for columnInfo in columnInfos: |
|
320 |
name = columnInfo[0] |
|
321 |
unit = self.convertToUnits(columnInfo[1]) |
|
322 |
|
|
323 |
self.tableWidgetHMB.setItem(rowIndex, 0, self.setTableWidgetItemProperties(name, Qt.AlignLeft | Qt.AlignVCenter, QColor(230, 230, 230))) |
|
324 |
self.tableWidgetHMB.setItem(rowIndex, 1, self.setTableWidgetItemProperties(unit, Qt.AlignHCenter | Qt.AlignVCenter, QColor(230, 230, 230))) |
|
377 | 325 |
|
378 | 326 |
rowIndex += 1 |
379 | 327 |
|
380 |
self.tableWidgetHMB.setEditTriggers(QAbstractItemView.NoEditTriggers) |
|
381 | 328 |
self.tableWidgetHMB.resizeColumnsToContents() |
382 | 329 |
self.tableWidgetHMB.resizeRowsToContents() |
383 |
|
|
384 |
self.tableWidgetHMB.horizontalHeader().setVisible(False) |
|
385 |
self.tableWidgetHMB.verticalHeader().setVisible(False) |
|
386 | 330 |
|
387 |
|
|
388 |
|
|
389 | 331 |
''' |
390 |
@brief Convert UnitsExpression To Units Value
|
|
332 |
@brief Drawing 속성의 Units 에서 Key값을 이용하여 Value를 찾음
|
|
391 | 333 |
@author yeonjin |
392 |
@date 19.08.29
|
|
334 |
@date 19.08.30
|
|
393 | 335 |
''' |
394 |
def convertToUnits(self, unitsExpression):
|
|
395 |
value = unitsExpression
|
|
336 |
def findValue(self, key):
|
|
337 |
value = None
|
|
396 | 338 |
|
339 |
key = key.replace("{","").replace("}","") |
|
397 | 340 |
for attr in AppDocData.instance().activeDrawing.attrs: |
398 | 341 |
if attr[0] == 'Units': |
399 |
key = unitsExpression.replace("{","").replace("}","") |
|
400 | 342 |
if key in attr[1]: |
401 | 343 |
value = attr[1][key] |
402 | 344 |
break |
403 | 345 |
|
404 | 346 |
return value |
405 | 347 |
|
348 |
''' |
|
349 |
@brief Convert UnitsExpression To Units Value |
|
350 |
@author yeonjin |
|
351 |
@date 19.08.29 |
|
352 |
''' |
|
353 |
def convertToUnits(self, unitsExpression): |
|
354 |
import re |
|
355 |
|
|
356 |
if unitsExpression is None or AppDocData.instance().activeDrawing is None: |
|
357 |
return '' |
|
358 |
|
|
359 |
found = re.findall('{.*?}', unitsExpression) |
|
360 |
for f in found: |
|
361 |
key = f |
|
362 |
val = self.findValue(key) |
|
363 |
if val: |
|
364 |
unitsExpression = unitsExpression.replace(key, val) |
|
365 |
|
|
366 |
return unitsExpression |
|
406 | 367 |
|
407 | 368 |
''' |
408 | 369 |
@brief Clear TreeWidget and Set Current PID |
... | ... | |
907 | 868 |
self.tableWidgetHMB.setColumnCount(0) |
908 | 869 |
|
909 | 870 |
def load_HMB(self): |
910 |
|
|
911 | 871 |
drawing = AppDocData.instance().activeDrawing |
912 | 872 |
if drawing is None: |
913 | 873 |
return |
... | ... | |
920 | 880 |
columnCount = self.tableWidgetHMB.columnCount() |
921 | 881 |
self.tableWidgetHMB.setColumnCount(columnCount + 1) |
922 | 882 |
|
923 |
uid = QTableWidgetItem(str(hmb.uid)) |
|
924 |
uid.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
925 |
|
|
926 |
components_uid = QTableWidgetItem(str(hmb.components_uid)) |
|
927 |
components_uid.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
928 |
|
|
929 |
stream_no = QTableWidgetItem(str(hmb.stream_no)) |
|
930 |
stream_no.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
931 |
|
|
932 |
phase_type = QTableWidgetItem(str(hmb.phase_type)) |
|
933 |
phase_type.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
934 |
|
|
935 |
if hmb.isDeleted == True: |
|
936 |
stream_no.setForeground(Qt.darkGray) |
|
937 |
else: |
|
938 |
stream_no.setForeground(Qt.black) |
|
939 |
|
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
self.tableWidgetHMB.setItem(0, columnCount, uid) |
|
944 |
self.tableWidgetHMB.setItem(1, columnCount, components_uid) |
|
945 |
self.tableWidgetHMB.setItem(2, columnCount, stream_no) |
|
946 |
self.tableWidgetHMB.setItem(3, columnCount, phase_type) |
|
883 |
self.tableWidgetHMB.setItem(0, columnCount, self.setTableWidgetItemProperties(hmb.uid, Qt.AlignHCenter | Qt.AlignVCenter)) |
|
884 |
self.tableWidgetHMB.setItem(1, columnCount, self.setTableWidgetItemProperties(hmb.components_uid, Qt.AlignHCenter | Qt.AlignVCenter)) |
|
885 |
self.tableWidgetHMB.setItem(2, columnCount, self.setTableWidgetItemProperties(hmb.stream_no, Qt.AlignHCenter | Qt.AlignVCenter)) |
|
886 |
self.tableWidgetHMB.setItem(3, columnCount, self.setTableWidgetItemProperties(hmb.phase_type, Qt.AlignHCenter | Qt.AlignVCenter)) |
|
947 | 887 |
|
948 | 888 |
|
949 | 889 |
''' |
... | ... | |
1158 | 1098 |
|
1159 | 1099 |
return itemList |
1160 | 1100 |
|
1101 |
def setTableWidgetItemProperties(self, name, alignment, color = None): |
|
1102 |
|
|
1103 |
item = QTableWidgetItem(str(name)) |
|
1104 |
item.setTextAlignment(alignment) |
|
1105 |
if color: |
|
1106 |
item.setBackground(color) |
|
1107 |
|
|
1108 |
return item |
|
1109 |
|
|
1110 |
|
|
1161 | 1111 |
if __name__ == '__main__': |
1162 | 1112 |
import locale |
1163 | 1113 |
from PyQt5.QtCore import QTranslator |
내보내기 Unified diff