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