프로젝트

일반

사용자정보

통계
| 개정판:

hytos / HYTOS / HYTOS / Drum_Vertical.py @ 39128c17

이력 | 보기 | 이력해설 | 다운로드 (19.7 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 Drum_Vertical_UI
14
import math
15

    
16

    
17
def is_not_blank(s):
18
    return bool(s and s.strip())
19

    
20

    
21
class QDrum_Vertical(QDialog):
22
    def __init__(self):
23
        QDialog.__init__(self)
24

    
25
        self.ui = Drum_Vertical_UI.Ui_Drum_VerticalDialog()
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
        self.ui.lineEdit_N10_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N10_Pressure))
39
        self.ui.lineEdit_N11_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N11_Pressure))
40
        self.ui.lineEdit_N12_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N12_Pressure))
41

    
42
        self.ui.lineEdit_N1_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Elevation))
43
        self.ui.lineEdit_N2_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Elevation))
44
        self.ui.lineEdit_N3_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Elevation))
45
        self.ui.lineEdit_N4_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Elevation))
46
        self.ui.lineEdit_N5_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Elevation))
47
        self.ui.lineEdit_N6_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Elevation))
48
        self.ui.lineEdit_N7_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Elevation))
49
        self.ui.lineEdit_N8_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Elevation))
50
        self.ui.lineEdit_N9_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Elevation))
51
        self.ui.lineEdit_N10_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N10_Elevation))
52
        self.ui.lineEdit_N11_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N11_Elevation))
53
        self.ui.lineEdit_N12_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N12_Elevation))
54

    
55
        self.initialize()
56

    
57
    def show_dialog(self, item):
58
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
59
        self._item = item
60

    
61
        self.ui.lineEdit_TagNo.setFocus()
62
        self.set_controls()
63
        self.load_data()
64

    
65
        return self.exec_()
66

    
67
    def initialize(self):
68
        # To do : 이름으로 Control 찾아오기
69
        self.ui.label_Img_N1.setVisible(False)
70
        self.ui.label_Img_N2.setVisible(False)
71
        self.ui.label_Img_N3.setVisible(False)
72
        self.ui.label_Img_N4.setVisible(False)
73
        self.ui.label_Img_N5.setVisible(False)
74
        self.ui.label_Img_N6.setVisible(False)
75
        self.ui.label_Img_N7.setVisible(False)
76
        self.ui.label_Img_N8.setVisible(False)
77
        self.ui.label_Img_N9.setVisible(False)
78
        self.ui.label_Img_N10.setVisible(False)
79
        self.ui.label_Img_N11.setVisible(False)
80
        self.ui.label_Img_N12.setVisible(False)
81

    
82
        self.ui.label_N1.setVisible(False)
83
        self.ui.lineEdit_N1_Pressure.setEnabled(False)
84
        self.ui.lineEdit_N1_Elevation.setEnabled(False)
85

    
86
        self.ui.label_N2.setVisible(False)
87
        self.ui.lineEdit_N2_Pressure.setEnabled(False)
88
        self.ui.lineEdit_N2_Elevation.setEnabled(False)
89

    
90
        self.ui.label_N3.setVisible(False)
91
        self.ui.lineEdit_N3_Pressure.setEnabled(False)
92
        self.ui.lineEdit_N3_Elevation.setEnabled(False)
93

    
94
        self.ui.label_N4.setVisible(False)
95
        self.ui.lineEdit_N4_Pressure.setEnabled(False)
96
        self.ui.lineEdit_N4_Elevation.setEnabled(False)
97

    
98
        self.ui.label_N5.setVisible(False)
99
        self.ui.lineEdit_N5_Pressure.setEnabled(False)
100
        self.ui.lineEdit_N5_Elevation.setEnabled(False)
101

    
102
        self.ui.label_N6.setVisible(False)
103
        self.ui.lineEdit_N6_Pressure.setEnabled(False)
104
        self.ui.lineEdit_N6_Elevation.setEnabled(False)
105

    
106
        self.ui.label_N7.setVisible(False)
107
        self.ui.lineEdit_N7_Pressure.setEnabled(False)
108
        self.ui.lineEdit_N7_Elevation.setEnabled(False)
109

    
110
        self.ui.label_N8.setVisible(False)
111
        self.ui.lineEdit_N8_Pressure.setEnabled(False)
112
        self.ui.lineEdit_N8_Elevation.setEnabled(False)
113

    
114
        self.ui.label_N9.setVisible(False)
115
        self.ui.lineEdit_N9_Pressure.setEnabled(False)
116
        self.ui.lineEdit_N9_Elevation.setEnabled(False)
117

    
118
        self.ui.label_N10.setVisible(False)
