hytos / HYTOS / HYTOS / Phase_LiquidDialog.py @ 2a175efe
이력 | 보기 | 이력해설 | 다운로드 (12.5 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
|
3 |
# Form implementation generated from reading ui file 'ProjectDialog.ui'
|
4 |
#
|
5 |
# Created by: PyQt5 UI code generator 5.6
|
6 |
#
|
7 |
# WARNING! All changes made in this file will be lost!
|
8 |
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 |
from PyQt5.QtWidgets import * |
11 |
import os |
12 |
import sys |
13 |
from Project import Project |
14 |
from AppDocData import AppDocData |
15 |
import Phase_Liquid_UI |
16 |
import math |
17 |
|
18 |
class QPhase_LiquidDialog(QDialog): |
19 |
def __init__(self): |
20 |
QDialog.__init__(self)
|
21 |
|
22 |
self.ui = Phase_Liquid_UI.Ui_LiquidDialog()
|
23 |
self.ui.setupUi(self) |
24 |
self.result = False |
25 |
|
26 |
#self.ui.pushButton_Roughness.setVisible(False)
|
27 |
|
28 |
self.ui.radioButton_Flowrate_Mass.clicked.connect(self.clickedEvent) |
29 |
self.ui.radioButton_Flowrate_Volume.clicked.connect(self.clickedEvent) |
30 |
self.ui.radioButton_Equivalent_Length_Input.clicked.connect(self.clickedEvent) |
31 |
self.ui.radioButton_Equivalent_Length_Cal.clicked.connect(self.clickedEvent) |
32 |
self.ui.comboBox_Roughness.currentIndexChanged.connect(self.onRoughnessChanged) |
33 |
self.ui.pushButton_Roughness.clicked.connect(self.roughnessClickedEvent) |
34 |
self.ui.pushButton_Fitting.clicked.connect(self.show_FittingMethodDialog) |
35 |
self.ui.comboBox_Nominal_Pipe_Size.currentIndexChanged.connect(self.getInsideDiameter) |
36 |
self.ui.comboBox_Schedule_No.currentIndexChanged.connect(self.getInsideDiameter) |
37 |
|
38 |
self.initUnits()
|
39 |
self.initNominalDiameter()
|
40 |
self.initSchedule()
|
41 |
self.initRoughness()
|
42 |
|
43 |
|
44 |
def onRoughnessChanged(self, index): |
45 |
value = self.ui.comboBox_Roughness.itemData(index)
|
46 |
self.ui.lineEdit_Roughness.setText('{}'.format(value)) |
47 |
|
48 |
def roughnessClickedEvent(self): |
49 |
from RoughnessDialog import QRoughnessDialog |
50 |
|
51 |
dialog = QRoughnessDialog() |
52 |
selectedRoughness = dialog.showDialog() |
53 |
|
54 |
def show_FittingMethodDialog(self): |
55 |
#from FittingMethodDialog import QFittingMethodDialog
|
56 |
|
57 |
#dialog = QFittingMethodDialog()
|
58 |
#selectedFittingMethod = dialog.showDialog(self)
|
59 |
#if selectedFittingMethod:
|
60 |
# if selectedFittingMethod == 'EquivalentLength':
|
61 |
# self.show_EquivalentLengthDialog()
|
62 |
# elif selectedFittingMethod == 'CraneK':
|
63 |
# self.show_CraneKDialog()
|
64 |
# elif selectedFittingMethod == '2K':
|
65 |
# self.show_2KDialog()
|
66 |
|
67 |
from FittingsDialog import QFittingsDialog |
68 |
dialog = QFittingsDialog() |
69 |
dialog.showDialog(self)
|
70 |
|
71 |
def clickedEvent(self): |
72 |
if self.sender() == self.ui.radioButton_Flowrate_Mass: |
73 |
self.ui.lineEdit_Flowrate_Mass.setEnabled(True) |
74 |
self.ui.lineEdit_Flowrate_Volume.setEnabled(False) |
75 |
elif self.sender() == self.ui.radioButton_Flowrate_Volume: |
76 |
self.ui.lineEdit_Flowrate_Mass.setEnabled(False) |
77 |
self.ui.lineEdit_Flowrate_Volume.setEnabled(True) |
78 |
elif self.sender() == self.ui.radioButton_Equivalent_Length_Input: |
79 |
self.ui.lineEdit_Equivalent_Length_Input.setEnabled(True) |
80 |
self.ui.pushButton_Fitting.setEnabled(False) |
81 |
elif self.sender() == self.ui.radioButton_Equivalent_Length_Cal: |
82 |
self.ui.lineEdit_Equivalent_Length_Input.setEnabled(False) |
83 |
self.ui.pushButton_Fitting.setEnabled(True) |
84 |
|
85 |
def show_EquivalentLengthDialog(self): |
86 |
from Fitting_EquivalentLengthDialog import QFitting_EquivalentLengthDialog |
87 |
|
88 |
dialog = QFitting_EquivalentLengthDialog() |
89 |
dialog.showDialog(self)
|
90 |
|
91 |
def show_CraneKDialog(self): |
92 |
from Fitting_CraneKDialog import QFitting_CraneKDialog |
93 |
|
94 |
dialog = QFitting_CraneKDialog() |
95 |
dialog.showDialog(self)
|
96 |
|
97 |
def show_2KDialog(self): |
98 |
from Fitting_2KDialog import QFitting_2KDialog |
99 |
|
100 |
dialog = QFitting_2KDialog() |
101 |
dialog.showDialog(self)
|
102 |
|
103 |
def show_VaporDialog(self): |
104 |
from Phase_VaporDialog import QPhase_VaporDialog |
105 |
|
106 |
dialog = QPhase_VaporDialog() |
107 |
dialog.showDialog(self)
|
108 |
|
109 |
def show_MixedDialog(self): |
110 |
from Phase_MixedDialog import QPhase_MixedDialog |
111 |
|
112 |
dialog = QPhase_MixedDialog() |
113 |
dialog.showDialog(self)
|
114 |
|
115 |
def initUnits(self): |
116 |
activeDrawing = AppDocData.instance().activeDrawing |
117 |
|
118 |
for attr in activeDrawing.attrs: |
119 |
if attr[0] == 'Units': |
120 |
self.ui.label_Flowrate_Mass_Unit.setText(attr[1]['Flowrate_Mass']) |
121 |
self.ui.label_Flowrate_Volume_Unit.setText(attr[1]['Flowrate_Volume']) |
122 |
self.ui.label_Density_Unit.setText(attr[1]['Density']) |
123 |
self.ui.label_Viscosity_Unit.setText(attr[1]['Viscosity']) |
124 |
self.ui.label_Velocity_Unit.setText(attr[1]['Velocity']) |
125 |
self.ui.label_DropPressure_Unit.setText('{}/100{}'.format(attr[1]['Pressure'], attr[1]['Length'])) |
126 |
self.ui.label_Nominal_Pipe_Size_Unit.setText(attr[1]['Pipe_Diameter']) |
127 |
self.ui.label_Inside_Pipe_Size_Unit.setText(attr[1]['Pipe_Diameter']) |
128 |
self.ui.label_Roughness_Unit.setText(attr[1]['Roughness']) |
129 |
self.ui.label_Straight_Lengh_Unit.setText(attr[1]['Length']) |
130 |
self.ui.label_Equivalent_Lenght_Input_Unit.setText(attr[1]['Length']) |
131 |
self.ui.label_Fitting_Length_Unit.setText(attr[1]['Length']) |
132 |
self.ui.label_Equivalent_Lenght_Cal_Unit.setText(attr[1]['Length']) |
133 |
|
134 |
|
135 |
def getInsideDiameter(self): |
136 |
from AppDocData import AppDocData |
137 |
|
138 |
self.ui.lineEdit_Inside_Pipe_Size.clear()
|
139 |
|
140 |
nominaldiameter_uid = self.ui.comboBox_Nominal_Pipe_Size.currentData()
|
141 |
schedule_uid = self.ui.comboBox_Schedule_No.currentData()
|
142 |
|
143 |
if nominaldiameter_uid and schedule_uid: |
144 |
insideDiameter = AppDocData.instance().getInsideDiameter(nominaldiameter_uid, schedule_uid) |
145 |
if len(insideDiameter) > 0: |
146 |
if self.ui.label_Inside_Pipe_Size_Unit.text() == 'mm': |
147 |
self.ui.lineEdit_Inside_Pipe_Size.setText(str(insideDiameter[0][1])) |
148 |
else:
|
149 |
self.ui.lineEdit_Inside_Pipe_Size.setText(str(insideDiameter[0][2])) |
150 |
|
151 |
def initNominalDiameter(self): |
152 |
from AppDocData import AppDocData |
153 |
|
154 |
self.ui.comboBox_Nominal_Pipe_Size.clear()
|
155 |
|
156 |
nominalDiameterList = AppDocData.instance().getNominalDiameter() |
157 |
for nominalDiameter in nominalDiameterList: |
158 |
if self.ui.label_Nominal_Pipe_Size_Unit.text() == 'mm': |
159 |
self.ui.comboBox_Nominal_Pipe_Size.addItem(str(nominalDiameter[1]), nominalDiameter[0]) |
160 |
else:
|
161 |
self.ui.comboBox_Nominal_Pipe_Size.addItem(str(nominalDiameter[2]), nominalDiameter[0]) |
162 |
self.ui.comboBox_Nominal_Pipe_Size.setCurrentIndex(-1) |
163 |
|
164 |
def initSchedule(self): |
165 |
from AppDocData import AppDocData |
166 |
|
167 |
self.ui.comboBox_Schedule_No.clear()
|
168 |
|
169 |
scheduleList = AppDocData.instance().getSchedule() |
170 |
for schedule in scheduleList: |
171 |
self.ui.comboBox_Schedule_No.addItem(schedule[1], schedule[0]) |
172 |
|
173 |
self.ui.comboBox_Schedule_No.setCurrentIndex(-1) |
174 |
|
175 |
|
176 |
def initRoughness(self): |
177 |
from AppDocData import AppDocData |
178 |
|
179 |
self.ui.comboBox_Roughness.clear()
|
180 |
|
181 |
roughnessList = AppDocData.instance().getRoughness() |
182 |
for roughness in roughnessList: |
183 |
if self.ui.label_Roughness_Unit.text() == 'm': |
184 |
self.ui.comboBox_Roughness.addItem(roughness[1], roughness[2]) |
185 |
elif self.ui.label_Roughness_Unit.text() == 'in': |
186 |
self.ui.comboBox_Roughness.addItem(roughness[1], roughness[3]) |
187 |
elif self.ui.label_Roughness_Unit.text() == 'ft': |
188 |
self.ui.comboBox_Roughness.addItem(roughness[1], roughness[4]) |
189 |
elif self.ui.label_Roughness_Unit.text() == 'mm': |
190 |
self.ui.comboBox_Roughness.addItem(roughness[1], roughness[5]) |
191 |
|
192 |
if self.ui.comboBox_Roughness.count() > 0: |
193 |
self.ui.comboBox_Roughness.setCurrentIndex(0) |
194 |
|
195 |
|
196 |
def showDialog(self, item): |
197 |
self.components_uid = item.uid
|
198 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
199 |
|
200 |
self.load_data()
|
201 |
self.exec_()
|
202 |
|
203 |
return self.result |
204 |
|
205 |
def load_data(self): |
206 |
from AppDocData import AppDocData |
207 |
|
208 |
drawing = AppDocData.instance().activeDrawing |
209 |
if drawing:
|
210 |
for hmb in drawing.hmbTable._hmbs: |
211 |
if hmb.components_uid == self.components_uid: |
212 |
if hmb.flowrate_mass:
|
213 |
self.ui.radioButton_Flowrate_Mass.setChecked(True) |
214 |
self.ui.lineEdit_Flowrate_Mass.setEnabled(True) |
215 |
self.ui.lineEdit_Flowrate_Volume.setEnabled(False) |
216 |
self.ui.lineEdit_Flowrate_Mass.setText(str(hmb.flowrate_mass)) |
217 |
if hmb.flowrate_volume:
|
218 |
self.ui.radioButton_Flowrate_Volume.setChecked(True) |
219 |
self.ui.lineEdit_Flowrate_Mass.setEnabled(False) |
220 |
self.ui.lineEdit_Flowrate_Volume.setEnabled(True) |
221 |
self.ui.lineEdit_Flowrate_Volume.setText(str(hmb.flowrate_volume)) |
222 |
if hmb.density:
|
223 |
self.ui.lineEdit_Density.setText(str(hmb.density)) |
224 |
if hmb.viscosity:
|
225 |
self.ui.lineEdit_Viscosity.setText(str(hmb.viscosity)) |
226 |
if hmb.limitation_velocity:
|
227 |
self.ui.lineEdit_Limitation_Velocity.setText(str(hmb.limitation_velocity)) |
228 |
if hmb.limitation_pressure_drop:
|
229 |
self.ui.lineEdit_Limitation_Pressure_Drop.setText(str(hmb.limitation_pressure_drop)) |
230 |
if hmb.nominal_pipe_size:
|
231 |
self.ui.comboBox_Nominal_Pipe_Size.setCurrentText(str(hmb.nominal_pipe_size)) |
232 |
if hmb.schedule_no:
|
233 |
self.ui.comboBox_Schedule_No.setCurrentText(str(hmb.schedule_no)) |
234 |
if hmb.roughness:
|
235 |
index = self.getIndexByValue(hmb.roughness)
|
236 |
if index:
|
237 |
self.ui.comboBox_Roughness.setCurrentIndex(index)
|
238 |
|
239 |
|
240 |
break
|
241 |
|
242 |
def getIndexByValue(self, value): |
243 |
index = None
|
244 |
|
245 |
for index in range(self.ui.comboBox_Roughness.count()): |
246 |
if float(self.ui.comboBox_Roughness.itemData(index)) == float(value): |
247 |
return index
|
248 |
|
249 |
return index
|
250 |
|
251 |
|
252 |
def update_HMB(self): |
253 |
from AppDocData import AppDocData |
254 |
|
255 |
drawing = AppDocData.instance().activeDrawing |
256 |
if drawing:
|
257 |
values = {} |
258 |
values['Phase_Type'] = 'Liquid' |
259 |
|
260 |
if self.ui.radioButton_Flowrate_Mass.isChecked(): |
261 |
values['Flowrate_Mass'] = self.ui.lineEdit_Flowrate_Mass.text() |
262 |
elif self.ui.radioButton_Flowrate_Volume.isChecked(): |
263 |
values['Flowrate_Volume'] = self.ui.lineEdit_Flowrate_Volume.text() |
264 |
|
265 |
values['Density'] = self.ui.lineEdit_Density.text() |
266 |
values['Viscosity'] = self.ui.lineEdit_Viscosity.text() |
267 |
values['Limitation_Velocity'] = self.ui.lineEdit_Limitation_Velocity.text() |
268 |
values['Limitation_Pressure_Drop'] = self.ui.lineEdit_Limitation_Pressure_Drop.text() |
269 |
values['Nominal_Pipe_Size'] = self.ui.comboBox_Nominal_Pipe_Size.currentText() |
270 |
values['Inside_Pipe_Size'] = self.ui.lineEdit_Inside_Pipe_Size.text() |
271 |
values['Schedule_No'] = self.ui.comboBox_Schedule_No.currentText() |
272 |
values['Roughness'] = self.ui.lineEdit_Roughness.text() |
273 |
values['Straight_Length'] = self.ui.lineEdit_Straight_Length.text() |
274 |
|
275 |
if self.ui.radioButton_Equivalent_Length_Input.isChecked(): |
276 |
values['Equivalent_Length'] = self.ui.lineEdit_Equivalent_Length_Input.text() |
277 |
elif self.ui.radioButton_Flowrate_Volume.isChecked(): |
278 |
values['Equivalent_Length'] = self.ui.lineEdit_Equivalent_Length_Cal.text() |
279 |
|
280 |
drawing.hmbTable.updateByUID(self.components_uid, values)
|
281 |
|
282 |
|
283 |
def accept(self): |
284 |
self.update_HMB()
|
285 |
|
286 |
self.result = True |
287 |
QDialog.accept(self)
|
288 |
|
289 |
def reject(self): |
290 |
|
291 |
self.result = False |
292 |
QDialog.reject(self)
|
293 |
|
294 |
if __name__ == '__main__': |
295 |
from Phase_LiquidDialog import QPhase_LiquidDialog |
296 |
from App import App |
297 |
app = App(sys.argv) |
298 |
|
299 |
|
300 |
if True: |
301 |
dlg = QPhase_LiquidDialog() |
302 |
dlg.exec_() |