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