프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

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

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

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

    
20
        self.ui = ShlTubHeatExchanger_UI.Ui_ShlTubHeatExchangerDialog()
21
        self.ui.setupUi(self)
22

    
23
        self.ui.lineEdit_Tub_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Tub_Pressure_Drop)) 
24
        self.ui.lineEdit_Shl_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Shl_Pressure_Drop))
25
        self.ui.lineEdit_Tub_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Tub_Elevation))                 
26
        self.ui.lineEdit_Shl_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Shl_Elevation))                
27

    
28
        self.initialize()
29

    
30
    def showDialog(self, item):
31
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
32
        self._item = item
33

    
34
        self.ui.lineEdit_TagNo.setFocus()
35
        self.set_controls(item)
36
        self.load_data()
37

    
38
        self.exec_()
39
    
40
    def initialize(self):
41
        self.ui.label_Img_Tub1.setVisible(False)
42
        self.ui.label_Img_Tub2.setVisible(False)
43
        self.ui.label_Img_Tub3.setVisible(False)
44
        self.ui.label_Img_Tub4.setVisible(False)
45
        self.ui.label_Img_Shl1.setVisible(False)
46
        self.ui.label_Img_Shl2.setVisible(False)
47
        self.ui.label_Img_Shl3.setVisible(False)
48

    
49
        self.ui.label_Tub.setVisible(False)
50
        self.ui.lineEdit_Tub_Pressure_Drop.setEnabled(False)                
51
        self.ui.lineEdit_Tub_Elevation.setEnabled(False)
52
    
53
        self.ui.label_Shl.setVisible(False)
54
        self.ui.lineEdit_Shl_Pressure_Drop.setEnabled(False)
55
        self.ui.lineEdit_Shl_Elevation.setEnabled(False)
56

    
57
    def set_controls(self, item):
58
        used_index = []
59

    
60
        for connector in item.connectors:            
61
            if connector.connectedItem:
62
                used_index.append(connector._conn_index)
63

    
64
        if len(used_index) > 0:
65
            if 1 in used_index or 3 in used_index:                
66
                self.ui.label_Img_Tub1.setVisible(True)
67
                self.ui.label_Img_Tub2.setVisible(True)
68
                self.ui.label_Img_Tub3.setVisible(True)
69
                self.ui.label_Img_Tub4.setVisible(True)
70
        
71
                self.ui.label_Tub.setVisible(True)
72
                self.ui.lineEdit_Tub_Pressure_Drop.setEnabled(True)                
73
                self.ui.lineEdit_Tub_Elevation.setEnabled(True)
74

    
75
            if 2 in used_index or 4 in used_index:
76
                self.ui.label_Img_Shl1.setVisible(True)
77
                self.ui.label_Img_Shl2.setVisible(True)
78
                self.ui.label_Img_Shl3.setVisible(True)
79

    
80
                self.ui.label_Shl.setVisible(True)
81
                self.ui.lineEdit_Shl_Pressure_Drop.setEnabled(True)
82
                self.ui.lineEdit_Shl_Elevation.setEnabled(True)
83

    
84
    def load_data(self):
85
        """ load tag no and nozzle data """
86
        from Drawing import Drawing
87
        
88
        appDocData = AppDocData.instance()
89
        drawing = appDocData.activeDrawing    
90
        if drawing:
91
            for attr in drawing.attrs:
92
                if attr[0] == 'Units':
93
                    self.ui.label_PressureUnit.setText(attr[1]['Pressure'])
94
                    self.ui.label_ElevationUnit.setText(attr[1]['Length'])
95

    
96
        for connector in self._item.connectors:
97
            index = connector._conn_index
98
            if connector.data:
99
                pressure_drop = connector.data.pressure_drop                                
100
                if pressure_drop:
101
                    if index == 1:
102
                        self.ui.lineEdit_Tub_Pressure_Drop.setText(str(pressure_drop))
103
                    elif index == 2:
104
                        self.ui.lineEdit_Shl_Pressure_Drop.setText(str(pressure_drop))
105
                    elif index == 3:
106
                        self.ui.lineEdit_Tub_Pressure_Drop.setText(str(pressure_drop))
107
                    elif index == 4:
108
                        self.ui.lineEdit_Shl_Pressure_Drop.setText(str(pressure_drop))
109
                    
110
                elevation = connector.data.elevation
111
                if elevation:
112
                    if index == 1:
113
                        self.ui.lineEdit_Tub_Elevation.setText(str(elevation))
114
                    elif index == 2:
115
                        self.ui.lineEdit_Shl_Elevation.setText(str(elevation))
116
                    elif index == 3:
117
                        self.ui.lineEdit_Tub_Elevation.setText(str(elevation))
118
                    elif index == 4:
119
                        self.ui.lineEdit_Shl_Elevation.setText(str(elevation))
120
                                 
121
    def accept(self):
122
        """ set tag no and nozzle data """
123
        from EngineeringConnectorItem import NozzleData
124

    
125
        for connector in self._item.connectors:
126
            index = connector._conn_index
127
            if not connector.data: 
128
                connector.data = NozzleData()
129

    
130
            if index == 1:
131
                pressure_drop = self.ui.lineEdit_Tub_Pressure_Drop.text()
132
                if pressure_drop:
133
                    connector.data.pressure_drop = float(pressure_drop)    
134
                else: 
135
                    connector.data.pressure_drop = None
136

    
137
                elevation = self.ui.lineEdit_Tub_Elevation.text()
138
                if elevation:
139
                    connector.data.elevation = float(elevation)  
140
                else:
141
                    connector.data.elevation = None
142
            elif index == 2:
143
                pressure_drop = self.ui.lineEdit_Shl_Pressure_Drop.text()
144
                if pressure_drop:
145
                    connector.data.pressure_drop = float(pressure_drop)    
146
                else: 
147
                    connector.data.pressure_drop = None
148

    
149
                elevation = self.ui.lineEdit_Shl_Elevation.text()
150
                if elevation:
151
                    connector.data.elevation = float(elevation)  
152
                else:
153
                    connector.data.elevation = None
154
            elif index == 3:
155
                pressure_drop = self.ui.lineEdit_Tub_Pressure_Drop.text()
156
                if pressure_drop:
157
                    connector.data.pressure_drop = float(pressure_drop)    
158
                else: 
159
                    connector.data.pressure_drop = None
160

    
161
                elevation = self.ui.lineEdit_Tub_Elevation.text()
162
                if elevation:
163
                    connector.data.elevation = float(elevation)  
164
                else:
165
                    connector.data.elevation = None
166
            elif index == 4:
167
                pressure_drop = self.ui.lineEdit_Shl_Pressure_Drop.text()
168
                if pressure_drop:
169
                    connector.data.pressure_drop = float(pressure_drop)    
170
                else: 
171
                    connector.data.pressure_drop = None
172

    
173
                elevation = self.ui.lineEdit_Shl_Elevation.text()
174
                if elevation:
175
                    connector.data.elevation = float(elevation)  
176
                else:
177
                    connector.data.elevation = None
178

    
179
        QDialog.accept(self)
180

    
181
    def reject(self):
182
        QDialog.reject(self)