프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / HYTOS / HYTOS / AirFinCooler.py @ 39128c17

이력 | 보기 | 이력해설 | 다운로드 (3.17 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 AirFinCooler_UI
14
import math
15

    
16

    
17
def is_not_blank(s):
18
    return bool(s and s.strip())
19

    
20

    
21
class QAirFinCooler(QDialog):
22
    def __init__(self):
23
        QDialog.__init__(self)
24

    
25
        self.ui = AirFinCooler_UI.Ui_AirFinCoolerDialog()
26
        self.ui.setupUi(self)
27
        self._item = None
28
        self.ui.lineEdit_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Pressure_Drop))
29
        self.ui.lineEdit_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Elevation))
30
        self.initialize()
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.set_controls()
38
        self.load_data()
39

    
40
        return self.exec_()
41

    
42
    def initialize(self):
43
        self.ui.label_Img.setVisible(False)
44

    
45
    def set_controls(self):
46
        self.ui.label_Img.setVisible(True)
47

    
48
    def load_data(self):
49
        """ load tag no and nozzle data """
50
        tag_no = self._item.tag_no
51
        if tag_no != 'None' and is_not_blank(tag_no):
52
            self.ui.lineEdit_TagNo.setText(tag_no)
53

    
54
        app_doc_data = AppDocData.instance()
55
        drawing = app_doc_data.activeDrawing
56
        if drawing:
57
            for attr in drawing.attrs:
58
                if attr[0] == 'Units':
59
                    self.ui.label_PressureUnit.setText(attr[1]['Pressure'])
60
                    self.ui.label_ElevationUnit.setText(attr[1]['Length'])
61

    
62
        matches = [connector.data for connector in self._item.connectors if connector.data]
63
        if matches:
64
            pressure_drop = matches[0].pressure_drop
65
            if pressure_drop:
66
                self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop))
67

    
68
            elevation = matches[0].elevation
69
            if elevation:
70
                self.ui.lineEdit_Elevation.setText(str(elevation))
71

    
72
    def accept(self):
73
        """ set tag no and nozzle data """
74
        from EngineeringConnectorItem import NozzleData
75
        tag_no = self.ui.lineEdit_TagNo.text()
76

    
77
        if is_not_blank(tag_no):
78
            for connector in self._item.connectors:
79
                if not connector.data:
80
                    connector.data = NozzleData()
81

    
82
                pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
83
                if pressure_drop:
84
                    connector.data.pressure_drop = float(pressure_drop)
85
                else:
86
                    connector.data.pressure_drop = None
87

    
88
                elevation = self.ui.lineEdit_Elevation.text()
89
                if elevation:
90
                    connector.data.elevation = float(elevation)
91
                else:
92
                    connector.data.elevation = None
93

    
94
            QDialog.accept(self)
95
        else:
96
            QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]'))
97

    
98
    def reject(self):
99
        QDialog.reject(self)
클립보드 이미지 추가 (최대 크기: 500 MB)