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