hytos / HYTOS / HYTOS / Reactor.py @ 24ea7edf
이력 | 보기 | 이력해설 | 다운로드 (9.84 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 Project import Project |
13 |
from AppDocData import AppDocData |
14 |
import Reactor_UI |
15 |
import math |
16 |
|
17 |
class QReactor(QDialog): |
18 |
def __init__(self): |
19 |
QDialog.__init__(self)
|
20 |
|
21 |
self.ui = Reactor_UI.Ui_ReactorDialog()
|
22 |
self.ui.setupUi(self) |
23 |
|
24 |
self.ui.lineEdit_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Pressure_Drop)) |
25 |
|
26 |
self.ui.lineEdit_N1_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Elevation)) |
27 |
self.ui.lineEdit_N2_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Elevation)) |
28 |
self.ui.lineEdit_N3_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Elevation)) |
29 |
self.ui.lineEdit_N4_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Elevation)) |
30 |
self.ui.lineEdit_N5_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Elevation)) |
31 |
self.ui.lineEdit_N6_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Elevation)) |
32 |
|
33 |
self.initialize()
|
34 |
|
35 |
def showDialog(self, item): |
36 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
37 |
self._item = item
|
38 |
|
39 |
self.ui.lineEdit_TagNo.setFocus()
|
40 |
self.set_controls(item)
|
41 |
self.load_data()
|
42 |
|
43 |
self.exec_()
|
44 |
|
45 |
def initialize(self): |
46 |
# To do : 이름으로 Control 찾아오기
|
47 |
self.ui.label_Img_N1.setVisible(False) |
48 |
self.ui.label_Img_N2.setVisible(False) |
49 |
self.ui.label_Img_N3.setVisible(False) |
50 |
self.ui.label_Img_N4.setVisible(False) |
51 |
self.ui.label_Img_N5.setVisible(False) |
52 |
self.ui.label_Img_N6.setVisible(False) |
53 |
|
54 |
self.ui.label_N1.setVisible(False) |
55 |
self.ui.lineEdit_N1_Elevation.setEnabled(False) |
56 |
|
57 |
self.ui.label_N2.setVisible(False) |
58 |
self.ui.lineEdit_N2_Elevation.setEnabled(False) |
59 |
|
60 |
self.ui.label_N3.setVisible(False) |
61 |
self.ui.lineEdit_N3_Elevation.setEnabled(False) |
62 |
|
63 |
self.ui.label_N4.setVisible(False) |
64 |
self.ui.lineEdit_N4_Elevation.setEnabled(False) |
65 |
|
66 |
self.ui.label_N5.setVisible(False) |
67 |
self.ui.lineEdit_N5_Elevation.setEnabled(False) |
68 |
|
69 |
self.ui.label_N6.setVisible(False) |
70 |
self.ui.lineEdit_N6_Elevation.setEnabled(False) |
71 |
|
72 |
|
73 |
def set_controls(self, item): |
74 |
# To do : 이름으로 Control 찾아오기
|
75 |
for connector in item.connectors: |
76 |
index = connector._conn_index |
77 |
if connector.connectedItem:
|
78 |
if index == 1: |
79 |
self.ui.label_Img_N1.setVisible(True) |
80 |
self.ui.label_N1.setVisible(True) |
81 |
self.ui.lineEdit_N1_Elevation.setEnabled(True) |
82 |
elif index == 2: |
83 |
self.ui.label_Img_N2.setVisible(True) |
84 |
self.ui.label_N2.setVisible(True) |
85 |
self.ui.lineEdit_N2_Elevation.setEnabled(True) |
86 |
elif index == 3: |
87 |
self.ui.label_Img_N3.setVisible(True) |
88 |
self.ui.label_N3.setVisible(True) |
89 |
self.ui.lineEdit_N3_Elevation.setEnabled(True) |
90 |
elif index == 4: |
91 |
self.ui.label_Img_N4.setVisible(True) |
92 |
self.ui.label_N4.setVisible(True) |
93 |
self.ui.lineEdit_N4_Elevation.setEnabled(True) |
94 |
elif index == 5: |
95 |
self.ui.label_Img_N5.setVisible(True) |
96 |
self.ui.label_N5.setVisible(True) |
97 |
self.ui.lineEdit_N5_Elevation.setEnabled(True) |
98 |
elif index == 6: |
99 |
self.ui.label_Img_N6.setVisible(True) |
100 |
self.ui.label_N6.setVisible(True) |
101 |
self.ui.lineEdit_N6_Elevation.setEnabled(True) |
102 |
|
103 |
def load_data(self): |
104 |
""" load tag no and nozzle data """
|
105 |
from Drawing import Drawing |
106 |
|
107 |
appDocData = AppDocData.instance() |
108 |
drawing = appDocData.activeDrawing |
109 |
if drawing:
|
110 |
for attr in drawing.attrs: |
111 |
if attr[0] == 'Units': |
112 |
self.ui.label_PressureUnit.setText(attr[1]['Pressure']) |
113 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
114 |
|
115 |
for connector in self._item.connectors: |
116 |
index = connector._conn_index |
117 |
if connector.nozzle_data:
|
118 |
pressure_drop = connector.nozzle_data.pressure_drop |
119 |
if pressure_drop:
|
120 |
if index == 1: |
121 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
122 |
elif index == 2: |
123 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
124 |
elif index == 3: |
125 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
126 |
elif index == 4: |
127 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
128 |
elif index == 5: |
129 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
130 |
elif index == 6: |
131 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
132 |
|
133 |
elevation = connector.nozzle_data.elevation |
134 |
if elevation:
|
135 |
if index == 1: |
136 |
self.ui.lineEdit_N1_Elevation.setText(str(elevation)) |
137 |
elif index == 2: |
138 |
self.ui.lineEdit_N2_Elevation.setText(str(elevation)) |
139 |
elif index == 3: |
140 |
self.ui.lineEdit_N3_Elevation.setText(str(elevation)) |
141 |
elif index == 4: |
142 |
self.ui.lineEdit_N4_Elevation.setText(str(elevation)) |
143 |
elif index == 5: |
144 |
self.ui.lineEdit_N5_Elevation.setText(str(elevation)) |
145 |
elif index == 6: |
146 |
self.ui.lineEdit_N6_Elevation.setText(str(elevation)) |
147 |
|
148 |
|
149 |
def accept(self): |
150 |
""" set tag no and nozzle data """
|
151 |
from EngineeringConnectorItem import NozzleData |
152 |
|
153 |
for connector in self._item.connectors: |
154 |
index = connector._conn_index |
155 |
if not connector.nozzle_data: |
156 |
connector.nozzle_data = NozzleData() |
157 |
|
158 |
if index == 1: |
159 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
160 |
if pressure_drop:
|
161 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
162 |
else:
|
163 |
connector.nozzle_data.pressure_drop = None
|
164 |
|
165 |
elevation = self.ui.lineEdit_N1_Elevation.text()
|
166 |
if elevation:
|
167 |
connector.nozzle_data.elevation = float(elevation)
|
168 |
else:
|
169 |
connector.nozzle_data.elevation = None
|
170 |
elif index == 2: |
171 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
172 |
if pressure_drop:
|
173 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
174 |
else:
|
175 |
connector.nozzle_data.pressure_drop = None
|
176 |
|
177 |
elevation = self.ui.lineEdit_N2_Elevation.text()
|
178 |
if elevation:
|
179 |
connector.nozzle_data.elevation = float(elevation)
|
180 |
else:
|
181 |
connector.nozzle_data.elevation = None
|
182 |
elif index == 3: |
183 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
184 |
if pressure_drop:
|
185 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
186 |
else:
|
187 |
connector.nozzle_data.pressure_drop = None
|
188 |
|
189 |
elevation = self.ui.lineEdit_N3_Elevation.text()
|
190 |
if elevation:
|
191 |
connector.nozzle_data.elevation = float(elevation)
|
192 |
else:
|
193 |
connector.nozzle_data.elevation = None
|
194 |
elif index == 4: |
195 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
196 |
if pressure_drop:
|
197 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
198 |
else:
|
199 |
connector.nozzle_data.pressure_drop = None
|
200 |
|
201 |
elevation = self.ui.lineEdit_N4_Elevation.text()
|
202 |
if elevation:
|
203 |
connector.nozzle_data.elevation = float(elevation)
|
204 |
else:
|
205 |
connector.nozzle_data.elevation = None
|
206 |
elif index == 5: |
207 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
208 |
if pressure_drop:
|
209 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
210 |
else:
|
211 |
connector.nozzle_data.pressure_drop = None
|
212 |
|
213 |
elevation = self.ui.lineEdit_N5_Elevation.text()
|
214 |
if elevation:
|
215 |
connector.nozzle_data.elevation = float(elevation)
|
216 |
else:
|
217 |
connector.nozzle_data.elevation = None
|
218 |
elif index == 6: |
219 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
220 |
if pressure_drop:
|
221 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
222 |
else:
|
223 |
connector.nozzle_data.pressure_drop = None
|
224 |
|
225 |
elevation = self.ui.lineEdit_N6_Elevation.text()
|
226 |
if elevation:
|
227 |
connector.nozzle_data.elevation = float(elevation)
|
228 |
else:
|
229 |
connector.nozzle_data.elevation = None
|
230 |
|
231 |
QDialog.accept(self)
|
232 |
|
233 |
def reject(self): |
234 |
QDialog.reject(self)
|