119
        self.ui.lineEdit_N10_Pressure.setEnabled(False)
120
        self.ui.lineEdit_N10_Elevation.setEnabled(False)
121

    
122
        self.ui.label_N11.setVisible(False)
123
        self.ui.lineEdit_N11_Pressure.setEnabled(False)
124
        self.ui.lineEdit_N11_Elevation.setEnabled(False)
125

    
126
        self.ui.label_N12.setVisible(False)
127
        self.ui.lineEdit_N12_Pressure.setEnabled(False)
128
        self.ui.lineEdit_N12_Elevation.setEnabled(False)
129

    
130
    def set_controls(self):
131
        # To do : 이름으로 Control 찾아오기
132
        for connector in self._item.connectors:
133
            index = connector._conn_index
134
            if connector.connectedItem:
135
                if index == 1:
136
                    self.ui.label_Img_N1.setVisible(True)
137
                    self.ui.label_N1.setVisible(True)
138
                    self.ui.lineEdit_N1_Pressure.setEnabled(True)
139
                    self.ui.lineEdit_N1_Elevation.setEnabled(True)
140
                elif index == 2:
141
                    self.ui.label_Img_N2.setVisible(True)
142
                    self.ui.label_N2.setVisible(True)
143
                    self.ui.lineEdit_N2_Pressure.setEnabled(True)
144
                    self.ui.lineEdit_N2_Elevation.setEnabled(True)
145
                elif index == 3:
146
                    self.ui.label_Img_N3.setVisible(True)
147
                    self.ui.label_N3.setVisible(True)
148
                    self.ui.lineEdit_N3_Pressure.setEnabled(True)
149
                    self.ui.lineEdit_N3_Elevation.setEnabled(True)
150
                elif index == 4:
151
                    self.ui.label_Img_N4.setVisible(True)
152
                    self.ui.label_N4.setVisible(True)
153
                    self.ui.lineEdit_N4_Pressure.setEnabled(True)
154
                    self.ui.lineEdit_N4_Elevation.setEnabled(True)
155
                elif index == 5:
156
                    self.ui.label_Img_N5.setVisible(True)
157
                    self.ui.label_N5.setVisible(True)
158
                    self.ui.lineEdit_N5_Pressure.setEnabled(True)
159
                    self.ui.lineEdit_N5_Elevation.setEnabled(True)
160
                elif index == 6:
161
                    self.ui.label_Img_N6.setVisible(True)
162
                    self.ui.label_N6.setVisible(True)
163
                    self.ui.lineEdit_N6_Pressure.setEnabled(True)
164
                    self.ui.lineEdit_N6_Elevation.setEnabled(True)
165
                elif index == 7:
166
                    self.ui.label_Img_N7.setVisible(True)
167
                    self.ui.label_N7.setVisible(True)
168
                    self.ui.lineEdit_N7_Pressure.setEnabled(True)
169
                    self.ui.lineEdit_N7_Elevation.setEnabled(True)
170
                elif index == 8:
171
                    self.ui.label_Img_N8.setVisible(True)
172
                    self.ui.label_N8.setVisible(True)
173
                    self.ui.lineEdit_N8_Pressure.setEnabled(True)
174
                    self.ui.lineEdit_N8_Elevation.setEnabled(True)
175
                elif index == 9:
176
                    self.ui.label_Img_N9.setVisible(True)
177
                    self.ui.label_N9.setVisible(True)
178
                    self.ui.lineEdit_N9_Pressure.setEnabled(True)
179
                    self.ui.lineEdit_N9_Elevation.setEnabled(True)
180
                elif index == 10:
181
                    self.ui.label_Img_N10.setVisible(True)
182
                    self.ui.label_N10.setVisible(True)
183
                    self.ui.lineEdit_N10_Pressure.setEnabled(True)
184
                    self.ui.lineEdit_N10_Elevation.setEnabled(True)
185
                elif index == 11:
186
                    self.ui.label_Img_N11.setVisible(True)
187
                    self.ui.label_N11.setVisible(True)
188
                    self.ui.lineEdit_N11_Pressure.setEnabled(True)
189
                    self.ui.lineEdit_N11_Elevation.setEnabled(True)
190
                elif index == 12:
191
                    self.ui.label_Img_N12.setVisible(True)
192
                    self.ui.label_N12.setVisible(True)
193
                    self.ui.lineEdit_N12_Pressure.setEnabled(True)
194
                    self.ui.lineEdit_N12_Elevation.setEnabled(True)
195

    
196
    def load_data(self):
197
        """ load tag no and nozzle data """
198
        tag_no = self._item.tag_no
199
        if tag_no != 'None' and is_not_blank(tag_no):
200
            self.ui.lineEdit_TagNo.setText(tag_no)
