hytos / HYTOS / HYTOS / Compressor.py @ c46ad1e0
이력 | 보기 | 이력해설 | 다운로드 (5.34 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 Compressor_UI |
14 |
import math |
15 |
|
16 |
|
17 |
def is_not_blank(s): |
18 |
return bool(s and s.strip()) |
19 |
|
20 |
|
21 |
class QCompressor(QDialog): |
22 |
def __init__(self): |
23 |
QDialog.__init__(self)
|
24 |
|
25 |
self.ui = Compressor_UI.Ui_CompressorDialog()
|
26 |
self.ui.setupUi(self) |
27 |
self._item = None |
28 |
|
29 |
self.ui.lineEdit_Suc_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Suc_Pressure)) |
30 |
self.ui.lineEdit_Dis_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Dis_Pressure)) |
31 |
self.ui.lineEdit_Suc_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Suc_Elevation)) |
32 |
self.ui.lineEdit_Dis_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Dis_Elevation)) |
33 |
|
34 |
self.initialize()
|
35 |
|
36 |
def show_dialog(self, item): |
37 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
38 |
self._item = item
|
39 |
|
40 |
self.ui.lineEdit_TagNo.setFocus()
|
41 |
self.set_controls()
|
42 |
self.load_data()
|
43 |
|
44 |
return self.exec_() |
45 |
|
46 |
def initialize(self): |
47 |
self.ui.label_Img_In.setVisible(False) |
48 |
self.ui.label_Img_Out.setVisible(False) |
49 |
|
50 |
self.ui.label_Suc.setVisible(False) |
51 |
self.ui.lineEdit_Suc_Pressure.setEnabled(False) |
52 |
self.ui.lineEdit_Suc_Elevation.setEnabled(False) |
53 |
|
54 |
self.ui.label_Dis.setVisible(False) |
55 |
self.ui.lineEdit_Dis_Pressure.setEnabled(False) |
56 |
self.ui.lineEdit_Dis_Elevation.setEnabled(False) |
57 |
|
58 |
def set_controls(self): |
59 |
used_index = [] |
60 |
|
61 |
for connector in self._item.connectors: |
62 |
if connector.connectedItem:
|
63 |
used_index.append(connector._conn_index) |
64 |
|
65 |
if len(used_index) > 0: |
66 |
if 1 in used_index: |
67 |
self.ui.label_Img_In.setVisible(True) |
68 |
|
69 |
self.ui.label_Suc.setVisible(True) |
70 |
self.ui.lineEdit_Suc_Pressure.setEnabled(True) |
71 |
self.ui.lineEdit_Suc_Elevation.setEnabled(True) |
72 |
|
73 |
if 2 in used_index: |
74 |
self.ui.label_Img_Out.setVisible(True) |
75 |
|
76 |
self.ui.label_Dis.setVisible(True) |
77 |
self.ui.lineEdit_Dis_Pressure.setEnabled(True) |
78 |
self.ui.lineEdit_Dis_Elevation.setEnabled(True) |
79 |
|
80 |
def load_data(self): |
81 |
""" load tag no and nozzle data """
|
82 |
from Drawing import Drawing |
83 |
self.ui.lineEdit_TagNo.setText(self._item.tag_no) |
84 |
|
85 |
appDocData = AppDocData.instance() |
86 |
drawing = appDocData.activeDrawing |
87 |
if drawing:
|
88 |
for attr in drawing.attrs: |
89 |
if attr[0] == 'Units': |
90 |
self.ui.label_PressureUnit.setText(attr[1]['Pressure']) |
91 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
92 |
|
93 |
for connector in self._item.connectors: |
94 |
index = connector._conn_index |
95 |
if connector.data:
|
96 |
pressure = connector.data.pressure |
97 |
if pressure:
|
98 |
if index == 1: |
99 |
self.ui.lineEdit_Suc_Pressure.setText(str(pressure)) |
100 |
elif index == 2: |
101 |
self.ui.lineEdit_Dis_Pressure.setText(str(pressure)) |
102 |
|
103 |
elevation = connector.data.elevation |
104 |
if elevation:
|
105 |
if index == 1: |
106 |
self.ui.lineEdit_Suc_Elevation.setText(str(elevation)) |
107 |
elif index == 2: |
108 |
self.ui.lineEdit_Dis_Elevation.setText(str(elevation)) |
109 |
|
110 |
def accept(self): |
111 |
""" set tag no and nozzle data """
|
112 |
from EngineeringConnectorItem import NozzleData |
113 |
tag_no = self.ui.lineEdit_TagNo.text()
|
114 |
|
115 |
if is_not_blank(tag_no):
|
116 |
self._item.tag_no = tag_no
|
117 |
for connector in self._item.connectors: |
118 |
index = connector._conn_index |
119 |
if not connector.data: |
120 |
connector.data = NozzleData() |
121 |
|
122 |
if index == 1: |
123 |
pressure = self.ui.lineEdit_Suc_Pressure.text()
|
124 |
if pressure:
|
125 |
connector.data.pressure = float(pressure)
|
126 |
else:
|
127 |
connector.data.pressure = None
|
128 |
|
129 |
elevation = self.ui.lineEdit_Suc_Elevation.text()
|
130 |
if elevation:
|
131 |
connector.data.elevation = float(elevation)
|
132 |
else:
|
133 |
connector.data.elevation = None
|
134 |
elif index == 2: |
135 |
pressure = self.ui.lineEdit_Dis_Pressure.text()
|
136 |
if pressure:
|
137 |
connector.data.pressure = float(pressure)
|
138 |
else:
|
139 |
connector.data.pressure = None
|
140 |
|
141 |
elevation = self.ui.lineEdit_Dis_Elevation.text()
|
142 |
if elevation:
|
143 |
connector.data.elevation = float(elevation)
|
144 |
else:
|
145 |
connector.data.elevation = None
|
146 |
|
147 |
QDialog.accept(self)
|
148 |
else:
|
149 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]')) |
150 |
|
151 |
def reject(self): |
152 |
QDialog.reject(self)
|