hytos / HYTOS / HYTOS / Strainer_T.py @ 24ea7edf
이력 | 보기 | 이력해설 | 다운로드 (2.88 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 Strainer_T_UI |
15 |
import math |
16 |
|
17 |
class QStrainer_T(QDialog): |
18 |
def __init__(self): |
19 |
QDialog.__init__(self)
|
20 |
|
21 |
self.ui = Strainer_T_UI.Ui_Strainer_T_Dialog()
|
22 |
self.ui.setupUi(self) |
23 |
self.ui.lineEdit_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Pressure_Drop)) |
24 |
self.ui.lineEdit_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Elevation)) |
25 |
self.initialize()
|
26 |
|
27 |
|
28 |
def showDialog(self, item): |
29 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
30 |
self._item = item
|
31 |
|
32 |
self.ui.lineEdit_TagNo.setFocus()
|
33 |
self.set_controls(item)
|
34 |
self.load_data()
|
35 |
|
36 |
self.exec_()
|
37 |
|
38 |
def initialize(self): |
39 |
self.ui.label_Img.setVisible(False) |
40 |
|
41 |
def set_controls(self, item): |
42 |
self.ui.label_Img.setVisible(True) |
43 |
|
44 |
def load_data(self): |
45 |
""" load tag no and nozzle data """
|
46 |
from Drawing import Drawing |
47 |
|
48 |
appDocData = AppDocData.instance() |
49 |
drawing = appDocData.activeDrawing |
50 |
if drawing:
|
51 |
for attr in drawing.attrs: |
52 |
if attr[0] == 'Units': |
53 |
self.ui.label_PressureUnit.setText(attr[1]['Pressure']) |
54 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
55 |
|
56 |
matches = [connector.nozzle_data for connector in self._item.connectors if connector.nozzle_data] |
57 |
if matches:
|
58 |
pressure_drop = matches[0].pressure_drop
|
59 |
if pressure_drop:
|
60 |
self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop)) |
61 |
|
62 |
elevation = matches[0].elevation
|
63 |
if elevation:
|
64 |
self.ui.lineEdit_Elevation.setText(str(elevation)) |
65 |
|
66 |
|
67 |
def accept(self): |
68 |
""" set tag no and nozzle data """
|
69 |
from EngineeringConnectorItem import NozzleData |
70 |
|
71 |
for connector in self._item.connectors: |
72 |
if not connector.nozzle_data: |
73 |
connector.nozzle_data = NozzleData() |
74 |
|
75 |
pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
|
76 |
if pressure_drop:
|
77 |
connector.nozzle_data.pressure_drop = float(pressure_drop)
|
78 |
else:
|
79 |
connector.nozzle_data.pressure_drop = None
|
80 |
|
81 |
elevation = self.ui.lineEdit_Elevation.text()
|
82 |
if elevation:
|
83 |
connector.nozzle_data.elevation = float(elevation)
|
84 |
else:
|
85 |
connector.nozzle_data.elevation = None
|
86 |
|
87 |
QDialog.accept(self)
|
88 |
|
89 |
def reject(self): |
90 |
QDialog.reject(self)
|