프로젝트

일반

사용자정보

통계
| 개정판:

hytos / HYTOS / HYTOS / DualPacked.py @ 206eb105

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

    
16
class QDualPacked(QDialog):
17
    def __init__(self):
18
        QDialog.__init__(self)
19

    
20
        self.ui = DualPacked_UI.Ui_DualPackedDialog()
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
        
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
        return self.exec_()
61

    
62
    def initialize(self):
63
        # To do : 이름으로 Control 찾아오기
64
        self.ui.label_Img_N1.setVisible(False)
65
        self.ui.label_Img_N2.setVisible(False)
66
        self.ui.label_Img_N3.setVisible(False)
67
        self.ui.label_Img_N4.setVisible(False)
68
        self.ui.label_Img_N5.setVisible(False)
69
        self.ui.label_Img_N6.setVisible(False)
70
        self.ui.label_Img_N7.setVisible(False)
71
        self.ui.label_Img_N8.setVisible(False)
72
        self.ui.label_Img_N9.setVisible(False)
73
        self.ui.label_Img_N10.setVisible(False)
74
        self.ui.label_Img_N11.setVisible(False)
75
        self.ui.label_Img_N12.setVisible(False)            
76
        
77
        self.ui.label_N1.setVisible(False)
78
        self.ui.lineEdit_N1_Pressure.setEnabled(False)                
79
        self.ui.lineEdit_N1_Elevation.setEnabled(False)
80
        
81
        self.ui.label_N2.setVisible(False)
82
        self.ui.lineEdit_N2_Pressure.setEnabled(False)                
83
        self.ui.lineEdit_N2_Elevation.setEnabled(False)
84
    
85
        self.ui.label_N3.setVisible(False)
86
        self.ui.lineEdit_N3_Pressure.setEnabled(False)                
87
        self.ui.lineEdit_N3_Elevation.setEnabled(False)
88

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

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

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

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

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

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

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

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

    
121
        self.ui.label_N12.setVisible(False)
122
        self.ui.lineEdit_N12_Pressure.setEnabled(False)                
123
        self.ui.lineEdit_N12_Elevation.setEnabled(False)
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
                
261
    def accept(self):
262
        
263
        """ set tag no and nozzle data """
264
        from EngineeringConnectorItem import NozzleData
265

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
416
        QDialog.accept(self)
417

    
418

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