1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
10
|
from PyQt5.QtWidgets import *
|
11
|
import os
|
12
|
from AppDocData import AppDocData
|
13
|
import Kompressor_UI
|
14
|
import math
|
15
|
|
16
|
|
17
|
def is_not_blank(s):
|
18
|
return bool(s and s.strip())
|
19
|
|
20
|
|
21
|
class QKompressor(QDialog):
|
22
|
def __init__(self):
|
23
|
QDialog.__init__(self)
|
24
|
|
25
|
self.ui = Kompressor_UI.Ui_KompressorDialog()
|
26
|
self.ui.setupUi(self)
|
27
|
self._item = None
|
28
|
|
29
|
self.ui.lineEdit_Diff_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Diff_Pressure))
|
30
|
self.ui.lineEdit_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Elevation))
|
31
|
|
32
|
def show_dialog(self, item):
|
33
|
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
|
34
|
self._item = item
|
35
|
|
36
|
self.ui.lineEdit_TagNo.setFocus()
|
37
|
self.load_data()
|
38
|
|
39
|
return self.exec_()
|
40
|
|
41
|
def load_data(self):
|
42
|
""" load tag no and nozzle data """
|
43
|
from Drawing import Drawing
|
44
|
self.ui.lineEdit_TagNo.setText(self._item.tag_no)
|
45
|
|
46
|
appDocData = AppDocData.instance()
|
47
|
drawing = appDocData.activeDrawing
|
48
|
if drawing:
|
49
|
for attr in drawing.attrs:
|
50
|
if attr[0] == 'Units':
|
51
|
self.ui.label_PressureUnit.setText(attr[1]['Pressure'])
|
52
|
self.ui.label_ElevationUnit.setText(attr[1]['Length'])
|
53
|
|
54
|
for connector in self._item.connectors:
|
55
|
index = connector._conn_index
|
56
|
if connector.data:
|
57
|
pressure = connector.data.pressure
|
58
|
if pressure:
|
59
|
self.ui.lineEdit_Diff_Pressure.setText(str(pressure))
|
60
|
|
61
|
elevation = connector.data.elevation
|
62
|
if elevation:
|
63
|
self.ui.lineEdit_Elevation.setText(str(elevation))
|
64
|
|
65
|
def accept(self):
|
66
|
""" set tag no and nozzle data """
|
67
|
from EngineeringConnectorItem import NozzleData
|
68
|
tag_no = self.ui.lineEdit_TagNo.text()
|
69
|
|
70
|
if is_not_blank(tag_no):
|
71
|
self._item.tag_no = tag_no
|
72
|
for connector in self._item.connectors:
|
73
|
index = connector._conn_index
|
74
|
if not connector.data:
|
75
|
connector.data = NozzleData()
|
76
|
|
77
|
pressure = self.ui.lineEdit_Diff_Pressure.text()
|
78
|
if pressure:
|
79
|
connector.data.pressure = float(pressure)
|
80
|
else:
|
81
|
connector.data.pressure = None
|
82
|
|
83
|
elevation = self.ui.lineEdit_Elevation.text()
|
84
|
if elevation:
|
85
|
connector.data.elevation = float(elevation)
|
86
|
else:
|
87
|
connector.data.elevation = None
|
88
|
|
89
|
QDialog.accept(self)
|
90
|
else:
|
91
|
QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]'))
|
92
|
|
93
|
def reject(self):
|
94
|
QDialog.reject(self)
|