프로젝트

일반

사용자정보

통계
| 개정판:

hytos / HYTOS / HYTOS / Drum_Vertical.py @ 4aa060ea

이력 | 보기 | 이력해설 | 다운로드 (19.5 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
class QDrum_Vertical(QDialog):
17
    def __init__(self):
18
        QDialog.__init__(self)
19

    
20
        self.ui = Drum_Vertical_UI.Ui_Drum_VerticalDialog()
21
        self.ui.setupUi(self)
22

    
23
        self.ui.lineEdit_N1_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Pressure)) 
24
        self.ui.lineEdit_N2_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Pressure))
25
        self.ui.lineEdit_N3_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Pressure))
26
        self.ui.lineEdit_N4_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Pressure))        
27
        self.ui.lineEdit_N5_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Pressure))        
28
        self.ui.lineEdit_N6_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Pressure))        
29
        self.ui.lineEdit_N7_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Pressure))        
30
        self.ui.lineEdit_N8_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Pressure))
31
        self.ui.lineEdit_N9_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Pressure))        
32
        self.ui.lineEdit_N10_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N10_Pressure))        
33
        self.ui.lineEdit_N11_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N11_Pressure))        
34
        self.ui.lineEdit_N12_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N12_Pressure))
35

    
36
        self.ui.lineEdit_N1_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Elevation))                 
37
        self.ui.lineEdit_N2_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Elevation))                
38
        self.ui.lineEdit_N3_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Elevation))
39
        self.ui.lineEdit_N4_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Elevation)) 
40
        self.ui.lineEdit_N5_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Elevation)) 
41
        self.ui.lineEdit_N6_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Elevation)) 
42
        self.ui.lineEdit_N7_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Elevation)) 
43
        self.ui.lineEdit_N8_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Elevation))
44
        self.ui.lineEdit_N9_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Elevation)) 
45
        self.ui.lineEdit_N10_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N10_Elevation)) 
46
        self.ui.lineEdit_N11_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N11_Elevation)) 
47
        self.ui.lineEdit_N12_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N12_Elevation))
48

    
49
        self.initialize()
