hytos / HYTOS / HYTOS / PlateHeatExchanger.py @ 4211450a
이력 | 보기 | 이력해설 | 다운로드 (7.48 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 |
from AppDocData import AppDocData |
13 |
import PlateHeatExchanger_UI |
14 |
import math |
15 |
|
16 |
|
17 |
def is_not_blank(s): |
18 |
return bool(s and s.strip()) |
19 |
|
20 |
|
21 |
class QPlateHeatExchanger(QDialog): |
22 |
def __init__(self): |
23 |
QDialog.__init__(self)
|
24 |
|
25 |
self.ui = PlateHeatExchanger_UI.Ui_PlateHeatExchangerDialog()
|
26 |
self.ui.setupUi(self) |
27 |
self._item = None |
28 |
|
29 |
self.ui.lineEdit_UpDown_Pressure_Drop.setValidator(
|
30 |
QtGui.QDoubleValidator(self.ui.lineEdit_UpDown_Pressure_Drop))
|
31 |
self.ui.lineEdit_DownUp_Pressure_Drop.setValidator(
|
32 |
QtGui.QDoubleValidator(self.ui.lineEdit_DownUp_Pressure_Drop))
|
33 |
self.ui.lineEdit_UpDown_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_UpDown_Elevation)) |
34 |
self.ui.lineEdit_DownUp_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_DownUp_Elevation)) |
35 |
|
36 |
self.initialize()
|
37 |
|
38 |
def show_dialog(self, item): |
39 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
40 |
self._item = item
|
41 |
|
42 |
self.ui.lineEdit_TagNo.setFocus()
|
43 |
self.set_controls()
|
44 |
self.load_data()
|
45 |
|
46 |
return self.exec_() |
47 |
|
48 |
def initialize(self): |
49 |
self.ui.label_Img_1.setVisible(False) |
50 |
self.ui.label_Img_2.setVisible(False) |
51 |
self.ui.label_Img_3.setVisible(False) |
52 |
self.ui.label_Img_4.setVisible(False) |
53 |
|
54 |
self.ui.label_UpDown.setVisible(False) |
55 |
self.ui.lineEdit_UpDown_Pressure_Drop.setEnabled(False) |
56 |
self.ui.lineEdit_UpDown_Elevation.setEnabled(False) |
57 |
|
58 |
self.ui.label_DownUp.setVisible(False) |
59 |
self.ui.lineEdit_DownUp_Pressure_Drop.setEnabled(False) |
60 |
self.ui.lineEdit_DownUp_Elevation.setEnabled(False) |
61 |
|
62 |
def set_controls(self): |
63 |
used_index = [] |
64 |
|
65 |
for connector in self._item.connectors: |
66 |
if connector.connectedItem:
|
67 |
used_index.append(connector._conn_index) |
68 |
|
69 |
if len(used_index) > 0: |
70 |
if 1 in used_index or 3 in used_index: |
71 |
self.ui.label_Img_1.setVisible(True) |
72 |
self.ui.label_Img_3.setVisible(True) |
73 |
|
74 |
self.ui.label_UpDown.setVisible(True) |
75 |
self.ui.lineEdit_UpDown_Pressure_Drop.setEnabled(True) |
76 |
self.ui.lineEdit_UpDown_Elevation.setEnabled(True) |
77 |
|
78 |
if 2 in used_index or 4 in used_index: |
79 |
self.ui.label_Img_2.setVisible(True) |
80 |
self.ui.label_Img_4.setVisible(True) |
81 |
|
82 |
self.ui.label_DownUp.setVisible(True) |
83 |
self.ui.lineEdit_DownUp_Pressure_Drop.setEnabled(True) |
84 |
self.ui.lineEdit_DownUp_Elevation.setEnabled(True) |
85 |
|
86 |
def load_data(self): |
87 |
""" load tag no and nozzle data """
|
88 |
tag_no = self._item.tag_no
|
89 |
if tag_no != 'None' and is_not_blank(tag_no): |
90 |
self.ui.lineEdit_TagNo.setText(tag_no)
|
91 |
|
92 |
app_doc_data = AppDocData.instance() |
93 |
drawing = app_doc_data.activeDrawing |
94 |
if drawing:
|
95 |
for attr in drawing.attrs: |
96 |
if attr[0] == 'Units': |
97 |
self.ui.label_PressureUnit.setText(attr[1]['Pressure']) |
98 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
99 |
|
100 |
for connector in self._item.connectors: |
101 |
index = connector._conn_index |
102 |
if connector.data:
|
103 |
pressure_drop = connector.data.pressure_drop |
104 |
if pressure_drop:
|
105 |
if index == 1: |
106 |
self.ui.lineEdit_UpDown_Pressure_Drop.setText(str(pressure_drop)) |
107 |
elif index == 2: |
108 |
self.ui.lineEdit_DownUp_Pressure_Drop.setText(str(pressure_drop)) |
109 |
elif index == 3: |
110 |
self.ui.lineEdit_UpDown_Pressure_Drop.setText(str(pressure_drop)) |
111 |
elif index == 4: |
112 |
self.ui.lineEdit_DownUp_Pressure_Drop.setText(str(pressure_drop)) |
113 |
|
114 |
elevation = connector.data.elevation |
115 |
if elevation:
|
116 |
if index == 1: |
117 |
self.ui.lineEdit_UpDown_Elevation.setText(str(elevation)) |
118 |
elif index == 2: |
119 |
self.ui.lineEdit_DownUp_Elevation.setText(str(elevation)) |
120 |
elif index == 3: |
121 |
self.ui.lineEdit_UpDown_Elevation.setText(str(elevation)) |
122 |
elif index == 4: |
123 |
self.ui.lineEdit_DownUp_Elevation.setText(str(elevation)) |
124 |
|
125 |
def accept(self): |
126 |
""" set tag no and nozzle data """
|
127 |
from EngineeringConnectorItem import NozzleData |
128 |
tag_no = self.ui.lineEdit_TagNo.text()
|
129 |
|
130 |
if is_not_blank(tag_no):
|
131 |
self._item.tag_no = tag_no
|
132 |
for connector in self._item.connectors: |
133 |
index = connector._conn_index |
134 |
if not connector.data: |
135 |
connector.data = NozzleData() |
136 |
|
137 |
if index == 1: |
138 |
pressure_drop = self.ui.lineEdit_UpDown_Pressure_Drop.text()
|
139 |
if pressure_drop:
|
140 |
connector.data.pressure_drop = float(pressure_drop)
|
141 |
else:
|
142 |
connector.data.pressure_drop = None
|
143 |
|
144 |
elevation = self.ui.lineEdit_UpDown_Elevation.text()
|
145 |
if elevation:
|
146 |
connector.data.elevation = float(elevation)
|
147 |
else:
|
148 |
connector.data.elevation = None
|
149 |
elif index == 2: |
150 |
pressure_drop = self.ui.lineEdit_DownUp_Pressure_Drop.text()
|
151 |
if pressure_drop:
|
152 |
connector.data.pressure_drop = float(pressure_drop)
|
153 |
else:
|
154 |
connector.data.pressure_drop = None
|
155 |
|
156 |
elevation = self.ui.lineEdit_DownUp_Elevation.text()
|
157 |
if elevation:
|
158 |
connector.data.elevation = float(elevation)
|
159 |
else:
|
160 |
connector.data.elevation = None
|
161 |
elif index == 3: |
162 |
pressure_drop = self.ui.lineEdit_UpDown_Pressure_Drop.text()
|
163 |
if pressure_drop:
|
164 |
connector.data.pressure_drop = float(pressure_drop)
|
165 |
else:
|
166 |
connector.data.pressure_drop = None
|
167 |
|
168 |
elevation = self.ui.lineEdit_UpDown_Elevation.text()
|
169 |
if elevation:
|
170 |
connector.data.elevation = float(elevation)
|
171 |
else:
|
172 |
connector.data.elevation = None
|
173 |
elif index == 4: |
174 |
pressure_drop = self.ui.lineEdit_DownUp_Pressure_Drop.text()
|
175 |
if pressure_drop:
|
176 |
connector.data.pressure_drop = float(pressure_drop)
|
177 |
else:
|
178 |
connector.data.pressure_drop = None
|
179 |
|
180 |
elevation = self.ui.lineEdit_DownUp_Elevation.text()
|
181 |
if elevation:
|
182 |
connector.data.elevation = float(elevation)
|
183 |
else:
|
184 |
connector.data.elevation = None
|
185 |
|
186 |
QDialog.accept(self)
|
187 |
else:
|
188 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]')) |
189 |
|
190 |
def reject(self): |
191 |
QDialog.reject(self)
|