201

    
202
        app_doc_data = AppDocData.instance()
203
        drawing = app_doc_data.activeDrawing
204
        if drawing:
205
            for attr in drawing.attrs:
206
                if attr[0] == 'Units':
207
                    self.ui.label_PressureUnit.setText('{}(g)'.format(attr[1]['Pressure']))
208
                    self.ui.label_ElevationUnit.setText(attr[1]['Length'])
209

    
210
        for connector in self._item.connectors:
211
            index = connector._conn_index
212
            if connector.data:
213
                pressure = connector.data.pressure
214
                if pressure:
215
                    if index == 1:
216
                        self.ui.lineEdit_N1_Pressure.setText(str(pressure))
217
                    elif index == 2:
218
                        self.ui.lineEdit_N2_Pressure.setText(str(pressure))
219
                    elif index == 3:
220
                        self.ui.lineEdit_N3_Pressure.setText(str(pressure))
221
                    elif index == 4:
222
                        self.ui.lineEdit_N4_Pressure.setText(str(pressure))
223
                    elif index == 5:
224
                        self.ui.lineEdit_N5_Pressure.setText(str(pressure))
225
                    elif index == 6:
226
                        self.ui.lineEdit_N6_Pressure.setText(str(pressure))
227
                    elif index == 7:
228
                        self.ui.lineEdit_N7_Pressure.setText(str(pressure))
229
                    elif index == 8:
230
                        self.ui.lineEdit_N8_Pressure.setText(str(pressure))
231
                    elif index == 9:
232
                        self.ui.lineEdit_N9_Pressure.setText(str(pressure))
233
                    elif index == 10:
234
                        self.ui.lineEdit_N10_Pressure.setText(str(pressure))
235
                    elif index == 11:
236
                        self.ui.lineEdit_N11_Pressure.setText(str(pressure))
237
                    elif index == 12:
238
                        self.ui.lineEdit_N12_Pressure.setText(str(pressure))
239

    
240
                elevation = connector.data.elevation
241
                if elevation:
242
                    if index == 1:
243
                        self.ui.lineEdit_N1_Elevation.setText(str(elevation))
244
                    elif index == 2:
245
                        self.ui.lineEdit_N2_Elevation.setText(str(elevation))
246
                    elif index == 3:
247
                        self.ui.lineEdit_N3_Elevation.setText(str(elevation))
248
                    elif index == 4:
249
                        self.ui.lineEdit_N4_Elevation.setText(str(elevation))
250
                    elif index == 5:
251
                        self.ui.lineEdit_N5_Elevation.setText(str(elevation))
252
                    elif index == 6:
253
                        self.ui.lineEdit_N6_Elevation.setText(str(elevation))
254
                    elif index == 7:
255
                        self.ui.lineEdit_N7_Elevation.setText(str(elevation))
256
                    elif index == 8:
257
                        self.ui.lineEdit_N8_Elevation.setText(str(elevation))
258
                    elif index == 9:
259
                        self.ui.lineEdit_N9_Elevation.setText(str(elevation))
260
                    elif index == 10:
261
                        self.ui.lineEdit_N10_Elevation.setText(str(elevation))
262
                    elif index == 11:
263
                        self.ui.lineEdit_N11_Elevation.setText(str(elevation))
264
                    elif index == 12:
265
                        self.ui.lineEdit_N12_Elevation.setText(str(elevation))
266

    
267
    def accept(self):
268
        """ set tag no and nozzle data """
269
        from EngineeringConnectorItem import NozzleData
270
        tag_no = self.ui.lineEdit_TagNo.text()
271

    
272
        if is_not_blank(tag_no):
273
            self._item.tag_no = tag_no
274
            for connector in self._item.connectors:
275
                index = connector._conn_index
276
                if not connector.data:
277
                    connector.data = NozzleData()
278

    
279
                if index == 1:
280
                    pressure = self.ui.lineEdit_N1_Pressure.text()
281
                    if pressure:
282
                        connector.data.pressure = float(pressure)
283
                    else:
284
                        connector.data.pressure = None
285

    
286
                    elevation = self.ui.lineEdit_N1_Elevation.text()
287
                    if elevation:
288
                        connector.data.elevation = float(elevation)
289
                    else:
290
                        connector.data.elevation = None
291
                elif index == 2:
292
                    pressure = self.ui.lineEdit_N2_Pressure.text()
293
                    if pressure:
294
                        connector.data.pressure = float(pressure)
295
                    else:
296
                        connector.data.pressure = None
297

    
298
                    elevation = self.ui.lineEdit_N2_Elevation.text()
299
                    if elevation:
300
                        connector.data.elevation = float(elevation)
301
                    else:
302
                        connector.data.elevation = None