50

    
51
    def showDialog(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(item)
57
        self.load_data()
58

    
59
        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
        self.ui.label_Img_N10.setVisible(False)
73
        self.ui.label_Img_N11.setVisible(False)
74
        self.ui.label_Img_N12.setVisible(False)            
75
        
76
        self.ui.label_N1.setVisible(False)
77
        self.ui.lineEdit_N1_Pressure.setEnabled(False)                
78
        self.ui.lineEdit_N1_Elevation.setEnabled(False)
79
        
80
        self.ui.label_N2.setVisible(False)
81
        self.ui.lineEdit_N2_Pressure.setEnabled(False)                
82
        self.ui.lineEdit_N2_Elevation.setEnabled(False)
83
    
84
        self.ui.label_N3.setVisible(False)
85
        self.ui.lineEdit_N3_Pressure.setEnabled(False)                
86
        self.ui.lineEdit_N3_Elevation.setEnabled(False)
87

    
88
        self.ui.label_N4.setVisible(False)
89
        self.ui.lineEdit_N4_Pressure.setEnabled(False)                
90
        self.ui.lineEdit_N4_Elevation.setEnabled(False)
91

    
92
        self.ui.label_N5.setVisible(False)
93
        self.ui.lineEdit_N5_Pressure.setEnabled(False)                
94
        self.ui.lineEdit_N5_Elevation.setEnabled(False)
95

    
96
        self.ui.label_N6.setVisible(False)
97
        self.ui.lineEdit_N6_Pressure.setEnabled(False)                
98
        self.ui.lineEdit_N6_Elevation.setEnabled(False)
99

    
100
        self.ui.label_N7.setVisible(False)
101
        self.ui.lineEdit_N7_Pressure.setEnabled(False)                
102
        self.ui.lineEdit_N7_Elevation.setEnabled(False)
103

    
104
        self.ui.label_N8.setVisible(False)
105
        self.ui.lineEdit_N8_Pressure.setEnabled(False)                
106
        self.ui.lineEdit_N8_Elevation.setEnabled(False)
107

    
108
        self.ui.label_N9.setVisible(False)
109
        self.ui.lineEdit_N9_Pressure.setEnabled(False)                
110
        self.ui.lineEdit_N9_Elevation.setEnabled(False)
111

    
112
        self.ui.label_N10.setVisible(False)
113
        self.ui.lineEdit_N10_Pressure.setEnabled(False)                
114
        self.ui.lineEdit_N10_Elevation.setEnabled(False)
115

    
116
        self.ui.label_N11.setVisible(False)
117
        self.ui.lineEdit_N11_Pressure.setEnabled(False)                
118
        self.ui.lineEdit_N11_Elevation.setEnabled(False)
119

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

    
191
    def load_data(self):
192
        """ load tag no and nozzle data """
193
        from Drawing import Drawing
194
        
195
        appDocData = AppDocData.instance()
196
        drawing = appDocData.activeDrawing    
197
        if drawing:
198
            for attr in drawing.attrs:
199
                if attr[0] == 'Units':
200
                    self.ui.label_PressureUnit.setText('{}(g)'.format(attr[1]['Pressure']))                    
201
                    self.ui.label_ElevationUnit.setText(attr[1]['Length'])
202
                
203
        for connector in self._item.connectors:
204
            index = connector._conn_index
205
            if connector.data:
206
                pressure = connector.data.pressure                                
207
                if pressure:
208
                    if index == 1:
209
                        self.ui.lineEdit_N1_Pressure.setText(str(pressure))
210
                    elif index == 2:
211
                        self.ui.lineEdit_N2_Pressure.setText(str(pressure))
212
                    elif index == 3:
213
                        self.ui.lineEdit_N3_Pressure.setText(str(pressure))
214
                    elif index == 4:
215
                        self.ui.lineEdit_N4_Pressure.setText(str(pressure))
216
                    elif index == 5:
217
                        self.ui.lineEdit_N5_Pressure.setText(str(pressure))  
218
                    elif index == 6:
219
                        self.ui.lineEdit_N6_Pressure.setText(str(pressure))
220
                    elif index == 7:
221
                        self.ui.lineEdit_N7_Pressure.setText(str(pressure))              
222
                    elif index == 8:
223
                        self.ui.lineEdit_N8_Pressure.setText(str(pressure))
224
                    elif index == 9:
225
                        self.ui.lineEdit_N9_Pressure.setText(str(pressure))  
226
                    elif index == 10:
227
                        self.ui.lineEdit_N10_Pressure.setText(str(pressure))
228
                    elif index == 11:
229
                        self.ui.lineEdit_N11_Pressure.setText(str(pressure))              
230
                    elif index == 12:
231
                        self.ui.lineEdit_N12_Pressure.setText(str(pressure))
232

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

    
260
    def accept(self):
261
        """ set tag no and nozzle data """
262
        from EngineeringConnectorItem import NozzleData
263

    
264
        for connector in self._item.connectors:
265
            index = connector._conn_index
266
            if not connector.data: 
267
                connector.data = NozzleData()
268

    
269
            if index == 1:
270
                pressure = self.ui.lineEdit_N1_Pressure.text()
271
                if pressure:
272
                    connector.data.pressure = float(pressure)    
273
                else: 
274
                    connector.data.pressure = None
275

    
276
                elevation = self.ui.lineEdit_N1_Elevation.text()
277
                if elevation:
278
                    connector.data.elevation = float(elevation)  
279
                else:
280
                    connector.data.elevation = None
281
            elif index == 2:
282
                pressure = self.ui.lineEdit_N2_Pressure.text()
283
                if pressure:
284
                    connector.data.pressure = float(pressure)    
285
                else: 
286
                    connector.data.pressure = None
287

    
288
                elevation = self.ui.lineEdit_N2_Elevation.text()
289
                if elevation:
290
                    connector.data.elevation = float(elevation)  
291
                else:
292
                    connector.data.elevation = None
293
            elif index == 3:
294
                pressure = self.ui.lineEdit_N3_Pressure.text()
295
                if pressure:
296
                    connector.data.pressure = float(pressure)    
297
                else: 
298
                    connector.data.pressure = None
299

    
300
                elevation = self.ui.lineEdit_N3_Elevation.text()
301
                if elevation:
302
                    connector.data.elevation = float(elevation)  
303
                else:
304
                    connector.data.elevation = None
305
            elif index == 4:
306
                pressure = self.ui.lineEdit_N4_Pressure.text()
307
                if pressure:
308
                    connector.data.pressure = float(pressure)    
309
                else: 
310
                    connector.data.pressure = None
311

    
312
                elevation = self.ui.lineEdit_N4_Elevation.text()
313
                if elevation:
314
                    connector.data.elevation = float(elevation)  
315
                else:
316
                    connector.data.elevation = None
317
            elif index == 5:
318
                pressure = self.ui.lineEdit_N5_Pressure.text()
319
                if pressure:
320
                    connector.data.pressure = float(pressure)    
321
                else: 
322
                    connector.data.pressure = None
323

    
324
                elevation = self.ui.lineEdit_N5_Elevation.text()
325
                if elevation:
326
                    connector.data.elevation = float(elevation)  
327
                else:
328
                    connector.data.elevation = None
329
            elif index == 6:
330
                pressure = self.ui.lineEdit_N6_Pressure.text()
331
                if pressure:
332
                    connector.data.pressure = float(pressure)    
333
                else: 
334
                    connector.data.pressure = None
335

    
336
                elevation = self.ui.lineEdit_N6_Elevation.text()
337
                if elevation:
338
                    connector.data.elevation = float(elevation)  
339
                else:
340
                    connector.data.elevation = None
341
            elif index == 7:
342
                pressure = self.ui.lineEdit_N7_Pressure.text()
343
                if pressure:
344
                    connector.data.pressure = float(pressure)    
345
                else: 
346
                    connector.data.pressure = None
347

    
348
                elevation = self.ui.lineEdit_N7_Elevation.text()
349
                if elevation:
350
                    connector.data.elevation = float(elevation)  
351
                else:
352
                    connector.data.elevation = None
353
            elif index == 8:
354
                pressure = self.ui.lineEdit_N8_Pressure.text()
355
                if pressure:
356
                    connector.data.pressure = float(pressure)    
357
                else: 
358
                    connector.data.pressure = None
359

    
360
                elevation = self.ui.lineEdit_N8_Elevation.text()
361
                if elevation:
362
                    connector.data.elevation = float(elevation)  
363
                else:
364
                    connector.data.elevation = None
365
            elif index == 9:
366
                pressure = self.ui.lineEdit_N9_Pressure.text()
367
                if pressure:
368
                    connector.data.pressure = float(pressure)    
369
                else: 
370
                    connector.data.pressure = None
371

    
372
                elevation = self.ui.lineEdit_N9_Elevation.text()
373
                if elevation:
374
                    connector.data.elevation = float(elevation)  
375
                else:
376
                    connector.data.elevation = None
377
            elif index == 10:
378
                pressure = self.ui.lineEdit_N10_Pressure.text()
379
                if pressure:
380
                    connector.data.pressure = float(pressure)    
381
                else: 
382
                    connector.data.pressure = None
383

    
384
                elevation = self.ui.lineEdit_N10_Elevation.text()
385
                if elevation:
386
                    connector.data.elevation = float(elevation)  
387
                else:
388
                    connector.data.elevation = None
389
            elif index == 11:
390
                pressure = self.ui.lineEdit_N11_Pressure.text()
391
                if pressure:
392
                    connector.data.pressure = float(pressure)    
393
                else: 
394
                    connector.data.pressure = None
395

    
396
                elevation = self.ui.lineEdit_N11_Elevation.text()
397
                if elevation:
398
                    connector.data.elevation = float(elevation)  
399
                else:
400
                    connector.data.elevation = None
401
            elif index == 12:
402
                pressure = self.ui.lineEdit_N12_Pressure.text()
403
                if pressure:
404
                    connector.data.pressure = float(pressure)    
405
                else: 
406
                    connector.data.pressure = None
407

    
408
                elevation = self.ui.lineEdit_N12_Elevation.text()
409
                if elevation:
410
                    connector.data.elevation = float(elevation)  
411
                else:
412
                    connector.data.elevation = None
413

    
414
        QDialog.accept(self)
415

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