hytos / HYTOS / HYTOS / DomeRoof.py @ 39128c17
이력 | 보기 | 이력해설 | 다운로드 (15.4 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 DomeRoof_UI |
14 |
import math |
15 |
|
16 |
|
17 |
def is_not_blank(s): |
18 |
return bool(s and s.strip()) |
19 |
|
20 |
|
21 |
class QDomeRoof(QDialog): |
22 |
def __init__(self): |
23 |
QDialog.__init__(self)
|
24 |
|
25 |
self.ui = DomeRoof_UI.Ui_DomeRoofDialog()
|
26 |
self.ui.setupUi(self) |
27 |
self._item = None |
28 |
|
29 |
self.ui.lineEdit_N1_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Pressure)) |
30 |
self.ui.lineEdit_N2_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Pressure)) |
31 |
self.ui.lineEdit_N3_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Pressure)) |
32 |
self.ui.lineEdit_N4_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Pressure)) |
33 |
self.ui.lineEdit_N5_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Pressure)) |
34 |
self.ui.lineEdit_N6_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Pressure)) |
35 |
self.ui.lineEdit_N7_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Pressure)) |
36 |
self.ui.lineEdit_N8_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Pressure)) |
37 |
self.ui.lineEdit_N9_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Pressure)) |
38 |
|
39 |
self.ui.lineEdit_N1_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Elevation)) |
40 |
self.ui.lineEdit_N2_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Elevation)) |
41 |
self.ui.lineEdit_N3_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Elevation)) |
42 |
self.ui.lineEdit_N4_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Elevation)) |
43 |
self.ui.lineEdit_N5_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Elevation)) |
44 |
self.ui.lineEdit_N6_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Elevation)) |
45 |
self.ui.lineEdit_N7_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Elevation)) |
46 |
self.ui.lineEdit_N8_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Elevation)) |
47 |
self.ui.lineEdit_N9_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Elevation)) |
48 |
|
49 |
self.initialize()
|
50 |
|
51 |
def show_dialog(self, item): |
52 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
53 |
self._item = item
|
54 |
|
55 |
self.ui.lineEdit_TagNo.setFocus()
|
56 |
self.set_controls()
|
57 |
self.load_data()
|
58 |
|
59 |
return self.exec_() |
60 |
|
61 |
def initialize(self): |
62 |
# To do : 이름으로 Control 찾아오기
|
63 |
self.ui.label_Img_N1.setVisible(False) |
64 |
self.ui.label_Img_N2.setVisible(False) |
65 |
self.ui.label_Img_N3.setVisible(False) |
66 |
self.ui.label_Img_N4.setVisible(False) |
67 |
self.ui.label_Img_N5.setVisible(False) |
68 |
self.ui.label_Img_N6.setVisible(False) |
69 |
self.ui.label_Img_N7.setVisible(False) |
70 |
self.ui.label_Img_N8.setVisible(False) |
71 |
self.ui.label_Img_N9.setVisible(False) |
72 |
|
73 |
self.ui.label_N1.setVisible(False) |
74 |
self.ui.lineEdit_N1_Pressure.setEnabled(False) |
75 |
self.ui.lineEdit_N1_Elevation.setEnabled(False) |
76 |
|
77 |
self.ui.label_N2.setVisible(False) |
78 |
self.ui.lineEdit_N2_Pressure.setEnabled(False) |
79 |
self.ui.lineEdit_N2_Elevation.setEnabled(False) |
80 |
|
81 |
self.ui.label_N3.setVisible(False) |
82 |
self.ui.lineEdit_N3_Pressure.setEnabled(False) |
83 |
self.ui.lineEdit_N3_Elevation.setEnabled(False) |
84 |
|
85 |
self.ui.label_N4.setVisible(False) |
86 |
self.ui.lineEdit_N4_Pressure.setEnabled(False) |
87 |
self.ui.lineEdit_N4_Elevation.setEnabled(False) |
88 |
|
89 |
self.ui.label_N5.setVisible(False) |
90 |
self.ui.lineEdit_N5_Pressure.setEnabled(False) |
91 |
self.ui.lineEdit_N5_Elevation.setEnabled(False) |
92 |
|
93 |
self.ui.label_N6.setVisible(False) |
94 |
self.ui.lineEdit_N6_Pressure.setEnabled(False) |
95 |
self.ui.lineEdit_N6_Elevation.setEnabled(False) |
96 |
|
97 |
self.ui.label_N7.setVisible(False) |
98 |
self.ui.lineEdit_N7_Pressure.setEnabled(False) |
99 |
self.ui.lineEdit_N7_Elevation.setEnabled(False) |
100 |
|
101 |
self.ui.label_N8.setVisible(False) |
102 |
self.ui.lineEdit_N8_Pressure.setEnabled(False) |
103 |
self.ui.lineEdit_N8_Elevation.setEnabled(False) |
104 |
|
105 |
self.ui.label_N9.setVisible(False) |
106 |
self.ui.lineEdit_N9_Pressure.setEnabled(False) |
107 |
self.ui.lineEdit_N9_Elevation.setEnabled(False) |
108 |
|
109 |
def set_controls(self): |
110 |
# To do : 이름으로 Control 찾아오기
|
111 |
for connector in self._item.connectors: |
112 |
index = connector._conn_index |
113 |
if connector.connectedItem:
|
114 |
if index == 1: |
115 |
self.ui.label_Img_N1.setVisible(True) |
116 |
self.ui.label_N1.setVisible(True) |
117 |
self.ui.lineEdit_N1_Pressure.setEnabled(True) |
118 |
self.ui.lineEdit_N1_Elevation.setEnabled(True) |
119 |
elif index == 2: |
120 |
self.ui.label_Img_N2.setVisible(True) |
121 |
self.ui.label_N2.setVisible(True) |
122 |
self.ui.lineEdit_N2_Pressure.setEnabled(True) |
123 |
self.ui.lineEdit_N2_Elevation.setEnabled(True) |
124 |
elif index == 3: |
125 |
self.ui.label_Img_N3.setVisible(True) |
126 |
self.ui.label_N3.setVisible(True) |
127 |
self.ui.lineEdit_N3_Pressure.setEnabled(True) |
128 |
self.ui.lineEdit_N3_Elevation.setEnabled(True) |
129 |
elif index == 4: |
130 |
self.ui.label_Img_N4.setVisible(True) |
131 |
self.ui.label_N4.setVisible(True) |
132 |
self.ui.lineEdit_N4_Pressure.setEnabled(True) |
133 |
self.ui.lineEdit_N4_Elevation.setEnabled(True) |
134 |
elif index == 5: |
135 |
self.ui.label_Img_N5.setVisible(True) |
136 |
self.ui.label_N5.setVisible(True) |
137 |
self.ui.lineEdit_N5_Pressure.setEnabled(True) |
138 |
self.ui.lineEdit_N5_Elevation.setEnabled(True) |
139 |
elif index == 6: |
140 |
self.ui.label_Img_N6.setVisible(True) |
141 |
self.ui.label_N6.setVisible(True) |
142 |
self.ui.lineEdit_N6_Pressure.setEnabled(True) |
143 |
self.ui.lineEdit_N6_Elevation.setEnabled(True) |
144 |
elif index == 7: |
145 |
self.ui.label_Img_N7.setVisible(True) |
146 |
self.ui.label_N7.setVisible(True) |
147 |
self.ui.lineEdit_N7_Pressure.setEnabled(True) |
148 |
self.ui.lineEdit_N7_Elevation.setEnabled(True) |
149 |
elif index == 8: |
150 |
self.ui.label_Img_N8.setVisible(True) |
151 |
self.ui.label_N8.setVisible(True) |
152 |
self.ui.lineEdit_N8_Pressure.setEnabled(True) |
153 |
self.ui.lineEdit_N8_Elevation.setEnabled(True) |
154 |
elif index == 9: |
155 |
self.ui.label_Img_N9.setVisible(True) |
156 |
self.ui.label_N9.setVisible(True) |
157 |
self.ui.lineEdit_N9_Pressure.setEnabled(True) |
158 |
self.ui.lineEdit_N9_Elevation.setEnabled(True) |
159 |
|
160 |
def load_data(self): |
161 |
""" load tag no and nozzle data """
|
162 |
tag_no = self._item.tag_no
|
163 |
if tag_no != 'None' and is_not_blank(tag_no): |
164 |
self.ui.lineEdit_TagNo.setText(tag_no)
|
165 |
|
166 |
app_doc_data = AppDocData.instance() |
167 |
drawing = app_doc_data.activeDrawing |
168 |
if drawing:
|
169 |
for attr in drawing.attrs: |
170 |
if attr[0] == 'Units': |
171 |
self.ui.label_PressureUnit.setText('{}(g)'.format(attr[1]['Pressure'])) |
172 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
173 |
|
174 |
for connector in self._item.connectors: |
175 |
index = connector._conn_index |
176 |
if connector.data:
|
177 |
pressure = connector.data.pressure |
178 |
if pressure:
|
179 |
if index == 1: |
180 |
self.ui.lineEdit_N1_Pressure.setText(str(pressure)) |
181 |
elif index == 2: |
182 |
self.ui.lineEdit_N2_Pressure.setText(str(pressure)) |
183 |
elif index == 3: |
184 |
self.ui.lineEdit_N3_Pressure.setText(str(pressure)) |
185 |
elif index == 4: |
186 |
self.ui.lineEdit_N4_Pressure.setText(str(pressure)) |
187 |
elif index == 5: |
188 |
self.ui.lineEdit_N5_Pressure.setText(str(pressure)) |
189 |
elif index == 6: |
190 |
self.ui.lineEdit_N6_Pressure.setText(str(pressure)) |
191 |
elif index == 7: |
192 |
self.ui.lineEdit_N7_Pressure.setText(str(pressure)) |
193 |
elif index == 8: |
194 |
self.ui.lineEdit_N8_Pressure.setText(str(pressure)) |
195 |
elif index == 9: |
196 |
self.ui.lineEdit_N9_Pressure.setText(str(pressure)) |
197 |
|
198 |
elevation = connector.data.elevation |
199 |
if elevation:
|
200 |
if index == 1: |
201 |
self.ui.lineEdit_N1_Elevation.setText(str(elevation)) |
202 |
elif index == 2: |
203 |
self.ui.lineEdit_N2_Elevation.setText(str(elevation)) |
204 |
elif index == 3: |
205 |
self.ui.lineEdit_N3_Elevation.setText(str(elevation)) |
206 |
elif index == 4: |
207 |
self.ui.lineEdit_N4_Elevation.setText(str(elevation)) |
208 |
elif index == 5: |
209 |
self.ui.lineEdit_N5_Elevation.setText(str(elevation)) |
210 |
elif index == 6: |
211 |
self.ui.lineEdit_N6_Elevation.setText(str(elevation)) |
212 |
elif index == 7: |
213 |
self.ui.lineEdit_N7_Elevation.setText(str(elevation)) |
214 |
elif index == 8: |
215 |
self.ui.lineEdit_N8_Elevation.setText(str(elevation)) |
216 |
elif index == 9: |
217 |
self.ui.lineEdit_N9_Elevation.setText(str(elevation)) |
218 |
|
219 |
def accept(self): |
220 |
""" set tag no and nozzle data """
|
221 |
from EngineeringConnectorItem import NozzleData |
222 |
tag_no = self.ui.lineEdit_TagNo.text()
|
223 |
|
224 |
if is_not_blank(tag_no):
|
225 |
self._item.tag_no = tag_no
|
226 |
for connector in self._item.connectors: |
227 |
index = connector._conn_index |
228 |
if not connector.data: |
229 |
connector.data = NozzleData() |
230 |
|
231 |
if index == 1: |
232 |
pressure = self.ui.lineEdit_N1_Pressure.text()
|
233 |
if pressure:
|
234 |
connector.data.pressure = float(pressure)
|
235 |
else:
|
236 |
connector.data.pressure = None
|
237 |
|
238 |
elevation = self.ui.lineEdit_N1_Elevation.text()
|
239 |
if elevation:
|
240 |
connector.data.elevation = float(elevation)
|
241 |
else:
|
242 |
connector.data.elevation = None
|
243 |
elif index == 2: |
244 |
pressure = self.ui.lineEdit_N2_Pressure.text()
|
245 |
if pressure:
|
246 |
connector.data.pressure = float(pressure)
|
247 |
else:
|
248 |
connector.data.pressure = None
|
249 |
|
250 |
elevation = self.ui.lineEdit_N2_Elevation.text()
|
251 |
if elevation:
|
252 |
connector.data.elevation = float(elevation)
|
253 |
else:
|
254 |
connector.data.elevation = None
|
255 |
elif index == 3: |
256 |
pressure = self.ui.lineEdit_N3_Pressure.text()
|
257 |
if pressure:
|
258 |
connector.data.pressure = float(pressure)
|
259 |
else:
|
260 |
connector.data.pressure = None
|
261 |
|
262 |
elevation = self.ui.lineEdit_N3_Elevation.text()
|
263 |
if elevation:
|
264 |
connector.data.elevation = float(elevation)
|
265 |
else:
|
266 |
connector.data.elevation = None
|
267 |
elif index == 4: |
268 |
pressure = self.ui.lineEdit_N4_Pressure.text()
|
269 |
if pressure:
|
270 |
connector.data.pressure = float(pressure)
|
271 |
else:
|
272 |
connector.data.pressure = None
|
273 |
|
274 |
elevation = self.ui.lineEdit_N4_Elevation.text()
|
275 |
if elevation:
|
276 |
connector.data.elevation = float(elevation)
|
277 |
else:
|
278 |
connector.data.elevation = None
|
279 |
elif index == 5: |
280 |
pressure = self.ui.lineEdit_N5_Pressure.text()
|
281 |
if pressure:
|
282 |
connector.data.pressure = float(pressure)
|
283 |
else:
|
284 |
connector.data.pressure = None
|
285 |
|
286 |
elevation = self.ui.lineEdit_N5_Elevation.text()
|
287 |
if elevation:
|
288 |
connector.data.elevation = float(elevation)
|
289 |
else:
|
290 |
connector.data.elevation = None
|
291 |
elif index == 6: |
292 |
pressure = self.ui.lineEdit_N6_Pressure.text()
|
293 |
if pressure:
|
294 |
connector.data.pressure = float(pressure)
|
295 |
else:
|
296 |
connector.data.pressure = None
|
297 |
|
298 |
elevation = self.ui.lineEdit_N6_Elevation.text()
|
299 |
if elevation:
|
300 |
connector.data.elevation = float(elevation)
|
301 |
else:
|
302 |
connector.data.elevation = None
|
303 |
elif index == 7: |
304 |
pressure = self.ui.lineEdit_N7_Pressure.text()
|
305 |
if pressure:
|
306 |
connector.data.pressure = float(pressure)
|
307 |
else:
|
308 |
connector.data.pressure = None
|
309 |
|
310 |
elevation = self.ui.lineEdit_N7_Elevation.text()
|
311 |
if elevation:
|
312 |
connector.data.elevation = float(elevation)
|
313 |
else:
|
314 |
connector.data.elevation = None
|
315 |
elif index == 8: |
316 |
pressure = self.ui.lineEdit_N8_Pressure.text()
|
317 |
if pressure:
|
318 |
connector.data.pressure = float(pressure)
|
319 |
else:
|
320 |
connector.data.pressure = None
|
321 |
|
322 |
elevation = self.ui.lineEdit_N8_Elevation.text()
|
323 |
if elevation:
|
324 |
connector.data.elevation = float(elevation)
|
325 |
else:
|
326 |
connector.data.elevation = None
|
327 |
elif index == 9: |
328 |
pressure = self.ui.lineEdit_N9_Pressure.text()
|
329 |
if pressure:
|
330 |
connector.data.pressure = float(pressure)
|
331 |
else:
|
332 |
connector.data.pressure = None
|
333 |
|
334 |
elevation = self.ui.lineEdit_N9_Elevation.text()
|
335 |
if elevation:
|
336 |
connector.data.elevation = float(elevation)
|
337 |
else:
|
338 |
connector.data.elevation = None
|
339 |
|
340 |
QDialog.accept(self)
|
341 |
else:
|
342 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]')) |
343 |
|
344 |
def reject(self): |
345 |
QDialog.reject(self)
|