303
                elif index == 3:
304
                    pressure = self.ui.lineEdit_N3_Pressure.text()
305
                    if pressure:
306
                        connector.data.pressure = float(pressure)
307
                    else:
308
                        connector.data.pressure = None
309

    
310
                    elevation = self.ui.lineEdit_N3_Elevation.text()
311
                    if elevation:
312
                        connector.data.elevation = float(elevation)
313
                    else:
314
                        connector.data.elevation = None
315
                elif index == 4:
316
                    pressure = self.ui.lineEdit_N4_Pressure.text()
317
                    if pressure:
318
                        connector.data.pressure = float(pressure)
319
                    else:
320
                        connector.data.pressure = None
321

    
322
                    elevation = self.ui.lineEdit_N4_Elevation.text()
323
                    if elevation:
324
                        connector.data.elevation = float(elevation)
325
                    else:
326
                        connector.data.elevation = None
327
                elif index == 5:
328
                    pressure = self.ui.lineEdit_N5_Pressure.text()
329
                    if pressure:
330
                        connector.data.pressure = float(pressure)
331
                    else:
332
                        connector.data.pressure = None
333

    
334
                    elevation = self.ui.lineEdit_N5_Elevation.text()
335
                    if elevation:
336
                        connector.data.elevation = float(elevation)
337
                    else:
338
                        connector.data.elevation = None
339
                elif index == 6:
340
                    pressure = self.ui.lineEdit_N6_Pressure.text()
341
                    if pressure:
342
                        connector.data.pressure = float(pressure)
343
                    else:
344
                        connector.data.pressure = None
345

    
346
                    elevation = self.ui.lineEdit_N6_Elevation.text()
347
                    if elevation:
348
                        connector.data.elevation = float(elevation)
349
                    else:
350
                        connector.data.elevation = None
351
                elif index == 7:
352
                    pressure = self.ui.lineEdit_N7_Pressure.text()
353
                    if pressure:
354
                        connector.data.pressure = float(pressure)
355
                    else:
356
                        connector.data.pressure = None
357

    
358
                    elevation = self.ui.lineEdit_N7_Elevation.text()
359
                    if elevation:
360
                        connector.data.elevation = float(elevation)
361
                    else:
362
                        connector.data.elevation = None
363
                elif index == 8:
364
                    pressure = self.ui.lineEdit_N8_Pressure.text()
365
                    if pressure:
366
                        connector.data.pressure = float(pressure)
367
                    else:
368
                        connector.data.pressure = None
369

    
370
                    elevation = self.ui.lineEdit_N8_Elevation.text()
371
                    if elevation:
372
                        connector.data.elevation = float(elevation)
373
                    else:
374
                        connector.data.elevation = None
375
                elif index == 9:
376
                    pressure = self.ui.lineEdit_N9_Pressure.text()
377
                    if pressure:
378
                        connector.data.pressure = float(pressure)
379
                    else:
380
                        connector.data.pressure = None
381

    
382
                    elevation = self.ui.lineEdit_N9_Elevation.text()
383
                    if elevation:
384
                        connector.data.elevation = float(elevation)
385
                    else:
386
                        connector.data.elevation = None
387
                elif index == 10:
388
                    pressure = self.ui.lineEdit_N10_Pressure.text()
389
                    if pressure:
390
                        connector.data.pressure = float(pressure)
391
                    else:
392
                        connector.data.pressure = None
393

    
394
                    elevation = self.ui.lineEdit_N10_Elevation.text()
395
                    if elevation:
396
                        connector.data.elevation = float(elevation)
397
                    else:
398
                        connector.data.elevation = None
399
                elif index == 11:
400
                    pressure = self.ui.lineEdit_N11_Pressure.text()
401
                    if pressure:
402
                        connector.data.pressure = float(pressure)
403
                    else:
404
                        connector.data.pressure = None
405

    
406
                    elevation = self.ui.lineEdit_N11_Elevation.text()
407
                    if elevation:
408
                        connector.data.elevation = float(elevation)
409
                    else:
410
                        connector.data.elevation = None
411
                elif index == 12:
412
                    pressure = self.ui.lineEdit_N12_Pressure.text()
413
                    if pressure:
414
                        connector.data.pressure = float(pressure)
415
                    else:
416
                        connector.data.pressure = None
417

    
418
                    elevation = self.ui.lineEdit_N12_Elevation.text()
419
                    if elevation:
420
                        connector.data.elevation = float(elevation)
421
                    else:
422
                        connector.data.elevation = None
423

    
424
            QDialog.accept(self)
425
        else:
426
            QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]'))
427

    
428
    def reject(self):
429
        QDialog.reject(self)
클립보드 이미지 추가 (최대 크기: 500 MB)