개정판 cce7850b
issue #1054: 계산 결과창에서 flowrate(Mass) 혹은 flowrate(Volume)을 입력 시 입력 항목 저장하도록 함
Change-Id: Iaa1c717b708073ab77514a3d95aa6f379a5bb74f
HYTOS/HYTOS/HMBTable.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
class HMBData: |
25 | 25 |
def __init__(self, uid=None): |
26 |
"""constructor""" |
|
26 | 27 |
self._uid = None |
27 | 28 |
self._components_uid = None |
28 | 29 |
self._stream_no = None |
... | ... | |
67 | 68 |
self._liquid_density = None |
68 | 69 |
self._liquid_viscosity = None |
69 | 70 |
self.isDeleted = False |
70 |
self._input_flowrate_type = None |
|
71 |
self._input_flowrate_type = None # save flowrate type by user input
|
|
71 | 72 |
''' |
72 | 73 |
@author humkyung |
73 | 74 |
@date 2018.07.12 |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
37 | 37 |
def is_blank(s): |
38 | 38 |
return not (s and s.strip()) |
39 | 39 |
|
40 |
|
|
40 | 41 |
def is_not_blank(s): |
41 | 42 |
return bool(s and s.strip()) |
42 | 43 |
|
... | ... | |
83 | 84 |
|
84 | 85 |
class ItemDelegate(QStyledItemDelegate): |
85 | 86 |
def createEditor(self, parent, option, index): |
87 |
""" |
|
88 |
create a editor for user input |
|
89 |
@param parent: |
|
90 |
@param option: |
|
91 |
@param index: |
|
92 |
@return: |
|
93 |
""" |
|
86 | 94 |
editor = None |
87 | 95 |
if index.column() >= 2: |
88 | 96 |
if index.row() == 3: |
... | ... | |
90 | 98 |
editor.addItems(['Liquid', 'Vapor', 'Mixed']) |
91 | 99 |
elif index.row() <= 23: |
92 | 100 |
editor = QLineEdit(parent) |
101 |
if index.row() in [4, 5]: |
|
102 |
validator = QDoubleValidator(parent) |
|
103 |
editor.setValidator(validator) |
|
104 |
|
|
93 | 105 |
value = editor.text() |
94 | 106 |
if type(value) is float: |
95 | 107 |
validator = QDoubleValidator(parent) |
... | ... | |
98 | 110 |
return editor |
99 | 111 |
|
100 | 112 |
def destroyEditor(self, editor, index): |
101 |
"""change background if value is changed""" |
|
113 |
""" |
|
114 |
change background if value is changed |
|
115 |
@param editor: |
|
116 |
@param index: |
|
117 |
@return: |
|
118 |
""" |
|
102 | 119 |
editor.blockSignals(True) |
103 | 120 |
if type(editor) is QComboBox: |
104 | 121 |
changed = editor.currentText() |
... | ... | |
107 | 124 |
item = editor.parentWidget().parentWidget().item(index.row(), index.column()) |
108 | 125 |
value = item.data(Qt.UserRole) |
109 | 126 |
|
127 |
value_changed = False |
|
110 | 128 |
if type(value) is float and changed: |
111 |
item.setBackground(Qt.magenta if float(changed) != value else Qt.white) |
|
129 |
value_changed = float(changed) != value |
|
130 |
item.setBackground(Qt.magenta if value_changed else Qt.white) |
|
112 | 131 |
else: |
113 |
item.setBackground(Qt.magenta if changed != value else Qt.white) |
|
132 |
value_changed = changed != value |
|
133 |
item.setBackground(Qt.magenta if value_changed else Qt.white) |
|
134 |
|
|
135 |
"""clear value of other side""" |
|
136 |
if value_changed: |
|
137 |
if index.row() == 4: |
|
138 |
item = editor.parentWidget().parentWidget().item(5, index.column()) |
|
139 |
item.setText('') |
|
140 |
item.setBackground(Qt.magenta) |
|
141 |
elif index.row() == 5: |
|
142 |
item = editor.parentWidget().parentWidget().item(4, index.column()) |
|
143 |
item.setText('') |
|
144 |
item.setBackground(Qt.magenta) |
|
145 |
|
|
146 |
""" |
|
147 |
if index.row() == 3: |
|
148 |
item = editor.parentWidget().parentWidget().item(5, index.column()) |
|
149 |
if changed in ['Liquid', 'Mixed']: |
|
150 |
item.setFlags(item.flags() | Qt.ItemIsEditable) |
|
151 |
else: |
|
152 |
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) |
|
153 |
""" |
|
114 | 154 |
|
115 | 155 |
editor.blockSignals(False) |
116 | 156 |
|
... | ... | |
128 | 168 |
self.setupUi(self) |
129 | 169 |
|
130 | 170 |
self._label_mouse = QLabel(self.statusbar) |
131 |
self._label_mouse.setText(self.tr('mouse pos : ({},{})'.format(0, 0)))
|
|
171 |
self._label_mouse.setText(self.tr(f'mouse pos : ({0},{0})'))
|
|
132 | 172 |
self.statusbar.addWidget(self._label_mouse) |
133 | 173 |
self.addMessage.connect(self.onAddMessage) |
134 | 174 |
|
... | ... | |
268 | 308 |
self.addMessage.emit(MessageType.Error, message) |
269 | 309 |
|
270 | 310 |
def on_sync_stream_data(self): |
271 |
"""sync stream data""" |
|
311 |
""" |
|
312 |
sync stream data |
|
313 |
@return: |
|
314 |
""" |
|
272 | 315 |
|
273 | 316 |
drawing = AppDocData.instance().activeDrawing |
274 | 317 |
if drawing is None: |
... | ... | |
296 | 339 |
item.setBackground(Qt.white) |
297 | 340 |
if row == 3: |
298 | 341 |
hmb.phase_type = value |
299 |
elif row == 4: |
|
342 |
elif row == 4: # Flowrate(Mass)
|
|
300 | 343 |
hmb.flowrate_mass = value |
301 |
elif row == 5: |
|
344 |
if value: |
|
345 |
hmb.input_flowrate_type = 'Mass' |
|
346 |
elif row == 5: # Flowrate(Volume) |
|
302 | 347 |
hmb.flowrate_volume = value |
348 |
if value: |
|
349 |
hmb.input_flowrate_type = 'Volume' |
|
303 | 350 |
elif row == 6: |
304 | 351 |
hmb.density = value |
305 | 352 |
elif row == 7: |
... | ... | |
2679 | 2726 |
self.tableWidgetHMB.setColumnCount(0) |
2680 | 2727 |
|
2681 | 2728 |
def load_HMB(self): |
2682 |
"""display hmb data to table widget""" |
|
2729 |
""" |
|
2730 |
display hmb data to table widget |
|
2731 |
@return: |
|
2732 |
""" |
|
2683 | 2733 |
from CalculationValidation import QCalculationValidation |
2684 | 2734 |
|
2685 | 2735 |
drawing = AppDocData.instance().activeDrawing |
... | ... | |
2709 | 2759 |
|
2710 | 2760 |
item = set_item_properties(convert_to_fixed_point(hmb.flowrate_mass), Qt.AlignHCenter | Qt.AlignVCenter) |
2711 | 2761 |
item.setData(Qt.UserRole, hmb.flowrate_mass) |
2712 |
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) |
|
2713 | 2762 |
self.tableWidgetHMB.setItem(4, columnCount, item) |
2714 | 2763 |
|
2715 | 2764 |
item = set_item_properties(convert_to_fixed_point(hmb.flowrate_volume), Qt.AlignHCenter | Qt.AlignVCenter) |
2716 | 2765 |
item.setData(Qt.UserRole, hmb.flowrate_volume) |
2717 |
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) |
|
2766 |
""" |
|
2767 |
if hmb.phase_type == 'Vapor': |
|
2768 |
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) |
|
2769 |
""" |
|
2718 | 2770 |
self.tableWidgetHMB.setItem(5, columnCount, item) |
2719 | 2771 |
|
2720 | 2772 |
item = set_item_properties(convert_to_fixed_point(hmb.density), Qt.AlignHCenter | Qt.AlignVCenter) |
내보내기 Unified diff